Package org.elasticsearch.common.geo

Examples of org.elasticsearch.common.geo.GeoPoint


                IndexGeoPointFieldData<?> fieldData = searchContext.fieldData().getForField(mapper);
                Filter filter;
                if (geometry.isRectangle()) {
                    Rectangle boundingBox = shape.getBoundingBox();
                    filter = new InMemoryGeoBoundingBoxFilter(
                            new GeoPoint(boundingBox.getMaxY(), boundingBox.getMinX()),
                            new GeoPoint(boundingBox.getMinY(), boundingBox.getMaxX()),
                            fieldData
                    );
                } else {
                    Coordinate[] coordinates = geometry.getCoordinates();
                    GeoPoint[] points = new GeoPoint[coordinates.length];
                    for (int i = 0; i < coordinates.length; i++) {
                        Coordinate coordinate = coordinates[i];
                        points[i] = new GeoPoint(coordinate.y, coordinate.x);
                    }
                    filter = new GeoPolygonFilter(fieldData, points);
                }
                return new FilteredQuery(Queries.newMatchAllQuery(), indexCache.filter().cache(filter));
            }
View Full Code Here


                        break;
                    default:
                        // invalid operator? give up
                        return null;
                }
                GeoPoint geoPoint = new GeoPoint(lat, lon);
                Filter filter = new GeoDistanceRangeFilter(
                        geoPoint,
                        from,
                        to,
                        includeLower,
View Full Code Here

    public Double[] value() {
        switch (values.setDocument(docId)) {
            case 0:
                return null;
            case 1:
                GeoPoint gp = values.nextValue();
                return new Double[] { gp.lon(), gp.lat() };
            default:
                throw new GroupByOnArrayUnsupportedException(columnName());
        }
    }
View Full Code Here

        else if (targetType.equals(UUID.class)) {
            return UUID.fromString((String) value);
        }
        else if (targetType.equals(GeoPoint.class)) {
            Map geoValuesMap = (Map) value;
            return new GeoPoint((Double)geoValuesMap.get("lat"),(Double)geoValuesMap.get("lon"));
        }
        else {
            return value;
        }
    }
View Full Code Here

        else if (targetType.equals(UUID.class)) {
            return UUID.fromString((String) value);
        }
        else if (targetType.equals(GeoPoint.class)) {
            Map geoValuesMap = (Map) value;
            return new GeoPoint((Double)geoValuesMap.get("lat"),(Double)geoValuesMap.get("lon"));
        }
        else {
            return value;
        }
    }
View Full Code Here

    public void parse(ParseContext context) throws IOException {
        ContentPath.Type origPathType = context.path().pathType();
        context.path().pathType(pathType);
        context.path().add(name());

        GeoPoint sparse = context.parseExternalValue(GeoPoint.class);
       
        if (sparse != null) {
            parse(context, sparse, null);
        } else {
            sparse = new GeoPoint();
            XContentParser.Token token = context.parser().currentToken();
            if (token == XContentParser.Token.START_ARRAY) {
                token = context.parser().nextToken();
                if (token == XContentParser.Token.START_ARRAY) {
                    // its an array of array of lon/lat [ [1.2, 1.3], [1.4, 1.5] ]
                    while (token != XContentParser.Token.END_ARRAY) {
                        parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
                        token = context.parser().nextToken();
                    }
                } else {
                    // its an array of other possible values
                    if (token == XContentParser.Token.VALUE_NUMBER) {
                        double lon = context.parser().doubleValue();
                        token = context.parser().nextToken();
                        double lat = context.parser().doubleValue();
                        while ((token = context.parser().nextToken()) != XContentParser.Token.END_ARRAY) {

                        }
                        parse(context, sparse.reset(lat, lon), null);
                    } else {
                        while (token != XContentParser.Token.END_ARRAY) {
                            if (token == XContentParser.Token.VALUE_STRING) {
                                parsePointFromString(context, sparse, context.parser().text());
                            } else {
View Full Code Here

            return Collections.unmodifiableList(resources);
        }

        @Override
        public MultiGeoPointValues getGeoPointValues() {
            final GeoPoint point = new GeoPoint();
            final GeoPointValues values = new GeoPointValues() {
                @Override
                public GeoPoint get(int docID) {
                    point.reset(lat.get(docID), lon.get(docID));
                    return point;
                }
            };
            return FieldData.singleton(values, set);
        }
View Full Code Here

        private final ObjectOpenHashSet<GeoPoint> points;

        public CustomGeoPointDocValuesField(String  name, double lat, double lon) {
            super(name);
            points = new ObjectOpenHashSet<>(2);
            points.add(new GeoPoint(lat, lon));
        }
View Full Code Here

            points = new ObjectOpenHashSet<>(2);
            points.add(new GeoPoint(lat, lon));
        }

        public void add(double lat, double lon) {
            points.add(new GeoPoint(lat, lon));
        }
View Full Code Here

        @Override
        public BytesRef binaryValue() {
            final byte[] bytes = new byte[points.size() * 16];
            int off = 0;
            for (Iterator<ObjectCursor<GeoPoint>> it = points.iterator(); it.hasNext(); ) {
                final GeoPoint point = it.next().value;
                ByteUtils.writeDoubleLE(point.getLat(), bytes, off);
                ByteUtils.writeDoubleLE(point.getLon(), bytes, off + 8);
                off += 16;
            }
            return new BytesRef(bytes);
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.geo.GeoPoint

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.