Created
January 28, 2013 06:29
-
-
Save christianroman/4653469 to your computer and use it in GitHub Desktop.
Find n coordinates around given latitude and longitude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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