diff --git a/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java index 5dfda3f527a5a..f9c27ae2e01c8 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java @@ -23,7 +23,6 @@ import org.elasticsearch.common.Explicit; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.geo.GeoPoint; -import org.elasticsearch.common.geo.GeometryFormat; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -182,93 +181,61 @@ protected void parsePointIgnoringMalformed(XContentParser parser, ParsedPoint po public static class PointParser
implements Parser parse(XContentParser parser, AbstractGeometryFieldMapper mapper) throws IOException, ParseException {
- return geometryFormat(parser, (AbstractPointGeometryFieldMapper)mapper).fromXContent(parser);
- }
+ public List parse(XContentParser parser, AbstractGeometryFieldMapper geometryMapper) throws IOException, ParseException {
+ AbstractPointGeometryFieldMapper mapper = (AbstractPointGeometryFieldMapper) geometryMapper;
- public GeometryFormat fromXContent(XContentParser parser) throws IOException {
- XContentParser.Token token = parser.nextToken();
- P point = (P)(mapper.newParsedPoint());
- ArrayList points = new ArrayList();
- if (token == XContentParser.Token.VALUE_NUMBER) {
- double x = parser.doubleValue();
- parser.nextToken();
- double y = parser.doubleValue();
- token = parser.nextToken();
- if (token == XContentParser.Token.VALUE_NUMBER) {
- GeoPoint.assertZValue((Boolean)(mapper.ignoreZValue().value()), parser.doubleValue());
- } else if (token != XContentParser.Token.END_ARRAY) {
- throw new ElasticsearchParseException("[{}] field type does not accept > 3 dimensions",
- mapper.contentType());
- }
-
- point.resetCoords(x, y);
- if ((Boolean)(mapper.ignoreMalformed().value()) == false) {
- point.validate(mapper.name());
- } else {
- point.normalize(mapper.name());
- }
- points.add(point);
- } else {
- while (token != XContentParser.Token.END_ARRAY) {
- mapper.parsePointIgnoringMalformed(parser, point);
- points.add(point);
- point = (P)(mapper.newParsedPoint());
- token = parser.nextToken();
- }
- }
- return points;
- }
-
- @Override
- public XContentBuilder toXContent(List points, XContentBuilder builder, Params params) throws IOException {
- return null;
- }
- };
- } else if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
- return new GeometryFormat fromXContent(XContentParser parser) throws IOException, ParseException {
- P point = null;
- ArrayList points = null;
- if (mapper.nullValue != null) {
- point = (P)(mapper.nullValue);
- if ((Boolean)(mapper.ignoreMalformed().value()) == false) {
- point.validate(mapper.name());
- } else {
- point.normalize(mapper.name());
- }
- points = new ArrayList<>();
- points.add(point);
- }
- return points;
+ XContentParser.Token token = parser.nextToken();
+ P point = (P)(mapper.newParsedPoint());
+ ArrayList points = new ArrayList();
+ if (token == XContentParser.Token.VALUE_NUMBER) {
+ double x = parser.doubleValue();
+ parser.nextToken();
+ double y = parser.doubleValue();
+ token = parser.nextToken();
+ if (token == XContentParser.Token.VALUE_NUMBER) {
+ GeoPoint.assertZValue((Boolean)(mapper.ignoreZValue().value()), parser.doubleValue());
+ } else if (token != XContentParser.Token.END_ARRAY) {
+ throw new ElasticsearchParseException("[{}] field type does not accept > 3 dimensions",
+ mapper.contentType());
}
- @Override
- public XContentBuilder toXContent(List points, XContentBuilder builder, Params params) throws IOException {
- return null;
+ point.resetCoords(x, y);
+ if ((Boolean)(mapper.ignoreMalformed().value()) == false) {
+ point.validate(mapper.name());
+ } else {
+ point.normalize(mapper.name());
}
- };
- } else {
- return new GeometryFormat fromXContent(XContentParser parser) throws IOException, ParseException {
- P point = (P)mapper.newParsedPoint();
+ points.add(point);
+ } else {
+ while (token != XContentParser.Token.END_ARRAY) {
mapper.parsePointIgnoringMalformed(parser, point);
- ArrayList points = new ArrayList();
points.add(point);
- return points;
+ point = (P)(mapper.newParsedPoint());
+ token = parser.nextToken();
}
-
- @Override
- public XContentBuilder toXContent(List points, XContentBuilder builder, Params params) throws IOException {
- return null;
+ }
+ return points;
+ } else if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
+ P point = null;
+ ArrayList points = null;
+ if (mapper.nullValue != null) {
+ point = (P)(mapper.nullValue);
+ if ((Boolean)(mapper.ignoreMalformed().value()) == false) {
+ point.validate(mapper.name());
+ } else {
+ point.normalize(mapper.name());
}
- };
+ points = new ArrayList<>();
+ points.add(point);
+ }
+ return points;
+ } else {
+ P point = (P)mapper.newParsedPoint();
+ mapper.parsePointIgnoringMalformed(parser, point);
+ ArrayList points = new ArrayList();
+ points.add(point);
+ return points;
}
}
}
> {
@Override
- public List
> geometryFormat(XContentParser parser, AbstractPointGeometryFieldMapper mapper) {
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
- return new GeometryFormat
>() {
- @Override
- public List
>() {
- @Override
- public List
>() {
- @Override
- public List