function toGeoJSON() { $rssDoc = new SimpleXMLElement($this->doc); $rssDoc->registerXPathNamespace('xls', 'http://www.opengis.net/xls'); $rssDoc->registerXPathNamespace('gml', 'http://www.opengis.net/gml'); $rssDoc->registerXPathNamespace('georss', 'http://www.georss.org/georss'); #for ingrid - portalu georss $rssDoc->registerXPathNamespace('ingrid', 'http://www.portalu.de/opensearch/extension/1.0'); // build feature collection $featureCollection = new FeatureCollection(); // elements of rss document $rssItems = $rssDoc->xpath("//item"); if (count($rssItems) > 0) { foreach ($rssItems as $item) { $rssItem_dom = dom_import_simplexml($item); $feature = new geoRSSItem(); $feature->targetEPSG = $this->targetEPSG; $feature->parse($rssItem_dom, $this->importItems); if (isset($feature->geometry) && $feature->geometry !== false) { $featureCollection->addFeature($feature); } } return $featureCollection->toGeoJSON(); } else { return "{'errorMessage':'Kein Ergebnis'}"; } }
/** * Rend toutes les ListeBars * @return array */ public function rend() { $sql = "SELECT * FROM ListeBars"; $statement = $this->db->prepare($sql); $statement->execute(); $resultats = $statement->fetchAll(PDO::FETCH_ASSOC); $i = 0; $rendu = array(); $fc = new FeatureCollection(); foreach ($resultats as $i => $resultat) { $fc->addFeature(new Feature($i, json_decode($resultat['geometry']), array("name" => $resultat['name']))); } array_push($rendu, $fc); return $rendu; }
/** * returns a Feature|FeatureCollection instance build from $object through $adapter * * @param mixed $object The data to load * @param GeoJSON_Adapter The adapter through which data will be extracted * * @return Feature|FeatureCollection A Feature|FeatureCollection instance */ static public function loadFrom($object, GeoJSON_Adapter $adapter) { if ($adapter->isMultiple($object)) { $result = new FeatureCollection(); foreach ($adapter->getIterable($object) as $feature) { $result->addFeature(self::loadFeatureFrom($feature, $adapter)); } } else { $result = self::loadFeatureFrom($object, $adapter); } return $result; }
function toGeoJSON() { $gmlDoc = new SimpleXMLElement($this->doc); $gmlDoc->registerXPathNamespace('xls', 'http://www.opengis.net/xls'); $gmlDoc->registerXPathNamespace('wfs', 'http://www.opengis.net/wfs'); $gmlDoc->registerXPathNamespace('gml', 'http://www.opengis.net/gml'); // build feature collection $featureCollection = new FeatureCollection(); // segments of the featzreCollection $gmlFeatureMembers = $gmlDoc->xpath("//gml:featureMember"); if (count($gmlFeatureMembers) > 0) { $cnt = 0; foreach ($gmlFeatureMembers as $gmlFeatureMember) { $featureMember_dom = dom_import_simplexml($gmlFeatureMember); $feature = new Feature(); if ($this->geomFeaturetypeElement != null) { $feature->parse($featureMember_dom, $this->geomFeaturetypeElement); } else { $feature->parse($featureMember_dom); } if (isset($feature->geometry)) { $featureCollection->addFeature($feature); } $cnt++; } return $featureCollection->toGeoJSON(); } else { return "{}"; } }