How to Get Lattitude and Longitude of US Interstate Exits programmatically?

我怕爱的太早我们不能终老 提交于 2019-12-01 04:57:00

问题


Is there a way to do that using open source map / API (Google Map API, Microsoft Live Map API)?

Or is there a way to traverse roads and junction from map files? (if I purchase commericial map data)

Thanks.

Edit: Either open source or API


回答1:


A possible solution based on openstreetmap depending on the quality of OSM data in the US.

As described here "Exit ramps/slip roads should be tagged as highway=motorway_link or highway=primary_link" if you import the map data for the US (using osm2pgsql) you can then select all motorway links.

E.g. (selects based on my own data, i.e. very much outside US)

openmapdb=# select osm_id, name, ref from planet_osm_roads where highway='motorway_link';
  osm_id  | name | ref 
----------+------+-----
 23683997 |      | 
 26436348 |      | 
 [..]

23683997 and 26436348 are the OSM ids - if you click on the links you'll see they are indeed entry/exit ramps.

Once you've identified a way, you can access the latitude and logitude:

openmapdb=# select astext(st_transform(way, 4326)) from planet_osm_roads where osm_id = '23683997';                                                                                                                                             
    LINESTRING(24.8757131412186 44.8730730514894,[..]
(1 row)


来源:https://stackoverflow.com/questions/1960005/how-to-get-lattitude-and-longitude-of-us-interstate-exits-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!