getGeometry() public méthode

Return the Geometry object for this Feature object.
public getGeometry ( ) : GeoJson\Geometry\Geometry
Résultat GeoJson\Geometry\Geometry
 public function testSerialization()
 {
     $geometry = $this->getMockGeometry();
     $geometry->expects($this->any())->method('jsonSerialize')->will($this->returnValue('geometry'));
     $properties = array('key' => 'value');
     $id = 'identifier';
     $feature = new Feature($geometry, $properties, $id);
     $expected = array('type' => 'Feature', 'geometry' => 'geometry', 'properties' => $properties, 'id' => 'identifier');
     $this->assertSame('Feature', $feature->getType());
     $this->assertSame($geometry, $feature->getGeometry());
     $this->assertSame($id, $feature->getId());
     $this->assertSame($properties, $feature->getProperties());
     $this->assertSame($expected, $feature->jsonSerialize());
 }
Exemple #2
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);
 }