2015-06-05 169 views
0

我想通过php使用OSM获得速度限制。但是,我无法这样做,因为我收到的信息如下所示:无法访问OSM数据库

本文档中包含的数据来自www.openstreetmap.org。数据在ODbL下可用。

可能是什么问题?以下是我的PHP文件。 注意:代码仍然是不完整的,我现在测试,如果我能够访问OSM数据库..但我不能。我希望有人能指出我朝着正确的方向..

<?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"}'; */ 
?> 

回答

2

你的边框是相当小的,有简单的为您的边框在OpenStreetMap的无数据。这就是为什么你会得到以下几乎是空的,但有效的结果:

<?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> 

我会强烈建议尝试在立交桥涡轮第一不同的选项来获得更多的熟悉立交桥API。请检查以下链接作为起点:http://overpass-turbo.eu/s/9MQ - 它也限制在具有最高速度标记的高速公路上(这是您要找的内容,对不对?)。

为了便于说明,这里是截图,在中间你的小边框:

enter image description here

+0

喔!雅,我认为这将是问题..非常感谢!尝试不同的坐标后会让你知道.. – 3mmaar

+0

发送最小和最大经纬度时,我的查询格式是否正确?我给出了坐标[24.883968,55.544899],其中[minlong = 24.89,minlat = 24.88,maxlong = 55.54,maxlat = 55.55],但是立交桥似乎并没有运行它!这需要时间,永远不会返回任何东西...有什么可以解决的问题:(?? – 3mmaar

+0

请点击“分享”在立交桥涡轮增加您的查询发表固定链接 – mmd