Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geo: Switch generated GeoJson type names to camel case (#50285) #50400

Merged
merged 4 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/ingest/processors/circle.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,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<>() {
@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 @@ -204,7 +204,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 @@ -179,7 +179,7 @@ public void testFromJson() throws IOException {
" }\n" +
"}";
ShapeQueryBuilder parsed = (ShapeQueryBuilder) parseQuery(json);
checkGeneratedJson(json, parsed);
checkGeneratedJson(json.replaceAll("envelope", "Envelope"), parsed);
talevy marked this conversation as resolved.
Show resolved Hide resolved
assertEquals(json, 42.0, parsed.boost(), 0.0001);
}

Expand Down