I am developing an android app where I have to get the user's speed and match it with the speedlimit of the road in order to see how he/she is driving.
I am using Open Street Maps to get the road speed limit. But, I'm having problem in getting the tag 'max-speedlimit' which gives the speed limit of the road. Below given php code I am using to get the latitude and longitude from the app and then finding the speed limit. I am having hardtime getting the speedlimit. As there are so many tags in the response from the OSM, I only want to get the max-speed tag's value
Thank you so much!
<?php
$lat = isset($_POST['lat']) ? floatval($_POST['lat']) : "";
$lng = isset($_POST['lng']) ? floatval($_POST['lng']) : "";
$latm = -0.00015 + $lat;
$latp = 0.00015 + $lat;
$lngm = -0.00015 + $lng;
$lngp = 0.00015 + $lng;
$json_url = 'http://overpass.osm.rambler.ru/cgi/interpreter';
$data = '<query type="way"> <bbox-query s="' . $lngm . '" w="' . $latm . '" n="' . $lngp . '" e="' . $latp . '"/> <!--this is auto-completed with the current map view coordinates.--> </query> <print/>';
$ch = curl_init( $json_url );
$options = array(
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_RETURNTRANSFER => true,
);
curl_setopt_array( $ch, $options );
$result = curl_exec($ch);
//CONVERT THE RESPONSE IN STRING AND GET THE MAXSPEED TAG VALUE ONLY!