See also: http://www.geojson.org/geojson-spec.html#feature-objects
Since: 1.0
Inheritance: extends GeoJson\GeoJson
示例#1
0
 /**
  * Save a new model and return the instance.
  *
  * @param  array  $attributes
  * @return static
  */
 public static function createFromFeature(Feature $feature, array $attributes = [])
 {
     $instance = new static();
     $properties = [$instance->getPropertiesField() => array_filter($feature->getAllProperties()), $instance->getGeometryField() => $feature->getGeometry()];
     $attributes = array_merge($attributes, $properties);
     return parent::create($attributes);
 }
 public function testSerializationShouldConvertEmptyPropertiesArrayToObject()
 {
     $feature = new Feature(null, array());
     $expected = array('type' => 'Feature', 'geometry' => null, 'properties' => new \stdClass());
     $this->assertEquals($expected, $feature->jsonSerialize());
 }