Skip to content

Commit 7f2f5ce

Browse files
committed
Geo: Switch generated WKT to upper case
Switches generated WKT to upper case to conform to the stanard recommendation. Relates elastic#49568
1 parent 012746d commit 7f2f5ce

File tree

11 files changed

+58
-58
lines changed

11 files changed

+58
-58
lines changed

libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownText.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -586,17 +586,17 @@ private static String getWKTName(Geometry geometry) {
586586
return geometry.visit(new GeometryVisitor<String, RuntimeException>() {
587587
@Override
588588
public String visit(Circle circle) {
589-
return "circle";
589+
return "CIRCLE";
590590
}
591591

592592
@Override
593593
public String visit(GeometryCollection<?> collection) {
594-
return "geometrycollection";
594+
return "GEOMETRYCOLLECTION";
595595
}
596596

597597
@Override
598598
public String visit(Line line) {
599-
return "linestring";
599+
return "LINESTRING";
600600
}
601601

602602
@Override
@@ -606,32 +606,32 @@ public String visit(LinearRing ring) {
606606

607607
@Override
608608
public String visit(MultiLine multiLine) {
609-
return "multilinestring";
609+
return "MULTILINESTRING";
610610
}
611611

612612
@Override
613613
public String visit(MultiPoint multiPoint) {
614-
return "multipoint";
614+
return "MULTIPOINT";
615615
}
616616

617617
@Override
618618
public String visit(MultiPolygon multiPolygon) {
619-
return "multipolygon";
619+
return "MULTIPOLYGON";
620620
}
621621

622622
@Override
623623
public String visit(Point point) {
624-
return "point";
624+
return "POINT";
625625
}
626626

627627
@Override
628628
public String visit(Polygon polygon) {
629-
return "polygon";
629+
return "POLYGON";
630630
}
631631

632632
@Override
633633
public String visit(Rectangle rectangle) {
634-
return "bbox";
634+
return "BBOX";
635635
}
636636
});
637637
}

libs/geo/src/test/java/org/elasticsearch/geometry/CircleTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ protected Circle createTestInstance(boolean hasAlt) {
4040

4141
public void testBasicSerialization() throws IOException, ParseException {
4242
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
43-
assertEquals("circle (20.0 10.0 15.0)", wkt.toWKT(new Circle(20, 10, 15)));
43+
assertEquals("CIRCLE (20.0 10.0 15.0)", wkt.toWKT(new Circle(20, 10, 15)));
4444
assertEquals(new Circle(20, 10, 15), wkt.fromWKT("circle (20.0 10.0 15.0)"));
4545

46-
assertEquals("circle (20.0 10.0 15.0 25.0)", wkt.toWKT(new Circle(20, 10, 25, 15)));
46+
assertEquals("CIRCLE (20.0 10.0 15.0 25.0)", wkt.toWKT(new Circle(20, 10, 25, 15)));
4747
assertEquals(new Circle(20, 10, 25, 15), wkt.fromWKT("circle (20.0 10.0 15.0 25.0)"));
4848

49-
assertEquals("circle EMPTY", wkt.toWKT(Circle.EMPTY));
50-
assertEquals(Circle.EMPTY, wkt.fromWKT("circle EMPTY)"));
49+
assertEquals("CIRCLE EMPTY", wkt.toWKT(Circle.EMPTY));
50+
assertEquals(Circle.EMPTY, wkt.fromWKT("CIRCLE EMPTY)"));
5151
}
5252

5353
public void testInitValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/GeometryCollectionTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ protected GeometryCollection<Geometry> createTestInstance(boolean hasAlt) {
3737

3838
public void testBasicSerialization() throws IOException, ParseException {
3939
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
40-
assertEquals("geometrycollection (point (20.0 10.0),point EMPTY)",
40+
assertEquals("GEOMETRYCOLLECTION (POINT (20.0 10.0),POINT EMPTY)",
4141
wkt.toWKT(new GeometryCollection<Geometry>(Arrays.asList(new Point(20, 10), Point.EMPTY))));
4242

4343
assertEquals(new GeometryCollection<Geometry>(Arrays.asList(new Point(20, 10), Point.EMPTY)),
44-
wkt.fromWKT("geometrycollection (point (20.0 10.0),point EMPTY)"));
44+
wkt.fromWKT("GEOMETRYCOLLECTION (POINT (20.0 10.0),POINT EMPTY)"));
4545

46-
assertEquals("geometrycollection EMPTY", wkt.toWKT(GeometryCollection.EMPTY));
47-
assertEquals(GeometryCollection.EMPTY, wkt.fromWKT("geometrycollection EMPTY)"));
46+
assertEquals("GEOMETRYCOLLECTION EMPTY", wkt.toWKT(GeometryCollection.EMPTY));
47+
assertEquals(GeometryCollection.EMPTY, wkt.fromWKT("GEOMETRYCOLLECTION EMPTY)"));
4848
}
4949

5050
@SuppressWarnings("ConstantConditions")

libs/geo/src/test/java/org/elasticsearch/geometry/LineTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ protected Line createTestInstance(boolean hasAlt) {
3636

3737
public void testBasicSerialization() throws IOException, ParseException {
3838
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
39-
assertEquals("linestring (3.0 1.0, 4.0 2.0)", wkt.toWKT(new Line(new double[]{3, 4}, new double[]{1, 2})));
40-
assertEquals(new Line(new double[]{3, 4}, new double[]{1, 2}), wkt.fromWKT("linestring (3 1, 4 2)"));
39+
assertEquals("LINESTRING (3.0 1.0, 4.0 2.0)", wkt.toWKT(new Line(new double[]{3, 4}, new double[]{1, 2})));
40+
assertEquals(new Line(new double[]{3, 4}, new double[]{1, 2}), wkt.fromWKT("LINESTRING (3 1, 4 2)"));
4141

42-
assertEquals("linestring (3.0 1.0 5.0, 4.0 2.0 6.0)", wkt.toWKT(new Line(new double[]{3, 4}, new double[]{1, 2},
42+
assertEquals("LINESTRING (3.0 1.0 5.0, 4.0 2.0 6.0)", wkt.toWKT(new Line(new double[]{3, 4}, new double[]{1, 2},
4343
new double[]{5, 6})));
4444
assertEquals(new Line(new double[]{3, 4}, new double[]{1, 2}, new double[]{6, 5}),
45-
wkt.fromWKT("linestring (3 1 6, 4 2 5)"));
45+
wkt.fromWKT("LINESTRING (3 1 6, 4 2 5)"));
4646

47-
assertEquals("linestring EMPTY", wkt.toWKT(Line.EMPTY));
48-
assertEquals(Line.EMPTY, wkt.fromWKT("linestring EMPTY)"));
47+
assertEquals("LINESTRING EMPTY", wkt.toWKT(Line.EMPTY));
48+
assertEquals(Line.EMPTY, wkt.fromWKT("LINESTRING EMPTY)"));
4949
}
5050

5151
public void testInitValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/MultiLineTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ protected MultiLine createTestInstance(boolean hasAlt) {
4444

4545
public void testBasicSerialization() throws IOException, ParseException {
4646
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
47-
assertEquals("multilinestring ((3.0 1.0, 4.0 2.0))", wkt.toWKT(
47+
assertEquals("MULTILINESTRING ((3.0 1.0, 4.0 2.0))", wkt.toWKT(
4848
new MultiLine(Collections.singletonList(new Line(new double[]{3, 4}, new double[]{1, 2})))));
4949
assertEquals(new MultiLine(Collections.singletonList(new Line(new double[]{3, 4}, new double[]{1, 2}))),
50-
wkt.fromWKT("multilinestring ((3 1, 4 2))"));
50+
wkt.fromWKT("MULTILINESTRING ((3 1, 4 2))"));
5151

52-
assertEquals("multilinestring EMPTY", wkt.toWKT(MultiLine.EMPTY));
53-
assertEquals(MultiLine.EMPTY, wkt.fromWKT("multilinestring EMPTY)"));
52+
assertEquals("MULTILINESTRING EMPTY", wkt.toWKT(MultiLine.EMPTY));
53+
assertEquals(MultiLine.EMPTY, wkt.fromWKT("MULTILINESTRING EMPTY)"));
5454
}
5555

5656
public void testValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/MultiPointTests.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ protected MultiPoint createTestInstance(boolean hasAlt) {
4545

4646
public void testBasicSerialization() throws IOException, ParseException {
4747
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
48-
assertEquals("multipoint (2.0 1.0)", wkt.toWKT(
48+
assertEquals("MULTIPOINT (2.0 1.0)", wkt.toWKT(
4949
new MultiPoint(Collections.singletonList(new Point(2, 1)))));
5050
assertEquals(new MultiPoint(Collections.singletonList(new Point(2, 1))),
51-
wkt.fromWKT("multipoint (2 1)"));
51+
wkt.fromWKT("MULTIPOINT (2 1)"));
5252

53-
assertEquals("multipoint (2.0 1.0, 3.0 4.0)",
53+
assertEquals("MULTIPOINT (2.0 1.0, 3.0 4.0)",
5454
wkt.toWKT(new MultiPoint(Arrays.asList(new Point(2, 1), new Point(3, 4)))));
5555
assertEquals(new MultiPoint(Arrays.asList(new Point(2, 1), new Point(3, 4))),
56-
wkt.fromWKT("multipoint (2 1, 3 4)"));
56+
wkt.fromWKT("MULTIPOINT (2 1, 3 4)"));
5757

58-
assertEquals("multipoint (2.0 1.0 10.0, 3.0 4.0 20.0)",
58+
assertEquals("MULTIPOINT (2.0 1.0 10.0, 3.0 4.0 20.0)",
5959
wkt.toWKT(new MultiPoint(Arrays.asList(new Point(2, 1, 10), new Point(3, 4, 20)))));
6060
assertEquals(new MultiPoint(Arrays.asList(new Point(2, 1, 10), new Point(3, 4, 20))),
61-
wkt.fromWKT("multipoint (2 1 10, 3 4 20)"));
61+
wkt.fromWKT("MULTIPOINT (2 1 10, 3 4 20)"));
6262

63-
assertEquals("multipoint EMPTY", wkt.toWKT(MultiPoint.EMPTY));
64-
assertEquals(MultiPoint.EMPTY, wkt.fromWKT("multipoint EMPTY)"));
63+
assertEquals("MULTIPOINT EMPTY", wkt.toWKT(MultiPoint.EMPTY));
64+
assertEquals(MultiPoint.EMPTY, wkt.fromWKT("MULTIPOINT EMPTY)"));
6565
}
6666

6767
public void testValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/MultiPolygonTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ protected MultiPolygon createTestInstance(boolean hasAlt) {
4444

4545
public void testBasicSerialization() throws IOException, ParseException {
4646
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
47-
assertEquals("multipolygon (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))",
47+
assertEquals("MULTIPOLYGON (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))",
4848
wkt.toWKT(new MultiPolygon(Collections.singletonList(
4949
new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}))))));
5050
assertEquals(new MultiPolygon(Collections.singletonList(
5151
new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1})))),
52-
wkt.fromWKT("multipolygon (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))"));
52+
wkt.fromWKT("MULTIPOLYGON (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))"));
5353

54-
assertEquals("multipolygon EMPTY", wkt.toWKT(MultiPolygon.EMPTY));
55-
assertEquals(MultiPolygon.EMPTY, wkt.fromWKT("multipolygon EMPTY)"));
54+
assertEquals("MULTIPOLYGON EMPTY", wkt.toWKT(MultiPolygon.EMPTY));
55+
assertEquals(MultiPolygon.EMPTY, wkt.fromWKT("MULTIPOLYGON EMPTY)"));
5656
}
5757

5858
public void testValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/PointTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ protected Point createTestInstance(boolean hasAlt) {
3636

3737
public void testBasicSerialization() throws IOException, ParseException {
3838
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
39-
assertEquals("point (20.0 10.0)", wkt.toWKT(new Point(20, 10)));
39+
assertEquals("POINT (20.0 10.0)", wkt.toWKT(new Point(20, 10)));
4040
assertEquals(new Point(20, 10), wkt.fromWKT("point (20.0 10.0)"));
4141

42-
assertEquals("point (20.0 10.0 100.0)", wkt.toWKT(new Point(20, 10, 100)));
43-
assertEquals(new Point(20, 10, 100), wkt.fromWKT("point (20.0 10.0 100.0)"));
42+
assertEquals("POINT (20.0 10.0 100.0)", wkt.toWKT(new Point(20, 10, 100)));
43+
assertEquals(new Point(20, 10, 100), wkt.fromWKT("POINT (20.0 10.0 100.0)"));
4444

45-
assertEquals("point EMPTY", wkt.toWKT(Point.EMPTY));
46-
assertEquals(Point.EMPTY, wkt.fromWKT("point EMPTY)"));
45+
assertEquals("POINT EMPTY", wkt.toWKT(Point.EMPTY));
46+
assertEquals(Point.EMPTY, wkt.fromWKT("POINT EMPTY)"));
4747
}
4848

4949
public void testInitValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/PolygonTests.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,27 @@ protected Polygon createTestInstance(boolean hasAlt) {
3636

3737
public void testBasicSerialization() throws IOException, ParseException {
3838
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
39-
assertEquals("polygon ((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0))",
39+
assertEquals("POLYGON ((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0))",
4040
wkt.toWKT(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}))));
4141
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1})),
42-
wkt.fromWKT("polygon ((3 1, 4 2, 5 3, 3 1))"));
42+
wkt.fromWKT("POLYGON ((3 1, 4 2, 5 3, 3 1))"));
4343

44-
assertEquals("polygon ((3.0 1.0 5.0, 4.0 2.0 4.0, 5.0 3.0 3.0, 3.0 1.0 5.0))",
44+
assertEquals("POLYGON ((3.0 1.0 5.0, 4.0 2.0 4.0, 5.0 3.0 3.0, 3.0 1.0 5.0))",
4545
wkt.toWKT(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}, new double[]{5, 4, 3, 5}))));
4646
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}, new double[]{5, 4, 3, 5})),
47-
wkt.fromWKT("polygon ((3 1 5, 4 2 4, 5 3 3, 3 1 5))"));
47+
wkt.fromWKT("POLYGON ((3 1 5, 4 2 4, 5 3 3, 3 1 5))"));
4848

4949
// Auto closing in coerce mode
5050
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1})),
51-
wkt.fromWKT("polygon ((3 1, 4 2, 5 3))"));
51+
wkt.fromWKT("POLYGON ((3 1, 4 2, 5 3))"));
5252
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}, new double[]{5, 4, 3, 5})),
53-
wkt.fromWKT("polygon ((3 1 5, 4 2 4, 5 3 3))"));
53+
wkt.fromWKT("POLYGON ((3 1 5, 4 2 4, 5 3 3))"));
5454
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}),
5555
Collections.singletonList(new LinearRing(new double[]{0.5, 2.5, 2.0, 0.5}, new double[]{1.5, 1.5, 1.0, 1.5}))),
56-
wkt.fromWKT("polygon ((3 1, 4 2, 5 3, 3 1), (0.5 1.5, 2.5 1.5, 2.0 1.0))"));
56+
wkt.fromWKT("POLYGON ((3 1, 4 2, 5 3, 3 1), (0.5 1.5, 2.5 1.5, 2.0 1.0))"));
5757

58-
assertEquals("polygon EMPTY", wkt.toWKT(Polygon.EMPTY));
59-
assertEquals(Polygon.EMPTY, wkt.fromWKT("polygon EMPTY)"));
58+
assertEquals("POLYGON EMPTY", wkt.toWKT(Polygon.EMPTY));
59+
assertEquals(Polygon.EMPTY, wkt.fromWKT("POLYGON EMPTY)"));
6060
}
6161

6262
public void testInitValidation() {

libs/geo/src/test/java/org/elasticsearch/geometry/RectangleTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ protected Rectangle createTestInstance(boolean hasAlt) {
3737

3838
public void testBasicSerialization() throws IOException, ParseException {
3939
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
40-
assertEquals("bbox (10.0, 20.0, 40.0, 30.0)", wkt.toWKT(new Rectangle(10, 20, 40, 30)));
41-
assertEquals(new Rectangle(10, 20, 40, 30), wkt.fromWKT("bbox (10.0, 20.0, 40.0, 30.0)"));
40+
assertEquals("BBOX (10.0, 20.0, 40.0, 30.0)", wkt.toWKT(new Rectangle(10, 20, 40, 30)));
41+
assertEquals(new Rectangle(10, 20, 40, 30), wkt.fromWKT("BBOX (10.0, 20.0, 40.0, 30.0)"));
4242

43-
assertEquals("bbox EMPTY", wkt.toWKT(Rectangle.EMPTY));
44-
assertEquals(Rectangle.EMPTY, wkt.fromWKT("bbox EMPTY)"));
43+
assertEquals("BBOX EMPTY", wkt.toWKT(Rectangle.EMPTY));
44+
assertEquals(Rectangle.EMPTY, wkt.fromWKT("BBOX EMPTY)"));
4545
}
4646

4747
public void testInitValidation() {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void testWKTParsing() throws Exception {
113113
XContentBuilder newGeoJson = XContentFactory.jsonBuilder().startObject().field("val");
114114
format.toXContent(new Point(100, 10), newGeoJson, ToXContent.EMPTY_PARAMS);
115115
newGeoJson.endObject();
116-
assertEquals("{\"val\":\"point (100.0 10.0)\"}", Strings.toString(newGeoJson));
116+
assertEquals("{\"val\":\"POINT (100.0 10.0)\"}", Strings.toString(newGeoJson));
117117
}
118118

119119
// Make sure we can parse values outside the normal lat lon boundaries

0 commit comments

Comments
 (0)