Example usage for org.apache.lucene.geo GeoEncodingUtils decodeLatitude

List of usage examples for org.apache.lucene.geo GeoEncodingUtils decodeLatitude

Introduction

In this page you can find the example usage for org.apache.lucene.geo GeoEncodingUtils decodeLatitude.

Prototype

public static double decodeLatitude(int encoded) 

Source Link

Document

Turns quantized value from #encodeLatitude back into a double.

Usage

From source file:org.elasticsearch.index.fielddata.plain.LatLonPointDVAtomicFieldData.java

License:Apache License

@Override
public MultiGeoPointValues getGeoPointValues() {
    return new MultiGeoPointValues() {
        GeoPoint[] points = new GeoPoint[0];
        private int count = 0;

        @Override//  w ww  .j a v a2  s. c om
        public void setDocument(int docId) {
            values.setDocument(docId);
            count = values.count();
            if (count > points.length) {
                final int previousLength = points.length;
                points = Arrays.copyOf(points,
                        ArrayUtil.oversize(count, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
                for (int i = previousLength; i < points.length; ++i) {
                    points[i] = new GeoPoint(Double.NaN, Double.NaN);
                }
            }
            long encoded;
            for (int i = 0; i < count; ++i) {
                encoded = values.valueAt(i);
                points[i].reset(GeoEncodingUtils.decodeLatitude((int) (encoded >>> 32)),
                        GeoEncodingUtils.decodeLongitude((int) encoded));
            }
        }

        @Override
        public int count() {
            return count;
        }

        @Override
        public GeoPoint valueAt(int index) {
            return points[index];
        }
    };
}

From source file:org.elasticsearch.search.aggregations.metrics.geocentroid.InternalGeoCentroidTests.java

License:Apache License

@Override
protected InternalGeoCentroid createTestInstance(String name, List<PipelineAggregator> pipelineAggregators,
        Map<String, Object> metaData) {
    GeoPoint centroid = RandomGeoGenerator.randomPoint(random());

    // Re-encode lat/longs to avoid rounding issue when testing InternalGeoCentroid#hashCode() and
    // InternalGeoCentroid#equals()
    int encodedLon = GeoEncodingUtils.encodeLongitude(centroid.lon());
    centroid.resetLon(GeoEncodingUtils.decodeLongitude(encodedLon));
    int encodedLat = GeoEncodingUtils.encodeLatitude(centroid.lat());
    centroid.resetLat(GeoEncodingUtils.decodeLatitude(encodedLat));
    long count = randomIntBetween(0, 1000);
    if (count == 0) {
        centroid = null;/* w w w.  j a v a  2  s .co  m*/
    }
    return new InternalGeoCentroid(name, centroid, count, Collections.emptyList(), Collections.emptyMap());
}