Package org.elasticsearch.index.mapper.geo

Examples of org.elasticsearch.index.mapper.geo.GeoPointFieldData


    public String fieldName() {
        return fieldName;
    }

    @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
        final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);
        return new GetDocSet(reader.maxDoc()) {

            @Override public boolean isCacheable() {
                // not cacheable for several reasons:
                // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset
                // 2. Its already fast without in mem bitset, since it works with field data
                return false;
            }

            @Override public boolean get(int doc) throws IOException {
                if (!fieldData.hasValue(doc)) {
                    return false;
                }

                if (fieldData.multiValued()) {
                    double[] lats = fieldData.latValues(doc);
                    double[] lons = fieldData.lonValues(doc);
                    for (int i = 0; i < lats.length; i++) {
                        double d = geoDistance.calculate(lat, lon, lats[i], lons[i], DistanceUnit.MILES);
                        if (d >= inclusiveLowerPoint && d <= inclusiveUpperPoint) {
                            return true;
                        }
                    }
                    return false;
                } else {
                    double d = geoDistance.calculate(lat, lon, fieldData.latValue(doc), fieldData.lonValue(doc), DistanceUnit.MILES);
                    if (d >= inclusiveLowerPoint && d <= inclusiveUpperPoint) {
                        return true;
                    }
                    return false;
                }
View Full Code Here


    public String fieldName() {
        return this.fieldName;
    }

    @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
        final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);

        return new GetDocSet(reader.maxDoc()) {

            @Override public boolean isCacheable() {
                // not cacheable for several reasons:
                // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset
                // 2. Its already fast without in mem bitset, since it works with field data
                return false;
            }

            @Override public boolean get(int doc) throws IOException {
                if (!fieldData.hasValue(doc)) {
                    return false;
                }

                if (fieldData.multiValued()) {
                    double[] lats = fieldData.latValues(doc);
                    double[] lons = fieldData.lonValues(doc);
                    for (int i = 0; i < lats.length; i++) {
                        if (pointInPolygon(points, lats[i], lons[i])) {
                            return true;
                        }
                    }
                } else {
                    double lat = fieldData.latValue(doc);
                    double lon = fieldData.lonValue(doc);
                    return pointInPolygon(points, lat, lon);
                }
                return false;
            }
        };
View Full Code Here

    public String fieldName() {
        return fieldName;
    }

    @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
        final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);
        return new GetDocSet(reader.maxDoc()) {

            @Override public boolean isCacheable() {
                // not cacheable for several reasons:
                // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset
                // 2. Its already fast without in mem bitset, since it works with field data
                return false;
            }

            @Override public boolean get(int doc) throws IOException {
                if (!fieldData.hasValue(doc)) {
                    return false;
                }

                if (fieldData.multiValued()) {
                    double[] lats = fieldData.latValues(doc);
                    double[] lons = fieldData.lonValues(doc);
                    for (int i = 0; i < lats.length; i++) {
                        double d = geoDistance.calculate(lat, lon, lats[i], lons[i], DistanceUnit.MILES);
                        if (d < distance) {
                            return true;
                        }
                    }
                    return false;
                } else {
                    double d = geoDistance.calculate(lat, lon, fieldData.latValue(doc), fieldData.lonValue(doc), DistanceUnit.MILES);
                    return d < distance;
                }
            }
        };
    }
View Full Code Here

    public String fieldName() {
        return fieldName;
    }

    @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
        final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);

        //checks to see if bounding box crosses 180 degrees
        if (topLeft.lon > bottomRight.lon) {
            return new GetDocSet(reader.maxDoc()) {

                @Override public boolean isCacheable() {
                    // not cacheable for several reasons:
                    // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset
                    // 2. Its already fast without in mem bitset, since it works with field data
                    return false;
                }

                @Override public boolean get(int doc) throws IOException {
                    if (!fieldData.hasValue(doc)) {
                        return false;
                    }

                    if (fieldData.multiValued()) {
                        double[] lats = fieldData.latValues(doc);
                        double[] lons = fieldData.lonValues(doc);
                        for (int i = 0; i < lats.length; i++) {
                            double lat = lats[i];
                            double lon = lons[i];
                            if (((topLeft.lon <= lon && 180 >= lon) || (-180 <= lon && bottomRight.lon >= lon)) &&
                                    (topLeft.lat >= lat && bottomRight.lat <= lat)) {
                                return true;
                            }
                        }
                    } else {
                        double lat = fieldData.latValue(doc);
                        double lon = fieldData.lonValue(doc);

                        if (((topLeft.lon <= lon && 180 >= lon) || (-180 <= lon && bottomRight.lon >= lon)) &&
                                (topLeft.lat >= lat && bottomRight.lat <= lat)) {
                            return true;
                        }
                    }
                    return false;
                }
            };
        } else {
            return new GetDocSet(reader.maxDoc()) {

                @Override public boolean isCacheable() {
                    // not cacheable for several reasons:
                    // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset
                    // 2. Its already fast without in mem bitset, since it works with field data
                    return false;
                }

                @Override public boolean get(int doc) throws IOException {
                    if (!fieldData.hasValue(doc)) {
                        return false;
                    }

                    if (fieldData.multiValued()) {
                        double[] lats = fieldData.latValues(doc);
                        double[] lons = fieldData.lonValues(doc);
                        for (int i = 0; i < lats.length; i++) {
                            if (topLeft.lon <= lons[i] && bottomRight.lon >= lons[i]
                                    && topLeft.lat >= lats[i] && bottomRight.lat <= lats[i]) {
                                return true;
                            }
                        }
                    } else {
                        double lat = fieldData.latValue(doc);
                        double lon = fieldData.lonValue(doc);

                        if (topLeft.lon <= lon && bottomRight.lon >= lon
                                && topLeft.lat >= lat && bottomRight.lat <= lat) {
                            return true;
                        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.mapper.geo.GeoPointFieldData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.