| @@ 10-62 (lines=53) @@ | ||
| 7 | use CultuurNet\Geocoding\Coordinate\Longitude; |
|
| 8 | use CultuurNet\UDB3\Event\EventEvent; |
|
| 9 | ||
| 10 | class GeoCoordinatesUpdated extends EventEvent |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var Coordinates |
|
| 14 | */ |
|
| 15 | private $coordinates; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param string $eventId |
|
| 19 | * @param Coordinates $coordinates |
|
| 20 | */ |
|
| 21 | public function __construct($eventId, Coordinates $coordinates) |
|
| 22 | { |
|
| 23 | parent::__construct($eventId); |
|
| 24 | $this->coordinates = $coordinates; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @return Coordinates |
|
| 29 | */ |
|
| 30 | public function getCoordinates() |
|
| 31 | { |
|
| 32 | return $this->coordinates; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | public function serialize() |
|
| 39 | { |
|
| 40 | return parent::serialize() + [ |
|
| 41 | 'coordinates' => [ |
|
| 42 | 'lat' => $this->coordinates->getLatitude()->toDouble(), |
|
| 43 | 'long' => $this->coordinates->getLongitude()->toDouble(), |
|
| 44 | ], |
|
| 45 | ]; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @param array $data |
|
| 50 | * @return GeoCoordinatesUpdated |
|
| 51 | */ |
|
| 52 | public static function deserialize(array $data) |
|
| 53 | { |
|
| 54 | return new GeoCoordinatesUpdated( |
|
| 55 | $data['event_id'], |
|
| 56 | new Coordinates( |
|
| 57 | new Latitude($data['coordinates']['lat']), |
|
| 58 | new Longitude($data['coordinates']['long']) |
|
| 59 | ) |
|
| 60 | ); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| @@ 10-62 (lines=53) @@ | ||
| 7 | use CultuurNet\Geocoding\Coordinate\Longitude; |
|
| 8 | use CultuurNet\UDB3\Place\PlaceEvent; |
|
| 9 | ||
| 10 | class GeoCoordinatesUpdated extends PlaceEvent |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var Coordinates |
|
| 14 | */ |
|
| 15 | private $coordinates; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param string $placeId |
|
| 19 | * @param Coordinates $coordinates |
|
| 20 | */ |
|
| 21 | public function __construct($placeId, Coordinates $coordinates) |
|
| 22 | { |
|
| 23 | parent::__construct($placeId); |
|
| 24 | $this->coordinates = $coordinates; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @return Coordinates |
|
| 29 | */ |
|
| 30 | public function getCoordinates() |
|
| 31 | { |
|
| 32 | return $this->coordinates; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | public function serialize() |
|
| 39 | { |
|
| 40 | return parent::serialize() + [ |
|
| 41 | 'coordinates' => [ |
|
| 42 | 'lat' => $this->coordinates->getLatitude()->toDouble(), |
|
| 43 | 'long' => $this->coordinates->getLongitude()->toDouble(), |
|
| 44 | ], |
|
| 45 | ]; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @param array $data |
|
| 50 | * @return GeoCoordinatesUpdated |
|
| 51 | */ |
|
| 52 | public static function deserialize(array $data) |
|
| 53 | { |
|
| 54 | return new GeoCoordinatesUpdated( |
|
| 55 | $data['place_id'], |
|
| 56 | new Coordinates( |
|
| 57 | new Latitude($data['coordinates']['lat']), |
|
| 58 | new Longitude($data['coordinates']['long']) |
|
| 59 | ) |
|
| 60 | ); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||