create FMS service with test
This commit is contained in:
@@ -30,4 +30,36 @@ class NominatimService
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getIDFromNominatim($s_lng, $s_lat, $d_lng, $d_lat)
|
||||
{
|
||||
if (App::isProduction())
|
||||
{
|
||||
$url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true";
|
||||
$arrContextOptions = array(
|
||||
"ssl" => array(
|
||||
"verify_peer" => false,
|
||||
"verify_peer_name" => false,
|
||||
),
|
||||
);
|
||||
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||
$result = json_decode($result);
|
||||
if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) {
|
||||
// if(){
|
||||
$ways = $result->routes[1]->legs[0]->steps;
|
||||
// }
|
||||
} else
|
||||
$ways = $result->routes[0]->legs[0]->steps;
|
||||
$ids = array();
|
||||
foreach ($ways as $key => $value) {
|
||||
if (!in_array($value->name, $ids)) {
|
||||
$ids[] = $value->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
return [1, 2, 3];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user