-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample/test of circle query with a radius of 100km
- Loading branch information
Showing
4 changed files
with
103 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ch.hsr.geohash.util; | ||
|
||
import ch.hsr.geohash.WGS84Point; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
public class RandomWGS84Points { | ||
private static final Random RAND = new Random(System.currentTimeMillis()); | ||
|
||
public static WGS84Point get() { | ||
return createRandomPoint(); | ||
} | ||
|
||
public static List<WGS84Point> get(int n) { | ||
List<WGS84Point> result = new ArrayList<>(n); | ||
for (int i = 0; i < n; i++) { | ||
result.add(createRandomPoint()); | ||
} | ||
return result; | ||
} | ||
|
||
private static WGS84Point createRandomPoint() { | ||
double latitude = (RAND.nextDouble() - 0.5) * 180; | ||
double longitude = (RAND.nextDouble() - 0.5) * 360; | ||
return new WGS84Point(latitude, longitude); | ||
} | ||
} |