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

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

Introduction

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

Prototype

public static int encodeLatitude(double latitude) 

Source Link

Document

Quantizes double (64 bit) latitude into 32 bits (rounding down: in the direction of -90)

Usage

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;//from   w  ww . ja  v  a2 s  .  com
    }
    return new InternalGeoCentroid(name, centroid, count, Collections.emptyList(), Collections.emptyMap());
}