You are here

public function NominatimRoadFirstFormattingBase::format in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 modules/geolocation_leaflet/src/NominatimRoadFirstFormattingBase.php \Drupal\geolocation_leaflet\NominatimRoadFirstFormattingBase::format()

Reverse geocode an address.

Intended return subject to available data:

[
  'organization',
  'address_line1',
  'address_line2',
  'postal_code',
  'sorting_code',
  'dependent_locality',
  'dependent_locality_code',
  'locality',
  'locality_code',
  'administrative_area',
  'administrative_area_code',
  'country',
  'country_code',
  'formatted_address',
];

Parameters

array $atomics: Address components.

Return value

array||null Address or NULL.

Overrides NominatimCountryFormattingBase::format

4 calls to NominatimRoadFirstFormattingBase::format()
Brazil::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/Brazil.php
Reverse geocode an address.
Germany::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/Germany.php
Reverse geocode an address.
PhotonAustria::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/PhotonAustria.php
Reverse geocode an address.
PhotonGermany::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/PhotonGermany.php
Reverse geocode an address.
4 methods override NominatimRoadFirstFormattingBase::format()
Brazil::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/Brazil.php
Reverse geocode an address.
Germany::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/Germany.php
Reverse geocode an address.
PhotonAustria::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/PhotonAustria.php
Reverse geocode an address.
PhotonGermany::format in modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting/PhotonGermany.php
Reverse geocode an address.

File

modules/geolocation_leaflet/src/NominatimRoadFirstFormattingBase.php, line 16

Class

NominatimRoadFirstFormattingBase
Alternative street formatting base class.

Namespace

Drupal\geolocation_leaflet

Code

public function format(array $atomics) {
  $address_elements = parent::format($atomics);
  if (!empty($atomics['road'])) {
    $address_elements['addressLine1'] = $atomics['road'];
  }
  if (!empty($atomics['houseNumber'])) {
    $address_elements['addressLine1'] .= ' ' . $atomics['houseNumber'];
  }
  return $address_elements;
}