Files
backend/app/Services/NominatimService.php
2024-03-05 10:32:25 +03:30

34 lines
939 B
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\App;
class NominatimService
{
public function get_way_id_from_nominatim($lat = null, $lng = null)
{
if (App::isProduction())
{
$url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16";
$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 (isset($result->osm_type)) {
if ($result->osm_type == 'way') {
return $result->osm_id;
}
}
return 0;
}
return 0;
}
}