1

I'm trying to solve common problem, how to generate route/navigate between two GPS coordinates and not between two edges using trsp algorithm. I did read many articles here but i'm not sure how should i create temporary edge on huge psql database where even now routing taking several seconds and insert/update can take forewer.

Solution where i will navigate to nearest edge and then calculate distance between edge coordinates and destination coordinates is in my case not good b/c i'm trying to avoid one way streets and this solution is ignoring it.

Another solution i have is to find edge where both start(x1,x2) and end(x2,y2) coordinates are nearest to the destination GPS coordinates ( which does not need to be nearest edge ) and navigate there but found this edge is also very slow.

2

Matus
It seems I am having the same problem. I will give you a partial answer and then present my problem.
Did you try the second version of pgr_trsp? Given start(x1,y1) and end(x2,y2) you can locate the nearest edges with an appropriate query. Then, with Linear Referencing functions, you can have the appropriate floating point (0 to 1) values that represent the points along that edge. Here is what I did:

WITH ways AS    (
    --The following selects the closest segment to the signal
    SELECT DISTINCT ON (tl.oid)     tl.oid AS oid,
                    map.id AS id,
                    map.geom_way AS map_geom,
                    tl.the_geom AS point_geom,
                    tl.veh_id AS veh_id
                FROM gps_signal_table tl
                JOIN ways_table map ON ST_DWithin (tl.the_geom, map.geom_way, 0.001)
            ORDER BY tl.oid,  ST_Distance(tl.the_geom,map.geom_way),tl.veh_id 
        )
UPDATE gps_signal_table AS tl SET
    edge_id = id,
    point_on_edge = ST_ClosestPoint (map_geom,point_geom),
    position_on_edge = ST_LineLocatePoint (map_geom,point_geom)
    FROM ways WHERE tl.oid = ways.oid;

My problem lies in the fact that I cannot (yet) take advantage of the results that this function pgr_trsp(sql,edgeid1,position1,edgeid2,position2) produces, i.e. create a LINESTRING geometry from it.
I hope this helps and I hope you can help back!

| improve this answer | |
1

If you don't have an edge from where you want to start from, you won't be able to apply routing logic to it. I suggest reworking your implementation to ensure you have adequate nodes based on your routing needs. If you don't have attributes such as streets, one way properties and so on encoded into your network graph, clearly you aren't going to be able to route it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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