示例#1
0
  @Test
  public void testNeighbourLocationCode() {
    // set up corner case
    hash.bits = 0xc400000000000000l;
    hash.significantBits = 7;

    long[] lonBits = hash.getRightAlignedLongitudeBits();
    assertEquals(0x8, lonBits[0]);
    assertEquals(4, lonBits[1]);

    long[] latBits = hash.getRightAlignedLatitudeBits();
    assertEquals(0x5, latBits[0]);
    assertEquals(3, latBits[1]);

    GeoHash north = hash.getNorthernNeighbour();
    assertEquals(0xd000000000000000l, north.bits);
    assertEquals(7, north.significantBits);

    GeoHash south = hash.getSouthernNeighbour();
    assertEquals(0xc000000000000000l, south.bits);
    assertEquals(7, south.significantBits());

    GeoHash east = hash.getEasternNeighbour();
    assertEquals(0xc600000000000000l, east.bits);

    // NOTE: this is actually a corner case!
    GeoHash west = hash.getWesternNeighbour();
    assertEquals(0x6e00000000000000l, west.bits);

    // NOTE: and now, for the most extreme corner case in 7-bit geohash-land
    hash.bits = 0xfe00000000000000l;

    east = hash.getEasternNeighbour();
    assertEquals(0x5400000000000000l, east.bits);
  }
示例#2
0
 @Test
 public void testGetLatitudeBits() {
   hash = GeoHash.withBitPrecision(30, 30, 16);
   long[] latitudeBits = hash.getRightAlignedLatitudeBits();
   assertEquals(0xaal, latitudeBits[0]);
   assertEquals(8, latitudeBits[1]);
 }