others (#15) - Map matching (#191) - Message List

Map matching

Please, do any one know if there is any function in postgresql for map matching or also known as map snapping.The Gps Unit (x,y) points are a little bit off the road. i want to know on how i can match the GPS (x,y) to the closext point on the map. i have tried several ways but the points(x,y) i am getting are not accurate. your urgent assitance is appreciated. Thank you

Ilotus

  • Message #672

    You could try this: http://pgrouting.postlbs.org/browser/trunk/core/sql/matching.sql

    It should be close to what you're looking for.
    It's currently in "trunk", so if you find any improvements or errors, please let us know about it.

    • Message #673

      Hello daniel, Thank you for your response. i have gone through the functions -(matching.sql). please can you give me more insight on how i can implement these functions. any simple example will be highly appreciated. Thank you and look forward to your kind reply.

      • Message #674

        I used this query to "match" a line with a road network:

        SELECT * FROM match_line_as_linestring(
                           'my_network_table',
        	            setsrid(GeometryFromText('LINESTRING(x1 y1, x2 y2, ... ),4326),
        	            0.01, 0.01, false, false
                    );
        
        • Message #676

          Hello daniel, Thank you once again. i have tried the same querry and it returns a linestring. actually, i want to pass a point i.e longitude, latitude from the gps unit, to get a matching point(x,y) on the map. do you have any idea on how to do that? secondly,does it mean i need to create a linestring from a point(x,y), knowing full well that a linestring comprises of two or more points?

          The scenario is like this; i have a gps unit but most times the recieved (lat lon) is not exactly on the road. so i want to correct this by obtaining the accurate point from the map, so that i can make use of the corrected point while rendering the map. so is there anyway, i can get a matching point from the linestring obtained? thank you for your kind assistance and hope to hear from you on this.

          • Message #677

            The function I mentioned above returns a single linestring (path) and tries to match it with the network.
            What you need is probably much more simple. You just want to find the nearest road link to your actual GPS point, right?

            This you can do with PostGIS only and it doesn't require pgRouting. Look at this example from the last year's workshop: http://pgrouting.postlbs.org/wiki/Workshop-ClosestEdge
            The query searches for all links within a bounding box around your point, orders them by distance and returns the one on the top.