I want to use pgRouting for showing shortest path on hiking trails. I created web map so I need to enable users when they click on start and end point somewhere on hiking trails, that it shows shortest path between those two points. I am beginner with it, so I just need to tell me where to start. I have those lines in postgis database and I am working with phpPgAdmin and Mapserver.

  • This question is much too broad. You should try some books on web mapping, first. – Sean Jun 15 '11 at 13:00
  • I developed web map which need to have this shortest path function. I don't think it is too broad. I just want you to tell me how to start. I am beginner with pgRouting, not with web mapping. – againstflow Jun 15 '11 at 13:03

First you'll need to get pgRouting running. For a tutorial check: A Beginner’s Guide to pgRouting.

The simplest approach is to do node-to-node routing using shortest_path().

You'll need to enable the user to pick start and end node for their routings. For example code check: Picking a Feature’s Attribute Value From a WMS Layer With OpenLayers

In Mapscript, you can then tie a "Get Routing" button to a function that loads a new layer based on the shortest_path() query.


This is a great tutorial for creating a webmap with routing functionality: http://workshop.pgrouting.org/chapters/geoext_client.html It is based on OpenLayers with GeoExt and pgRouting, but it's easy to adjust it to any other routing webservice.

| improve this answer | |
  • UGh, our IT just blocked wordpress.com, can you provide a direct link so I can wget it perhaps? – dassouki Jun 15 '11 at 13:45
  • 1
    @dassouki use Google Translate then hit the Orginal option (top right corner) translate.google.com/… too work around your IT url blocker... – Mapperz Jun 15 '11 at 13:58
  • @Mapperz - Still Blocked – dassouki Jun 15 '11 at 14:38

Your Answer

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

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