I am using the pgr_NodeNetwork
function of the pgrouting
extension to process a table that contains linestring geometries (essentially, roads).
The syntax is the following :
select pgr_nodeNetwork(edge_table:='my_table',
tolerance:=0.0001,
id:='id',
the_geom:='the_geom',
table_ending:='noded',
rows_where:='id < 10',
outall:=false);
In particular, the argument rows_where
is used to process only the rows for which the condition rows_where
is true.
However, at the beginning of the execution, the following notice is raised:
NOTICE: pgr_nodeNetwork('my_table', 0.0001, 'id', 'the_geom', 'noded', '<NULL>', f)
You can see that the notice doesn't take account of the rows_where
argument that was passed to the function (in my example, it was 'id < 10'
).
Moreover, it doesn't seem to be only a display problem in the notice itself, because the processing takes hours for a table with millions of rows, while it should be very fast if the condition 'id < 10'
had really been taken account of (because it would be a table with less than 10 rows).
On the other hand, if we explore the code of the function itself, it begins with:
CREATE OR REPLACE FUNCTION sig.pgr_nodenetwork(
edge_table text,
tolerance double precision,
id text DEFAULT 'id'::text,
the_geom text DEFAULT 'the_geom'::text,
table_ending text DEFAULT 'noded'::text,
rows_where text DEFAULT ''::text,
outall boolean DEFAULT false)
....
raise notice 'pgr_nodeNetwork(''%'', %, ''%'', ''%'', ''%'', ''%'', %)',
edge_table, tolerance, id, the_geom, table_ending, rows_where, outall;
If you define another function with the same parameters and the same RAISE NOTICE
instruction at the beginning, you will see that the notice raised by the function correctly reproduces the rows_where
argument passed by the user.
Does anybody has an explanation as to why the rows_where
argument seems to be utterly ignored by the pgr_nodeNetwork function, while defining a brand new function with the exact same code doesn't yield the same result?
It seems to be a bug (https://github.com/pgRouting/pgrouting/issues/1074). Although not fixed in the extension itself, I provided an alternative (custom) function (see link above).