Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have an application where the user selects some "markers" from a google maps (all those coordinates' markers are stored into a postgresql database). Right now, I can draw the route between all selected markers (using DirectionService) but when I have over 10 waypoints the route seems to be drawn in the user selected order (not in the "shortest route" order - I also used optimizeWaypoints param to true and split the route into subroutes of 8 points + start and stop points without success). What I`m trying to do now: when the user selects a marker, I save his selection (marker coordinates) and then all selected coordinates are sent (via ajax) to the server. The received coordinates are in a format something like this: array((lat1,lng1), (lat2,lng2), ...(latn,lngn)) From here, I want to return back to the user all those coordinates ordered by "shortest path" and I dont know how to achieve this.

Any idea will be great. Thanks.

share|improve this question
    
An illustration could help: in its current form, your question seems to be asking for a solution to the Traveling Salesman Problem, but it is not clear this is what you really need. –  whuber Jun 26 '13 at 18:08
    
Yes, I think it`s a form of TSP but all my points are not stored into database table. –  George Hown Jun 26 '13 at 18:19
    
What exactly are you asking for, then? A detailed TSP algorithm? TSP code that you could use? Help in reformatting your points so that they could be read by such code? –  whuber Jun 26 '13 at 19:20
add comment

1 Answer

Since you say your markers are stored in a postgresql database, this material will be very useful for you: TSP with pgRouting

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.