You are here

public function Random::reverse in Geocoder 7.2

Reverse geocode latitude and longitude.

Parameters

float $latitude: The latitude

float $longitude: The longitude

Return value

AddressCollection|FALSE

Overrides Provider::reverse

File

src/Plugin/Geocoder/Provider/Random.php, line 61
The TomTom plugin.

Class

Random
Class Random.

Namespace

Drupal\geocoder\Plugin\Geocoder\Provider

Code

public function reverse($latitude, $longitude) {
  $cid = $this
    ->getCacheCid($latitude, $longitude);
  if ($value = $this
    ->cache_get($cid)) {
    return $value;
  }
  try {
    $result = $this
      ->getRandomResult();
    $result['latitude'] = $latitude;
    $result['longitude'] = $longitude;
    $value = $this->factory
      ->createFromArray(array(
      $result,
    ));
    $this
      ->cache_set($cid, $value);
  } catch (\Exception $e) {
    $this->loggerChannel
      ->error($e
      ->getMessage(), array(
      'channel' => 'geocoder',
    ));
    $this->messenger
      ->addMessage($e
      ->getMessage(), 'error', FALSE);
    $value = FALSE;
  }
  return $value;
}