本文整理汇总了Java中org.elasticsearch.common.geo.GeoPoint.fromIndexLong方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPoint.fromIndexLong方法的具体用法?Java GeoPoint.fromIndexLong怎么用?Java GeoPoint.fromIndexLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.geo.GeoPoint
的用法示例。
在下文中一共展示了GeoPoint.fromIndexLong方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doReadFrom
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
protected void doReadFrom(StreamInput in) throws IOException {
count = in.readVLong();
if (in.readBoolean()) {
centroid = GeoPoint.fromIndexLong(in.readLong());
} else {
centroid = null;
}
}
示例2: getLeafCollector
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCollector sub) throws IOException {
if (valuesSource == null) {
return LeafBucketCollector.NO_OP_COLLECTOR;
}
final BigArrays bigArrays = context.bigArrays();
final MultiGeoPointValues values = valuesSource.geoPointValues(ctx);
return new LeafBucketCollectorBase(sub, values) {
@Override
public void collect(int doc, long bucket) throws IOException {
centroids = bigArrays.grow(centroids, bucket + 1);
counts = bigArrays.grow(counts, bucket + 1);
values.setDocument(doc);
final int valueCount = values.count();
if (valueCount > 0) {
double[] pt = new double[2];
// get the previously accumulated number of counts
long prevCounts = counts.get(bucket);
// increment by the number of points for this document
counts.increment(bucket, valueCount);
// get the previous GeoPoint if a moving avg was computed
if (prevCounts > 0) {
final GeoPoint centroid = GeoPoint.fromIndexLong(centroids.get(bucket));
pt[0] = centroid.lon();
pt[1] = centroid.lat();
}
// update the moving average
for (int i = 0; i < valueCount; ++i) {
GeoPoint value = values.valueAt(i);
pt[0] = pt[0] + (value.getLon() - pt[0]) / ++prevCounts;
pt[1] = pt[1] + (value.getLat() - pt[1]) / prevCounts;
}
centroids.set(bucket, GeoEncodingUtils.mortonHash(pt[0], pt[1]));
}
}
};
}
示例3: buildAggregation
import org.elasticsearch.common.geo.GeoPoint; //导入方法依赖的package包/类
@Override
public InternalAggregation buildAggregation(long bucket) {
if (valuesSource == null || bucket >= centroids.size()) {
return buildEmptyAggregation();
}
final long bucketCount = counts.get(bucket);
final GeoPoint bucketCentroid = (bucketCount > 0) ? GeoPoint.fromIndexLong(centroids.get(bucket)) :
new GeoPoint(Double.NaN, Double.NaN);
return new InternalGeoCentroid(name, bucketCentroid , bucketCount, pipelineAggregators(), metaData());
}