Search in sources :

Example 1 with LatLonPoint

use of org.apache.lucene.document.LatLonPoint in project elasticsearch by elastic.

the class GeoPoint method resetFromIndexableField.

// todo this is a crutch because LatLonPoint doesn't have a helper for returning .stringValue()
// todo remove with next release of lucene
public GeoPoint resetFromIndexableField(IndexableField field) {
    if (field instanceof LatLonPoint) {
        BytesRef br = field.binaryValue();
        byte[] bytes = Arrays.copyOfRange(br.bytes, br.offset, br.length);
        return this.reset(GeoEncodingUtils.decodeLatitude(bytes, 0), GeoEncodingUtils.decodeLongitude(bytes, Integer.BYTES));
    } else if (field instanceof LatLonDocValuesField) {
        long encoded = (long) (field.numericValue());
        return this.reset(GeoEncodingUtils.decodeLatitude((int) (encoded >>> 32)), GeoEncodingUtils.decodeLongitude((int) encoded));
    }
    return resetFromIndexHash(Long.parseLong(field.stringValue()));
}
Also used : LatLonDocValuesField(org.apache.lucene.document.LatLonDocValuesField) LatLonPoint(org.apache.lucene.document.LatLonPoint) BytesRef(org.apache.lucene.util.BytesRef)

Aggregations

LatLonDocValuesField (org.apache.lucene.document.LatLonDocValuesField)1 LatLonPoint (org.apache.lucene.document.LatLonPoint)1 BytesRef (org.apache.lucene.util.BytesRef)1