コード例 #1
0
 /**
  * @param string $type
  * @param Array $response
  * @return \Meup\Bundle\GeoLocationBundle\Model\LocationInterface
  * @throws \Exception
  */
 protected function populate($type, $response)
 {
     if ($response['info']['statuscode'] != '0' || count($response['results'][0]['locations']) === 0) {
         throw new \Exception('No results found.');
     }
     return $this->hydrator->hydrate($response['results'], $type);
 }
コード例 #2
0
 /**
  * @param string $type
  * @param Array $response
  * @return \Meup\Bundle\GeoLocationBundle\Model\LocationInterface
  * @throws \Exception
  */
 protected function populate($type, $response)
 {
     if ($response['response']['GeoObjectCollection']['metaDataProperty']['GeocoderResponseMetaData']['found'] == '0') {
         throw new \Exception('No results found.');
     }
     return $this->hydrator->hydrate($response['response']['GeoObjectCollection']['featureMember'][0], $type);
 }
コード例 #3
0
 /**
  * @param string $type
  * @param Array $response
  *
  * @return \Meup\Bundle\GeoLocationBundle\Model\LocationInterface
  */
 protected function populate($type, $response)
 {
     if ($response['status'] != 'OK') {
         throw new \Exception('No results found.');
     }
     return $this->hydrator->hydrate($response['results'], $type);
 }
コード例 #4
0
 /**
  * @param string $type
  * @param Array $response
  *
  * @return \Meup\Bundle\GeoLocationBundle\Model\LocationInterface
  */
 protected function populate($type, $response)
 {
     if (empty($response)) {
         throw new \Exception('No results found.');
     }
     return $this->hydrator->hydrate($response, $type);
 }
コード例 #5
0
 /**
  * @param string $type
  * @param Array $response
  * @return \Meup\Bundle\GeoLocationBundle\Model\LocationInterface
  * @throws \Exception
  */
 protected function populate($type, $response)
 {
     if (count($response['Response']['View']) == 0 || array_key_exists('Result', $response['Response']['View'][0]) === false) {
         throw new \Exception('No results found.');
     }
     // if relevance too low, consided like No Result Found.
     if ($response['Response']['View'][0]['Result'][0]['Relevance'] <= 0.5) {
         throw new \Exception('No results found.');
     }
     return $this->hydrator->hydrate($response['Response']['View'], $type);
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  *
  * @link http://msdn.microsoft.com/en-us/library/ff701710.aspx
  */
 public function getAddress(CoordinatesInterface $coordinates)
 {
     $address = $this->hydrator->hydrate($this->client->get(sprintf('%s%d,%d?o=json&key=%s', $this->api_endpoint, $coordinates->getLatitude(), $coordinates->getLongitude(), $this->api_key))->send()->json(), Hydrator::TYPE_ADDRESS);
     $this->logger->debug('Locate address by coordinates', array('provider' => 'bing', 'address' => $address->getFullAddress(), 'latitude' => $coordinates->getLatitude(), 'longitude' => $coordinates->getLongitude()));
     return $address;
 }