Thursday 20 October 2016

postgis - How to add offsets to the route?


Edited:


sample


I want to ilustrate my question. Suppose that you're in "Point A" and want to go to "Point B". This points wouldn't be in "at_2po_4pgr" table cause aren't source/targets nodes. Then, I would search for the nearest node for points A and B (green points). After this, I might perform a shortest_path call using green points ids and I would obtain "orange" path. But to obtain the real path cost (distance) in first case I would have to substract "offsetA" and in second case add de "offset B". To calculate distance between red-points and green-points, I run the following query:


SELECT * FROM st_distance( ST_GeomFromText('POINT(-3.6963314 42.3498066)',4326), ST_GeomFromText('POINT(-3.6954276 42.3479634)',4326)).


How I would know when add or substract the offset?



Sorry for my english!



Answer



I do not think that you can rely on the nearest vertex. Imagine source and target are located on the same edge close to the same vertex.


You'd rather considered three! different cases:



  1. a vertex is the nearest point.

  2. a form node of the edge is the right one

  3. the edge-line itself is nearer. (orthogonal)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...