Skip to content

Instantly share code, notes, and snippets.

@jens-a-e
Created March 5, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jens-a-e/2174dc29c1d1362831617ccc2defe0ce to your computer and use it in GitHub Desktop.
Save jens-a-e/2174dc29c1d1362831617ccc2defe0ce to your computer and use it in GitHub Desktop.
boolean withinPosition(float lat, float lon, float tolarance) {
float gpsLat, gpsLong;
// read gps...
tolarance = tolarance / 1000.0; // 10 => 0.0010
// Check position within tolarance
boolean isLat = lat >= gpsLat - tolarance && lat <= gpsLat+tolarance;
boolean isLon = lon >= gpsLon - tolarance && lon <= gpsLong+tolarance;
return isLat && isLon;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment