As part of my slow but sure attempt at entering the competition I have created a simple but effective solution to this part of the rules using a Ray casting algorithm and running this on a Netduino in C# (easy to convert to Arduino).
Here is the code to test if the current location falls within a polygon:
public static bool LocationInsideBoundry(Position point, Position boundry)
bool insideBoundry = false;
int j = boundry.Length - 1;
for (int i = 0; i < boundry.Length; i++)
if (boundry[i].Longitude < point.Longitude && boundry[j].Longitude >= point.Longitude ||
boundry[j].Longitude < point.Longitude && boundry[i].Longitude >= point.Longitude)
if (boundry[i].Latitude +
(point.Longitude - boundry[i].Longitude) / (boundry[j].Longitude - boundry[i].Longitude) * (boundry[j].Latitude - boundry[i].Latitude) < point.Latitude)
insideBoundry = !insideBoundry;
j = i;
Pretty simple stuff and works a treat.
Here is a simple app in .net that shows if the current location is inside the boundary – drag the map around with the right mouse button add some points and if the location is inside the boundary then the group box background will be green – outside then red.
Hopefully it will be of some use.