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

与世无争的帅哥 提交于 2019-12-01 06:27:10

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