Use your imagination on the following visual representation of a building:
- you have a building
- the building has floors
- the floors have halls and rooms
- the connection between floors is by stairs and elevators
- main floor has an exit door that connects to the outside
How to prepare the graph for routing from one room to another?
2 floor building
- The nodes are: the outside, the room's doors, the stair and elevator doors and all the nodes along the hall way: a1~a4 & b1~b4
- The black edges are in the middle of the the hall,
- The blue edges go from the middle of the hall to the room's door,
- The edges connecting the floors are the stairs an elevator shaft respectively
The edge table for routing might have this information:
for the (stair_door1, the stair_door2) edge:
- id = 1
- source = 15 (assuming that star_door1 has id 15)
- target = 66 (assuming that star_door2 has id 16)
- cost = 1.5 (going upstairs is slower)
- reverse_cost = 0.6 (going downstairs is faster)
for the (elevator_door1, elevator_door2) edge:
- id = 1
- source = 15 (assuming that star_door1 has id 15)
- target = 66 (assuming that star_door2 has id 16)
- cost = 0.3
- reverse_cost = 0.3
And so on for each edge.
You have to decide what the costs are, if you have geometries available, you might use length and use undirected graph.
Once you have your edges table and vertex table (remember a graph G = {E, V})
) you can proceed to use for example pgr_dijkstra
That is all you need for routing, as you can see there is no need for geometries, etc, but, for a final application en the edges and vertices table you might need geometries, names (like the node names), floor number, etc, but the additional columns on the tables depend on the application.