Esempio n. 1
0
 private void checkMovingInCircle(double latitude, double longitude) {
   GeoHash start;
   GeoHash end;
   start = GeoHash.withCharacterPrecision(latitude, longitude, 12);
   end = start.getEasternNeighbour();
   end = end.getSouthernNeighbour();
   end = end.getWesternNeighbour();
   end = end.getNorthernNeighbour();
   assertEquals(start, end);
   assertEquals(start.getBoundingBox(), end.getBoundingBox());
 }
Esempio n. 2
0
  @Test
  public void testDecode() {
    // for all lat/lon pairs check decoded point is in the same bbox as the
    // geohash formed by encoder
    for (GeoHash gh : RandomGeohashes.fullRange()) {
      BoundingBox bbox = gh.getBoundingBox();
      GeoHash decodedHash = GeoHash.fromGeohashString(gh.toBase32());
      WGS84Point decodedCenter = decodedHash.getBoundingBoxCenterPoint();

      assertTrue(
          "bbox " + bbox + " should contain the decoded center value " + decodedCenter,
          bbox.contains(decodedCenter));
      BoundingBox decodedBoundingBox = decodedHash.getBoundingBox();
      assertEquals(bbox, decodedBoundingBox);
      assertEquals(gh, decodedHash);
      assertEquals(gh.toBase32(), decodedHash.toBase32());
    }
  }
Esempio n. 3
0
 @Test
 public void testThatAdjacentHashesHavePointInitialized() {
   String center = "dqcjqc";
   GeoHash geohash = GeoHash.fromGeohashString(center);
   GeoHash[] adjacentHashes = geohash.getAdjacent();
   for (GeoHash adjacentHash : adjacentHashes) {
     assertNotNull(adjacentHash.getBoundingBox());
     assertNotNull(adjacentHash.getBoundingBoxCenterPoint());
     assertNotNull(adjacentHash.getPoint());
   }
 }
Esempio n. 4
0
 private void printBoundingBox(GeoHash hash) {
   System.out.println("Bounding Box: \ncenter =" + hash.getBoundingBoxCenterPoint());
   System.out.print("corners=");
   System.out.println(hash.getBoundingBox());
 }