MobilityDB / MobilityDB-BerlinMOD

BerlinMOD benchmark, a data generator and a tool for comparying Moving Object Databases
8 stars 9 forks source link

script berlinmod_datagenerator.sql function createPath seems outdated. #11

Closed mitirmizi closed 3 months ago

mitirmizi commented 8 months ago

Setup

pgr_version: 3.6.1

Issue:

As part of my translation of berlinmod generator to python I'm working on the functions in the berlinmod_datagenerator.sql script. When I run the function (link: https://github.com/MobilityDB/MobilityDB-BerlinMOD/blob/65f2c86715764bd75e47e03c8bcafe39f305621c/BerlinMOD/berlinmod_datagenerator.sql#L336) createPath (to understand it) I get the error:

temp_berlinmod=# select createPath(9598, 4010, 'Fastest Path')
temp_berlinmod-# ;
ERROR:  column p.seqno does not exist
LINE 2:     SELECT P.seqNo, P.node, P.edge
                   ^
HINT:  Perhaps you meant to reference the column "p.seq".
QUERY:  WITH Temp1 AS (
    SELECT P.seqNo, P.node, P.edge
    FROM pgr_dijkstra(query_pgr, sourceN, targetN, true) P
  ),
  Temp2 AS (
    SELECT T.seqNo,
      -- adjusting directionality
      CASE
        WHEN T.node = E.sourceNode THEN E.geom
        ELSE ST_Reverse(geom)
      END AS geom,
      maxspeed_forward AS maxSpeed, berlinmod_roadCategory(tag_id) AS category
    FROM Temp1 T, Edges E
    WHERE edge IS NOT NULL AND E.id = T.edge
  )
  SELECT array_agg((geom, maxSpeed, category)::step ORDER BY seqNo)               FROM Temp2
CONTEXT:  PL/pgSQL function createpath(bigint,bigint,text) line 14 at SQL statement

Upon further investigation I also found that indeed the return column for pgr_dijstra in version: 3.6, at least, is seq and not seqno.

Also found that use of column sourceNode in line 345 also give an error:

(psycopg2.errors.InternalError_) Column 'source' not Found
HINT:  SELECT id, sourcenode, targetNode AS target, 
                              cost_s AS cost, reverse_cost_s as reverse_cost FROM Edges
CONTEXT:  SQL function "pgr_dijkstra" statement 1

It requires the use of source and target respectively. I also checked the documentation and the expectations in the errors line up with the documentation. pg_routing documentation: https://docs.pgrouting.org/latest/en/pgr_dijkstra.html

My questions: 1) Is this really an error or am I missing something? 2) If this is an error can I open a pull request to update this function?

mschoema commented 3 months ago

Thanks for the notice, this was indeed an error that was not detected because the createPath function is never automatically called. I have pushed commit a81b5f8 to address this.