1

I tried to setup routing in Spatialite following this guide. The setup of routing data was alright. I'm trying to achieve route from point to point that are not lying directly on the network. Im able to get the results right with using network nodes as points. Example query:

SELECT Algorithm, Request, Options, RouteId, RouteRow, Role, LinkRowid, NodeFrom, NodeTo, PointFrom, PointTo, Tolerance, Cost, Geometry, Name FROM route WHERE PointFrom = (select geometry from guzly where cis_uzlu='0314A013')     AND PointTo = (select geometry from guzly where cis_uzlu='0314A004');

When I try to use points that do not lie exactly on nodes I get one row with 'null' results. Example query:

SELECT Algorithm, Request, Options, RouteId, RouteRow, Role, LinkRowid, NodeFrom, NodeTo, PointFrom, PointTo, Tolerance, Cost, Geometry, Name FROM route WHERE PointFrom = (makepoint(-967512.84770330, -707802.80109579))     AND PointTo = (makepoint(-983114.46396299, -694210.32858570));

Also I'm not able to change routing options as described in guide with this query:

UPDATE route SET Options = 'NO GEOMETRIES', Tolerance = 200;

Tolerance stays always 20 and Options 'Full'. Table route after UPDATE: enter image description here I'm using QGIS DB manager as client. Does anyone has a clue why are not working points aside from nodes?

3
  • Could it be because makepoint(-983114.46396299, -694210.32858570) creates a geometry without SRID?
    – user30184
    Commented Jun 21, 2022 at 22:32
  • Indeed, you were right. I have to add a SRID to makepoint: so it goes like this makepoint(-707802.80109579, -967512.84770330, 5514). Anyway I'm still unable to update routing options, so i'm stuck with 20 m tolerance.
    – Albine Pro
    Commented Jun 22, 2022 at 8:34
  • @user30184 Probably you could add that as an answer and I can make the update options as a separate question.
    – Albine Pro
    Commented Jun 23, 2022 at 10:25

1 Answer 1

1

You missed the note in the Virtual Routing guide https://www.gaia-gis.it/fossil/libspatialite/wiki?name=VirtualRouting

A Point-to-Point query is very similar to a most usual single-destination Shortest Path query, except that:

A classic > Shortest Path query requires to specify a NodeFrom (origin) and a NodeTo (destination).

A Point-to-Point query has a more relaxed requirement, and just requires to specify a PointFrom (origin) and a PointTo (destination). Both Points can be freely positioned everywhere on a map, and are not required to precisely intersect either a Node nor a Link of the underlaying Network. The Point-to-Point's internal logic will then automatically identify (if possible) the appropriate Nodes for computing a Shortest Path solution.

Note: the two Points must use the same SRID of the underlying Network.

makepoint(-983114.46396299, -694210.32858570) does not set SRID at all. Use makepoint(-707802.80109579, -967512.84770330, [SRID_CODE]) instead.

1
  • I was aware of that, the points are the same SRID as the network, but I didn't know it has to be explicitly included in the geometry. Thanks
    – Albine Pro
    Commented Jun 23, 2022 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.