allebb /
cartographer
| 1 | <?php |
||
| 2 | namespace Ballen\Cartographer; |
||
| 3 | |||
| 4 | use Ballen\Cartographer\Core\GeoJSONTypeInterface; |
||
| 5 | use Ballen\Cartographer\Core\Multipliable; |
||
| 6 | use Ballen\Cartographer\Core\GeoJSON; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Cartographer |
||
| 10 | * |
||
| 11 | * Cartographer is a PHP library providing the ability to programmatically |
||
| 12 | * generate GeoJSON objects. |
||
| 13 | * |
||
| 14 | * @author Bobby Allen <[email protected]> |
||
| 15 | * @license http://www.gnu.org/licenses/gpl-3.0.html |
||
| 16 | * @link https://github.com/allebb/cartographer |
||
| 17 | * @link http://bobbyallen.me |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | class Feature extends GeoJSON implements GeoJSONTypeInterface |
||
| 21 | { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The GeoJSON schema type |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $type = GeoJSON::TYPE_FEATURE; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * The Geometry Object |
||
| 31 | * @var Multipliable |
||
| 32 | */ |
||
| 33 | private $geometry; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Feature properties array. |
||
| 37 | * @param array $geometry |
||
| 38 | */ |
||
| 39 | private $properties; |
||
| 40 | |||
| 41 | 8 | public function __construct(Multipliable $geometry, array $properties = []) |
|
| 42 | { |
||
| 43 | 8 | $this->geometry = $geometry; |
|
| 44 | 8 | $this->properties = $properties; |
|
| 45 | 8 | } |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Exports the type specific schema element(s). |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | 6 | public function export() |
|
| 52 | { |
||
| 53 | return [ |
||
| 54 | 6 | 'geometry' => $this->geometry->generateMember(), |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 55 | 6 | 'properties' => $this->properties, |
|
| 56 | ]; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Validate the type specific schema element(s). |
||
| 61 | * @return boolean |
||
| 62 | */ |
||
| 63 | 2 | public function validate() |
|
| 64 | { |
||
| 65 | // This schema type is self validating due to the class method type hinting. |
||
| 66 | 2 | return true; |
|
| 67 | } |
||
| 68 | } |
||
| 69 |