| Ticket Hash: | cd17e2742e8ef1ba1b2c71d20f00238fbc06cf15 | |||
| Title: | Failed route geometry uses incorrect SRID | |||
| Status: | Closed | Type: | Code_Defect | |
| Severity: | Minor | Priority: | Immediate | |
| Subsystem: | Resolution: | Overcome_By_Events | ||
| Last Modified: | 2017-03-27 15:34:50 | |||
| Version Found In: | 4.3.0a | |||
| User Comments: | ||||
anonymous added on 2017-03-23 11:11:05:
If a route is calculated that isn't possible because the start and end nodes aren't connected then the geometry that is returned (an empty line?) doesn't have the same SRID as the network data. Ideally the empty geometry would be in the same CRS
Demo script below:
-- Set up node and link tables
create table net_nodes (
node_num integer primary key);
SELECT AddGeometryColumn('net_nodes', 'geometry',27700,'POINT','XY');
insert into net_nodes values (1,MakePoint(400000,100000,27700));
insert into net_nodes values (2,MakePoint(400000,100500,27700));
insert into net_nodes values (3,MakePoint(401000,100000,27700));
insert into net_nodes values (4,MakePoint(401000,100500,27700));
create table net_links (
link_id integer primary key,
node_from integer,
node_to integer);
SELECT AddGeometryColumn('net_links', 'geometry',27700,'LINESTRING','XY');
insert into net_links values (1,1,2,MakeLine((SELECT geometry FROM net_nodes WHERE node_num = 1),(SELECT geometry FROM net_nodes WHERE node_num = 2)));
insert into net_links values (2,3,4,MakeLine((SELECT geometry FROM net_nodes WHERE node_num = 3),(SELECT geometry FROM net_nodes WHERE node_num = 4)));
-- Build network (virt_network)
-- Execute routing queries
create table route_output (
from_node INTEGER,
to_node INTEGER,
Cost NUMBER,
PRIMARY KEY (from_node, to_node));
SELECT AddGeometryColumn('route_output', 'geometry',27700,'LINESTRING','XY');
-- Possible route
SELECT * FROM virt_network WHERE NodeFrom = 1 AND NodeTo = 2;
-- Impossible route
SELECT * FROM virt_network WHERE NodeFrom = 1 AND NodeTo = 3;
-- Insert into permanent table:
-- Possible route
INSERT INTO route_output
SELECT NodeFrom,NodeTo,Cost,geometry
FROM virt_network
WHERE NodeFrom = 1 AND NodeTo = 2 AND ArcRowid IS NULL;
SELECT * FROM route_output;
-- Impossible route - this raises a SRID not allowed error
INSERT INTO route_output
SELECT NodeFrom,NodeTo,Cost,geometry
FROM virt_network
WHERE NodeFrom = 1 AND NodeTo = 3 AND ArcRowid IS NULL;
-- Workaround
INSERT INTO route_output
SELECT NodeFrom,NodeTo,Cost,SetSRID(geometry,27700)
FROM virt_network
WHERE NodeFrom = 1 AND NodeTo = 3 AND ArcRowid IS NULL;
SELECT * FROM route_output;
mj10777 added on 2017-03-25 05:18:15:
I can't follow this, since I am not sure hoẃ to SELECT NodeFrom,NodeTo,Cost,geometry FROM virt_network WHERE NodeFrom = 1 AND NodeTo = 3 AND ArcRowid IS NULL; Is the geometry NULL? Add a 'AsEWKT(geometry)' to the SELECT query
anonymous added on 2017-03-27 10:50:30: Sorry, the -- Build network (virt_network) comment is denoting the construction of the pair of Spatialite network tables using the following command: spatialite_network.exe -d "Demo.sqlite" -T net_links -f node_from -t node_to -g geometry -o network_data -v virt_network The output of the following query: SELECT NodeFrom,NodeTo,Cost,geometry FROM virt_network WHERE NodeFrom = 1 AND NodeTo = 3 AND ArcRowid IS NULL; is as follows: NodeFrom NodeTo Cost Geometry 1 3 0.000000 BLOB sz=48 GEOMETRY The geometry isn't NULL, but seems to be a degenerate line In the same query, the AsEWKT(geometry) column has the following value: SRID=-1;LINESTRING() mj10777 (claiming to be mj10777@googlemail.com) added on 2017-03-27 15:24:16:
Thank you.
The '-- Possible route' returned
mj10777 added on 2017-03-27 15:34:50: Since NULL is now returned, this can be closed. | ||||