Skip to content

Instantly share code, notes, and snippets.

@arkty
Created March 24, 2015 09:56
Show Gist options
  • Save arkty/44255134b0e116c1650f to your computer and use it in GitHub Desktop.
Save arkty/44255134b0e116c1650f to your computer and use it in GitHub Desktop.
private boolean isPointInRange(double latitude, double longitude, List<GeoPoint> range) {
int i, j;
boolean c = false;
int nvert = range.size();
for (i = 0, j = nvert-1; i < nvert; j = i++) {
GeoPoint jPoint = range.get(j);
GeoPoint iPoint = range.get(i);
if ( ((iPoint.Longitude >longitude) != (jPoint.Longitude>longitude)) &&
(latitude < (jPoint.Latitude-iPoint.Latitude) * (longitude-iPoint.Longitude) / (jPoint.Longitude-iPoint.Longitude) + iPoint.Latitude))
c = !c;
}
return c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment