Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GeoHashUtils {
- public static void main(String[] args ){
- SpatialContext spatialContext = SpatialContext.GEO;
- Point paris_opera = new PointImpl(48.871949, 2.331601, spatialContext);
- Point montparnasse = new PointImpl(48.8436, 2.3238, spatialContext);
- Point saint_germain = new PointImpl(48.8539, 2.3344, spatialContext);
- String hash_opera = GeohashUtils.encodeLatLon(48.871949, 2.331601);
- System.out.println("hash opera : " + hash_opera);
- System.out.println("hash montparnasse : " + GeohashUtils.encodeLatLon(48.8436, 2.3238));
- System.out.println("hash saint-germain : " + GeohashUtils.encodeLatLon(48.8539, 2.3344));
- GeoHash geoHash = GeoHash.withCharacterPrecision(48.13, 16.28, 12);
- System.out.println("========= Geohash - java ============== ");
- System.out.println("hash opera : " + GeoHash.withCharacterPrecision(48.8719, 2.3316, 12));
- System.out.println("hash montparnasse : " + GeoHash.withCharacterPrecision(48.8436, 2.3238, 12));
- System.out.println("hash saint-germain : " + GeoHash.withCharacterPrecision(48.8539, 2.3344, 12));
- System.out.println("Test if Montparnasse is within 3.km cirle radius of the Eiffel Tower");
- WGS84Point eiffel = new WGS84Point(48.8582 , 2.2945);
- WGS84Point mtparnasse = new WGS84Point(48.8436, 2.3238);
- //Build a circle of 3.7km centered on the eiffel tower
- GeoHashCircleQuery geocircle = new GeoHashCircleQuery(eiffel, 3000);
- Boolean mtparnasse_in_eiffel = geocircle.contains(mtparnasse);
- System.out.println("Is Montparnasse around Eiffel tower ? : " + mtparnasse_in_eiffel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement