import ch.hsr.geohash.GeoHash;
import ch.hsr.geohash.WGS84Point;
import ch.hsr.geohash.util.VincentyGeodesy;
// 经度
double longitude = 114.10183699999999;
// 纬度
double latitude = 22.567774000150113;
// 算出当关geoHash
GeoHash userGeohash = GeoHash.withCharacterPrecision(latitude, longitude,NearByKeyUtils.getMaxRange());
String geoHash=userGeohash.toBase32();
// 查询附近周围geoHash
GeoHash[] userGeohashs= userGeohash.getAdjacent();
// 装入所有的GeoHash
final List<String> geoHashs=Lists.newArrayList(geoHash);
for(GeoHash gh:userGeohashs)
{
geoHashs.add(gh.toBase32());
System.out.println(gh.toBase32());
}
// 表示保留几位geohash
public static Integer getMaxRange(){
return 6;
}
需要用到geohash.jar包