2017 © Pedro Peláez
 

library php-nominatim

Wrapper for Nominatim API

image

maxh/php-nominatim

Wrapper for Nominatim API

  • Monday, July 9, 2018
  • by maxh
  • Repository
  • 4 Watchers
  • 8 Stars
  • 3,285 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 14 Versions
  • 21 % Grown

The README.md

Wrapper Nominatim API

Latest Stable Version Build Status Scrutinizer Code Quality Total Downloads MIT licensed, (*1)

SensioLabsInsight, (*2)

A simple interface to OSM Nominatim., (*3)

See Nominatim documentation for info on the service., (*4)

Installation

Install the package through composer:, (*5)

composer require maxh/php-nominatim

Make sure, that you include the composer autoloader somewhere in your codebase., (*6)

Basic usage

Create a new instance of Nominatim., (*7)

use maxh\Nominatim\Nominatim;

$url = "http://nominatim.openstreetmap.org/";
$nominatim = new Nominatim($url);

Searching by query :, (*8)

$search = $nominatim->newSearch();
$search->query('HelloWorld');

$nominatim->find($search);

Or break it down by address :, (*9)

$search = $nominatim->newSearch()
            ->country('France')
            ->city('Bayonne')
            ->postalCode('64100')
            ->polygon('geojson')    //or 'kml', 'svg' and 'text'
            ->addressDetails();

$result = $nominatim->find($search);

Or do a reverse query :, (*10)

$reverse = $nominatim->newReverse()
            ->latlon(43.4843941, -1.4960842);

$result = $nominatim->find($reverse);

Or do a lookup query :, (*11)

$lookup = $nominatim->newLookup()
            ->format('xml')
            ->osmIds('R146656,W104393803,N240109189')
            ->nameDetails(true);

$result = $nominatim->find($lookup);

Or do a details query (by place_id):, (*12)

$details = $nominatim->newDetails()
            ->placeId(1234)
            ->polygon('geojson');

$result = $nominatim->find($details);

Or do a details query (by osm type and osm id):, (*13)

$details = $nominatim->newDetails()
            ->osmType('R')
            ->osmId(1234)
            ->polygon('geojson');

$result = $nominatim->find($details);

By default, the output format of the request is json and the wrapper return a array of results. It can be also xml, but the wrapper return a object SimpleXMLElement, (*14)

How to override request header ?

There are two possibilities :, (*15)

  1. By Nominatim instance, for all request :
$nominatim = new Nominatim($url, [
    'verify' => false
]);
  1. By find method, for a request :
$result = $nominatim->find($lookup, [
    'verify' => false
]);

How to customize HTTP client configuration ?

You can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests, (*16)

<?php
use maxh\Nominatim\Nominatim;
use GuzzleHttp\Client;

$url = "http://nominatim.openstreetmap.org/";
$defaultHeader = [
    'verify' => false,
    'headers', array('User-Agent' => 'api_client')
];

$client = new Client([
    'base_uri'           => $url,
    'timeout'            => 30,
    'connection_timeout' => 5,
]);

$nominatim = new Nominatim($url, $defaultHeader, $client);

Note

This projet was inpired by the Opendi/nominatim project with more features like reverse query, support of the xml format, customize HTTP client and more on which i work., (*17)

Recall Usage Policy Nominatim

If you use the service : http://nominatim.openstreetmap.org/, please see Nominatim usage policy., (*18)

The Versions

09/07 2018

dev-master

9999999-dev https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

26/05 2018

2.1.0

2.1.0.0 https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

25/05 2018

dev-dev

dev-dev https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

25/05 2018

2.0.1

2.0.1.0 https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

26/03 2018

2.0.0

2.0.0.0 https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

26/03 2018

v2.x-dev

2.9999999.9999999.9999999-dev https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

15/01 2018

1.2.3

1.2.3.0 https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

15/01 2018

v1.x-dev

1.9999999.9999999.9999999-dev https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

28/05 2017

1.2.2

1.2.2.0 https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

04/02 2017

1.2.1

1.2.1.0 https://github.com/maxhelias/php-nominatim

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

06/01 2017

1.2.0

1.2.0.0

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

06/01 2017

1.1.1

1.1.1.0

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

01/12 2016

1.1.0

1.1.0.0

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim

22/11 2016

1.0.0

1.0.0.0

Wrapper for Nominatim API

  Sources   Download

MIT

The Requires

 

The Development Requires

geolocation geo web service osm open street map nominatim