Author: desruisseaux Date: Mon Jan 6 05:19:30 2014 New Revision: 1555662 URL: http://svn.apache.org/r1555662 Log: Added tests for DefaultGeodeticCRS. Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java (with props) sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml (with props) Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java?rev=1555662&r1=1555661&r2=1555662&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java [UTF-8] Mon Jan 6 05:19:30 2014 @@ -26,11 +26,13 @@ import org.opengis.referencing.datum.Ell import org.opengis.referencing.datum.PrimeMeridian; import org.opengis.referencing.datum.GeodeticDatum; import org.opengis.referencing.datum.VerticalDatum; +import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.cs.CoordinateSystemAxis; import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.cs.CartesianCS; import org.opengis.referencing.cs.EllipsoidalCS; import org.opengis.referencing.cs.RangeMeaning; +import org.opengis.referencing.crs.GeodeticCRS; import static org.apache.sis.test.Assert.*; @@ -211,6 +213,37 @@ public final strictfp class GeodeticObje } /** + * Asserts that the given CRS is the WGS 84 one. + * This method verifies the following properties: + * + * + * + * + * + * + * + * + * + * + * + *
Property Expected value
{@linkplain ReferenceIdentifier#getCode() Code} of the {@linkplain GeodeticCRS#getName() name}{@code "WGS 84"}
{@linkplain GeodeticCRS#getDomainOfValidity() Domain of validity}{@linkplain #assertIsWorld(GeographicBoundingBox) Is world} or absent
{@linkplain GeodeticCRS#getDatum() Datum}{@linkplain #assertIsWGS84(GeodeticDatum, boolean) Is WGS84}
{@linkplain GeodeticCRS#getCoordinateSystem() Coordinate system}{@linkplain #assertIsGeodetic2D(EllipsoidalCS, boolean) Is for a 2D geodetic CRS}
+ * + * @param crs The coordinate reference system to verify. + * @param isExtentMandatory {@code true} if the CRS and datum domains of validity are required to contain an + * {@code Extent} element for the world, or {@code false} if optional. + * @param isRangeMandatory {@code true} if the coordinate system axes range and range meaning properties + * shall be defined, or {@code false} if they are optional. + */ + public static void assertIsWGS84(final GeodeticCRS crs, final boolean isExtentMandatory, final boolean isRangeMandatory) { + assertEquals("name", "WGS 84", crs.getName().getCode()); + assertIsWorld(crs.getDomainOfValidity(), isExtentMandatory); + assertIsWGS84(crs.getDatum(), isExtentMandatory); + final CoordinateSystem cs = crs.getCoordinateSystem(); + assertInstanceOf("coordinateSystem", EllipsoidalCS.class, cs); + assertIsGeodetic2D((EllipsoidalCS) cs, isRangeMandatory); + } + + /** * Asserts that the given datum is the Mean Sea Level one. * This method verifies the following properties: * @@ -312,10 +345,10 @@ public final strictfp class GeodeticObje * * * @param cs The coordinate system to verify. - * @param rangeIsMandatory {@code true} if the axes range and range meaning properties shall be defined, + * @param isRangeMandatory {@code true} if the axes range and range meaning properties shall be defined, * or {@code false} if they are optional. */ - public static void assertIsGeodetic2D(final EllipsoidalCS cs, final boolean rangeIsMandatory) { + public static void assertIsGeodetic2D(final EllipsoidalCS cs, final boolean isRangeMandatory) { assertEquals("dimension", 2, cs.getDimension()); final CoordinateSystemAxis latitude = cs.getAxis(0); final CoordinateSystemAxis longitude = cs.getAxis(1); @@ -327,8 +360,8 @@ public final strictfp class GeodeticObje assertEquals("axis[1].direction", AxisDirection.EAST, longitude.getDirection()); assertEquals("axis[0].unit", NonSI.DEGREE_ANGLE, latitude .getUnit()); assertEquals("axis[1].unit", NonSI.DEGREE_ANGLE, longitude.getUnit()); - verifyRange(latitude, -90, +90, RangeMeaning.EXACT, rangeIsMandatory); - verifyRange(longitude, -180, +180, RangeMeaning.WRAPAROUND, rangeIsMandatory); + verifyRange(latitude, -90, +90, RangeMeaning.EXACT, isRangeMandatory); + verifyRange(longitude, -180, +180, RangeMeaning.WRAPAROUND, isRangeMandatory); } /** Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java?rev=1555662&view=auto ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java (added) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java [UTF-8] Mon Jan 6 05:19:30 2014 @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.referencing.crs; + +import javax.xml.bind.JAXBException; +import org.opengis.test.Validators; +import org.apache.sis.referencing.GeodeticObjectVerifier; +import org.apache.sis.test.XMLTestCase; +import org.apache.sis.test.DependsOn; +import org.junit.Test; + +import static org.apache.sis.test.Assert.*; + + +/** + * Tests {@link DefaultGeodeticCRS} + * + * @author Cédric Briançon (Geomatys) + * @author Guilhem Legal (Geomatys) + * @author Martin Desruisseaux (Geomatys) + * @since 0.4 (derived from geotk-3.04) + * @version 0.4 + * @module + */ +@DependsOn({ + org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class, + org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class +}) +public final strictfp class DefaultGeodeticCRSTest extends XMLTestCase { + /** + * An XML file in this package containing a Cartesian coordinate system definition. + */ + private static final String XML_FILE = "WGS 84.xml"; + + /** + * Tests (un)marshalling of a geodetic coordinate reference system. + * + * @throws JAXBException If an error occurred during unmarshalling. + */ + @Test + public void testXML() throws JAXBException { + final DefaultGeodeticCRS crs = unmarshalFile(DefaultGeodeticCRS.class, XML_FILE); + Validators.validate(crs); + GeodeticObjectVerifier.assertIsWGS84(crs, false, true); + /* + * Values in the following tests are specific to our XML file. + * The actual texts in the EPSG database are more descriptive. + */ + assertEquals("scope", "Horizontal component of 3D system.", crs.getScope().toString()); + /* + * Marshal and compare with the original file. + */ + assertMarshalEqualsFile(XML_FILE, crs, "xmlns:*", "xsi:schemaLocation"); + } +} Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain;charset=UTF-8 Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1555662&r1=1555661&r2=1555662&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Mon Jan 6 05:19:30 2014 @@ -66,6 +66,7 @@ import org.junit.BeforeClass; org.apache.sis.referencing.cs.DefaultCartesianCSTest.class, org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class, org.apache.sis.referencing.cs.CoordinateSystemsTest.class, + org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class, org.apache.sis.referencing.StandardDefinitionsTest.class, org.apache.sis.referencing.GeodeticObjectsTest.class, Added: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS%2084.xml?rev=1555662&view=auto ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml (added) +++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml Mon Jan 6 05:19:30 2014 @@ -0,0 +1,84 @@ + + + + + urn:ogc:def:crs:EPSG::4326 + WGS 84 + Horizontal component of 3D system. + + + urn:ogc:def:cs:EPSG::6422 + Latitude (north), Longitude (east) + + + urn:ogc:def:axis:EPSG::106 + Geodetic latitude + φ + north + -90 + +90 + exact + + + + + urn:ogc:def:axis:EPSG::107 + Geodetic longitude + λ + east + -180 + +180 + wraparound + + + + + + + urn:ogc:def:datum:EPSG::6326 + World Geodetic System 1984 + Satellite navigation. + + + urn:ogc:def:meridian:EPSG::8901 + Greenwich + 0 + + + + + urn:ogc:def:ellipsoid:EPSG::7030 + WGS 84 + 6378137.0 + + + 298.257223563 + + + + + + + Propchange: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml?rev=1555662&r1=1555661&r2=1555662&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml Mon Jan 6 05:19:30 2014 @@ -22,6 +22,7 @@ xmlns:gml = "http://www.opengis.net/gml/3.2" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" gml:id = "epsg-cs-4400"> + urn:ogc:def:cs:EPSG::4400 Easting, northing (E,N) Used in ProjectedCRS. Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml?rev=1555662&r1=1555661&r2=1555662&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml Mon Jan 6 05:19:30 2014 @@ -22,6 +22,7 @@ xmlns:gml = "http://www.opengis.net/gml/3.2" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" gml:id = "epsg-cs-6422"> + urn:ogc:def:cs:EPSG::6422 Latitude (north), Longitude (east) Used in two-dimensional GeographicCRS.