public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, point, false); }
/** * Parse a {@link GeoPoint} with a {@link XContentParser}: * * @param parser {@link XContentParser} to parse the value from * @return new {@link GeoPoint} parsed from the parse */ public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, new GeoPoint()); }
/** * Parses geopoint represented as an object or an array, ignores malformed geopoints if needed */ private void parseGeoPointIgnoringMalformed(ParseContext context, GeoPoint sparse) throws IOException { try { parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse)); } catch (ElasticsearchParseException e) { if (ignoreMalformed.value() == false) { throw e; } context.addIgnoredField(fieldType.name()); } }
boolean ignoreZValue = builder.ignoreZValue == null ? Defaults.IGNORE_Z_VALUE.value() : builder.ignoreZValue; boolean ignoreMalformed = builder.ignoreMalformed == null ? Defaults.IGNORE_MALFORMED.value() : builder.ignoreZValue; GeoPoint point = GeoUtils.parseGeoPoint(nullValue, ignoreZValue); if (ignoreMalformed == false) { if (point.lat() > 90.0 || point.lat() < -90.0) {
GeoPoint point = GeoUtils.parseGeoPoint(parser); contexts.add(stringEncode(point.getLon(), point.getLat(), precision)); token = parser.nextToken(); } else { GeoPoint point = GeoUtils.parseGeoPoint(parser); contexts.add(stringEncode(point.getLon(), point.getLat(), precision));
scaleString = parser.text(); } else if (DecayFunctionBuilder.ORIGIN.equals(parameterName)) { origin = GeoUtils.parseGeoPoint(parser); } else if (DecayFunctionBuilder.DECAY.equals(parameterName)) { decay = parser.doubleValue();
/** * Parses the value as a geopoint. The following types of values are supported: * <p> * Object: has to contain either lat and lon or geohash fields * <p> * String: expected to be in "latitude, longitude" format or a geohash * <p> * Array: two or more elements, the first element is longitude, the second is latitude, the rest is ignored if ignoreZValue is true */ public static GeoPoint parseGeoPoint(Object value, final boolean ignoreZValue) throws ElasticsearchParseException { try { XContentBuilder content = JsonXContent.contentBuilder(); content.startObject(); content.field("null_value", value); content.endObject(); try (InputStream stream = BytesReference.bytes(content).streamInput(); XContentParser parser = JsonXContent.jsonXContent.createParser( NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream)) { parser.nextToken(); // start object parser.nextToken(); // field name parser.nextToken(); // field value return parseGeoPoint(parser, new GeoPoint(), ignoreZValue); } } catch (IOException ex) { throw new ElasticsearchParseException("error parsing geopoint", ex); } }
static void parseGeoPoints(XContentParser parser, List<GeoPoint> geoPoints) throws IOException { while (!parser.nextToken().equals(XContentParser.Token.END_ARRAY)) { if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) { // we might get here if the geo point is " number, number] " and the parser already moved over the // opening bracket in this case we cannot use GeoUtils.parseGeoPoint(..) because this expects an opening // bracket double lon = parser.doubleValue(); parser.nextToken(); if (!parser.currentToken().equals(XContentParser.Token.VALUE_NUMBER)) { throw new ElasticsearchParseException( "geo point parsing: expected second number but got [{}] instead", parser.currentToken()); } double lat = parser.doubleValue(); GeoPoint point = new GeoPoint(); point.reset(lat, lon); geoPoints.add(point); } else { GeoPoint point = new GeoPoint(); GeoUtils.parseGeoPoint(parser, point); geoPoints.add(point); } } }
public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, point, false); }
public static GeoPoint parseGeoPoint(XContentParser parser, GeoPoint point) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, point, false); }
} else { if (TOP_LEFT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); top = sparse.getLat(); left = sparse.getLon(); } else if (BOTTOM_RIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); bottom = sparse.getLat(); right = sparse.getLon(); } else if (TOP_RIGHT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); top = sparse.getLat(); right = sparse.getLon(); } else if (BOTTOM_LEFT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { GeoUtils.parseGeoPoint(parser, sparse); bottom = sparse.getLat(); left = sparse.getLon();
} else if (token == XContentParser.Token.START_ARRAY) { fieldName = currentFieldName; GeoUtils.parseGeoPoint(parser, point); } else if (token == XContentParser.Token.START_OBJECT) { throwParsingExceptionOnMultipleFields(NAME, parser.getTokenLocation(), fieldName, currentFieldName);
shell = new ArrayList<>(); while ((token = parser.nextToken()) != Token.END_ARRAY) { shell.add(GeoUtils.parseGeoPoint(parser));
/** * Parse a {@link GeoPoint} with a {@link XContentParser}: * * @param parser {@link XContentParser} to parse the value from * @return new {@link GeoPoint} parsed from the parse */ public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, new GeoPoint()); }
/** * Parse a {@link GeoPoint} with a {@link XContentParser}: * * @param parser {@link XContentParser} to parse the value from * @return new {@link GeoPoint} parsed from the parse */ public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, new GeoPoint()); }
/** * Parse a {@link GeoPoint} with a {@link XContentParser}: * * @param parser {@link XContentParser} to parse the value from * @return new {@link GeoPoint} parsed from the parse */ public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, new GeoPoint()); }
/** * Parse a {@link GeoPoint} with a {@link XContentParser}: * * @param parser {@link XContentParser} to parse the value from * @return new {@link GeoPoint} parsed from the parse */ public static GeoPoint parseGeoPoint(XContentParser parser) throws IOException, ElasticsearchParseException { return parseGeoPoint(parser, new GeoPoint()); }
GeoUtils.parseGeoPoint(parser, point); geoPoints.add(point);
/** * Parses geopoint represented as an object or an array, ignores malformed geopoints if needed */ private void parseGeoPointIgnoringMalformed(ParseContext context, GeoPoint sparse) throws IOException { try { parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse)); } catch (ElasticsearchParseException e) { if (ignoreMalformed.value() == false) { throw e; } context.addIgnoredField(fieldType.name()); } }
/** * Parses geopoint represented as an object or an array, ignores malformed geopoints if needed */ private void parseGeoPointIgnoringMalformed(ParseContext context, GeoPoint sparse) throws IOException { try { parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse)); } catch (ElasticsearchParseException e) { if (ignoreMalformed.value() == false) { throw e; } context.addIgnoredField(fieldType.name()); } }