예제 #1
0
  @Override
  public BigInteger randomHash() {
    float lat =
        random.nextFloat()
            * Geohash.LATITUDE_RANGE
            * (random.nextBoolean() ? 1 : -1); // randomly negate

    float lon = random.nextFloat() * Geohash.LONGITUDE_RANGE * (random.nextBoolean() ? 1 : -1);

    String hash = Geohash.encode(lat, lon, PRECISION);
    return BigInteger.valueOf(Geohash.hashToLong(hash));
  }
예제 #2
0
  @Override
  public BigInteger hash(SpatialProperties spatialProps) throws HashException {

    String hash = "";

    if (spatialProps.hasRange()) {
      hash = Geohash.encode(spatialProps.getSpatialRange(), PRECISION);
    } else {
      hash = Geohash.encode(spatialProps.getCoordinates(), PRECISION);
    }

    return BigInteger.valueOf(Geohash.hashToLong(hash));
  }