featureCollection === null) { return null; } return $this->featureCollection->toGeoJSON(); } /** * Shortcut for GeoJSON conversion * * @return String * @param $geoJson String */ public static function geoJsonToGml ($geoJson) { $gmlFactory = new UniversalGmlFactory(); $myGmlObj = $gmlFactory->createFromGeoJson($geoJson); return $myGmlObj->toGml(); } public function getBbox () { if (is_null($this->featureCollection)) { return null; } return $this->featureCollection->getBbox(); } /** * Exports the file to CSV. * * @param string $filenamePrefix the filename without an ending like .csv */ public function toCsv ($xmlData, $filenamePrefix, $currentFeaturetype) { /* * @security_patch exec done * Added escapeshellcmd() */ $unique = TMPDIR . $filenamePrefix; $fCsv = $unique.".csv"; $fGml = $unique.".gml"; $pathOgr = '/usr/bin/ogr2ogr'; $w = $this->toFile($fGml,$xmlData); $exec = $pathOgr.' -f "CSV" "'.$unique.'" '.$fGml; #$e = new mb_exception($exec); exec(escapeshellcmd($exec)); $exec = 'recode UTF-8..latin1 '.$unique.'/'.$currentFeaturetype.'.csv'; $e = new mb_exception($exec); exec(escapeshellcmd($exec)); $exec = 'chmod 777 '.$unique.'.*'; exec(escapeshellcmd($exec)); } /** * Writes a file containing the GML. * * @param string $path the path to the file. * @param string $path the path to the file. * @return bool true if the file could be saved; else false. */ public function toFile ($file,$xml) { $handle = fopen($file, "w"); if (!$handle) { $e = new mb_exception("class_gml.php: Filehandler error (" . $file . ")."); return false; } if (!fwrite($handle,$xml)) { $e = new mb_exception("class_gml.php: Could not write file (" . $file . ")."); fclose($handle); return false; } fclose($handle); return true; } public function getFeatureMemberCount () { if ($this->featureCollection === null) { return null; } return $this->featureCollection->getFeatureMemberCount(); } } ?>