From 1ea4cee8f08b61524c18bdfa71631c800e95b974 Mon Sep 17 00:00:00 2001
From: Martin Desruisseaux
- * A shared fixture should be used with caution in order to avoid undesirable
- * test interactions. In general, it should be populated with "read-only"
- * objects that are not modified during the test run.
- *
* Sources *
@@ -90,7 +92,7 @@ public void findCurves() { /** * [{@code Test}] Verifies that a gml:Curve element has a valid CRS * reference. - * + * ** Sources *
@@ -115,7 +117,7 @@ public void curveHasValidCRS() { ** Sources *
@@ -127,8 +129,7 @@ public void curveHasValidCRS() { public void validCurveSegments() { Unmarshaller gmlUnmarshaller; try { - MarshallerPool pool = new MarshallerPool( - "org.geotoolkit.gml.xml.v321"); + MarshallerPool pool = GMLMarshallerPool.getInstance(); gmlUnmarshaller = pool.acquireUnmarshaller(); } catch (JAXBException jxe) { throw new RuntimeException(jxe); diff --git a/src/main/java/org/opengis/cite/iso19136/data/spatial/EnvelopeTests.java b/src/main/java/org/opengis/cite/iso19136/data/spatial/EnvelopeTests.java index eb92587..86f4828 100644 --- a/src/main/java/org/opengis/cite/iso19136/data/spatial/EnvelopeTests.java +++ b/src/main/java/org/opengis/cite/iso19136/data/spatial/EnvelopeTests.java @@ -3,19 +3,21 @@ import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; import javax.xml.namespace.QName; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamReader; -import org.geotoolkit.geometry.GeneralEnvelope; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Unmarshaller; + +import org.apache.sis.geometry.GeneralEnvelope; +import org.apache.sis.referencing.CRS; +import org.apache.sis.xml.MarshallerPool; import org.geotoolkit.gml.xml.v321.EnvelopeType; -import org.geotoolkit.referencing.CRS; -import org.geotoolkit.xml.MarshallerPool; +import org.geotoolkit.gml.xml.GMLMarshallerPool; + import org.opengis.cite.geomatics.GeodesyUtils; import org.opengis.cite.iso19136.GML32; import org.opengis.cite.iso19136.data.DataFixture; @@ -30,14 +32,14 @@ /** * Validates the content of a gml:Envelope element, which implements the * GM_Envelope class from ISO 19107. - * + * ** The "lowerCorner" represents a coordinate position consisting of all the * minimal ordinates for each dimension for all points within the envelope. The * "upperCorner" is a coordinate position consisting of all the maximal * ordinates for each dimension for all points within the envelope. *
- * + * ** Sources *
@@ -63,8 +65,7 @@ public void findEnvelopes() { this.envelopes = new ArrayList* The value of the srsName attribute must be an absolute URI, but it need * not be dereferenceable for well-known CRS identifiers. The 'urn' or @@ -134,13 +135,13 @@ public void findEnvelopes() { *
* Note: Since gml:Envelope is not a geometry object, the * CRS reference cannot be inherited from some larger spatial context * according to ISO 19136, cl. 9.10. *
- * + * * @see OGC 09-048r3 */ @@ -165,7 +166,7 @@ public void envelopeHasValidCRS() { * coordinates of the upper corner, where the coordinate tuples are compared * item by item. Furthermore, the dimension of the corner positions must be * identical and equal to that of the CRS. - * + * * @see "ISO 19107: cl. 6.4.3.2, 6.4.3.3" */ @Test(description = "See ISO 19107: 6.4.3.2, 6.4.3.3") diff --git a/src/main/java/org/opengis/cite/iso19136/data/spatial/GeometryAssert.java b/src/main/java/org/opengis/cite/iso19136/data/spatial/GeometryAssert.java index 9aa8fc5..7859e84 100644 --- a/src/main/java/org/opengis/cite/iso19136/data/spatial/GeometryAssert.java +++ b/src/main/java/org/opengis/cite/iso19136/data/spatial/GeometryAssert.java @@ -5,23 +5,31 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; -import org.geotoolkit.geometry.Envelopes; -import org.geotoolkit.geometry.jts.JTS; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Unmarshaller; + +import org.apache.sis.referencing.CRS; +import org.apache.sis.xml.MarshallerPool; import org.geotoolkit.gml.xml.AbstractRing; import org.geotoolkit.gml.xml.v321.AbstractCurveSegmentType; import org.geotoolkit.gml.xml.v321.AbstractCurveType; import org.geotoolkit.gml.xml.v321.AbstractGeometryType; import org.geotoolkit.gml.xml.v321.AbstractSurfaceType; import org.geotoolkit.gml.xml.v321.CurveType; -import org.geotoolkit.referencing.CRS; -import org.geotoolkit.xml.MarshallerPool; +import org.geotoolkit.gml.xml.GMLMarshallerPool; + +import org.locationtech.jts.algorithm.CGAlgorithms; +import org.locationtech.jts.geom.Coordinate; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.GeometryCollection; +import org.locationtech.jts.geom.GeometryFactory; +import org.locationtech.jts.geom.LineString; +import org.locationtech.jts.geom.Polygon; + import org.opengis.cite.geomatics.Extents; import org.opengis.cite.geomatics.GeodesyUtils; import org.opengis.cite.geomatics.gml.CurveCoordinateListFactory; @@ -35,21 +43,11 @@ import org.opengis.cite.iso19136.util.XMLUtils; import org.opengis.geometry.Envelope; import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; import org.opengis.util.FactoryException; import org.testng.Assert; import org.w3c.dom.Element; import org.w3c.dom.NodeList; -import com.vividsolutions.jts.algorithm.CGAlgorithms; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryCollection; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.LineString; -import com.vividsolutions.jts.geom.Polygon; - /** * Provides specialized assertion methods that apply to representations of * geometry objects. @@ -62,7 +60,7 @@ public class GeometryAssert { private static Unmarshaller initGmlUnmarshaller() { Unmarshaller unmarshaller = null; try { - MarshallerPool pool = new MarshallerPool("org.geotoolkit.gml.xml.v321"); + MarshallerPool pool = GMLMarshallerPool.getInstance(); unmarshaller = pool.acquireUnmarshaller(); } catch (JAXBException je) { throw new RuntimeException(je); @@ -79,11 +77,11 @@ private GeometryAssert() { * a "well-known" CRS definition or refers to a CRS definition. The * reference may be inherited from a containing geometry (aggregate) or * feature envelope. - * + * * @param geom * A DOM Element node representing a GML geometry element (or an * element that can be substituted for one). - * + * * @see "ISO 19136: cl. 9.10, 10.1.3.2" */ public static void assertValidCRS(Element geom) { @@ -103,11 +101,11 @@ public static void assertValidCRS(Element geom) { /** * Asserts that the given geometry element is covered by the valid area of * its associated CRS. - * + * ** WARNING: May be problematic for 3D coordinates. *
- * + * * @param gmlGeom * A GML geometry element. */ @@ -117,7 +115,7 @@ public static void assertGeometryCoveredByValidArea(AbstractGeometryType gmlGeom gmlGeom.getClass().getSimpleName(), gmlGeom.getId())); // Geotk v3 does not recognize 'http' CRS identifiers gmlGeom.setSrsName(GeodesyUtils.convertSRSNameToURN(srsName)); - Envelope crsDomain = Envelopes.getDomainOfValidity(gmlGeom.getCoordinateReferenceSystem()); + Envelope crsDomain = CRS.getDomainOfValidity(gmlGeom.getCoordinateReferenceSystem(false)); Polygon validArea = Extents.envelopeAsPolygon(crsDomain); Geometry geom = GmlUtils.computeConvexHull(gmlGeom); if (geom.getClass().equals(GeometryCollection.class)) { @@ -132,13 +130,13 @@ public static void assertGeometryCoveredByValidArea(AbstractGeometryType gmlGeom * Asserts that the number of direct positions in the posList element * appearing within each segment of the given curve geometry satisfies the * minimum length requirements. - * + * * The number of entries in a posList element is equal to the product of the * dimensionality of the CRS and the number of direct positions. An * additional check ensures that the number of entries is consistent with * the CRS even if the minimum length constraint is satisfied; that is, *size(posList) % dimCRS = 0
.
- *
+ *
* @param gmlCurve
* An Element node representing a GML curve geometry (gml:Curve
* or gml:LineString)
@@ -158,7 +156,7 @@ public static void assertAllCurveSegmentsHaveRequiredLength(Element gmlCurve) {
// Geotk v3 does not recognize 'http' CRS identifiers
srsName = GeodesyUtils.convertSRSNameToURN(srsName);
try {
- CoordinateReferenceSystem crs = CRS.decode(srsName);
+ CoordinateReferenceSystem crs = CRS.forCode(srsName);
crsDim = crs.getCoordinateSystem().getDimension();
} catch (FactoryException fe) {
TestSuiteLogger.log(Level.WARNING, srsName, fe);
@@ -182,7 +180,7 @@ public static void assertAllCurveSegmentsHaveRequiredLength(Element gmlCurve) {
* Asserts that all segments of a curve are connected; that is, the end
* point of each segment (except the last) is identical to the start point
* of the next segment.
- *
+ *
* @param gmlCurve
* An Element node representing a gml:Curve element.
*/
@@ -210,7 +208,7 @@ public static void assertCurveSegmentsAreConnected(Element gmlCurve) {
for (int i = 0; i < segmentList.size(); i++) {
AbstractCurveSegmentType segment = segmentList.get(i);
CurveSegmentType segmentType = CurveCoordinateListFactory.segmentTypeMap.get(segment.getClass().getName());
- List* Sources *
@@ -86,7 +88,7 @@ public void findLineStrings() { /** * [{@code Test}] Verifies that a gml:LineString element has a valid CRS * reference. - * + * ** Sources *
@@ -106,7 +108,7 @@ public void lineHasValidCRS() { /** * [{@code Test}] Verifies that a gml:LineString element contains at least * two coordinate tuples and that it lies within the valid area of the CRS. - * + * ** Sources *
@@ -118,8 +120,7 @@ public void lineHasValidCRS() { public void validLineString() { Unmarshaller gmlUnmarshaller; try { - MarshallerPool pool = new MarshallerPool( - "org.geotoolkit.gml.xml.v321"); + MarshallerPool pool = GMLMarshallerPool.getInstance(); gmlUnmarshaller = pool.acquireUnmarshaller(); } catch (JAXBException jxe) { throw new RuntimeException(jxe); diff --git a/src/main/java/org/opengis/cite/iso19136/data/spatial/PointTests.java b/src/main/java/org/opengis/cite/iso19136/data/spatial/PointTests.java index ccdda82..71986c3 100644 --- a/src/main/java/org/opengis/cite/iso19136/data/spatial/PointTests.java +++ b/src/main/java/org/opengis/cite/iso19136/data/spatial/PointTests.java @@ -13,10 +13,10 @@ import javax.xml.xpath.XPathExpressionException; import org.apache.xerces.xs.XSElementDeclaration; -import org.geotoolkit.geometry.Envelopes; -import org.geotoolkit.geometry.GeneralDirectPosition; -import org.geotoolkit.geometry.ImmutableEnvelope; -import org.geotoolkit.referencing.CRS; +import org.apache.sis.geometry.GeneralDirectPosition; +import org.apache.sis.geometry.ImmutableEnvelope; +import org.apache.sis.referencing.CRS; + import org.opengis.cite.geomatics.GeodesyUtils; import org.opengis.cite.geomatics.gml.GmlUtils; import org.opengis.cite.iso19136.ErrorMessage; @@ -39,7 +39,7 @@ * Validates the content of a gml:Point element (or any element in its * substitution group), which implements the GM_Point class from ISO 19107. A * point is defined by a single coordinate tuple. - * + * ** Sources *
@@ -88,7 +88,7 @@ public void findPoints() { /** * [{@code Test}] Verifies that a gml:Point element has a valid CRS * reference. - * + * ** Sources *
@@ -112,13 +112,13 @@ public void pointHasValidCRS() { ** Note that the last constraint will detect obvious cases where the axis * order is incorrect (e.g. a position expressed in EPSG 4326 as -122.22, * 50.55). *
- * + * ** Sources *
@@ -150,7 +150,7 @@ public void pointHasValidPosition() { point.getAttributeNS(GML32.NS_NAME, "id"), GmlUtils.findCRSReference(point))); ImmutableEnvelope validArea = new ImmutableEnvelope( - Envelopes.getDomainOfValidity(dpos + CRS.getDomainOfValidity(dpos .getCoordinateReferenceSystem())); Assert.assertTrue(validArea.contains(dpos), String.format( "%s[@gml:id='%s'] is not within CRS area of use: %s.", @@ -164,12 +164,12 @@ public void pointHasValidPosition() { * Creates a DirectPosition object from a gml:Point element. It will have * the same CRS as the given point; the reference system may be inherited * from a containing geometry (aggregate) or feature. - * + * * @param point * A gml:Point element (or an element in its substitution group). * @param ignoreThirdDimension - * If this flag is true then it will ignore third dimension - * else it will include all dimension. + * If this flag is true then it will ignore third dimension + * else it will include all dimension. * @throws IndexOutOfBoundsException * If the length of the coordinate tuple exceeds the dimension * of the associated CRS. @@ -185,10 +185,10 @@ DirectPosition createDirectPosition(Element point, boolean ignoreThirdDimension) String srsName = GmlUtils.findCRSReference(point); CoordinateReferenceSystem crs = null; try { - crs = CRS.decode(GeodesyUtils.getAbbreviatedCRSIdentifier(srsName)); + crs = CRS.forCode(GeodesyUtils.getAbbreviatedCRSIdentifier(srsName)); // The only Projected CRS is returned if third dimension is ignored. if (ignoreThirdDimension) { - crs = CRS.getHorizontalCRS(crs); + crs = CRS.getHorizontalComponent(crs); } } catch (FactoryException fex) { TestSuiteLogger.log(Level.WARNING, String.format( diff --git a/src/main/resources/org/opengis/cite/iso19136/testng.xml b/src/main/resources/org/opengis/cite/iso19136/testng.xml index 5c70f6f..f08e485 100644 --- a/src/main/resources/org/opengis/cite/iso19136/testng.xml +++ b/src/main/resources/org/opengis/cite/iso19136/testng.xml @@ -4,7 +4,6 @@