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


Java GeoPoint.fromIndexLong方法代码示例

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

示例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]));
            }
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:GeoCentroidAggregator.java

示例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());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:GeoCentroidAggregator.java


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