2 if (!defined('_ECRIRE_INC_VERSION')) {
5 include_spip('inc/distant');
8 * Proxy vers le service Nomatim d'OpenStreetMap.
10 * Cette fonction permet de transmettre une requete auprès du service
11 * de recherche d'adresse d'OpenStreetMap (Nomatim).
13 * Seuls les arguments spécifiques à Nomatim sont transmis.
15 function action_gis_geocoder_rechercher_dist() {
16 include_spip('inc/modifier');
18 $mode = _request('mode');
19 if (!$mode ||
!in_array($mode, array('search', 'reverse'))) {
23 /* On filtre les arguments à renvoyer à Nomatim (liste blanche) */
24 $arguments = collecter_requests(array('json_callback', 'format', 'q', 'limit', 'addressdetails', 'accept-language', 'lat', 'lon'), array());
26 $geocoder = defined('_GIS_GEOCODER') ? _GIS_GEOCODER
: 'nominatim';
28 if (!empty($arguments) && in_array($geocoder, array('photon','nominatim'))) {
29 header('Content-Type: application/json; charset=UTF-8');
30 if ($geocoder == 'photon') {
31 if (isset($arguments['accept-language'])) {
32 $arguments['lang'] = $arguments['accept-language'];
33 unset($arguments['accept-language']);
35 if ($mode == 'search') {
40 $url = 'http://photon.komoot.de/';
42 $url = 'http://nominatim.openstreetmap.org/';
45 $url = defined('_GIS_GEOCODER_URL') ? _GIS_GEOCODER_URL
: $url;
46 $data = recuperer_page("{$url}{$mode}?" . http_build_query($arguments));