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

无法访问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

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

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗