TransWikia.com

PGRouting Error Missing table?

Geographic Information Systems Asked by sachin manandhar on October 3, 2020

I am trying to use pgrouting to find the shortest path in GeoServer. So I created new layer in sql view but its giving me error.

I created 3 table in database:

at_2po_4pgr = main table
at_2po_4pgr_noded = contains node network
at_2po_4pgr_noded_vertices_pgr= contains network topology [fields:]

and I wrote following sql statements in sql view in GeoServer

SELECT
 min(r.seq) AS seq,
 e.old_id AS id,
 e.name,
 sum(e.distance) AS distance,
ST_Collect(e.the_geom) AS geom 
 FROM pgr_dijkstra('SELECT id,source,target,distance AS cost FROM at_2po_4pgr_noded',%source%,%target%,false) AS r,at_2po_4pgr_noded AS e 
 WHERE r.at_2po_4pgr=e.id 
GROUP BY e.old_id,e.name

but it shows this error:

Failed to create SQL view: ERROR: column r.at_2po_4pgr does not exist Position: 270

One Answer

As written, r is a table - the output from the pgr_dikstra function, and at_2po_4pgr is your main table.

The join between at_2po_4pgr_noded (aliased as e) and r must be done on the id column, not on the table name.

Try

 SELECT ...  
 FROM pgr_dijkstra('SELECT id,source,target,distance AS cost FROM at_2po_4pgr_noded',%source%,%target%,false) AS r,at_2po_4pgr_noded AS e  
 WHERE r.id=e.id -- <**********

Answered by JGH on October 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP