Best Practices--GPS-Geo Fencing application

M Marcus Kurath 3 years 7 months ago
2 1 0

I have a reseller/ISV who needs to write an application which launches other apps when a vehicle is within a specified distance (50-100 feet) of a specific work location. The obvious part of this is the customer must provide a longitude / latitude location of the work site(s) in a database format Has anyone done this type of coding/development  who could share some of their experiences?

Please Register or Login to post a reply

1 Replies

Y Yanis Dalabiras

Hello marc This is quite easier to do Some code is below that will calculate the distance between two points in decinal lat/long.  So one would be the fix point and the other the mobile position.  So when less than X you know you are within the radius of the fix point and then can run apps etc.. double DistanceLatLong(double lat1, double lon1, double lat2, double lon2, char units) {       double R = 6367.0;
   double dlon = (lon2 - lon1) / DEG_TO_RAD ;    double dlat = (lat2 - lat1) / DEG_TO_RAD;    double a = pow( (sin(dlat/2)), 2.0) + cos(lat1) * cos(lat2) * pow( (sin(dlon/2)), 2.0);    double c = 2 * atan2( sqrt(a), sqrt(1-a) );

   // R (Earth Radius) = 3956.0 mi = 3437.7 nm = 6367.0 km

   switch(units)    {    case 'S': // STATUTE MILES      R = 3956.0;       break;    case 'N': // NAUTICAL       R = 3437.7;       break;    case 'K': // KILOMETERS       R = 6366.564;       break;    }

   return (R * c); }

 

CONTACT
Can’t find what you’re looking for?