Esempio n. 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));
  }
Esempio n. 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));
  }