Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem creating topology on pgrouting #299

Open
rmarzocchi84 opened this issue May 25, 2022 · 2 comments
Open

Problem creating topology on pgrouting #299

rmarzocchi84 opened this issue May 25, 2022 · 2 comments
Labels

Comments

@rmarzocchi84
Copy link

I import my OSM data using osm2pgrouting and then I try to create topology with pgrouting topology functions:

1)pgr_createTopology works correctly

SELECT pgr_createTopology('network.ways', 0.001, 'the_geom', 'gid');
  1. pgr_createVerticesTable fails
SELECT  pgr_createVerticesTable('network.ways');

Here the error:

PROCESSING:
pgr_createVerticesTable('network.ways','the_geom','source','target','true')
Performing checks, please wait .....
Got cannot truncate a table referenced in a foreign key constraint
ERROR: Initializing vertex table
select count(*) from network.ways WHERE (the_geom IS NULL or source is null or target is null)=true  AND (true)

Platform/versions

  • PostgreSQL 13.7 (Ubuntu 13.7-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit

  • POSTGIS="3.2.1 5fae8e5" [EXTENSION] PGSQL="130" GEOS="3.8.0-CAPI-1.13.1 " PROJ="6.3.1" LIBXML="2.9.10" LIBJSON="0.13.1" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"

  • PgRouting Version 3.3.0

@cvvergara
Copy link
Member

Recommended reading:

@rmarzocchi84
Copy link
Author

I try to follow the instruction in the https://docs.pgrouting.org/dev/en/pgr_extractVertices.html#create-a-routing-topology page:

NOTES:

  1. to drop the vertices table imported with osm2pgrouting DROP TABLE IF EXISTS vertices_table; I need to drop constrains:
ALTER TABLE edge_table DROP CONSTRAINT ways_target_fkey;
ALTER TABLE edge_table DROP CONSTRAINT ways_target_osm_fkey;
ALTER TABLE edge_table DROP CONSTRAINT ways_source_fkey;
ALTER TABLE edge_table DROP CONSTRAINT ways_source_osm_fkey;
  1. --Create the vertices table seems to works not correctly:
    Updated Rows 34701 (not selected !!)

In fact

SELECT  * FROM pgr_extractVertices(
  'SELECT gid, the_geom AS geom FROM edge_table',
  dryrun => true); 

extract 0 row

and

select * from vertices_table;

the result is the following:

image

in_edges and out_edges are null

Finally

WITH
out_going AS (
  SELECT id AS vid, unnest(out_edges) AS eid, x, y
  FROM vertices_table
)
UPDATE edge_table
SET source = vid, x1 = x, y1 = y
FROM out_going WHERE gid = eid;

--> Updated Rows 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants