I am newbie in PostGIS and also GIS particularly.
I need to check that a vehicle is outside of a route. This route has been defined in advance, and of course it stores in a table: RROUTEDETAIL. This table contains: ROUTE_ID, LONGITUDE and LATITUDE.
So, when vehicle leaves the route they should be on, the system will give a warning message and then record it into other table.
I imagine to check the point I get with every point store in the RROUTEDETAIL, one by one with ST_DWITHIN. If all check get FALSE value, then the system give a warning message.
Is this the best approach or is there a better idea ?
Thank you very much.
Best regards, Dion.
For example, this is the point where vehicle leaves: -7.539079, 109.322891 with value tolerance: 0.5. Then I write:
select st_dwithin((select st_makeline(ST_Point(-7.539079, 109.322891))), (select st_makeline(ST_Point(foo."TRACKERDATA_LATITUDE",foo."TRACKERDATA_LONGITUDE")) from (select ht."TRACKERDATA_LATITUDE", ht."TRACKERDATA_LONGITUDE" from "HTRACKERDATA" ht left join "RVEHICLE" rv on ht."VEHICLE_ID" = rv."VEHICLE_ID" where ht."VEHICLE_ID" = 106 and ht."TRACKERDATA_GPSTIME" BETWEEN '2012-01-01 08:00' AND '2012-01-01 17:00' order by ht."TRACKERDATA_GPSTIME", ht."TRACKERDATA_REPORTTIME") as foo), 0.5);
It always return FALSE. Then I check again with ST_DISTANCE, it gives 99999999999.9 (double precision).
How to fix that ?