Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. public class GeoHashUtils {
  2.  
  3. public static void main(String[] args ){
  4.  
  5. SpatialContext spatialContext = SpatialContext.GEO;
  6.  
  7. Point paris_opera = new PointImpl(48.871949, 2.331601, spatialContext);
  8. Point montparnasse = new PointImpl(48.8436, 2.3238, spatialContext);
  9. Point saint_germain = new PointImpl(48.8539, 2.3344, spatialContext);
  10.  
  11. String hash_opera = GeohashUtils.encodeLatLon(48.871949, 2.331601);
  12.  
  13. System.out.println("hash opera : " + hash_opera);
  14. System.out.println("hash montparnasse : " + GeohashUtils.encodeLatLon(48.8436, 2.3238));
  15. System.out.println("hash saint-germain : " + GeohashUtils.encodeLatLon(48.8539, 2.3344));
  16.  
  17. GeoHash geoHash = GeoHash.withCharacterPrecision(48.13, 16.28, 12);
  18.  
  19. System.out.println("========= Geohash - java ============== ");
  20.  
  21.  
  22. System.out.println("hash opera : " + GeoHash.withCharacterPrecision(48.8719, 2.3316, 12));
  23. System.out.println("hash montparnasse : " + GeoHash.withCharacterPrecision(48.8436, 2.3238, 12));
  24. System.out.println("hash saint-germain : " + GeoHash.withCharacterPrecision(48.8539, 2.3344, 12));
  25.  
  26.  
  27. System.out.println("Test if Montparnasse is within 3.km cirle radius of the Eiffel Tower");
  28.  
  29. WGS84Point eiffel = new WGS84Point(48.8582 , 2.2945);
  30. WGS84Point mtparnasse = new WGS84Point(48.8436, 2.3238);
  31. //Build a circle of 3.7km centered on the eiffel tower
  32. GeoHashCircleQuery geocircle = new GeoHashCircleQuery(eiffel, 3000);
  33. Boolean mtparnasse_in_eiffel = geocircle.contains(mtparnasse);
  34.  
  35. System.out.println("Is Montparnasse around Eiffel tower ? : " + mtparnasse_in_eiffel);
  36.  
  37.  
  38.  
  39.  
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement