sheub/ban-france-provider

Geocoder Base Addresse Nationale France adapter

dev-master / 1.0.x-dev 2018-12-11 23:00 UTC

This package is auto-updated.

Last update: 2024-10-12 11:33:51 UTC


README

Build Status Quality Score Latest Stable Version Software License

Geocoder PHP is a PHP library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding and reverse-geocoding. See the main repo for the documentation.

This is the provider for the Base Addresse Nationale Geocoder. Its coverage is limited to France. Additional information on the service and the API can be found here: https://adresse.data.gouv.fr/

Install

composer require sheub/ban-france-provider

Usage

use Geocoder\Query\GeocodeQuery;
use Geocoder\Provider\BANFrance\BANFrance;
use Geocoder\Model\Coordinates;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
use Http\Client\HttpClient;


$httpClient = new \Http\Adapter\Guzzle6\Client();
$geocoder = new BANFrance($httpClient);

// Query with unstructured address
$result = $geocoder->geocodeQuery(GeocodeQuery::create('8 Boulevard du Port 80000 Amiens'));

// Query with limit and postcode
$query = GeocodeQuery::create('8 Boulevard du Port');
$query = $query->withLimit(1);
$query = $query->withData('postcode', 80000);

$result = $provider->geocodeQuery($query);


// Reverse geocoding
$provider = new BANFrance($httpClient);
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(48.8632156, 2.3887722));

Contribute

Contributions are very welcome! Send a pull request to the main repository or report any issues you find on the issue tracker.