简体   繁体   English

获取道路的几何图形(线/图)

[英]Get the geometry (line/draw) of a road

How to get the geometry (line/draw) of a road in an array? 如何在阵列中获取道路的几何图形(线/图)?

It's possible? 这是可能的?

Thanks! 谢谢!

[Sorry my bad english] [抱歉我的英语不好]

This is not currently possible with Google Maps. Google地图当前无法做到这一点。 Open-source web-services like OpenStreetMap are able to return the geometry of all roads in the database (which are pretty much all of them) inside a given bounds. OpenStreetMap这样的开源Web服务能够在给定范围内返回数据库中所有道路的几何图形(几乎所有道路)。 This data can be retrieved in HTTP using an API called Overpass . 可以使用称为Overpass的API在HTTP中检索此数据。

A query for finding all nodes that belong to a specific road could be: 查找属于特定道路的所有节点的查询可以是:

way(s,w,n,e)["name"="Your Road Name"];out;

s,w,n,e are south, west, north, and east bounds for the data to come from. s,w,n,e位于数据的来源地的南,西,北和东边界。

You would need to know approximate bounds. 您将需要知道近似界限。 This can be taken by a geocoding in Google for a road, and then expanding the returned coordinates by, say, 0.1 degrees. 可以通过在Google中对道路进行地理编码,然后将返回的坐标扩展为0.1度来实现。

This will return an XML document: 这将返回一个XML文档:

<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-08-17T12:36:02Z"/>
<way id="16578496">
<nd ref="2399812387"/>
<nd ref="2399812388"/>
<nd ref="2399812389"/>
<nd ref="2399812390"/>
<nd ref="171131426"/>
<tag k="highway" v="residential"/>
<tag k="name" v="Halifax Court"/>
<tag k="tiger:cfcc" v="A41"/>
<tag k="tiger:county" v="Guilford, NC"/>
<tag k="tiger:name_base" v="Halifax"/>
<tag k="tiger:name_type" v="Ct"/>
<tag k="tiger:reviewed" v="no"/>
<tag k="tiger:zip_left" v="27265"/>
<tag k="tiger:zip_right" v="27265"/>
</way>
</osm>

After this, you can query all of the node refs by using: 之后,可以使用以下命令查询所有节点引用:

node(2399812389);out;

You may only query one node at a time. 您一次只能查询一个节点。 This will return something like: 这将返回类似:

<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-08-17T12:58:02Z"/>
<node id="2399812389" lat="36.0107609" lon="-79.9805742"/>
</osm>

After combining the latitude/longitude data for all of the points into a polyline, you have your road geometry. 将所有点的纬度/经度数据合并为折线后,您便拥有了道路几何形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM