1

I would like to know if it is possible to add dependencies to an edge? (In form of a sql sub-select)

For example:

We have bidirectional (default) edges from node A to B and another "special" edge from B to C. In my case this might be a ship transfer from port B to port C. There are hundreds more streets and a lot less ship edges. But for the sake of simplicity we keep those 3 nodes and 2 edges.

A <--(street)--> B <--(ship)--> C

Those streets reflect a simple and standard topology. Nothing fancy here. But this special edge (B->C) depends on the users presets of using a ship or not.

Now we query a route from A to C:

If the users preference "Use Ships" flag is set to true, the result would be: A -> B -> C.

But if the user has disabled the "Use Ships" flag there is no possible way and the routing function should return an empty result set. The sub-query for our "use_ship" edge would be as simple as SELECT use_ships FROM users WHERE id = $1;

A route for A -> B would always work for any user because they don't hit the special edge from B->C.

Is it possible to add some kind of dependency to an edge like a variable? And which topology function would be able to query something like that?

Thanks in advance! Best, Jan

  • 1
    Think I'm right in saying that the pgrouting functions take queries as arguments, so you can simply add a where clause to the query in the argument list. Which functions are you wanting to use? – mlinth Jan 24 '22 at 11:56
  • 2
    @mlinth You are right! I think it should be possible to add custom columns to the edge_table that might be queried by the given select. `select pgr_dijkstra('SELECT * FROM edge_table WHERE is_ship_edge = true | false', 1, 2)` – Jan Rembold Jan 24 '22 at 12:51

0 Answers0