/** * Return first address coordinates * * @return mixed */ public function getFirstCoordinates() { if ($this->hasError()) { return false; } $coordinates = $this->addresses->first()->getCoordinates(); return ['latitude' => $coordinates->getLatitude(), 'longitude' => $coordinates->getLongitude()]; }
/** * Initialize model & validate client data * * @param \Geocoder\Model\AddressCollection $data */ public function __construct($data) { // setup incoming data $this->setCoordinates($data->first()); $this->setAddress($data->first()); $this->setLocality($data->first()); $this->setCountry($data->first()); $this->setCountryCode($data->first()); $this->setPostalCode($data->first()); }
/** * @param \Geocoder\Model\AddressCollection $addresses * @return array */ private function getResult(\Geocoder\Model\AddressCollection $addresses) { $a = $addresses->first(); return array('latitude' => $a->getLatitude(), 'longitude' => $a->getLongitude(), 'street_name' => $a->getStreetName(), 'street_number' => $a->getStreetNumber(), 'postal_code' => $a->getPostalCode(), 'locality_city' => $a->getLocality(), 'city_district' => $a->getSubLocality(), 'country' => $a->getCountry()->getName(), 'country_code' => $a->getCountryCode(), 'timezone' => $a->getTimezone()); }
/** * Seems like there are no details info anymore, or the provider does not forward it * * @param \Geocoder\Model\AddressCollection $addresses * @return bool True if inconclusive */ public function isConclusive(AddressCollection $addresses) { return $addresses->count() === 1; }