发布于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黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 java黑洞网 All Rights Reserved 版权所有,并保留所有权利。京ICP备18063182号-2
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!