@Override public GeoPoint getKey() { return GeoPoint.fromGeohash(geohashAsString); }
@Override public GeoPoint getKey() { return GeoPoint.fromGeohash(geohashAsLong); }
/** * Adds points. * @param topLeft topLeft point to add as geohash. * @param bottomRight bottomRight point to add as geohash. * */ public GeoBoundingBoxQueryBuilder setCorners(String topLeft, String bottomRight) { return setCorners(GeoPoint.fromGeohash(topLeft), GeoPoint.fromGeohash(bottomRight)); }
/** * Adds corners in OGC standard bbox/ envelop format. * * @param bottomLeft bottom left corner geohash. * @param topRight top right corner geohash. */ public GeoBoundingBoxQueryBuilder setCornersOGC(String bottomLeft, String topRight) { return setCornersOGC(GeoPoint.fromGeohash(bottomLeft), GeoPoint.fromGeohash(topRight)); }
/** * The geohash of the geo point to create the range distance facets from. * * Deprecated - please use points(GeoPoint... points) instead. */ @Deprecated public GeoDistanceSortBuilder geohashes(String... geohashes) { for (String geohash : geohashes) { this.points.add(GeoPoint.fromGeohash(geohash)); } return this; }
/** * Constructs a new distance based sort on a geo point like field. * * @param fieldName The geo point like field name. * @param geohashes The points to create the range distance facets from. */ public GeoDistanceSortBuilder(String fieldName, String ... geohashes) { if (geohashes.length == 0) { throw new IllegalArgumentException("Geo distance sorting needs at least one point."); } for (String geohash : geohashes) { this.points.add(GeoPoint.fromGeohash(geohash)); } this.fieldName = fieldName; }
/** * Computes the bounding box coordinates from a given geohash * * @param geohash Geohash of the defined cell * @return GeoRect rectangle defining the bounding box */ public static Rectangle bbox(final String geohash) { // bottom left is the coordinate GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash); int len = Math.min(12, geohash.length()); long ghLong = longEncode(geohash, len); // shift away the level ghLong >>>= 4; // deinterleave long lon = BitUtil.deinterleave(ghLong >>> 1); long lat = BitUtil.deinterleave(ghLong); if (lat < MAX_LAT_BITS) { // add 1 to lat and lon to get topRight GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)(lat + 1), (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon()); } else { // We cannot go north of north pole, so just using 90 degrees instead of calculating it using // add 1 to lon to get lon of topRight, we are going to use 90 for lat GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lat, (int)(lon + 1)) << 4 | len); return new Rectangle(bottomLeft.lat(), MAX_LAT_INCL, bottomLeft.lon(), topRight.lon()); } }
public static GeoQueryContext fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); GeoQueryContext.Builder builder = new Builder(); if (token == XContentParser.Token.START_OBJECT) { GEO_CONTEXT_PARSER.parse(parser, builder, null); } else if (token == XContentParser.Token.VALUE_STRING) { builder.setGeoPoint(GeoPoint.fromGeohash(parser.text())); } else { throw new ElasticsearchParseException("geo context must be an object or string"); } return builder.build(); }
@Override public GeoPoint getKey() { return GeoPoint.fromGeohash(geohashAsString); }
@Override public GeoPoint getKey() { return GeoPoint.fromGeohash(geohashAsLong); }
/** * Adds points. * @param topLeft topLeft point to add as geohash. * @param bottomRight bottomRight point to add as geohash. * */ public GeoBoundingBoxQueryBuilder setCorners(String topLeft, String bottomRight) { return setCorners(GeoPoint.fromGeohash(topLeft), GeoPoint.fromGeohash(bottomRight)); }
/** * Adds corners in OGC standard bbox/ envelop format. * * @param bottomLeft bottom left corner geohash. * @param topRight top right corner geohash. */ public GeoBoundingBoxQueryBuilder setCornersOGC(String bottomLeft, String topRight) { return setCornersOGC(GeoPoint.fromGeohash(bottomLeft), GeoPoint.fromGeohash(topRight)); }
/** * Adds corners in OGC standard bbox/ envelop format. * * @param bottomLeft bottom left corner geohash. * @param topRight top right corner geohash. */ public GeoBoundingBoxQueryBuilder setCornersOGC(String bottomLeft, String topRight) { return setCornersOGC(GeoPoint.fromGeohash(bottomLeft), GeoPoint.fromGeohash(topRight)); }
/** * Adds points. * @param topLeft topLeft point to add as geohash. * @param bottomRight bottomRight point to add as geohash. * */ public GeoBoundingBoxQueryBuilder setCorners(String topLeft, String bottomRight) { return setCorners(GeoPoint.fromGeohash(topLeft), GeoPoint.fromGeohash(bottomRight)); }
/** * Adds corners in OGC standard bbox/ envelop format. * * @param bottomLeft bottom left corner geohash. * @param topRight top right corner geohash. */ public GeoBoundingBoxQueryBuilder setCornersOGC(String bottomLeft, String topRight) { return setCornersOGC(GeoPoint.fromGeohash(bottomLeft), GeoPoint.fromGeohash(topRight)); }
/** * The geohash of the geo point to create the range distance facets from. * * Deprecated - please use points(GeoPoint... points) instead. */ @Deprecated public GeoDistanceSortBuilder geohashes(String... geohashes) { for (String geohash : geohashes) { this.points.add(GeoPoint.fromGeohash(geohash)); } return this; }
/** * The geohash of the geo point to create the range distance facets from. * * Deprecated - please use points(GeoPoint... points) instead. */ @Deprecated public GeoDistanceSortBuilder geohashes(String... geohashes) { for (String geohash : geohashes) { this.points.add(GeoPoint.fromGeohash(geohash)); } return this; }
/** * Adds points. * @param topLeft topLeft point to add as geohash. * @param bottomRight bottomRight point to add as geohash. * */ public GeoBoundingBoxQueryBuilder setCorners(String topLeft, String bottomRight) { return setCorners(GeoPoint.fromGeohash(topLeft), GeoPoint.fromGeohash(bottomRight)); }
public static GeoQueryContext fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); GeoQueryContext.Builder builder = new Builder(); if (token == XContentParser.Token.START_OBJECT) { GEO_CONTEXT_PARSER.parse(parser, builder, null); } else if (token == XContentParser.Token.VALUE_STRING) { builder.setGeoPoint(GeoPoint.fromGeohash(parser.text())); } else { throw new ElasticsearchParseException("geo context must be an object or string"); } return builder.build(); }
public static GeoQueryContext fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); GeoQueryContext.Builder builder = new Builder(); if (token == XContentParser.Token.START_OBJECT) { GEO_CONTEXT_PARSER.parse(parser, builder, null); } else if (token == XContentParser.Token.VALUE_STRING) { builder.setGeoPoint(GeoPoint.fromGeohash(parser.text())); } else { throw new ElasticsearchParseException("geo context must be an object or string"); } return builder.build(); }