View Full Version : Check out if GPS pos is on a Route
11-14-2005, 09:52 AM
First thank you for this great forum, i searched through it but couldn't find exactly what i am looking for.
I have a problem, i don't exactly know how to solve.
I have a route going from A to B.
I get an GPS coordinate.
How do i check if the GPS position is on the Route between A and B ?
Thank you for any suggestions !
11-15-2005, 02:33 PM
The only way to know this is to draw a polygon around the route. The poligon has to be wider than the route because there could be traffic deviations.
11-17-2005, 02:54 AM
thank you for your response.
this sounds very difficult. I think i don't quite understand, how do i draw the polygon ? Am i able to move along the route, which is calculatet and displayed in Mappoint. Do i draw the polygon then in mappoint ?
Might there be any hope that in mappoint 2006 this would be better ?
11-17-2005, 08:51 AM
Sorry that I was so unclear. First let mappoint calculate the route for the vehicle. Then you can draw a polygon around the route. For each point in the polygon you draw you have to save the coordinates. This you can do in a beforeClick event handler.
To actual see if each GPS position of the car is within the polygon has nothing to do with mappoint anymore. Your program has to calculate it. It can be done following way:
Reduce the polygon to a triangle by replacing 2 successive sides by 1 new side, then calculate if the residual riangle contains the point. If not then calculate on the next triangle etc...
Not very easy done but not a big problem tough.
11-17-2005, 01:23 PM
I'm not getting what you mean too... do you have a bit of code or pseudo code that gives us a better idea... It seems your solution is brilliant but I'm not sure the majority of us are understanding it.
11-17-2005, 01:48 PM
I guess you right. If I read my explanation then I dont understeand eahter :shock:
This it is difficult because I dont know all the naming of figures etc. I try to make some drawings to explain what I mean, because even with some pseudocode it will be difficult, and it is really not so difficult, I have done sutch things several times.
I'll keep in touch :)
11-17-2005, 02:06 PM
Whell I made a little drawing to explain what I mean. See http://www.mestdagh.biz/mp/polygon.gif
The top drawing is the polygon where the vehicle is maybe in or maybe not. How to check this simple. See second drawing.
we connect 2 sides (starting at random place), eg the red one, and by connecting we only have a triangle. Since we have not a matematical figure it is mutch more simple to calculate if vehicle is in it or not. If it is not in then we connect next point, the green one, if not in then the blue, etc...
if we are at the end then we have red alert: vehicle is not where it should be.
Is this more clear ?
Maybe this is stuff for a little article, but then better explaned and with some code samples :)
12-01-2005, 06:46 PM
Sorry I missed your response on this item. Must of slipped through somehow.
It appears the link to the gif file is no longer available?
So Yes likey more clear - but No I didn't get a chance to look at it...
Can you verfify the link?
12-02-2005, 05:08 AM
The link is still valid, it works here. It redirect to this: http://users.pandora.be/sonal.nv/mp/polygon.gif
12-02-2005, 08:53 AM
Another approach to point-in-polygon calculations is outlined in Sedgwick's "Algorithms" (I see this is now a multi-volume work: I only have the 1 volume edition).
Basically, you project a 'ray' from your point to inifinity. Count the number of times it crosses the polygon edge. If this is odd, then the point must be in the polygon. If it is even, then the point must be outside the polygon.
I've implemented it for cartesian coordinates, and the maths becomes pretty simple if your ray is parallel to one of the axes.
12-03-2005, 04:54 AM
Looks also a nice aproach :)
04-19-2006, 11:46 AM
did you wrote some lines of code about this?
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO