/**
  * @param string $address
  * @param int    $limit
  *
  * @return $this
  */
 public function geocode($address, $limit = 1)
 {
     try {
         $this->addresses = $this->geocoder->limit($limit)->geocode($address);
     } catch (\Geocoder\Exception\NoResult $ex) {
         $this->errorKey = 'no_results';
         $this->error = RootLocator_Errors::noResults();
         PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error');
     } catch (\Geocoder\Exception\HttpError $ex) {
         $this->errorKey = 'http_error';
         $this->error = RootLocator_Errors::httpError();
         PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error');
     } catch (\Geocoder\Exception\InvalidCredentials $ex) {
         $this->errorKey = 'invalid_credentials';
         $this->error = RootLocator_Errors::invalidCredentials();
         PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error');
     } catch (\Geocoder\Exception\QuotaExceeded $ex) {
         $this->errorKey = 'quota_exceeded';
         $this->error = RootLocator_Errors::quotaExceeded();
         PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error');
     } catch (Exception $ex) {
         $this->errorKey = 'unknown';
         $this->error = RootLocator_Errors::unknown();
         PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error');
     }
     return $this;
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function reverse($latitude, $longitude)
 {
     try {
         return $this->provider->limit($this->getLimit())->reverse($latitude, $longitude);
     } catch (Geocoder\Exception\NoResult $e) {
     } catch (Geocoder\Exception\QuotaExceeded $e) {
         $this->logger->warning(sprintf('QuotaExceeded(%s): %s', $this->provider->getName(), $e->getMessage()));
     } catch (Geocoder\Exception\Exception $e) {
         $this->logger->warning(sprintf('%s(%s): %s', get_class($e), $this->provider->getName(), $e->getMessage()));
     } catch (Ivory\HttpAdapter\HttpAdapterException $e) {
         $this->logger->warning(sprintf('%s(%s): %s', get_class($e), $this->provider->getName(), $e->getMessage()));
     }
     return new AddressCollection([]);
 }