|
|
@@ -210,8 +210,8 @@ public class GeoJSONShapeParserTests extends ElasticsearchTestCase {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testParse_polygonNoHolesOGCCompliance() throws IOException {
|
|
|
- // test ccw poly (large poly intended to not cross dateline)
|
|
|
+ public void testParse_OGCPolygonWithoutHoles() throws IOException {
|
|
|
+ // test ccw poly not crossing dateline
|
|
|
String polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon")
|
|
|
.startArray("coordinates")
|
|
|
.startArray()
|
|
|
@@ -228,8 +228,10 @@ public class GeoJSONShapeParserTests extends ElasticsearchTestCase {
|
|
|
XContentParser parser = JsonXContent.jsonXContent.createParser(polygonGeoJson);
|
|
|
parser.nextToken();
|
|
|
Shape shape = ShapeBuilder.parse(parser).build();
|
|
|
+
|
|
|
+ ElasticsearchGeoAssertions.assertPolygon(shape);
|
|
|
|
|
|
- // test cw poly (small poly expected to cross dateline)
|
|
|
+ // test ccw poly crossing dateline
|
|
|
polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon")
|
|
|
.startArray("coordinates")
|
|
|
.startArray()
|
|
|
@@ -246,13 +248,65 @@ public class GeoJSONShapeParserTests extends ElasticsearchTestCase {
|
|
|
parser = JsonXContent.jsonXContent.createParser(polygonGeoJson);
|
|
|
parser.nextToken();
|
|
|
shape = ShapeBuilder.parse(parser).build();
|
|
|
+
|
|
|
+ ElasticsearchGeoAssertions.assertMultiPolygon(shape);
|
|
|
}
|
|
|
|
|
|
-// @Test
|
|
|
-// public void testParse_polygonWithHolesWKTReorder() throws IOException {
|
|
|
-//
|
|
|
-// }
|
|
|
+ @Test
|
|
|
+ public void testParse_OGCPolygonWithHoles() throws IOException {
|
|
|
+ // test ccw poly not crossing dateline
|
|
|
+ String polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon")
|
|
|
+ .startArray("coordinates")
|
|
|
+ .startArray()
|
|
|
+ .startArray().value(176.0).value(15.0).endArray()
|
|
|
+ .startArray().value(-177.0).value(10.0).endArray()
|
|
|
+ .startArray().value(-177.0).value(-10.0).endArray()
|
|
|
+ .startArray().value(176.0).value(-15.0).endArray()
|
|
|
+ .startArray().value(172.0).value(0.0).endArray()
|
|
|
+ .startArray().value(176.0).value(15.0).endArray()
|
|
|
+ .endArray()
|
|
|
+ .startArray()
|
|
|
+ .startArray().value(-172.0).value(8.0).endArray()
|
|
|
+ .startArray().value(174.0).value(10.0).endArray()
|
|
|
+ .startArray().value(-172.0).value(-8.0).endArray()
|
|
|
+ .startArray().value(-172.0).value(8.0).endArray()
|
|
|
+ .endArray()
|
|
|
+ .endArray()
|
|
|
+ .endObject().string();
|
|
|
+
|
|
|
+ XContentParser parser = JsonXContent.jsonXContent.createParser(polygonGeoJson);
|
|
|
+ parser.nextToken();
|
|
|
+ Shape shape = ShapeBuilder.parse(parser).build();
|
|
|
+
|
|
|
+ ElasticsearchGeoAssertions.assertPolygon(shape);
|
|
|
|
|
|
+ // test ccw poly crossing dateline
|
|
|
+ polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon")
|
|
|
+ .startArray("coordinates")
|
|
|
+ .startArray()
|
|
|
+ .startArray().value(-177.0).value(10.0).endArray()
|
|
|
+ .startArray().value(176.0).value(15.0).endArray()
|
|
|
+ .startArray().value(172.0).value(0.0).endArray()
|
|
|
+ .startArray().value(176.0).value(-15.0).endArray()
|
|
|
+ .startArray().value(-177.0).value(-10.0).endArray()
|
|
|
+ .startArray().value(-177.0).value(10.0).endArray()
|
|
|
+ .endArray()
|
|
|
+ .startArray()
|
|
|
+ .startArray().value(178.0).value(8.0).endArray()
|
|
|
+ .startArray().value(-178.0).value(8.0).endArray()
|
|
|
+ .startArray().value(-180.0).value(-8.0).endArray()
|
|
|
+ .startArray().value(178.0).value(8.0).endArray()
|
|
|
+ .endArray()
|
|
|
+ .endArray()
|
|
|
+ .endObject().string();
|
|
|
+
|
|
|
+ parser = JsonXContent.jsonXContent.createParser(polygonGeoJson);
|
|
|
+ parser.nextToken();
|
|
|
+ shape = ShapeBuilder.parse(parser).build();
|
|
|
+
|
|
|
+ ElasticsearchGeoAssertions.assertMultiPolygon(shape);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testParse_invalidPolygon() throws IOException {
|
|
|
/**
|