pgRouting / pgRoutingLayer

pgRouting Layer plugin for QGIS
https://qgis.pgrouting.org/
GNU General Public License v2.0
23 stars 18 forks source link

When "directed" option is enabled, "No paths found in (U) pgr_..." error is shown #144

Open sanak opened 1 year ago

sanak commented 1 year ago

Problem From the following issue's comment: https://github.com/pgRouting/pgRoutingLayer/issues/133#issuecomment-1257613070

: However none of the functions work with directed option enabled (pgrouting 3.3.0 , osm2pgrouting 2.3.8.1) Sql querys work

No paths found in (U) ...

Here is the error message when using pgr_dijkstra.

pgrouting-layer-directed-enabled-error

To Reproduce

  1. Check on "directed" option
  2. Execute "Preview" function

Expectation The error message should not shown, and the directed result should be drawn.

sanak commented 1 year ago

@jonath35 On my environment, turning on Reverse Cost and set appropriate column name solved the above No paths found in (U) pgr_... issue when directed is enabled. pgrouting-layer-directed-workaround

If you don't set Reverse Cost, could you try above once ?

cvvergara commented 1 year ago

Ah, interesting ...

no reverse_cost

For this structure edge_table1 without reverse_cost

gid source target cost
1000 1 2 23
1001 2 1 23

Without the tick mark: SELECT gid AS id, source, target, cost FROM edge_table1 This represents,1<--->2 With the tick mark: There would be an error because the reverse_cost column does not exist on the edge_table1

with reverse_cost

For this structure edge_table2 with reverse_cost

id source target cost reverse cost
1000 1 2 23 23

Without the tick mark: These represents,1<--->2 SELECT gid AS id, source, target, cost, reverse_cost FROM edge_table2 This is weird but also works SELECT gid AS id, source, target, reverse_cost AS cost, cost AS reverse_cost FROM edge_table2

Without the tick mark: But if the tick is not there then the query of the image above is SELECT gid AS id, source, target, cost FROM edge_table2 This represents,1--->2 path from 2 to 1 will not be found

If the word reverse_cost is on the Cost field the query would be SELECT gid AS id, source, target, reverse_cost AS cost FROM edge_table2 This represents,1<---2 path from 1 to 2 will not be found In these last 2 cases, the graph is not complete as you want 1<-->2 as the graph and no path will be found depending on the query.

conclusion

sanak commented 1 year ago

@cvvergara Okay, thanks for the details!

About graph related part, I may not understand correctly, so I will try to check those in the following example data, later. https://docs.pgrouting.org/3.3/en/sampledata.html

About the conclusion part,

  • Have a tick mark on the Reverse_cost field as default as the data from osm2pgrouting has the reverse_cost column

Okay, sure. Default tick mark=on will have less troubles.

  • Send an appropiate message when the reverse_cost column does not exist on the inner query

Okay, but is it better to show (raise) this message before running pgr_xxx query in pgRoutingLayer side ? Or is there possibility to show error in each pgr_xxx functions initial validation process ?