GeocodingService
in package
Geocoding service using OpenStreetMap Nominatim
Table of Contents
Constants
- NOMINATIM_BASE_URL = 'https://nominatim.openstreetmap.org'
Properties
- $bounded : bool
- $client : Client
- $countryCode : string|null
- $retryCount : int
- $timeout : int
- $userAgent : string
- $viewbox : array<string|int, mixed>|null
Methods
- __construct() : mixed
- geocode() : GeocodeResult
- Geocode an address to coordinates
- reverseGeocode() : GeocodeResult
- Reverse geocode coordinates to an address
- validateCoordinates() : void
- Validate coordinates
Constants
NOMINATIM_BASE_URL
private
mixed
NOMINATIM_BASE_URL
= 'https://nominatim.openstreetmap.org'
Properties
$bounded read-only
private
bool
$bounded
= false
$client
private
Client
$client
$countryCode read-only
private
string|null
$countryCode
= null
$retryCount read-only
private
int
$retryCount
= 3
$timeout read-only
private
int
$timeout
= 10
$userAgent read-only
private
string
$userAgent
= 'bmlt-php-query-client/1.0.0'
$viewbox read-only
private
array<string|int, mixed>|null
$viewbox
= null
Methods
__construct()
public
__construct([int $timeout = 10 ][, int $retryCount = 3 ][, string $userAgent = 'bmlt-php-query-client/1.0.0' ][, string|null $countryCode = null ][, array<string|int, mixed>|null $viewbox = null ][, bool $bounded = false ]) : mixed
Parameters
- $timeout : int = 10
- $retryCount : int = 3
- $userAgent : string = 'bmlt-php-query-client/1.0.0'
- $countryCode : string|null = null
- $viewbox : array<string|int, mixed>|null = null
- $bounded : bool = false
geocode()
Geocode an address to coordinates
public
geocode(string $address) : GeocodeResult
Parameters
- $address : string
Return values
GeocodeResultreverseGeocode()
Reverse geocode coordinates to an address
public
reverseGeocode(Coordinates $coordinates) : GeocodeResult
Parameters
- $coordinates : Coordinates
Return values
GeocodeResultvalidateCoordinates()
Validate coordinates
private
validateCoordinates(Coordinates $coordinates) : void
Parameters
- $coordinates : Coordinates