| @@ 23-95 (lines=73) @@ | ||
| 20 | * @ODM\EmbeddedDocument |
|
| 21 | * |
|
| 22 | */ |
|
| 23 | class Coordinates extends AbstractEntity implements CoordinatesInterface |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * The GeoJSON type |
|
| 27 | * |
|
| 28 | * @var string |
|
| 29 | * @ODM\Field(type="string") |
|
| 30 | */ |
|
| 31 | protected $type; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * The GeoJSON coordinates. |
|
| 35 | * |
|
| 36 | * This is an array which format depends on the $type beeing used. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | * @ODM\Collection |
|
| 40 | */ |
|
| 41 | protected $coordinates; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @param $type |
|
| 45 | * |
|
| 46 | * @return $this |
|
| 47 | */ |
|
| 48 | public function setType($type) |
|
| 49 | { |
|
| 50 | $this->type = $type; |
|
| 51 | ||
| 52 | return $this; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @return string |
|
| 57 | */ |
|
| 58 | public function getType() |
|
| 59 | { |
|
| 60 | return $this->type; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @param array $coordinates |
|
| 65 | * |
|
| 66 | * @return $this |
|
| 67 | */ |
|
| 68 | public function setCoordinates(array $coordinates) |
|
| 69 | { |
|
| 70 | $this->coordinates = $coordinates; |
|
| 71 | ||
| 72 | return $this; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return array |
|
| 77 | */ |
|
| 78 | public function getCoordinates() |
|
| 79 | { |
|
| 80 | return $this->coordinates; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * @return string |
|
| 85 | */ |
|
| 86 | public function toJson() |
|
| 87 | { |
|
| 88 | $data = [ |
|
| 89 | 'type' => $this->getType(), |
|
| 90 | 'coordinates' => $this->getCoordinates(), |
|
| 91 | ]; |
|
| 92 | ||
| 93 | return Json::encode($data); |
|
| 94 | } |
|
| 95 | } |
|
| 96 | ||
| @@ 23-95 (lines=73) @@ | ||
| 20 | * @ODM\EmbeddedDocument |
|
| 21 | * |
|
| 22 | */ |
|
| 23 | class Coordinates extends AbstractEntity implements CoordinatesInterface |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * The GeoJSON type |
|
| 27 | * |
|
| 28 | * @var string |
|
| 29 | * @ODM\Field(type="string") |
|
| 30 | */ |
|
| 31 | protected $type; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * The GeoJSON coordinates. |
|
| 35 | * |
|
| 36 | * This is an array which format depends on the $type beeing used. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | * @ODM\Collection |
|
| 40 | */ |
|
| 41 | protected $coordinates; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @param $type |
|
| 45 | * |
|
| 46 | * @return $this |
|
| 47 | */ |
|
| 48 | public function setType($type) |
|
| 49 | { |
|
| 50 | $this->type = $type; |
|
| 51 | ||
| 52 | return $this; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @return string |
|
| 57 | */ |
|
| 58 | public function getType() |
|
| 59 | { |
|
| 60 | return $this->type; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @param array $coordinates |
|
| 65 | * |
|
| 66 | * @return $this |
|
| 67 | */ |
|
| 68 | public function setCoordinates(array $coordinates) |
|
| 69 | { |
|
| 70 | $this->coordinates = $coordinates; |
|
| 71 | ||
| 72 | return $this; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return array |
|
| 77 | */ |
|
| 78 | public function getCoordinates() |
|
| 79 | { |
|
| 80 | return $this->coordinates; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * @return string |
|
| 85 | */ |
|
| 86 | public function toJson() |
|
| 87 | { |
|
| 88 | $data = [ |
|
| 89 | 'type' => $this->getType(), |
|
| 90 | 'coordinates' => $this->getCoordinates(), |
|
| 91 | ]; |
|
| 92 | ||
| 93 | return Json::encode($data); |
|
| 94 | } |
|
| 95 | } |
|
| 96 | ||