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'}";
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
 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 "{}";
     }
 }
Ejemplo n.º 4
0
/**
 * Convert an array of features in GeoJSON format.
 * 
 * @param array $features The array of features to convert.
 * @param stdClass $context The context object.
 * @param int $treasurehuntid The identifier of the treasure hunt instance.
 * @param int $groupid The identifier of the group or 0 if is individually.
 * @return array
 */
function treasurehunt_features_to_geojson($features, $context, $treasurehuntid, $groupid = 0)
{
    $featuresarray = array();
    foreach ($features as $feature) {
        $geometry = treasurehunt_wkt_to_object($feature->geometry);
        if (isset($feature->cluetext)) {
            $cluetext = file_rewrite_pluginfile_urls($feature->cluetext, 'pluginfile.php', $context->id, 'mod_treasurehunt', 'cluetext', $feature->stageid ? $feature->stageid : $feature->id);
        } else {
            $cluetext = null;
        }
        $attr = array('roadid' => intval($feature->roadid), 'stageposition' => intval($feature->position), 'name' => $feature->name, 'treasurehuntid' => $treasurehuntid, 'clue' => $cluetext);
        if (property_exists($feature, 'geometrysolved') && property_exists($feature, 'success')) {
            $attr['geometrysolved'] = intval($feature->geometrysolved);
            // The type of attempt is modified to location for the next function.
            $feature->type = "location";
            $attr['info'] = treasurehunt_set_string_attempt($feature, $groupid);
        }
        $feature = new Feature($feature->id ? intval($feature->id) : 0, $geometry, $attr);
        array_push($featuresarray, $feature);
    }
    $featurecollection = new FeatureCollection($featuresarray);
    $geojson = $featurecollection->getGeoInterface();
    return $geojson;
}
Ejemplo n.º 5
0
  /**
   * 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;
  }