pgRouting

Forum #15 - Topic #108 - Message List

Show nearest firestation and plan the route

Hi,

I am trying to prepare a function that the user gives a location on a road where there was an accident, and the system checks which are the nearest firestation / hospital (taking it only firestation for the sake of discussion) is and plans the route to the accident. I want that the nearest firestation will be the nearest on road network, not on Distance().

This is how I am tackling it (I am going to use paste-bin links so as to better show the code and easily reading) :

-1- Receive location of accident through OpenLayers

-2- Request the 3 nearest firestations using Distance() function (so as to minimise the resultset), and grab the total length of each and order so as to present the least lengthy road using a custom PL/PGSQL function : http://yancho.pastebin.com/f65192041

-3- Display the route : http://yancho.pastebin.com/f2e37d248

*** give_source and give_target are customised functions and can be seen here : http://yancho.pastebin.com/f18ff6401 and http://yancho.pastebin.com/f2e1bd4b7 ***

The problem is that some of the times, when the firestation (or hospital for that matter) is near the accident it is disregarded and a further away one is chosen... why is this the case? Where is the bug?

Any help is extremely appreciated

Matthew

  • Message #399

    That sounds really interesting, I would like to have a look to the source code but I think your server is down in the moment.

    • Message #402

      Seems ok now :) pastebin.com decided to go offline for a bit hehe