opendi / nominatim
A simple interface to OSM Nominatim search.
Installs: 1 478
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 2
Open Issues: 0
Requires
- php: ^5.6.0 || ^7.0.0
- guzzlehttp/guzzle: ^6.0.0
Requires (Dev)
- mockery/mockery: @stable
- phpunit/phpunit: ^6.0.0
This package is not auto-updated.
Last update: 2024-10-26 17:04:30 UTC
README
A simple interface to OSM Nominatim search.
See Nominatim documentation for info on the service.
Basic usage
Create a new instance of Nominatim by using the newInstance()
factory method.
use Opendi\Nominatim\Nominatim; $url = "http://nominatim.openstreetmap.org/"; $nominatim = Nominatim::newInstance($url);
Searching by query:
$search = $nominatim->newSearch(); $search->query('1600 Pennsylvania Ave NW, Washington, DC 20500, United States'); $nominatim->find($search);
Or break it down by address:
$search = $nominatim->newSearch() ->street('1600 Pennsylvania Ave NW') ->city('Washington') ->county('Washington') ->state('Washington DC') ->postalCode('DC 20500') ->country('United States') ->addressDetails(); $nominatim->find($search);
The result will be an array of results (in this case, only one result was found).
Array ( [0] => Array ( [place_id] => 2632584431 [licence] => Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright [osm_type] => way [osm_id] => 238241022 [boundingbox] => Array ( [0] => 38.8974898 [1] => 38.897911 [2] => -77.0368539 [3] => -77.0362521 ) [lat] => 38.8976989 [lon] => -77.036553192281 [display_name] => The White House, 1600, Pennsylvania Avenue Northwest, Thomas Circle, Southwest Waterfront, Washington, 20500, United States of America [class] => tourism [type] => attraction [importance] => 1.5576757387296 [icon] => http://nominatim.openstreetmap.org/images/mapicons/poi_point_of_interest.p.20.png [address] => Array ( [attraction] => The White House [house_number] => 1600 [pedestrian] => Pennsylvania Avenue Northwest [neighbourhood] => Thomas Circle [suburb] => Southwest Waterfront [city] => Washington [county] => Washington [postcode] => 20500 [country] => United States of America [country_code] => us ) ) )