[GIS] Doubts about how pgRouting topology is built and how flexible it is

pgroutingtopology

I'm learning pgRouting, to validate if it can be used in a project. I have several doubts. Mostly related with how could I "fill the gap" between the "bricks" it provides and the real world applications based on routing I normally use. I will summarize the questions in a few ones. Sorry if they're too silly. I have little experience with topology.

EDIT: PolyGeo wisely suggests that I focus this question in one important topic, and leave the rest for different questions. I will reformulate my doubts to create a general question important for me. The already existent responses will still make sense. Anyway, I keep the original questions at the end.

My general doubt is about the topology creation process and how flexible is.

If my data consists in a bunch of lines, and I tell pgRouting to create a topology from that, is a node created at any intersection, apart from the nodes created at the beginning and end of any line? And what about intersections at different level? (for example: a bridge above a motorway: http://goo.gl/pVeE4j, that's not really an intersection) How are these handled? –> EDIT: I've already found this http://goo.gl/ojGmuH. I think it is a response. I need to investigate it.

Once the topology has been built, what do I do if I need new nodes for a query? Example: I want the shortest path from any arbitrary point in my route to another arbitrary point, not just from one existent node to another one (example: the Google Maps feature "give me directions from my current location to this marker I've just put in the map")

Regarding the topology, my last doubt is if the PostGIS topology and the pgRouting topology are related in any sense.

These are the original 6 questions I made:

  1. About creating the topology: you feed the engine with a few lines, as the base of the topology. I guess a new vertex is created every time two of these lines intersect, apart from the vertex created at the beginning and the end of each line. Am I right?

  2. When two lines intersect at different level, how is it handled? (if it's really handled). For example, a bridge above a motorway. Something like this: http://goo.gl/pVeE4j

  3. I've seen several examples using really simple data: a few lines forming a simple network. I've also seen examples using OSM data imported with osm2po or osm2pgrouting. OSM data is great, and complex. But what if I want an intermediate point? Not as simple as a single table with a few dozens of prepared linestrings and not as complex as OSM datasets. Sometimes, we need to work with data provided by public institutions (old digitized maps, cadastre datasets, etc). Is there any way to integrate data from different sources? Any method to ease the compliance of my data with the minimum requisites for pgRouting to create a topology based on it? So, to go from chaos (different sources, different methods to obtain the data…) to a polished set of PostgreSQL tables, ready to work with?

  4. The minimum path algorithms always need two nodes (from A to B). No problem if those points are actual vertices of my topology. But, what if I want to calculate a path from this exact point where I am right now to another arbitrary point? Like the Google Maps calculation: "give me the path from my current location to X". Creating new vertices every time an arbitrary path is requested and rebuilding the topology sounds like nonsense for me.

  5. About the turn restrictions, I find the underlying logic difficult to understand. What do the parameters of restriction SQL mean? In the example, a restrictions table is created. Why those fields?

  6. Do pgRouting topology and PostGIS topology know each other? If not, are they planning to converge/collaborate in any point?

So, summarizing, in my opinion pgRouting looks like a really great framework, but I think there are a lot of things to learn, understand and build in order to construct a routing engine using it.

Best Answer

I'm trying to give a brief reply to your questions:

  1. The topology function assigns a source and a vertex ID for each road segment. To do this a vertex table is created, which contains all source and target IDs. You can use this vertex table, but it's not required.

  2. If there is no shared node at an intersection, then the topology script will not connect these 2 roads.

  3. You can use any network data you want.

  4. You need to handle intermediate points yourself. PostGIS provides various functions to find nearest roads and split them, see ST_LineLocatePoint or ST_LineSubstring. pgRouting is a set of basic functions, which add routing or network analysis functionality.

  5. Turn restrictions are complex. You should first start with something simple.

  6. PostGIS and pgRouting topology functions are different. pgRouting cares about a valid "network".

You probably best start with the pgRouting workshop.

Related Question