Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function geocode($address)
 {
     $key = 'geocoder_' . sha1($this->locale . $address);
     if (false !== ($data = $this->cache->fetch($key))) {
         return unserialize($data);
     }
     $data = $this->provider->geocode($address);
     $this->cache->save($key, serialize($data), $this->lifetime);
     return $data;
 }
 /**
  * {@inheritdoc}
  */
 public function geocode($address)
 {
     $key = 'geocoder_' . sha1($this->locale . $address);
     if (null !== $this->getLocale() && $this->provider instanceof LocaleAwareProvider) {
         $this->provider->setLocale($this->getLocale());
     }
     if (false !== ($data = $this->cache->fetch($key))) {
         return unserialize($data);
     }
     $data = $this->provider->geocode($address);
     $this->cache->save($key, serialize($data), $this->lifetime);
     return $data;
 }
Пример #3
0
 /**
  * Actual querying.
  * The query will be flatted, and if multiple results are fetched, they will be found
  * in $result['all'].
  *
  * @param string $address
  * @param array $params
  * @return \Geocoder\Model\AddressCollection Result
  */
 public function geocode($address, array $params = [])
 {
     $this->_buildGeocoder();
     try {
         $result = $this->geocoder->geocode($address);
     } catch (NoResult $e) {
         throw new InconclusiveException(sprintf('Inconclusive result (total of %s)', 0));
     }
     if (!$this->_config['allowInconclusive'] && !$this->isConclusive($result)) {
         throw new InconclusiveException(sprintf('Inconclusive result (total of %s)', $result->count()));
     }
     if ($this->_config['minAccuracy'] && !$this->containsAccurateEnough($result)) {
         throw new NotAccurateEnoughException('Result is not accurate enough');
     }
     return $result;
 }