-
Notifications
You must be signed in to change notification settings - Fork 0
/
QueryLocation.php
36 lines (28 loc) · 1.02 KB
/
QueryLocation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
//gestisce la query Overpass di Openstreetmap
include('settings.php');
function give_osm_data($lat,$lon)
{
$around =AROUND; //Number of meters to calculate radius to search
$max=MAX; //max number of points to search
$tag=TAG; //tag to search accoring to Overpass_API Query Language
//inserire qui la query Overpass modificando i paramentri
$query = 'node(around:'.$around.','.$lat.','.$lon.')['.$tag.'];out '.$max.';';
$context = stream_context_create( array('http' => array(
'method' => 'POST',
'header' => array('Content-Type: application/x-www-form-urlencoded'), //comment out headers for attachment to app engine
'content' => 'data=' . urlencode($query),
)));
$endpoint = 'http://overpass-api.de/api/interpreter';
$json = file_get_contents($endpoint, false, $context);
//echo $json;
//var_dump(json_decode($json));
if (false === $json) {
$error = error_get_last();
echo $error['message'];
// throw new ClientException($error['message']);
}
//ritorno il dato
return $json;
}
?>