Geo: Switch generated WKT to upper case (#50285)
Switches generated WKT to upper case to conform to the standard recommendation. Relates #49568
This commit is contained in:
parent
d3c83cd55a
commit
c77ca98928
|
@ -81,7 +81,7 @@ The response from the above index request:
|
|||
"_seq_no": 22,
|
||||
"_primary_term": 1,
|
||||
"_source": {
|
||||
"circle": "polygon ((30.000365257263184 10.0, 30.000111397193788 10.00034284530941, 29.999706043744222 10.000213571721195, 29.999706043744222 9.999786428278805, 30.000111397193788 9.99965715469059, 30.000365257263184 10.0))"
|
||||
"circle": "POLYGON ((30.000365257263184 10.0, 30.000111397193788 10.00034284530941, 29.999706043744222 10.000213571721195, 29.999706043744222 9.999786428278805, 30.000111397193788 9.99965715469059, 30.000365257263184 10.0))"
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
|
|
@ -586,17 +586,17 @@ public class WellKnownText {
|
|||
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
|
||||
|
@ -606,32 +606,32 @@ public class WellKnownText {
|
|||
|
||||
@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 "bbox";
|
||||
return "BBOX";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -40,14 +40,14 @@ public class CircleTests extends BaseGeometryTestCase<Circle> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("circle (20.0 10.0 15.0)", wkt.toWKT(new Circle(20, 10, 15)));
|
||||
assertEquals("CIRCLE (20.0 10.0 15.0)", wkt.toWKT(new Circle(20, 10, 15)));
|
||||
assertEquals(new Circle(20, 10, 15), wkt.fromWKT("circle (20.0 10.0 15.0)"));
|
||||
|
||||
assertEquals("circle (20.0 10.0 15.0 25.0)", wkt.toWKT(new Circle(20, 10, 25, 15)));
|
||||
assertEquals("CIRCLE (20.0 10.0 15.0 25.0)", wkt.toWKT(new Circle(20, 10, 25, 15)));
|
||||
assertEquals(new Circle(20, 10, 25, 15), wkt.fromWKT("circle (20.0 10.0 15.0 25.0)"));
|
||||
|
||||
assertEquals("circle EMPTY", wkt.toWKT(Circle.EMPTY));
|
||||
assertEquals(Circle.EMPTY, wkt.fromWKT("circle EMPTY)"));
|
||||
assertEquals("CIRCLE EMPTY", wkt.toWKT(Circle.EMPTY));
|
||||
assertEquals(Circle.EMPTY, wkt.fromWKT("CIRCLE EMPTY)"));
|
||||
}
|
||||
|
||||
public void testInitValidation() {
|
||||
|
|
|
@ -37,14 +37,14 @@ public class GeometryCollectionTests extends BaseGeometryTestCase<GeometryCollec
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("geometrycollection (point (20.0 10.0),point EMPTY)",
|
||||
assertEquals("GEOMETRYCOLLECTION (POINT (20.0 10.0),POINT EMPTY)",
|
||||
wkt.toWKT(new GeometryCollection<Geometry>(Arrays.asList(new Point(20, 10), Point.EMPTY))));
|
||||
|
||||
assertEquals(new GeometryCollection<Geometry>(Arrays.asList(new Point(20, 10), Point.EMPTY)),
|
||||
wkt.fromWKT("geometrycollection (point (20.0 10.0),point EMPTY)"));
|
||||
wkt.fromWKT("GEOMETRYCOLLECTION (POINT (20.0 10.0),POINT EMPTY)"));
|
||||
|
||||
assertEquals("geometrycollection EMPTY", wkt.toWKT(GeometryCollection.EMPTY));
|
||||
assertEquals(GeometryCollection.EMPTY, wkt.fromWKT("geometrycollection EMPTY)"));
|
||||
assertEquals("GEOMETRYCOLLECTION EMPTY", wkt.toWKT(GeometryCollection.EMPTY));
|
||||
assertEquals(GeometryCollection.EMPTY, wkt.fromWKT("GEOMETRYCOLLECTION EMPTY)"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
|
|
|
@ -36,16 +36,16 @@ public class LineTests extends BaseGeometryTestCase<Line> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("linestring (3.0 1.0, 4.0 2.0)", wkt.toWKT(new Line(new double[]{3, 4}, new double[]{1, 2})));
|
||||
assertEquals(new Line(new double[]{3, 4}, new double[]{1, 2}), wkt.fromWKT("linestring (3 1, 4 2)"));
|
||||
assertEquals("LINESTRING (3.0 1.0, 4.0 2.0)", wkt.toWKT(new Line(new double[]{3, 4}, new double[]{1, 2})));
|
||||
assertEquals(new Line(new double[]{3, 4}, new double[]{1, 2}), wkt.fromWKT("LINESTRING (3 1, 4 2)"));
|
||||
|
||||
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},
|
||||
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},
|
||||
new double[]{5, 6})));
|
||||
assertEquals(new Line(new double[]{3, 4}, new double[]{1, 2}, new double[]{6, 5}),
|
||||
wkt.fromWKT("linestring (3 1 6, 4 2 5)"));
|
||||
wkt.fromWKT("LINESTRING (3 1 6, 4 2 5)"));
|
||||
|
||||
assertEquals("linestring EMPTY", wkt.toWKT(Line.EMPTY));
|
||||
assertEquals(Line.EMPTY, wkt.fromWKT("linestring EMPTY)"));
|
||||
assertEquals("LINESTRING EMPTY", wkt.toWKT(Line.EMPTY));
|
||||
assertEquals(Line.EMPTY, wkt.fromWKT("LINESTRING EMPTY)"));
|
||||
}
|
||||
|
||||
public void testInitValidation() {
|
||||
|
|
|
@ -44,13 +44,13 @@ public class MultiLineTests extends BaseGeometryTestCase<MultiLine> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("multilinestring ((3.0 1.0, 4.0 2.0))", wkt.toWKT(
|
||||
assertEquals("MULTILINESTRING ((3.0 1.0, 4.0 2.0))", wkt.toWKT(
|
||||
new MultiLine(Collections.singletonList(new Line(new double[]{3, 4}, new double[]{1, 2})))));
|
||||
assertEquals(new MultiLine(Collections.singletonList(new Line(new double[]{3, 4}, new double[]{1, 2}))),
|
||||
wkt.fromWKT("multilinestring ((3 1, 4 2))"));
|
||||
wkt.fromWKT("MULTILINESTRING ((3 1, 4 2))"));
|
||||
|
||||
assertEquals("multilinestring EMPTY", wkt.toWKT(MultiLine.EMPTY));
|
||||
assertEquals(MultiLine.EMPTY, wkt.fromWKT("multilinestring EMPTY)"));
|
||||
assertEquals("MULTILINESTRING EMPTY", wkt.toWKT(MultiLine.EMPTY));
|
||||
assertEquals(MultiLine.EMPTY, wkt.fromWKT("MULTILINESTRING EMPTY)"));
|
||||
}
|
||||
|
||||
public void testValidation() {
|
||||
|
|
|
@ -45,23 +45,23 @@ public class MultiPointTests extends BaseGeometryTestCase<MultiPoint> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("multipoint (2.0 1.0)", wkt.toWKT(
|
||||
assertEquals("MULTIPOINT (2.0 1.0)", wkt.toWKT(
|
||||
new MultiPoint(Collections.singletonList(new Point(2, 1)))));
|
||||
assertEquals(new MultiPoint(Collections.singletonList(new Point(2, 1))),
|
||||
wkt.fromWKT("multipoint (2 1)"));
|
||||
wkt.fromWKT("MULTIPOINT (2 1)"));
|
||||
|
||||
assertEquals("multipoint (2.0 1.0, 3.0 4.0)",
|
||||
assertEquals("MULTIPOINT (2.0 1.0, 3.0 4.0)",
|
||||
wkt.toWKT(new MultiPoint(Arrays.asList(new Point(2, 1), new Point(3, 4)))));
|
||||
assertEquals(new MultiPoint(Arrays.asList(new Point(2, 1), new Point(3, 4))),
|
||||
wkt.fromWKT("multipoint (2 1, 3 4)"));
|
||||
wkt.fromWKT("MULTIPOINT (2 1, 3 4)"));
|
||||
|
||||
assertEquals("multipoint (2.0 1.0 10.0, 3.0 4.0 20.0)",
|
||||
assertEquals("MULTIPOINT (2.0 1.0 10.0, 3.0 4.0 20.0)",
|
||||
wkt.toWKT(new MultiPoint(Arrays.asList(new Point(2, 1, 10), new Point(3, 4, 20)))));
|
||||
assertEquals(new MultiPoint(Arrays.asList(new Point(2, 1, 10), new Point(3, 4, 20))),
|
||||
wkt.fromWKT("multipoint (2 1 10, 3 4 20)"));
|
||||
wkt.fromWKT("MULTIPOINT (2 1 10, 3 4 20)"));
|
||||
|
||||
assertEquals("multipoint EMPTY", wkt.toWKT(MultiPoint.EMPTY));
|
||||
assertEquals(MultiPoint.EMPTY, wkt.fromWKT("multipoint EMPTY)"));
|
||||
assertEquals("MULTIPOINT EMPTY", wkt.toWKT(MultiPoint.EMPTY));
|
||||
assertEquals(MultiPoint.EMPTY, wkt.fromWKT("MULTIPOINT EMPTY)"));
|
||||
}
|
||||
|
||||
public void testValidation() {
|
||||
|
|
|
@ -44,15 +44,15 @@ public class MultiPolygonTests extends BaseGeometryTestCase<MultiPolygon> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("multipolygon (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))",
|
||||
assertEquals("MULTIPOLYGON (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))",
|
||||
wkt.toWKT(new MultiPolygon(Collections.singletonList(
|
||||
new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}))))));
|
||||
assertEquals(new MultiPolygon(Collections.singletonList(
|
||||
new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1})))),
|
||||
wkt.fromWKT("multipolygon (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))"));
|
||||
wkt.fromWKT("MULTIPOLYGON (((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0)))"));
|
||||
|
||||
assertEquals("multipolygon EMPTY", wkt.toWKT(MultiPolygon.EMPTY));
|
||||
assertEquals(MultiPolygon.EMPTY, wkt.fromWKT("multipolygon EMPTY)"));
|
||||
assertEquals("MULTIPOLYGON EMPTY", wkt.toWKT(MultiPolygon.EMPTY));
|
||||
assertEquals(MultiPolygon.EMPTY, wkt.fromWKT("MULTIPOLYGON EMPTY)"));
|
||||
}
|
||||
|
||||
public void testValidation() {
|
||||
|
|
|
@ -36,14 +36,14 @@ public class PointTests extends BaseGeometryTestCase<Point> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("point (20.0 10.0)", wkt.toWKT(new Point(20, 10)));
|
||||
assertEquals("POINT (20.0 10.0)", wkt.toWKT(new Point(20, 10)));
|
||||
assertEquals(new Point(20, 10), wkt.fromWKT("point (20.0 10.0)"));
|
||||
|
||||
assertEquals("point (20.0 10.0 100.0)", wkt.toWKT(new Point(20, 10, 100)));
|
||||
assertEquals(new Point(20, 10, 100), wkt.fromWKT("point (20.0 10.0 100.0)"));
|
||||
assertEquals("POINT (20.0 10.0 100.0)", wkt.toWKT(new Point(20, 10, 100)));
|
||||
assertEquals(new Point(20, 10, 100), wkt.fromWKT("POINT (20.0 10.0 100.0)"));
|
||||
|
||||
assertEquals("point EMPTY", wkt.toWKT(Point.EMPTY));
|
||||
assertEquals(Point.EMPTY, wkt.fromWKT("point EMPTY)"));
|
||||
assertEquals("POINT EMPTY", wkt.toWKT(Point.EMPTY));
|
||||
assertEquals(Point.EMPTY, wkt.fromWKT("POINT EMPTY)"));
|
||||
}
|
||||
|
||||
public void testInitValidation() {
|
||||
|
|
|
@ -36,27 +36,27 @@ public class PolygonTests extends BaseGeometryTestCase<Polygon> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("polygon ((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0))",
|
||||
assertEquals("POLYGON ((3.0 1.0, 4.0 2.0, 5.0 3.0, 3.0 1.0))",
|
||||
wkt.toWKT(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}))));
|
||||
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1})),
|
||||
wkt.fromWKT("polygon ((3 1, 4 2, 5 3, 3 1))"));
|
||||
wkt.fromWKT("POLYGON ((3 1, 4 2, 5 3, 3 1))"));
|
||||
|
||||
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))",
|
||||
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))",
|
||||
wkt.toWKT(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}, new double[]{5, 4, 3, 5}))));
|
||||
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}, new double[]{5, 4, 3, 5})),
|
||||
wkt.fromWKT("polygon ((3 1 5, 4 2 4, 5 3 3, 3 1 5))"));
|
||||
wkt.fromWKT("POLYGON ((3 1 5, 4 2 4, 5 3 3, 3 1 5))"));
|
||||
|
||||
// Auto closing in coerce mode
|
||||
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1})),
|
||||
wkt.fromWKT("polygon ((3 1, 4 2, 5 3))"));
|
||||
wkt.fromWKT("POLYGON ((3 1, 4 2, 5 3))"));
|
||||
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}, new double[]{5, 4, 3, 5})),
|
||||
wkt.fromWKT("polygon ((3 1 5, 4 2 4, 5 3 3))"));
|
||||
wkt.fromWKT("POLYGON ((3 1 5, 4 2 4, 5 3 3))"));
|
||||
assertEquals(new Polygon(new LinearRing(new double[]{3, 4, 5, 3}, new double[]{1, 2, 3, 1}),
|
||||
Collections.singletonList(new LinearRing(new double[]{0.5, 2.5, 2.0, 0.5}, new double[]{1.5, 1.5, 1.0, 1.5}))),
|
||||
wkt.fromWKT("polygon ((3 1, 4 2, 5 3, 3 1), (0.5 1.5, 2.5 1.5, 2.0 1.0))"));
|
||||
wkt.fromWKT("POLYGON ((3 1, 4 2, 5 3, 3 1), (0.5 1.5, 2.5 1.5, 2.0 1.0))"));
|
||||
|
||||
assertEquals("polygon EMPTY", wkt.toWKT(Polygon.EMPTY));
|
||||
assertEquals(Polygon.EMPTY, wkt.fromWKT("polygon EMPTY)"));
|
||||
assertEquals("POLYGON EMPTY", wkt.toWKT(Polygon.EMPTY));
|
||||
assertEquals(Polygon.EMPTY, wkt.fromWKT("POLYGON EMPTY)"));
|
||||
}
|
||||
|
||||
public void testInitValidation() {
|
||||
|
|
|
@ -37,11 +37,11 @@ public class RectangleTests extends BaseGeometryTestCase<Rectangle> {
|
|||
|
||||
public void testBasicSerialization() throws IOException, ParseException {
|
||||
WellKnownText wkt = new WellKnownText(true, new GeographyValidator(true));
|
||||
assertEquals("bbox (10.0, 20.0, 40.0, 30.0)", wkt.toWKT(new Rectangle(10, 20, 40, 30)));
|
||||
assertEquals(new Rectangle(10, 20, 40, 30), wkt.fromWKT("bbox (10.0, 20.0, 40.0, 30.0)"));
|
||||
assertEquals("BBOX (10.0, 20.0, 40.0, 30.0)", wkt.toWKT(new Rectangle(10, 20, 40, 30)));
|
||||
assertEquals(new Rectangle(10, 20, 40, 30), wkt.fromWKT("BBOX (10.0, 20.0, 40.0, 30.0)"));
|
||||
|
||||
assertEquals("bbox EMPTY", wkt.toWKT(Rectangle.EMPTY));
|
||||
assertEquals(Rectangle.EMPTY, wkt.fromWKT("bbox EMPTY)"));
|
||||
assertEquals("BBOX EMPTY", wkt.toWKT(Rectangle.EMPTY));
|
||||
assertEquals(Rectangle.EMPTY, wkt.fromWKT("BBOX EMPTY)"));
|
||||
}
|
||||
|
||||
public void testInitValidation() {
|
||||
|
|
|
@ -113,7 +113,7 @@ public class GeometryParserTests extends ESTestCase {
|
|||
XContentBuilder newGeoJson = XContentFactory.jsonBuilder().startObject().field("val");
|
||||
format.toXContent(new Point(100, 10), newGeoJson, ToXContent.EMPTY_PARAMS);
|
||||
newGeoJson.endObject();
|
||||
assertEquals("{\"val\":\"point (100.0 10.0)\"}", Strings.toString(newGeoJson));
|
||||
assertEquals("{\"val\":\"POINT (100.0 10.0)\"}", Strings.toString(newGeoJson));
|
||||
}
|
||||
|
||||
// Make sure we can parse values outside the normal lat lon boundaries
|
||||
|
|
|
@ -15,7 +15,7 @@ selectAsWKT
|
|||
SELECT city, ST_AsWKT(location) location FROM "geo" WHERE city = 'Amsterdam';
|
||||
|
||||
city:s | location:s
|
||||
Amsterdam |point (4.850311987102032 52.347556999884546)
|
||||
Amsterdam |POINT (4.850311987102032 52.347556999884546)
|
||||
// end::aswkt
|
||||
;
|
||||
|
||||
|
@ -24,7 +24,7 @@ selectWKTToSQL
|
|||
SELECT CAST(ST_WKTToSQL('POINT (10 20)') AS STRING) location;
|
||||
|
||||
location:s
|
||||
point (10.0 20.0)
|
||||
POINT (10.0 20.0)
|
||||
// end::wkttosql
|
||||
;
|
||||
|
||||
|
|
|
@ -33,21 +33,21 @@ selectAllPointsAsStrings
|
|||
SELECT city, CAST(location AS STRING) location, CAST(location_no_dv AS STRING) location_no_dv, CAST(geoshape AS STRING) geoshape, CAST(shape AS STRING) shape, region FROM "geo" ORDER BY "city";
|
||||
|
||||
city:s | location:s | location_no_dv:s | geoshape:s | shape:s | region:s
|
||||
Amsterdam |point (4.850311987102032 52.347556999884546) |point (4.850312 52.347557) |point (4.850312 52.347557 2.0) |point (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |point (13.390888944268227 52.48670099303126) |point (13.390889 52.486701) |point (13.390889 52.486701 34.0) |point (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |point (-87.63787407428026 41.888782968744636) |point (-87.637874 41.888783) |point (-87.637874 41.888783 181.0) |point (-87.637874 41.888783 181.0) |Americas
|
||||
Hong Kong |point (114.18392493389547 22.28139698971063) |point (114.183925 22.281397) |point (114.183925 22.281397 552.0) |point (114.183925 22.281397 552.0) |Asia
|
||||
London |point (-0.12167204171419144 51.51087098289281)|point (-0.121672 51.510871) |point (-0.121672 51.510871 11.0) |point (-0.121672 51.510871 11.0) |Europe
|
||||
Mountain View |point (-122.08384302444756 37.38648299127817) |point (-122.083843 37.386483) |point (-122.083843 37.386483 30.0) |point (-122.083843 37.386483 30.0) |Americas
|
||||
Munich |point (11.537504978477955 48.14632098656148) |point (11.537505 48.146321) |point (11.537505 48.146321 519.0) |point (11.537505 48.146321 519.0) |Europe
|
||||
New York |point (-73.9900270756334 40.74517097789794) |point (-73.990027 40.745171) |point (-73.990027 40.745171 10.0) |point (-73.990027 40.745171 10.0) |Americas
|
||||
Paris |point (2.3517729341983795 48.84553796611726) |point (2.351773 48.845538) |point (2.351773 48.845538 35.0) |point (2.351773 48.845538 35.0) |Europe
|
||||
Phoenix |point (-111.97350500151515 33.37624196894467) |point (-111.973505 33.376242) |point (-111.973505 33.376242 331.0)|point (-111.973505 33.376242 331.0)|Americas
|
||||
San Francisco |point (-122.39422800019383 37.789540970698) |point (-122.394228 37.789541) |point (-122.394228 37.789541 16.0) |point (-122.394228 37.789541 16.0) |Americas
|
||||
Seoul |point (127.06085099838674 37.50913198571652) |point (127.060851 37.509132) |point (127.060851 37.509132 38.0) |point (127.060851 37.509132 38.0) |Asia
|
||||
Singapore |point (103.8555349688977 1.2958679627627134) |point (103.855535 1.295868) |point (103.855535 1.295868 15.0) |point (103.855535 1.295868 15.0) |Asia
|
||||
Sydney |point (151.20862897485495 -33.863385021686554)|point (151.208629 -33.863385) |point (151.208629 -33.863385 100.0)|point (151.208629 -33.863385 100.0)|Asia
|
||||
Tokyo |point (139.76402222178876 35.66961596254259) |point (139.76402225 35.669616)|point (139.76402225 35.669616 40.0)|point (139.76402225 35.669616 40.0)|Asia
|
||||
Amsterdam |POINT (4.850311987102032 52.347556999884546) |POINT (4.850312 52.347557) |POINT (4.850312 52.347557 2.0) |POINT (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |POINT (13.390888944268227 52.48670099303126) |POINT (13.390889 52.486701) |POINT (13.390889 52.486701 34.0) |POINT (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |POINT (-87.63787407428026 41.888782968744636) |POINT (-87.637874 41.888783) |POINT (-87.637874 41.888783 181.0) |POINT (-87.637874 41.888783 181.0) |Americas
|
||||
Hong Kong |POINT (114.18392493389547 22.28139698971063) |POINT (114.183925 22.281397) |POINT (114.183925 22.281397 552.0) |POINT (114.183925 22.281397 552.0) |Asia
|
||||
London |POINT (-0.12167204171419144 51.51087098289281)|POINT (-0.121672 51.510871) |POINT (-0.121672 51.510871 11.0) |POINT (-0.121672 51.510871 11.0) |Europe
|
||||
Mountain View |POINT (-122.08384302444756 37.38648299127817) |POINT (-122.083843 37.386483) |POINT (-122.083843 37.386483 30.0) |POINT (-122.083843 37.386483 30.0) |Americas
|
||||
Munich |POINT (11.537504978477955 48.14632098656148) |POINT (11.537505 48.146321) |POINT (11.537505 48.146321 519.0) |POINT (11.537505 48.146321 519.0) |Europe
|
||||
New York |POINT (-73.9900270756334 40.74517097789794) |POINT (-73.990027 40.745171) |POINT (-73.990027 40.745171 10.0) |POINT (-73.990027 40.745171 10.0) |Americas
|
||||
Paris |POINT (2.3517729341983795 48.84553796611726) |POINT (2.351773 48.845538) |POINT (2.351773 48.845538 35.0) |POINT (2.351773 48.845538 35.0) |Europe
|
||||
Phoenix |POINT (-111.97350500151515 33.37624196894467) |POINT (-111.973505 33.376242) |POINT (-111.973505 33.376242 331.0)|POINT (-111.973505 33.376242 331.0)|Americas
|
||||
San Francisco |POINT (-122.39422800019383 37.789540970698) |POINT (-122.394228 37.789541) |POINT (-122.394228 37.789541 16.0) |POINT (-122.394228 37.789541 16.0) |Americas
|
||||
Seoul |POINT (127.06085099838674 37.50913198571652) |POINT (127.060851 37.509132) |POINT (127.060851 37.509132 38.0) |POINT (127.060851 37.509132 38.0) |Asia
|
||||
Singapore |POINT (103.8555349688977 1.2958679627627134) |POINT (103.855535 1.295868) |POINT (103.855535 1.295868 15.0) |POINT (103.855535 1.295868 15.0) |Asia
|
||||
Sydney |POINT (151.20862897485495 -33.863385021686554)|POINT (151.208629 -33.863385) |POINT (151.208629 -33.863385 100.0)|POINT (151.208629 -33.863385 100.0)|Asia
|
||||
Tokyo |POINT (139.76402222178876 35.66961596254259) |POINT (139.76402225 35.669616)|POINT (139.76402225 35.669616 40.0)|POINT (139.76402225 35.669616 40.0)|Asia
|
||||
;
|
||||
|
||||
// TODO: Both shape and location contain the same data for now, we should change it later to make things more interesting
|
||||
|
@ -55,28 +55,28 @@ selectAllPointsAsWKT
|
|||
SELECT city, ST_ASWKT(location) location_wkt, ST_ASWKT(geoshape) geoshape_wkt, region FROM "geo" ORDER BY "city";
|
||||
|
||||
city:s | location_wkt:s | geoshape_wkt:s | region:s
|
||||
Amsterdam |point (4.850311987102032 52.347556999884546) |point (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |point (13.390888944268227 52.48670099303126) |point (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |point (-87.63787407428026 41.888782968744636) |point (-87.637874 41.888783 181.0) |Americas
|
||||
Hong Kong |point (114.18392493389547 22.28139698971063) |point (114.183925 22.281397 552.0) |Asia
|
||||
London |point (-0.12167204171419144 51.51087098289281)|point (-0.121672 51.510871 11.0) |Europe
|
||||
Mountain View |point (-122.08384302444756 37.38648299127817) |point (-122.083843 37.386483 30.0) |Americas
|
||||
Munich |point (11.537504978477955 48.14632098656148) |point (11.537505 48.146321 519.0) |Europe
|
||||
New York |point (-73.9900270756334 40.74517097789794) |point (-73.990027 40.745171 10.0) |Americas
|
||||
Paris |point (2.3517729341983795 48.84553796611726) |point (2.351773 48.845538 35.0) |Europe
|
||||
Phoenix |point (-111.97350500151515 33.37624196894467) |point (-111.973505 33.376242 331.0) |Americas
|
||||
San Francisco |point (-122.39422800019383 37.789540970698) |point (-122.394228 37.789541 16.0) |Americas
|
||||
Seoul |point (127.06085099838674 37.50913198571652) |point (127.060851 37.509132 38.0) |Asia
|
||||
Singapore |point (103.8555349688977 1.2958679627627134) |point (103.855535 1.295868 15.0) |Asia
|
||||
Sydney |point (151.20862897485495 -33.863385021686554)|point (151.208629 -33.863385 100.0) |Asia
|
||||
Tokyo |point (139.76402222178876 35.66961596254259) |point (139.76402225 35.669616 40.0) |Asia
|
||||
Amsterdam |POINT (4.850311987102032 52.347556999884546) |POINT (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |POINT (13.390888944268227 52.48670099303126) |POINT (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |POINT (-87.63787407428026 41.888782968744636) |POINT (-87.637874 41.888783 181.0) |Americas
|
||||
Hong Kong |POINT (114.18392493389547 22.28139698971063) |POINT (114.183925 22.281397 552.0) |Asia
|
||||
London |POINT (-0.12167204171419144 51.51087098289281)|POINT (-0.121672 51.510871 11.0) |Europe
|
||||
Mountain View |POINT (-122.08384302444756 37.38648299127817) |POINT (-122.083843 37.386483 30.0) |Americas
|
||||
Munich |POINT (11.537504978477955 48.14632098656148) |POINT (11.537505 48.146321 519.0) |Europe
|
||||
New York |POINT (-73.9900270756334 40.74517097789794) |POINT (-73.990027 40.745171 10.0) |Americas
|
||||
Paris |POINT (2.3517729341983795 48.84553796611726) |POINT (2.351773 48.845538 35.0) |Europe
|
||||
Phoenix |POINT (-111.97350500151515 33.37624196894467) |POINT (-111.973505 33.376242 331.0) |Americas
|
||||
San Francisco |POINT (-122.39422800019383 37.789540970698) |POINT (-122.394228 37.789541 16.0) |Americas
|
||||
Seoul |POINT (127.06085099838674 37.50913198571652) |POINT (127.060851 37.509132 38.0) |Asia
|
||||
Singapore |POINT (103.8555349688977 1.2958679627627134) |POINT (103.855535 1.295868 15.0) |Asia
|
||||
Sydney |POINT (151.20862897485495 -33.863385021686554)|POINT (151.208629 -33.863385 100.0) |Asia
|
||||
Tokyo |POINT (139.76402222178876 35.66961596254259) |POINT (139.76402225 35.669616 40.0) |Asia
|
||||
;
|
||||
|
||||
selectWithAsWKTInWhere
|
||||
SELECT city, ST_ASWKT(location) location_wkt, region FROM "geo" WHERE LOCATE('114', ST_ASWKT(location)) > 0 ORDER BY "city";
|
||||
|
||||
city:s | location_wkt:s | region:s
|
||||
Hong Kong |point (114.18392493389547 22.28139698971063)|Asia
|
||||
Hong Kong |POINT (114.18392493389547 22.28139698971063)|Asia
|
||||
;
|
||||
|
||||
selectAllPointsOrderByLonFromAsWKT
|
||||
|
@ -112,30 +112,30 @@ selectRegionUsingWktToSql
|
|||
SELECT region, city, ST_ASWKT(ST_WKTTOSQL(region_point)) region_wkt FROM geo ORDER BY region, city;
|
||||
|
||||
region:s | city:s | region_wkt:s
|
||||
Americas |Chicago |point (-105.2551 54.526)
|
||||
Americas |Mountain View |point (-105.2551 54.526)
|
||||
Americas |New York |point (-105.2551 54.526)
|
||||
Americas |Phoenix |point (-105.2551 54.526)
|
||||
Americas |San Francisco |point (-105.2551 54.526)
|
||||
Asia |Hong Kong |point (100.6197 34.0479)
|
||||
Asia |Seoul |point (100.6197 34.0479)
|
||||
Asia |Singapore |point (100.6197 34.0479)
|
||||
Asia |Sydney |point (100.6197 34.0479)
|
||||
Asia |Tokyo |point (100.6197 34.0479)
|
||||
Europe |Amsterdam |point (15.2551 54.526)
|
||||
Europe |Berlin |point (15.2551 54.526)
|
||||
Europe |London |point (15.2551 54.526)
|
||||
Europe |Munich |point (15.2551 54.526)
|
||||
Europe |Paris |point (15.2551 54.526)
|
||||
Americas |Chicago |POINT (-105.2551 54.526)
|
||||
Americas |Mountain View |POINT (-105.2551 54.526)
|
||||
Americas |New York |POINT (-105.2551 54.526)
|
||||
Americas |Phoenix |POINT (-105.2551 54.526)
|
||||
Americas |San Francisco |POINT (-105.2551 54.526)
|
||||
Asia |Hong Kong |POINT (100.6197 34.0479)
|
||||
Asia |Seoul |POINT (100.6197 34.0479)
|
||||
Asia |Singapore |POINT (100.6197 34.0479)
|
||||
Asia |Sydney |POINT (100.6197 34.0479)
|
||||
Asia |Tokyo |POINT (100.6197 34.0479)
|
||||
Europe |Amsterdam |POINT (15.2551 54.526)
|
||||
Europe |Berlin |POINT (15.2551 54.526)
|
||||
Europe |London |POINT (15.2551 54.526)
|
||||
Europe |Munich |POINT (15.2551 54.526)
|
||||
Europe |Paris |POINT (15.2551 54.526)
|
||||
;
|
||||
|
||||
selectCitiesWithAGroupByWktToSql
|
||||
SELECT COUNT(city) city_by_region, CAST(ST_WKTTOSQL(region_point) AS STRING) region FROM geo WHERE city LIKE '%a%' GROUP BY ST_WKTTOSQL(region_point) ORDER BY ST_WKTTOSQL(region_point);
|
||||
|
||||
city_by_region:l | region:s
|
||||
3 |point (-105.2551 54.526)
|
||||
1 |point (100.6197 34.0479)
|
||||
2 |point (15.2551 54.526)
|
||||
3 |POINT (-105.2551 54.526)
|
||||
1 |POINT (100.6197 34.0479)
|
||||
2 |POINT (15.2551 54.526)
|
||||
;
|
||||
|
||||
selectCitiesWithEOrderByWktToSql
|
||||
|
|
|
@ -33,8 +33,8 @@ public class GeoProcessorTests extends AbstractWireSerializingTestCase<GeoProces
|
|||
}
|
||||
|
||||
public void testApplyAsWKT() throws Exception {
|
||||
assertEquals("point (10.0 20.0)", new GeoProcessor(GeoOperation.ASWKT).process(new GeoShape(10, 20)));
|
||||
assertEquals("point (10.0 20.0)", new GeoProcessor(GeoOperation.ASWKT).process(new GeoShape("POINT (10 20)")));
|
||||
assertEquals("POINT (10.0 20.0)", new GeoProcessor(GeoOperation.ASWKT).process(new GeoShape(10, 20)));
|
||||
assertEquals("POINT (10.0 20.0)", new GeoProcessor(GeoOperation.ASWKT).process(new GeoShape("POINT (10 20)")));
|
||||
}
|
||||
|
||||
public void testApplyGeometryType() throws Exception {
|
||||
|
|
|
@ -21,7 +21,7 @@ public class StWkttosqlProcessorTests extends ESTestCase {
|
|||
Object result = proc.process("POINT (10 20)");
|
||||
assertThat(result, instanceOf(GeoShape.class));
|
||||
GeoShape geoShape = (GeoShape) result;
|
||||
assertEquals("point (10.0 20.0)", geoShape.toString());
|
||||
assertEquals("POINT (10.0 20.0)", geoShape.toString());
|
||||
}
|
||||
|
||||
public void testTypeCheck() {
|
||||
|
@ -46,6 +46,6 @@ public class StWkttosqlProcessorTests extends ESTestCase {
|
|||
Object result = proc.process("POLYGON ((3 1 5, 4 2 4, 5 3 3))");
|
||||
assertThat(result, instanceOf(GeoShape.class));
|
||||
GeoShape geoShape = (GeoShape) result;
|
||||
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))", geoShape.toString());
|
||||
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))", geoShape.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ public class QueryTranslatorTests extends ESTestCase {
|
|||
assertEquals(operator.equals("=") || operator.equals("!=") || operator.equals(">="), rq.includeLower());
|
||||
assertEquals(pattern, rq.format());
|
||||
}
|
||||
|
||||
|
||||
private void testDateRangeWithCurrentFunctions_AndRangeOptimization(String function, String pattern, ZonedDateTime lowerValue,
|
||||
ZonedDateTime upperValue) {
|
||||
String lowerOperator = randomFrom(new String[] {"<", "<="});
|
||||
|
@ -324,7 +324,7 @@ public class QueryTranslatorTests extends ESTestCase {
|
|||
assertEquals(1, eqe.output().size());
|
||||
assertEquals("test.some.string", eqe.output().get(0).qualifiedName());
|
||||
assertEquals(DataType.TEXT, eqe.output().get(0).dataType());
|
||||
|
||||
|
||||
Query query = eqe.queryContainer().query();
|
||||
// the range queries optimization should create a single "range" query with "from" and "to" populated with the values
|
||||
// in the two branches of the AND condition
|
||||
|
@ -820,7 +820,7 @@ public class QueryTranslatorTests extends ESTestCase {
|
|||
"InternalSqlScriptUtils.eq(InternalSqlScriptUtils.stWktToSql(" +
|
||||
"InternalSqlScriptUtils.docValue(doc,params.v0)),InternalSqlScriptUtils.stWktToSql(params.v1)))",
|
||||
aggFilter.scriptTemplate().toString());
|
||||
assertEquals("[{v=keyword}, {v=point (10.0 20.0)}]", aggFilter.scriptTemplate().params().toString());
|
||||
assertEquals("[{v=keyword}, {v=POINT (10.0 20.0)}]", aggFilter.scriptTemplate().params().toString());
|
||||
}
|
||||
|
||||
public void testTranslateStDistanceToScript() {
|
||||
|
@ -840,7 +840,7 @@ public class QueryTranslatorTests extends ESTestCase {
|
|||
"InternalSqlScriptUtils.stDistance(" +
|
||||
"InternalSqlScriptUtils.geoDocValue(doc,params.v0),InternalSqlScriptUtils.stWktToSql(params.v1)),params.v2))",
|
||||
sc.script().toString());
|
||||
assertEquals("[{v=point}, {v=point (10.0 20.0)}, {v=20}]", sc.script().params().toString());
|
||||
assertEquals("[{v=point}, {v=POINT (10.0 20.0)}, {v=20}]", sc.script().params().toString());
|
||||
}
|
||||
|
||||
public void testTranslateStDistanceToQuery() {
|
||||
|
|
Loading…
Reference in New Issue