I have to develop a map-matching algorithm. By the moment I only match gps points with the closest road segment. I'm looking for a way to compare the directions between a gps point and a road to improve the matching. I already have looked at many subjects and I found a way to compare the directions but i've an issue for getting the direction of each GPS point.
I use PostGIS to store and manipulate my data and I want to compute the azimuth of each gps point.
My problem is to have the set of point wich can be use to build a line and calculate the azimuth of this line with :
ST_Azimuth(ST_StartPoint(lineBuilt), ST_EndPoint(lineBuilt))
My idea was to take all gps points inside an area around the current GPS point to build a line and finaly give the direction of this line to the current GPS point, but apparently I'm not as good as I should be with SQL to achieve it. Now, my query looks like that :
SELECT degrees(ST_Azimuth(ST_StartPoint(new_line),ST_EndPoint(new_line)))
FROM
(
SELECT DISTINCT ON(gps.gid) gps.gid, ST_MakeLine(gps.geom ORDER BY gps.gid) AS new_line FROM gps WHERE ST_DWITHIN( currentPoint?, gps.geom, 50) ) AS query;`
I appreciate any help ! =)
أكثر...
I use PostGIS to store and manipulate my data and I want to compute the azimuth of each gps point.
My problem is to have the set of point wich can be use to build a line and calculate the azimuth of this line with :
ST_Azimuth(ST_StartPoint(lineBuilt), ST_EndPoint(lineBuilt))
My idea was to take all gps points inside an area around the current GPS point to build a line and finaly give the direction of this line to the current GPS point, but apparently I'm not as good as I should be with SQL to achieve it. Now, my query looks like that :
SELECT degrees(ST_Azimuth(ST_StartPoint(new_line),ST_EndPoint(new_line)))
FROM
(
SELECT DISTINCT ON(gps.gid) gps.gid, ST_MakeLine(gps.geom ORDER BY gps.gid) AS new_line FROM gps WHERE ST_DWITHIN( currentPoint?, gps.geom, 50) ) AS query;`
I appreciate any help ! =)
أكثر...