Skip to content

Instantly share code, notes, and snippets.

@jnslxndr
Created March 5, 2018 12:48
Show Gist options
  • Save jnslxndr/2174dc29c1d1362831617ccc2defe0ce to your computer and use it in GitHub Desktop.
Save jnslxndr/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