Given a set of geo coordinates and a geo line (KML file or GeoJSON data) is there an API or algorithm that returns a line that goes along that highway as much as possible while stopping at each coordinate on the way?

With most APIs the driving directions favor the shortest route between points.

What I'm looking for is a route that is not necessarily the shortest but that goes along a particular highway as much as possible.

  • Do you mind to define as much as possible? – FelixIP Nov 30 '16 at 2:13
  • @FelixIP say I want to travel along U.S. Route 66 but stop at various locations along the way. If I just entered the locations as coordinates to a driving API I would get the shortest driving route. But I want the route to go along U.S. Route 66 as much as possible. – Reed G. Law Nov 30 '16 at 2:16
  • 1
    Make the cost of travel trough it's edges close to zero, it will force shortest routes algorithms to favour it. You need a better definition of "as much..". If you highway starts in Mexico and ends in Canada, do you still want to travel it all before exiting? – FelixIP Nov 30 '16 at 2:18
  • @FelixIP can you give me an example? I'm not sure how to set cost of travel. I have a KML file of the route with hundreds of coordinates and a collection of about 20 points of interest along the route. Currently I'm using Mapbox Directions API but I'm open to other possibilities. – Reed G. Law Nov 30 '16 at 2:26
  • 1
    Your API should be able to solve traveling salesperson problem, it is not just the shortest path algorithm. In any case you have to find a way to change cost of travel between nodes. It is easy in arcgis, one can do it by field calculator on 'cost' field – FelixIP Nov 30 '16 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.