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

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

Introduction

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

Prototype

public static int encodeLongitude(double longitude) 

Source Link

Document

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

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;//w ww .  j  a  va2 s.  c o m
    }
    return new InternalGeoCentroid(name, centroid, count, Collections.emptyList(), Collections.emptyMap());
}