Skip to content

Commit 1dcaee9

Browse files
committed
Geo: Switch generated WKT to upper case (elastic#50285)
Switches generated WKT to upper case to conform to the standard recommendation. Closes elastic#49568
1 parent 3b8f5d9 commit 1dcaee9

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
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

+8-8
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ 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
@@ -392,7 +392,7 @@ public String visit(GeometryCollection<?> collection) {
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" +

server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public void testShapeFetchingPath() throws Exception {
254254
createIndex("shapes");
255255
client().admin().indices().prepareCreate("test").addMapping("_doc", "location", "type=geo_shape").get();
256256

257-
String location = "\"location\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}";
257+
String location = "\"location\" : {\"type\":\"POLYGON\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}";
258258

259259
client().prepareIndex("shapes").setId("1")
260260
.setSource(

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/extractor/GeoShapeFieldTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void testObjectFormat() {
2222
String[] expected = new String[] {lat + "," + lon};
2323

2424
SearchHit hit = new SearchHitBuilder(42)
25-
.setSource("{\"geo\":{\"type\":\"point\", \"coordinates\": [" + lon + ", " + lat + "]}}")
25+
.setSource("{\"geo\":{\"type\":\"POINT\", \"coordinates\": [" + lon + ", " + lat + "]}}")
2626
.build();
2727

2828
ExtractedField geo = new GeoShapeField("geo");

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

x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void testShapeFetchingPath() throws Exception {
111111
createIndex(indexName);
112112
client().admin().indices().prepareCreate(searchIndex).addMapping("type", "location", "type=shape").get();
113113

114-
String location = "\"location\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}";
114+
String location = "\"location\" : {\"type\":\"POLYGON\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}";
115115

116116
client().prepareIndex(indexName).setId("1")
117117
.setSource(

0 commit comments

Comments
 (0)