Skip to content

Commit

Permalink
Merge pull request #1489 from guadaltel/issue-1480
Browse files Browse the repository at this point in the history
Improved tests for GMLGeometryValidator handling left- and right-handed CRS
  • Loading branch information
stephanr authored Aug 23, 2023
2 parents e353425 + 52ab14c commit 15b0a97
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,51 @@ public void validatePolygonExteriorClockwise()
Assert.assertTrue( ( (InteriorRingOrientation) ( eventHandler.getEvents().get( 1 ).getEvent() ) ).isClockwise() );
Assert.assertTrue( ( (InteriorRingOrientation) ( eventHandler.getEvents().get( 2 ).getEvent() ) ).isClockwise() );
}

@Test
public void validateLeftHandRightHandClockwiseOrientation()
throws XMLStreamException, UnknownCRSException, FactoryConfigurationError, IOException {
TestEventHandler eventHandler = validate( "invalid/LeftHanded_exterior_clockwise_interior_clockwise.gml" );
assertEquals( 2, eventHandler.getEvents().size() );
Assert.assertTrue( ( (ExteriorRingOrientation) ( eventHandler.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertFalse( ( (InteriorRingOrientation) ( eventHandler.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler2 = validate( "invalid/LeftHanded_exterior_clockwise_interior_anticlockwise.gml" );
assertEquals( 2, eventHandler2.getEvents().size() );
Assert.assertTrue( ( (ExteriorRingOrientation) ( eventHandler2.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertTrue( ( (InteriorRingOrientation) ( eventHandler2.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler3 = validate( "invalid/LeftHanded_exterior_anticlockwise_interior_clockwise.gml" );
assertEquals( 2, eventHandler3.getEvents().size() );
Assert.assertFalse( ( (ExteriorRingOrientation) ( eventHandler3.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertFalse( ( (InteriorRingOrientation) ( eventHandler3.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler4 = validate( "invalid/LeftHanded_exterior_anticlockwise_interior_anticlockwise.gml" );
assertEquals( 2, eventHandler4.getEvents().size() );
Assert.assertFalse( ( (ExteriorRingOrientation) ( eventHandler4.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertTrue( ( (InteriorRingOrientation) ( eventHandler4.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler5 = validate( "invalid/RightHanded_exterior_clockwise_interior_clockwise.gml" );
assertEquals( 2, eventHandler5.getEvents().size() );
Assert.assertFalse( ( (ExteriorRingOrientation) ( eventHandler5.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertTrue( ( (InteriorRingOrientation) ( eventHandler5.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler6 = validate( "invalid/RightHanded_exterior_clockwise_interior_anticlockwise.gml" );
assertEquals( 2, eventHandler6.getEvents().size() );
Assert.assertFalse( ( (ExteriorRingOrientation) ( eventHandler6.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertFalse( ( (InteriorRingOrientation) ( eventHandler6.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler7 = validate( "invalid/RightHanded_exterior_anticlockwise_interior_clockwise.gml" );
assertEquals( 2, eventHandler7.getEvents().size() );
Assert.assertTrue( ( (ExteriorRingOrientation) ( eventHandler7.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertTrue( ( (InteriorRingOrientation) ( eventHandler7.getEvents().get( 1 ).getEvent() ) ).isInterior() );

TestEventHandler eventHandler8 = validate( "invalid/RightHanded_exterior_anticlockwise_interior_anticlockwise.gml" );
assertEquals( 2, eventHandler8.getEvents().size() );
Assert.assertTrue( ( (ExteriorRingOrientation) ( eventHandler8.getEvents().get( 0 ).getEvent() ) ).isExterior() );
Assert.assertFalse( ( (InteriorRingOrientation) ( eventHandler8.getEvents().get( 1 ).getEvent() ) ).isInterior() );

}

private TestEventHandler validate( String resourceName )
throws XMLStreamException, UnknownCRSException, FactoryConfigurationError, IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/4258" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570111 2886900 4570122 2886900 4570122 2886911 4570122 2886922 4570111 2886922 4570100 2886922 4570100 2886911 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570111 2886910 4570112 2886910 4570112 2886911 4570112 2886912 4570111 2886912 4570110 2886912 4570110 2886911 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/4258" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570111 2886900 4570122 2886900 4570122 2886911 4570122 2886922 4570111 2886922 4570100 2886922 4570100 2886911 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570110 2886911 4570110 2886912 4570111 2886912 4570112 2886912 4570112 2886911 4570112 2886910 4570111 2886910 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/4258" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570100 2886911 4570100 2886922 4570111 2886922 4570122 2886922 4570122 2886911 4570122 2886900 4570111 2886900 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570111 2886910 4570112 2886910 4570112 2886911 4570112 2886912 4570111 2886912 4570110 2886912 4570110 2886911 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/4258" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570100 2886911 4570100 2886922 4570111 2886922 4570122 2886922 4570122 2886911 4570122 2886900 4570111 2886900 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570110 2886911 4570110 2886912 4570111 2886912 4570112 2886912 4570112 2886911 4570112 2886910 4570111 2886910 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/25830" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570111 2886900 4570122 2886900 4570122 2886911 4570122 2886922 4570111 2886922 4570100 2886922 4570100 2886911 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570111 2886910 4570112 2886910 4570112 2886911 4570112 2886912 4570111 2886912 4570110 2886912 4570110 2886911 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/25830" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570111 2886900 4570122 2886900 4570122 2886911 4570122 2886922 4570111 2886922 4570100 2886922 4570100 2886911 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570110 2886911 4570110 2886912 4570111 2886912 4570112 2886912 4570112 2886911 4570112 2886910 4570111 2886910 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/25830" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570100 2886911 4570100 2886922 4570111 2886922 4570122 2886922 4570122 2886911 4570122 2886900 4570111 2886900 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570111 2886910 4570112 2886910 4570112 2886911 4570112 2886912 4570111 2886912 4570110 2886912 4570110 2886911 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Polygon xmlns="http://www.opengis.net/gml" xmlns:gml="http://www.opengis.net/gml" srsName="http://www.opengis.net/def/crs/EPSG/0/25830" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd">
<exterior>
<LinearRing>
<posList>4570100 2886900 4570100 2886911 4570100 2886922 4570111 2886922 4570122 2886922 4570122 2886911 4570122 2886900 4570111 2886900 4570100 2886900</posList>
</LinearRing>
</exterior>
<interior>
<LinearRing>
<posList>4570110 2886910 4570110 2886911 4570110 2886912 4570111 2886912 4570112 2886912 4570112 2886911 4570112 2886910 4570111 2886910 4570110 2886910</posList>
</LinearRing>
</interior>
</Polygon>

0 comments on commit 15b0a97

Please sign in to comment.