Skip to content

Commit 7f81467

Browse files
authored
Geo: Switch generated GeoJson type names to camel case (#50285) (#50400)
Switches generated GeoJson type names to camel case to conform to the standard. Closes #49568
1 parent f66555e commit 7f81467

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

docs/reference/ingest/processors/circle.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ The response from the above index request:
128128
[30.000365257263184, 10.0]
129129
]
130130
],
131-
"type": "polygon"
131+
"type": "Polygon"
132132
}
133133
}
134134
}

server/src/main/java/org/elasticsearch/common/geo/GeoJson.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,17 @@ public static String getGeoJsonName(Geometry geometry) {
382382
return geometry.visit(new GeometryVisitor<>() {
383383
@Override
384384
public String visit(Circle circle) {
385-
return "circle";
385+
return "Circle";
386386
}
387387

388388
@Override
389389
public String visit(GeometryCollection<?> collection) {
390-
return "geometrycollection";
390+
return "GeometryCollection";
391391
}
392392

393393
@Override
394394
public String visit(Line line) {
395-
return "linestring";
395+
return "LineString";
396396
}
397397

398398
@Override
@@ -402,32 +402,32 @@ public String visit(LinearRing ring) {
402402

403403
@Override
404404
public String visit(MultiLine multiLine) {
405-
return "multilinestring";
405+
return "MultiLineString";
406406
}
407407

408408
@Override
409409
public String visit(MultiPoint multiPoint) {
410-
return "multipoint";
410+
return "MultiPoint";
411411
}
412412

413413
@Override
414414
public String visit(MultiPolygon multiPolygon) {
415-
return "multipolygon";
415+
return "MultiPolygon";
416416
}
417417

418418
@Override
419419
public String visit(Point point) {
420-
return "point";
420+
return "Point";
421421
}
422422

423423
@Override
424424
public String visit(Polygon polygon) {
425-
return "polygon";
425+
return "Polygon";
426426
}
427427

428428
@Override
429429
public String visit(Rectangle rectangle) {
430-
return "envelope";
430+
return "Envelope";
431431
}
432432
});
433433
}

server/src/test/java/org/elasticsearch/common/geo/GeometryParserTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testGeoJsonParsing() throws Exception {
5151
assertEquals(new Point(100, 0), format.fromXContent(parser));
5252
XContentBuilder newGeoJson = XContentFactory.jsonBuilder();
5353
format.toXContent(new Point(100, 10), newGeoJson, ToXContent.EMPTY_PARAMS);
54-
assertEquals("{\"type\":\"point\",\"coordinates\":[100.0,10.0]}", Strings.toString(newGeoJson));
54+
assertEquals("{\"type\":\"Point\",\"coordinates\":[100.0,10.0]}", Strings.toString(newGeoJson));
5555
}
5656

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

153153
newGeoJson = XContentFactory.jsonBuilder().startObject().field("val");
154154
format.toXContent(null, newGeoJson, ToXContent.EMPTY_PARAMS);

server/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void testFromJson() throws IOException {
204204
" \"geo_shape\" : {\n" +
205205
" \"location\" : {\n" +
206206
" \"shape\" : {\n" +
207-
" \"type\" : \"envelope\",\n" +
207+
" \"type\" : \"Envelope\",\n" +
208208
" \"coordinates\" : [ [ 13.0, 53.0 ], [ 14.0, 52.0 ] ]\n" +
209209
" },\n" +
210210
" \"relation\" : \"intersects\"\n" +

x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void testFromJson() throws IOException {
179179
" }\n" +
180180
"}";
181181
ShapeQueryBuilder parsed = (ShapeQueryBuilder) parseQuery(json);
182-
checkGeneratedJson(json, parsed);
182+
checkGeneratedJson(json.replaceAll("envelope", "Envelope"), parsed);
183183
assertEquals(json, 42.0, parsed.boost(), 0.0001);
184184
}
185185

0 commit comments

Comments
 (0)