Skip to content

Instantly share code, notes, and snippets.

@christianroman
Created January 28, 2013 06:29
Show Gist options
  • Save christianroman/4653469 to your computer and use it in GitHub Desktop.
Save christianroman/4653469 to your computer and use it in GitHub Desktop.
Find n coordinates around given latitude and longitude
private static ArrayList<Point> findAroundCoordinates(Double lat, Double lon, Double range){
// Number of points
int numberOfPoints = 32;
Double degreesPerPoint = 360.0 / numberOfPoints;
int currentAngle = 0;
Double x2;
Double y2;
ArrayList<Point> points = new ArrayList<Point>();
for(int i = 0; i < numberOfPoints; i++) {
x2 = Math.cos(currentAngle) * range;
y2 = Math.sin(currentAngle) * range;
// Custom class, object, etc.
Point p = new Point(lat+x2, lon+y2);
// Save the object
points.add(p);
currentAngle += degreesPerPoint;
}
return points;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment