Skip to content

Commit

Permalink
Geo: Switch generated GeoJson type names to camel case (#50400)
Browse files Browse the repository at this point in the history
Switches generated GeoJson type names to camel case
to conform to the standard.

Closes #49568
  • Loading branch information
imotov committed Dec 20, 2019
1 parent 1ec89f7 commit 339d10c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/reference/ingest/processors/circle.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The response from the above index request:
[30.000365257263184, 10.0]
]
],
"type": "polygon"
"type": "Polygon"
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions server/src/main/java/org/elasticsearch/common/geo/GeoJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,17 @@ public static String getGeoJsonName(Geometry geometry) {
return geometry.visit(new GeometryVisitor<String, RuntimeException>() {
@Override
public String visit(Circle circle) {
return "circle";
return "Circle";
}

@Override
public String visit(GeometryCollection<?> collection) {
return "geometrycollection";
return "GeometryCollection";
}

@Override
public String visit(Line line) {
return "linestring";
return "LineString";
}

@Override
Expand All @@ -402,32 +402,32 @@ public String visit(LinearRing ring) {

@Override
public String visit(MultiLine multiLine) {
return "multilinestring";
return "MultiLineString";
}

@Override
public String visit(MultiPoint multiPoint) {
return "multipoint";
return "MultiPoint";
}

@Override
public String visit(MultiPolygon multiPolygon) {
return "multipolygon";
return "MultiPolygon";
}

@Override
public String visit(Point point) {
return "point";
return "Point";
}

@Override
public String visit(Polygon polygon) {
return "polygon";
return "Polygon";
}

@Override
public String visit(Rectangle rectangle) {
return "envelope";
return "Envelope";
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testGeoJsonParsing() throws Exception {
assertEquals(new Point(100, 0), format.fromXContent(parser));
XContentBuilder newGeoJson = XContentFactory.jsonBuilder();
format.toXContent(new Point(100, 10), newGeoJson, ToXContent.EMPTY_PARAMS);
assertEquals("{\"type\":\"point\",\"coordinates\":[100.0,10.0]}", Strings.toString(newGeoJson));
assertEquals("{\"type\":\"Point\",\"coordinates\":[100.0,10.0]}", Strings.toString(newGeoJson));
}

XContentBuilder pointGeoJsonWithZ = XContentFactory.jsonBuilder()
Expand Down Expand Up @@ -148,7 +148,7 @@ public void testNullParsing() throws Exception {
// if we serialize non-null value - it should be serialized as geojson
format.toXContent(new Point(100, 10), newGeoJson, ToXContent.EMPTY_PARAMS);
newGeoJson.endObject();
assertEquals("{\"val\":{\"type\":\"point\",\"coordinates\":[100.0,10.0]}}", Strings.toString(newGeoJson));
assertEquals("{\"val\":{\"type\":\"Point\",\"coordinates\":[100.0,10.0]}}", Strings.toString(newGeoJson));

newGeoJson = XContentFactory.jsonBuilder().startObject().field("val");
format.toXContent(null, newGeoJson, ToXContent.EMPTY_PARAMS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void testFromJson() throws IOException {
" \"geo_shape\" : {\n" +
" \"location\" : {\n" +
" \"shape\" : {\n" +
" \"type\" : \"envelope\",\n" +
" \"type\" : \"Envelope\",\n" +
" \"coordinates\" : [ [ 13.0, 53.0 ], [ 14.0, 52.0 ] ]\n" +
" },\n" +
" \"relation\" : \"intersects\"\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void testFromJson() throws IOException {
" }\n" +
"}";
ShapeQueryBuilder parsed = (ShapeQueryBuilder) parseQuery(json);
checkGeneratedJson(json, parsed);
checkGeneratedJson(json.replaceAll("envelope", "Envelope"), parsed);
assertEquals(json, 42.0, parsed.boost(), 0.0001);
}

Expand Down

0 comments on commit 339d10c

Please sign in to comment.