3

I'm new to PostGis and exploring pgrouting features. The requirement is to trace assets within a floor. For example, Our data consists of few building, floor information and assets within the floor. Each building is isolated(not connected to each other but each building have multiple floors. I wanted to select a floor and trace(shortest-path) of the assets within the select floor.

How do I build a topology in this case? I looked into the documentation and there is pgr_labelGraph to label subnetwork.

Can someone help me with some directions on how can I approach this problem.

As far as datamodel, Building is having multiple floors. Both are joined via a foreign key We have captured all the asset geoms in a common table liked via a foreign key with each internal_floor object.

Thank you in advance

  • 1
    (Disclaimer: I am somewhat new to gis and pgrouting myself, and have only used it for 2d data.) Once you have an edges table with `(source, target)` columns, you should be able to use a routing function like `pgr_dijkstra` to calculate paths. If your edges table includes the floor/building, you could use an edges query that filters by floor/building. If you do not have an edges table yet, maybe look into `pgr_createTopology` ... either create topology for each floor separately, or use a tolerance that is less than the vertical distance between floors. – Chris Chudzicki Apr 20 '20 at 16:24

1 Answers1

0

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.

Vicky
  • 119
  • 2