Exemple #1
0
 public function featureFromJSON($featureInfo)
 {
     if (isset($featureInfo['foundFieldName'])) {
         // will be set if we got here from a search
         $displayField = $featureInfo['foundFieldName'];
     } else {
         $displayField = $this->displayField;
     }
     $attribs = $featureInfo['attributes'];
     $displayAttribs = array();
     // use human-readable field alias to construct feature details
     foreach ($attribs as $name => $value) {
         if (strtoupper($name) == strtoupper($displayField)) {
             $index = $value;
         }
         if ($value !== null && trim($value) !== '') {
             if (isset($this->fieldNames[$name])) {
                 $name = $this->fieldNames[$name];
             }
             $displayAttribs[$name] = $value;
         }
     }
     if ($this->geometryType && isset($featureInfo['geometry'])) {
         $geometry = $featureInfo['geometry'];
     } else {
         $geometry = NULL;
     }
     if (!isset($displayAttribs[$this->idField]) && !isset($displayAttribs[$this->fieldNames[$this->displayField]])) {
         // no usable data was included with this result
         return NULL;
     }
     $feature = new ArcGISFeature($displayAttribs, $geometry, $index, $this->getCategory());
     if ($this->geometryType) {
         $feature->setGeometryType($this->geometryType);
     }
     $feature->setTitleField($this->fieldNames[$this->displayField]);
     if (isset($this->idField) && isset($attribs[$this->idField])) {
         $feature->setId($attribs[$this->idField]);
     } else {
         $feature->setId($feature->getTitle());
     }
     return $feature;
 }
    public function featureFromJSON($featureInfo) {
        if (isset($featureInfo['foundFieldName'])) { // will be set if we got here from a search
            $displayField = $featureInfo['foundFieldName'];
        } else {
            $displayField = $this->displayField;
        }

        $attribs = $featureInfo['attributes'];
        $displayAttribs = array();
        // use human-readable field alias to construct feature details
        foreach ($attribs as $name => $value) {
            if ($value !== null && trim($value) !== '') {
                if (isset($this->fieldNames[$name]))
                    $name = $this->fieldNames[$name];
                $displayAttribs[$name] = $value;
            }
        }
        if ($this->geometryType && isset($featureInfo['geometry'])) {
            $geometry = $featureInfo['geometry'];
        } else {
            $geometry = NULL;
        }
        
        if (!$displayAttribs && !$geometry) { // we basically got empty JSON, so don't create anything
            return NULL;
        }
        
        // doing this assumes the display names for buildings are unique
        // this is because we have no way of figuring out the object's actual ID
        $index = $attribs[$displayField];
        $feature = new ArcGISFeature($displayAttribs, $geometry, $index, $this->getCategory());
        if ($this->geometryType) {
            $feature->setGeometryType($this->geometryType);
        }
        $feature->setTitleField($this->fieldNames[$this->displayField]);
        return $feature;
    }
 public function featureFromJSON($featureInfo) {
     $attribs = $featureInfo['attributes'];
     $displayAttribs = array();
     // use human-readable field alias to construct feature details
     foreach ($attribs as $name => $value) {
         if (isset($this->fieldNames[$name]))
             $name = $this->fieldNames[$name];
         $displayAttribs[$name] = $value;
     }
     if ($this->geometryType && isset($featureInfo['geometry'])) {
         $geometry = $featureInfo['geometry'];
         $feature = new ArcGISFeature($displayAttribs, $geometry);
         $feature->setGeometryType($this->geometryType);
     } else {
         $feature = new ArcGISFeature($displayAttribs, null);
     }
     $feature->setTitleField($this->fieldNames[$this->displayField]);
     return $feature;
 }