0

I was able to create a routable grid based network table with gid, source, target, cost columns. I used pgr_create_topology function for this purpose. I use this map to apply the pgrouting algorithms and works perfectly fine.

The worldmap I have used has the boundaries [-180,180] and [-90,90]. So the problem I have is to route from a port in Japan to a port in west coast of US. Since the network table is disconnected at -180 and 180, the pgrouting routes alon the longest route.

My question is how can I create a routable network from pgrouting considering -180 & 180 issue?

1 Answer 1

1

The antimeridian can cause problems; however, you can choose a different prime meridian (I'm sure that, historically, several nations have claimed their own prime meridian).

Create a copy of whatever data source you used to generate the routing tables.

  • To each node East of Prime Meridian, subtract 180.0 from its longitude
  • For each node West of Prime Meridian, add 180.0 to its longitude
  • For Prime Meridian, choose either -180 or +180

You've now moved the Prime Meridian to the antimeridian, and should be able to route without problems :)

Of course this now breaks routing across the Greenwich Meridian...you've simply moved the discontinuity elsewhere. But you could bring this in as a separate routing network to handle this (literal) edge case, and use your existing network for normal cases.

You'll need to reverse this when it comes to plotting the route, of course - simply reverse the calculations above (bearing in mind the 'prime meridian' is your new antipodean prime meridian, not the one going through Greenwich!)

You could perform routing on both tables, and choose the shorter route.

2
  • I thought about having two networks too. And it seems that is the way to go based on your answer. But with one network table in postgres, won't it work if I give the same ids to -180 meiridan and 180 meridian? (basically replacing 180 meridian ids with -180 meridians)
    – kaja
    Sep 13, 2015 at 1:35
  • I think going with two tables is the right way. I tried ST_SHIFT_Longitude and tried to tweak. It did not work and it won't work as well.
    – kaja
    Sep 23, 2015 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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