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

后端 未结 1 812
南方客
南方客 2021-01-13 14:44

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

相关标签:
1条回答
  • 2021-01-13 15:25

    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)
    
    0 讨论(0)
提交回复
热议问题