SparkFun Forums 

Where electronics enthusiasts find answers.

Tips and questions relating to the GPS modules from SFE
By kenshin
#49651
Hi all,
I'm currently doing a university project which is using Gm862-GPS as my main hardware. I had finish and downloaded the SMS and GPRS script into the module and it works fine. Now I need to do a slightly improvement on my project which is include it with geo-fence setting. Geo-fence means when the vehicle is entering or leaving a certain area a msg will send to the server to inform that particular vehicle has entering to leaving the geo-fence zone. I have the idea is comparing the Geo-fence zone coordinates with the current vehicle coordinates,if it was the same then a signal will to send to the server through GPRS. Anyone here can help me with the python code?How to write the python code to get this feature? Helps are highly appreciated. Thanks.
By Shifted
#49666
Is your geo-fence area rectangular or polygonal? Is it guaranteed to be convex, or can it be concave?

This gets into what gamers call collision detection. If its a rectangle, then its easy, when the coordinates are outside any of the extents (MinX, MinY, MaxX, MaxY), then you can say it is outside of the box. If it is a convex polygon, then you have some options, you can create a bounding box around the extents of the polygon for an approximation, or you can do a little more math which would cover the concave polygon.

In a concave/convex polygon intersection detection, you just have to realize that the segments of a polygon are made up of lines. If you can store the formula's for the lines(y = mx + b) instead of the points of the polygons, then you just have to test for intersection (plug the numbers of your point into the formula and if it works, you intersected). That only works if the point lies exactly on the line, you'd have to see what line the point lies closest to and then determine if it is outside the polygon or inside it.

Look up bounding box collision detection formula's, gamasutra and even codeproject has a lot of these algorithms. Then its just a matter of converting whatever code its written in to your code.
By kenshin
#49846
Rectangular? Polygonal? Basically my idea was only set up a small radius around the base station's main gate because there is no way for the vehicle to come from the other way of the base station except the main gate. Instead of setting up the whole radius surrounding the base station, setting up the small radius around the gate would be much easier am I right?
Consider rectangular maybe, whenever the vehicle leave or entering the box, it will consider either leaving or entering.
My main problem is I need some guide and help on modyfying my Python code in order to archieve this feature. Not much reference I can get from the internet.
Please help me if anyone are able to. Thanks alot.