当前位置: 首页>>代码示例>>Java>>正文


Java GeoHash.withCharacterPrecision方法代码示例

本文整理汇总了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;
}
 
开发者ID:East196,项目名称:maker,代码行数:17,代码来源:KNNQuery.java

示例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");
}
 
开发者ID:East196,项目名称:maker,代码行数:26,代码来源:WithinQuery.java

示例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;
}
 
开发者ID:RedisLabs,项目名称:ReSearch,代码行数:33,代码来源:FullTextFacetedIndex.java

示例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;

}
 
开发者ID:RedisLabs,项目名称:ReSearch,代码行数:15,代码来源:Encoders.java

示例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);
}
 
开发者ID:adrianulbona,项目名称:jts-discretizer,代码行数:5,代码来源:CoordinateDiscretizer.java

示例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);

}
 
开发者ID:RedisLabs,项目名称:ReSearch,代码行数:8,代码来源:FullTextFacetedIndex.java


注:本文中的ch.hsr.geohash.GeoHash.withCharacterPrecision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。