[PLUGINS] +maj gis4
[lhc/web/www.git] / www / plugins / gis / action / gis_geocoder_rechercher.php
1 <?php
2 if (!defined('_ECRIRE_INC_VERSION')) return;
3
4 include_spip("inc/distant");
5
6 /**
7 * Proxy vers le service Nomatim d'OpenStreetMap.
8 *
9 * Cette fonction permet de transmettre une requete auprès du service
10 * de recherche d'adresse d'OpenStreetMap (Nomatim).
11 *
12 * Seuls les arguments spécifiques à Nomatim sont transmis.
13 */
14 function action_gis_geocoder_rechercher_dist() {
15 include_spip("inc/modifier");
16
17 $mode = _request("mode");
18 if(!$mode || !in_array($mode, array("search", "reverse")))
19 return;
20
21 /* On filtre les arguments à renvoyer à Nomatim (liste blanche) */
22 $arguments = collecter_requests(array("json_callback", "format", "q", "limit", "addressdetails", "accept-language", "lat", "lon"), array());
23
24 if(!empty($arguments)) {
25 header('Content-Type: application/json; charset=UTF-8');
26 echo recuperer_page("http://nominatim.openstreetmap.org/{$mode}?" . http_build_query($arguments));
27 }
28 }