本文整理汇总了Java中ch.hsr.geohash.GeoHash.withCharacterPrecision方法的典型用法代码示例。如果您正苦于以下问题:Java GeoHash.withCharacterPrecision方法的具体用法?Java GeoHash.withCharacterPrecision怎么用?Java GeoHash.withCharacterPrecision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.hsr.geohash.GeoHash
的用法示例。
在下文中一共展示了GeoHash.withCharacterPrecision方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryKNN
import ch.hsr.geohash.GeoHash; //导入方法依赖的package包/类
public Queue<QueryMatch> queryKNN(double lat, double lon, int n)
throws IOException {
DistanceComparator comp = new DistanceComparator(lon, lat);
Queue<QueryMatch> ret
= MinMaxPriorityQueue.orderedBy(comp)
.maximumSize(n)
.create();
GeoHash target = GeoHash.withCharacterPrecision(lat, lon, precision);
ret.addAll(takeN(comp, target.toBase32(), n));
for (GeoHash h : target.getAdjacent()) {
ret.addAll(takeN(comp, h.toBase32(), n));
}
return ret;
}
示例2: minimumBoundingPrefixes
import ch.hsr.geohash.GeoHash; //导入方法依赖的package包/类
GeoHash[] minimumBoundingPrefixes(Geometry query) {
GeoHash candidate;
Geometry candidateGeom;
Point queryCenter = query.getCentroid();
for (int precision = 7; precision > 0; precision--) {
candidate
= GeoHash.withCharacterPrecision(queryCenter.getY(),
queryCenter.getX(),
precision);
candidateGeom = convexHull(new GeoHash[]{ candidate });
if (candidateGeom.contains(query)) {
return new GeoHash[]{ candidate };
}
candidateGeom = convexHull(candidate.getAdjacent());
if (candidateGeom.contains(query)) {
GeoHash[] ret = Arrays.copyOf(candidate.getAdjacent(), 9);
ret[8] = candidate;
return ret;
}
}
throw new IllegalArgumentException(
"Geometry cannot be contained by GeoHashs");
}
示例3: getSearchHashes
import ch.hsr.geohash.GeoHash; //导入方法依赖的package包/类
/**
* Calculate the geo hash cells we need to query in order to cover all points within this query
*
* @return
*/
private Set<String> getSearchHashes() {
GeoHashCircleQuery q = new GeoHashCircleQuery(new WGS84Point(lat, lon), radius);
// Since the circle query doesn't have pre-defined precision, we need to calculate all the
// relevant geohashes in our precision manually
GeoHash center = GeoHash.withCharacterPrecision(lat, lon, precision);
Set<String> hashKeys = new HashSet<>(8);
Set<GeoHash> seen = new HashSet<>(8);
Queue<GeoHash> candidates = new LinkedList<>();
candidates.add(center);
while (!candidates.isEmpty()) {
GeoHash gh = candidates.remove();
hashKeys.add(geoKey(gh.toBase32()));
GeoHash[] neighbors = gh.getAdjacent();
for (GeoHash neighbor : neighbors) {
if (seen.add(neighbor) && q.contains(neighbor)) {
candidates.add(neighbor);
}
}
}
return hashKeys;
}
示例4: encode
import ch.hsr.geohash.GeoHash; //导入方法依赖的package包/类
@Override
public List<byte[]> encode(Double[] latlon) {
ArrayList<byte[]> ret = new ArrayList<>(1);
try {
GeoHash h = GeoHash.withCharacterPrecision(latlon[0], latlon[1], precision);
ret.add(h.toBase32().getBytes());
}
catch (IllegalArgumentException e) {
e.printStackTrace();
}
return ret;
}
示例5: apply
import ch.hsr.geohash.GeoHash; //导入方法依赖的package包/类
public GeoHash apply(@NonNull Coordinate coordinate, @NonNull Integer precision) {
final WGS84Point point = this.coordinate2WGS84Point.apply(coordinate);
return GeoHash.withCharacterPrecision(point.getLatitude(), point.getLongitude(), precision);
}
示例6: indexGeoPoint
import ch.hsr.geohash.GeoHash; //导入方法依赖的package包/类
void indexGeoPoint(String docId, Double lat, Double lon, int precision, Pipeline pipe) {
GeoHash coarse = GeoHash.withCharacterPrecision(lat, lon, precision);
GeoHash fine = GeoHash.withBitPrecision(lat, lon, 53);
pipe.zadd(geoKey(coarse.toBase32()), fine.longValue(), docId);
}