程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

How to get the speed limit of a road using OpenStreetMaps?

发布于2022-09-30 20:01     阅读(140)     评论(0)     点赞(30)     收藏(1)


Im trying to get the speed limit in a specified road using coordinates, I have tried using OpenStreetMaps but I am very new to this API requesting thing, how would you go about requesting info to the API in java? thanks.


解决方案


Roads in OSM are part of the broader category called 'ways'. For example, to find the max speed of the M25 around London you would query a HTTP GET on

/api/0.6/way/27731013

The response is

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.8.1 (12076 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
 <way id="27731013" visible="true" version="17" changeset="69008803" timestamp="2019-04-08T14:10:29Z" user="ika-chan! UK-USA" uid="1016290">
  <nd ref="210993597"/>
  <nd ref="6390949913"/>
  <nd ref="204492"/>
  <nd ref="12086420"/>
  <nd ref="6390949910"/>
  <nd ref="204490"/>
  <nd ref="6390949967"/>
  <nd ref="6390949908"/>
  <nd ref="669805479"/>
  <tag k="active_traffic_management" v="yes"/>
  <tag k="bicycle" v="no"/>
  <tag k="carriageway_ref" v="A"/>
  <tag k="description" v="London Orbital Motorway"/>
  <tag k="foot" v="no"/>
  <tag k="highway" v="motorway"/>
  <tag k="highways_england:area" v="DBFO5"/>
  <tag k="horse" v="no"/>
  <tag k="int_ref" v="E 15;E 30"/>
  <tag k="lanes" v="4"/>
  <tag k="lit" v="yes"/>
  <tag k="maxspeed" v="70 mph"/>
  <tag k="maxspeed:variable" v="peak_traffic"/>
  <tag k="motor_vehicle" v="designated"/>
  <tag k="oneway" v="yes"/>
  <tag k="operator" v="Highways England"/>
  <tag k="ref" v="M25"/>
  <tag k="source:maxspeed" v="UK:motorway"/>
  <tag k="surface" v="asphalt"/>
 </way>
</osm>

The max speed is

<tag k="maxspeed" v="70 mph"/>

This may not always be present. As per this post on the OSM forums

Data in OSM is patchy, and only ~7% of highways in OSM have a maxspeed tag. But many (all?) countries have default speed limits based on the road classification, and you can deduce this from the highway tag value (or the ref), so just because the maxspeed tag is missing doesn't mean that you cannot deduce the speed limit. However this requires you to know the speed limits (or road classifications) for the country/ies you're interested in.



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.javaheidong.com/blog/article/526536/70784bb7907102878f87/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

30 0
收藏该文
已收藏

评论内容:(最多支持255个字符)