reverse() публичный Метод

Reverses geocode given latitude and longitude values.
public reverse ( double $latitude, double $longitude ) : Geocoder\Model\AddressCollection
$latitude double
$longitude double
Результат Geocoder\Model\AddressCollection
Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function reverse($latitude, $longitude)
 {
     if ($this->getProvider() instanceof GeocoderProvider) {
         return $this->getProvider()->getReversedData(array($latitude, $longitude));
     }
     return parent::reverse($latitude, $longitude);
 }
 public function geolocateSubmit()
 {
     if (isset($_POST['lat'], $_POST['lng'])) {
         $lat = $_POST['lat'];
         $lng = $_POST['lng'];
         $url = sprintf("https://maps.googleapis.com/maps/api/geocode/json?latlng=%s,%s", $lat, $lng);
         $content = file_get_contents($url);
         // get json content
         $metadata = json_decode($content, true);
         //json decoder
         if (count($metadata['results']) > 0) {
             // for format example look at url
             // https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452
             $result = $metadata['results'][0];
             $GeoJSON = new \Geocoder\Dumper\GeoJsonDumper();
             $adapter = new \Geocoder\HttpAdapter\CurlHttpAdapter();
             $geocoder = new \Geocoder\Geocoder();
             $geocoder->registerProvider(new \Geocoder\Provider\GoogleMapsProvider($adapter));
             $address = $geocoder->reverse($lat, $lng);
             $result = $this->locationFormatter($address);
             return view('result', $result);
         } else {
             // no results returned
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function reverse($latitude, $longitude)
 {
     if ($this->getProvider() instanceof Provider) {
         $value = $latitude . '-' . $longitude;
         return $this->getProvider()->getReversedData(array($latitude, $longitude));
     } else {
         return parent::reverse($latitude, $longitude);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function reverse($latitude, $longitude)
 {
     if (null === $this->logger) {
         return parent::reverse($latitude, $longitude);
     }
     $startTime = microtime(true);
     $results = parent::reverse($latitude, $longitude);
     $duration = (microtime(true) - $startTime) * 1000;
     $value = sprintf("[Reverse geocoding] latitude: %s, longitude: %s", $latitude, $longitude);
     $this->logger->logRequest($value, $duration, $this->getProviderClass(), $results);
     return $results;
 }
Пример #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $coordinate = new Coordinate($input->getArgument('coordinate'));
     $geocoder = new Geocoder();
     $adapter = $this->getAdapter($input->getOption('adapter'));
     $provider = $this->getProvider($input->getOption('provider'));
     if ($input->getOption('args')) {
         $args = is_array($input->getOption('args')) ? implode(',', $input->getOption('args')) : $input->getOption('args');
         $geocoder->registerProvider(new $provider(new $adapter(), $args));
     } else {
         $geocoder->registerProvider(new $provider(new $adapter()));
     }
     $reversed = $geocoder->reverse($coordinate->getLatitude(), $coordinate->getLongitude());
     $formatter = new Formatter($reversed);
     if ($input->getOption('raw')) {
         $result = array();
         $result[] = sprintf('<label>Adapter</label>:       <value>%s</value>', $adapter);
         $result[] = sprintf('<label>Provider</label>:      <value>%s</value>', $provider);
         if ($input->getOption('args')) {
             $result[] = sprintf('<label>Arguments</label>:     <value>%s</value>', $args);
         }
         $result[] = '---';
         $result[] = sprintf('<label>Latitude</label>:      <value>%s</value>', $reversed->getLatitude());
         $result[] = sprintf('<label>Longitude</label>:     <value>%s</value>', $reversed->getLongitude());
         if (null !== ($bounds = $reversed->getBounds())) {
             $result[] = '<label>Bounds</label>';
             $result[] = sprintf(' - <label>South</label>: <value>%s</value>', $bounds['south']);
             $result[] = sprintf(' - <label>West</label>:  <value>%s</value>', $bounds['west']);
             $result[] = sprintf(' - <label>North</label>: <value>%s</value>', $bounds['north']);
             $result[] = sprintf(' - <label>East</label>:  <value>%s</value>', $bounds['east']);
         }
         $result[] = sprintf('<label>Street Number</label>: <value>%s</value>', $reversed->getStreetNumber());
         $result[] = sprintf('<label>Street Name</label>:   <value>%s</value>', $reversed->getStreetName());
         $result[] = sprintf('<label>Zipcode</label>:       <value>%s</value>', $reversed->getZipcode());
         $result[] = sprintf('<label>City</label>:          <value>%s</value>', $reversed->getCity());
         $result[] = sprintf('<label>City District</label>: <value>%s</value>', $reversed->getCityDistrict());
         $result[] = sprintf('<label>County</label>:        <value>%s</value>', $reversed->getCounty());
         $result[] = sprintf('<label>County Code</label>:   <value>%s</value>', $reversed->getCountyCode());
         $result[] = sprintf('<label>Region</label>:        <value>%s</value>', $reversed->getRegion());
         $result[] = sprintf('<label>Region Code</label>:   <value>%s</value>', $reversed->getRegionCode());
         $result[] = sprintf('<label>Country</label>:       <value>%s</value>', $reversed->getCountry());
         $result[] = sprintf('<label>Country Code</label>:  <value>%s</value>', $reversed->getCountryCode());
         $result[] = sprintf('<label>Timezone</label>:      <value>%s</value>', $reversed->getTimezone());
     } elseif ($input->getOption('json')) {
         $result = sprintf('<value>%s</value>', json_encode($reversed->toArray()));
     } else {
         $result = sprintf('<value>%s</value>', $formatter->format($input->getOption('format')));
     }
     $output->writeln($result);
 }
Пример #6
0
 /**
  * {@inheritDoc}
  *
  * @static 
  */
 public static function reverse($latitude, $longitude)
 {
     return \Geocoder\Geocoder::reverse($latitude, $longitude);
 }