All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.elasticsearch.GeohashUtils Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
package org.vertexium.elasticsearch;

import org.elasticsearch.common.geo.GeoHashUtils;
import org.vertexium.VertexiumException;

import java.lang.reflect.Method;

class GeohashUtils {
    private static final Method decodeCell;

    static {
        try {
            decodeCell = GeoHashUtils.class.getDeclaredMethod("decodeCell", String.class);
            decodeCell.setAccessible(true);
        } catch (NoSuchMethodException e) {
            throw new VertexiumException("Could not find decodeCell method", e);
        }
    }

    public static void decodeCell(String key, org.elasticsearch.common.geo.GeoPoint northWest, org.elasticsearch.common.geo.GeoPoint southEast) {
        try {
            double[] interval = (double[]) decodeCell.invoke(null, key);
            northWest.reset(interval[1], interval[2]);
            southEast.reset(interval[0], interval[3]);
        } catch (Exception e) {
            throw new VertexiumException("Could not decode cell", e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy