Example #1
0
 /**
  * @param Point     $point
  * @param \DateTime $date
  *
  * @return array
  *
  * @throws null
  */
 public function getZonesFromCoordinates(Point $point, \DateTime $date = null) : array
 {
     $date = $date ?? new \DateTime('now');
     $datas = $this->manager->getDBResults('@Api/sql/zones/getMatchingZones.sql.twig', ['point' => $point, 'date' => $date], new NoZonesForLatLonException($point->getX(), $point->getY()));
     $zones = [];
     foreach ($datas as $zone) {
         $zone = ArraysUtils::toMultiDimensional($zone);
         $zones[] = $this->hydrator->hydrateZone($zone['id'], $this->hydrator->hydrateCountry($zone['country']['id'], $zone['country']['name'], $zone['country']['iso_code_2_letters']), $this->hydrator->hydrateZoneType($zone['zone_type']['id'], $zone['zone_type']['name'], $zone['zone_type']['slug'], $zone['zone_type']['level'], $this->hydrator->hydrateCountry($zone['country']['id'], $zone['country']['name'], $zone['country']['iso_code_2_letters'])), $zone['ref'], $zone['ref_official'], $zone['name'], $zone['slug'], $zone['population'], $zone['wikipedia'], !is_null($zone['date_from']) ? new \DateTime($zone['date_from']) : null, !is_null($zone['date_until']) ? new \DateTime($zone['date_until']) : null, $zone['shape_polygon'], $zone['shape_multipolygon']);
     }
     return $zones;
 }
Example #2
0
 /**
  * @param Point $point1
  * @param Point $point2
  *
  * @return $this
  */
 public function setCoordinatesFromPoints(Point $point1, Point $point2)
 {
     $this->coordinates = [$point1->getCoordinates(), $point2->getCoordinates()];
     return $this;
 }