Package org.elasticsearch.common.geo

Examples of org.elasticsearch.common.geo.GeoPoint


            rightValues.setDocument(i);;
            assertEquals(numValues, rightValues.count());
            List<GeoPoint> leftPoints = Lists.newArrayList();
            List<GeoPoint> rightPoints = Lists.newArrayList();
            for (int j = 0; j < numValues; ++j) {
                GeoPoint l = leftValues.valueAt(j);
                leftPoints.add(new GeoPoint(l.getLat(), l.getLon()));
                GeoPoint r = rightValues.valueAt(j);
                rightPoints.add(new GeoPoint(r.getLat(), r.getLon()));
            }
            for (GeoPoint l : leftPoints) {
                assertTrue("Couldn't find " + l + " among " + rightPoints, contains(l, rightPoints, precision));
            }
            for (GeoPoint r : rightPoints) {
View Full Code Here


    private AbstractDistanceScoreFunction parseGeoVariable(String fieldName, XContentParser parser, QueryParseContext parseContext,
            GeoPointFieldMapper mapper, MultiValueMode mode) throws IOException {
        XContentParser.Token token;
        String parameterName = null;
        GeoPoint origin = new GeoPoint();
        String scaleString = null;
        String offsetString = "0km";
        double decay = 0.5;
        while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (token == XContentParser.Token.FIELD_NAME) {
View Full Code Here

            geoPointValues.setDocument(docId);
            final int num = geoPointValues.count();
            if (num > 0) {
                double value = mode.startDouble();
                for (int i = 0; i < num; i++) {
                    GeoPoint other = geoPointValues.valueAt(i);
                    value = mode.apply(Math.max(0.0d, distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(),
                            DistanceUnit.METERS) - offset), value);
                }
                return mode.reduce(value, num);
            } else {
                return 0.0;
View Full Code Here

            values.append(" of: [");
            geoPointValues.setDocument(docId);
            final int num = geoPointValues.count();
            if (num > 0) {
                for (int i = 0; i < num; i++) {
                    GeoPoint value = geoPointValues.valueAt(i);
                    values.append("Math.max(arcDistance(");
                    values.append(value).append("(=doc value),").append(origin).append("(=origin)) - ").append(offset).append("(=offset), 0)");
                    if (i != num - 1) {
                        values.append(", ");
                    }
View Full Code Here

        return new InternalGeoBounds(name, top, bottom, posLeft, posRight, negLeft, negRight, wrapLongitude, getMetaData());
    }
   
    @Override
    public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
        GeoPoint topLeft = topLeft();
        GeoPoint bottomRight = bottomRight();
        if (topLeft != null) {
            builder.startObject("bounds");
            builder.startObject("top_left");
            builder.field("lat", topLeft.lat());
            builder.field("lon", topLeft.lon());
            builder.endObject();
            builder.startObject("bottom_right");
            builder.field("lat", bottomRight.lat());
            builder.field("lon", bottomRight.lon());
            builder.endObject();
            builder.endObject();
        }
        return builder;
    }
View Full Code Here

   
    private BoundingBox resolveBoundingBox() {
        if (Double.isInfinite(top)) {
            return null;
        } else if (Double.isInfinite(posLeft)) {
            return new BoundingBox(new GeoPoint(top, negLeft), new GeoPoint(bottom, negRight));
        } else if (Double.isInfinite(negLeft)) {
            return new BoundingBox(new GeoPoint(top, posLeft), new GeoPoint(bottom, posRight));
        } else if (wrapLongitude) {
            double unwrappedWidth = posRight - negLeft;
            double wrappedWidth = (180 - posLeft) - (-180 - negRight);
            if (unwrappedWidth <= wrappedWidth) {
                return new BoundingBox(new GeoPoint(top, negLeft), new GeoPoint(bottom, posRight));
            } else {
                return new BoundingBox(new GeoPoint(top, posLeft), new GeoPoint(bottom, negRight));
            }
        } else {
            return new BoundingBox(new GeoPoint(top, negLeft), new GeoPoint(bottom, posRight));
        }
    }
View Full Code Here

        values.setDocument(docId);
        final int valuesCount = values.count();

        for (int i = 0; i < valuesCount; ++i) {
            GeoPoint value = values.valueAt(i);
            double top = tops.get(owningBucketOrdinal);
            if (value.lat() > top) {
                top = value.lat();
            }
            double bottom = bottoms.get(owningBucketOrdinal);
            if (value.lat() < bottom) {
                bottom = value.lat();
            }
            double posLeft = posLefts.get(owningBucketOrdinal);
            if (value.lon() > 0 && value.lon() < posLeft) {
                posLeft = value.lon();
            }
            double posRight = posRights.get(owningBucketOrdinal);
            if (value.lon() > 0 && value.lon() > posRight) {
                posRight = value.lon();
            }
            double negLeft = negLefts.get(owningBucketOrdinal);
            if (value.lon() < 0 && value.lon() < negLeft) {
                negLeft = value.lon();
            }
            double negRight = negRights.get(owningBucketOrdinal);
            if (value.lon() < 0 && value.lon() > negRight) {
                negRight = value.lon();
            }
            tops.set(owningBucketOrdinal, top);
            bottoms.set(owningBucketOrdinal, bottom);
            posLefts.set(owningBucketOrdinal, posLeft);
            posRights.set(owningBucketOrdinal, posRight);
View Full Code Here

                int numValues = values.count();
                list.offset = 0;
                list.grow(numValues);
                list.length = numValues;
                for (int i = 0; i < numValues; i++) {
                    GeoPoint next = values.valueAt(i);
                    GeoPoint point = list.values[i];
                    if (point == null) {
                        point = list.values[i] = new GeoPoint();
                    }
                    point.reset(next.lat(), next.lon());
                    list.values[i] = point;
                }
                listLoaded = true;
            }
            return list;
View Full Code Here

            return list;

        }

        public double factorDistance(double lat, double lon) {
            GeoPoint point = getValue();
            return GeoDistance.FACTOR.calculate(point.lat(), point.lon(), lat, lon, DistanceUnit.DEFAULT);
        }
View Full Code Here

        public double factorDistanceWithDefault(double lat, double lon, double defaultValue) {
            if (isEmpty()) {
                return defaultValue;
            }
            GeoPoint point = getValue();
            return GeoDistance.FACTOR.calculate(point.lat(), point.lon(), lat, lon, DistanceUnit.DEFAULT);
        }
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.