duanlun4411 2015-06-05 16:53
浏览 275
已采纳

无法访问OSM数据库

I am trying to get the speed limit using the OSM through php. But, I am unable to do that because I am getting the message as written below:

The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.

What could be the problem? Below is my php file. Note: the code is still incomplete, I'm for now testing if I am able to access the OSM database.. But I cant. I hope someone could point me to the right direction..

 <?php

$lat  = 24.32633;
$lng = 54.58061;

$latm = -0.00015 + $lat;
$latp = 0.00015 + $lat;
$lngm = -0.00015 + $lng;
$lngp = 0.00015 + $lng;

//$json_url = 'http://overpass-api.de/api/interpreter?data=[out:json];node(24.326180, 54.580460,24.336580, 54.580860);way(bn);(._;>;);out;';
$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_HTTPHEADER => array('Content-type: application/json') ,
CURLOPT_POSTFIELDS => $data,
CURLOPT_RETURNTRANSFER => true,
);

curl_setopt_array( $ch, $options );
$result =  curl_exec($ch);
echo curl_exec($ch);

/*$resultArr = explode("<",$result);
foreach ($resultArr as $val) {
    $temp = explode('"', $val);
    //check the size of the array, if it is == 5, then do
    if ($temp[1]=="maxspeed")
        $speedlimit=$temp[3];

}

echo '{"speedlimit": "120"}'; */
?>
  • 写回答

1条回答 默认 最新

  • ds9567 2015-06-06 08:17
    关注

    Your bounding box is quite small and there's simply no data available in OpenStreetMap for your bounding box. That why you get the following almost empty, but valid result:

    <?xml version="1.0" encoding="UTF-8"?>
    <osm version="0.6" generator="Overpass API">
    <note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
    <meta osm_base="2015-06-06T08:10:03Z"/>
    
      <bounds minlat="54.5805" minlon="24.3262" maxlat="54.5808" maxlon="24.3265"/>
    
    
    </osm>
    

    I would highly recommend to try different options in overpass turbo first to get more familiar with Overpass API. Please check the following link as a starting point: http://overpass-turbo.eu/s/9MQ - it's also restricted to highways with a maxspeed tag (that's what you're looking for, right?).

    For illustration purposes, here's a screenshot with your tiny bounding box in the middle:

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 网页游戏在本地页面修改游戏结果
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化
  • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数