Esempio n. 1
0
 @Test
 public void testToAndFromBinaryString() {
   for (GeoHash gh : RandomGeohashes.fullRange()) {
     String binaryString = gh.toBinaryString();
     GeoHash readBack = GeoHash.fromBinaryString(binaryString);
     assertEquals(gh, readBack);
   }
 }
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());
    }
  }