diff --git a/example/README.md b/example/README.md
index fdf480f..dd659de 100644
--- a/example/README.md
+++ b/example/README.md
@@ -4,5 +4,5 @@ on-the-fly by the `java` command.
```
mvn install
-java --class-path target/proj-1.0-SNAPSHOT.jar example/TransformPoints.java
+java --class-path target/proj-2.0-SNAPSHOT.jar example/TransformPoints.java
```
diff --git a/pom.xml b/pom.xml
index a18eb92..600d645 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
> implements Unit{ @@ -102,7 +101,7 @@ private UnitOfMeasure(final int type, final String name, final double toSI) { * @param type the type of quantity represented by the unit of measurement. * @param toSI the conversion factory to system unit (provided by PROJ). */ - private UnitOfMeasure(final Classtype, final double toSI) { + UnitOfMeasure(final Classtype, final double toSI) { this.type = type; this.name = null; this.toSI = toSI; @@ -233,7 +232,7 @@ private static final class Converter implements UnitConverter { @Override public boolean isIdentity() {return factor == 1;} @Override public Number convert(Number value) {return factor * value.doubleValue();} @Override public double convert(double value) {return factor * value;} - @Override public ListgetConversionSteps() {return Collections.singletonList(this);} + @Override public List getConversionSteps() {return List.of(this);} @Override public UnitConverter concatenate(final UnitConverter other) { if (other.isLinear()) { return new Converter(factor * other.convert(1)); diff --git a/src/main/java/org/kortforsyningen/proj/UnitType.java b/src/main/java/org/kortforsyningen/proj/UnitType.java index 418174d..cc759a7 100644 --- a/src/main/java/org/kortforsyningen/proj/UnitType.java +++ b/src/main/java/org/kortforsyningen/proj/UnitType.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Arrays; -import java.util.HashMap; import javax.measure.Unit; import javax.measure.Quantity; import javax.measure.UnitConverter; @@ -129,15 +128,11 @@ enum UnitType { * This is similar to {@link #forOrdinal(int)} method, but using * a {@link Class} argument instead than an enumeration ordinal. */ - static final Map , UnitType> FOR_QUANTITY_TYPE; - static { - final HashMap , UnitType> m = new HashMap<>(8); - m.put(Time.class, TIME); - m.put(Angle.class, ANGULAR); - m.put(Length.class, LINEAR); - m.put(Dimensionless.class, SCALE); - FOR_QUANTITY_TYPE = m; - } + static final Map , UnitType> FOR_QUANTITY_TYPE = Map.of( + Time.class, TIME, + Angle.class, ANGULAR, + Length.class, LINEAR, + Dimensionless.class, SCALE); /** * Returns the unit type from the given ordinal value. diff --git a/src/main/java/org/kortforsyningen/proj/Units.java b/src/main/java/org/kortforsyningen/proj/Units.java index 5c61261..24395e3 100644 --- a/src/main/java/org/kortforsyningen/proj/Units.java +++ b/src/main/java/org/kortforsyningen/proj/Units.java @@ -21,6 +21,7 @@ */ package org.kortforsyningen.proj; +import java.util.Set; import java.util.Objects; import javax.measure.Unit; import javax.measure.Quantity; @@ -62,7 +63,8 @@ public final class Units { SystemOfUnits system = null; try { final SystemOfUnitsService service = ServiceProvider.current().getSystemOfUnitsService(); - if (service != null) { + // Exclude our own UnitProvider class (defined in test package). + if (service != null && !service.getClass().getPackageName().equals(Units.class.getPackageName())) { system = service.getSystemOfUnits("SI"); if (system == null) { system = service.getSystemOfUnits(); @@ -74,11 +76,11 @@ public final class Units { if (system == null) { /* * The call to NativeResource.logger() is necessary - do not replace by - * Logger.getLogger(NativeResource.LOGGER_NAME). The code below has the + * System.getLogger(NativeResource.LOGGER_NAME). The code below has the * desired side effect of initializing the NativeResource class, which * is necessary for using the UnitOfMeasure fallback. */ - NativeResource.logger().fine("No JSR-363 implementation found."); + NativeResource.logger().log(System.Logger.Level.DEBUG, "No JSR-363 implementation found."); } SI = system; } @@ -202,6 +204,15 @@ private static > Unitcreate(final Classtype, final private Units() { } + /** + * Returns all predefined units. + * + * @return all predefined units. + */ + static Set> predefined() { + return Set.of(PREDEFINED); + } + /** * Returns a unit of measurement for this given {@link UnitOfMeasure} constant. * This method is invoked by {@link UnitType#getPredefinedUnit(double)} for diff --git a/src/main/java/org/kortforsyningen/proj/package-info.java b/src/main/java/org/kortforsyningen/proj/package-info.java index 19f9a02..976138a 100644 --- a/src/main/java/org/kortforsyningen/proj/package-info.java +++ b/src/main/java/org/kortforsyningen/proj/package-info.java @@ -138,7 +138,7 @@ * * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ package org.kortforsyningen.proj; diff --git a/src/main/java/org/kortforsyningen/proj/spi/CRSAuthorityFactoryProvider.java b/src/main/java/org/kortforsyningen/proj/spi/CRSAuthorityFactoryProvider.java index 010f17b..f881335 100644 --- a/src/main/java/org/kortforsyningen/proj/spi/CRSAuthorityFactoryProvider.java +++ b/src/main/java/org/kortforsyningen/proj/spi/CRSAuthorityFactoryProvider.java @@ -33,6 +33,7 @@ import org.opengis.referencing.crs.GeocentricCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.ImageCRS; +import org.opengis.referencing.crs.ParametricCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.VerticalCRS; @@ -47,7 +48,7 @@ * should be sufficient. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 * * @see Issue #15 @@ -141,4 +142,9 @@ public TemporalCRS createTemporalCRS(String code) throws FactoryException { public VerticalCRS createVerticalCRS(String code) throws FactoryException { return impl.createVerticalCRS(code); } + + @Override + public ParametricCRS createParametricCRS(String code) throws FactoryException { + return impl.createParametricCRS(code); + } } diff --git a/src/main/java/org/kortforsyningen/proj/spi/OperationFactoryProvider.java b/src/main/java/org/kortforsyningen/proj/spi/OperationFactoryProvider.java index fbda348..c5017cc 100644 --- a/src/main/java/org/kortforsyningen/proj/spi/OperationFactoryProvider.java +++ b/src/main/java/org/kortforsyningen/proj/spi/OperationFactoryProvider.java @@ -25,6 +25,7 @@ import org.kortforsyningen.proj.Proj; import org.opengis.metadata.citation.Citation; import org.opengis.parameter.ParameterValueGroup; +import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.Conversion; import org.opengis.referencing.operation.CoordinateOperation; @@ -39,7 +40,7 @@ * in which case the public static {@code provider()} method should be sufficient. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 * * @see Issue #15 @@ -81,4 +82,14 @@ public CoordinateOperation createConcatenatedOperation(Map map, Coord public Conversion createDefiningConversion(Map map, OperationMethod om, ParameterValueGroup pvg) throws FactoryException { return impl.createDefiningConversion(map, om, pvg); } + + @Override + public OperationMethod createOperationMethod(Map map, Integer intgr, Integer intgr1, ParameterDescriptorGroup pdg) throws FactoryException { + return impl.createOperationMethod(map, intgr, intgr1, pdg); + } + + @Override + public OperationMethod getOperationMethod(String code) throws FactoryException { + return impl.getOperationMethod(code); + } } diff --git a/src/main/java/org/kortforsyningen/proj/spi/package-info.java b/src/main/java/org/kortforsyningen/proj/spi/package-info.java index 48d36f6..a339737 100644 --- a/src/main/java/org/kortforsyningen/proj/spi/package-info.java +++ b/src/main/java/org/kortforsyningen/proj/spi/package-info.java @@ -33,7 +33,7 @@ * While the classes in this packages are public, they usually don't need to be used directly. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ package org.kortforsyningen.proj.spi; diff --git a/src/test/java/org/kortforsyningen/proj/AuthorityFactoryTest.java b/src/test/java/org/kortforsyningen/proj/AuthorityFactoryTest.java index 7553514..322a727 100644 --- a/src/test/java/org/kortforsyningen/proj/AuthorityFactoryTest.java +++ b/src/test/java/org/kortforsyningen/proj/AuthorityFactoryTest.java @@ -24,7 +24,7 @@ import java.util.List; import org.opengis.util.FactoryException; import org.opengis.util.InternationalString; -import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.metadata.Identifier; import org.opengis.referencing.NoSuchAuthorityCodeException; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.GeographicCRS; @@ -50,7 +50,7 @@ * Tests the {@link AuthorityFactory} class. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ public final strictfp class AuthorityFactoryTest { @@ -258,10 +258,10 @@ public void testCache() throws FactoryException { * @param identifiers the collection to verify. */ private static void assertIdentifierEquals(final String codeSpace, final String code, - final Iterable identifiers) + final Iterable identifiers) { boolean found = false; - for (final ReferenceIdentifier id : identifiers) { + for (final Identifier id : identifiers) { if (codeSpace.equalsIgnoreCase(id.getCodeSpace())) { assertEquals("code", code, id.getCode()); found = true; diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2001Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2001Test.java new file mode 100644 index 0000000..c4dff71 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2001Test.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.Test; +import org.junit.Ignore; +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + + +/** + * Tests creation of units of measurements from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2001Test extends org.opengis.test.referencing.gigs.GIGS2001 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2001Test() { + super(TestFactorySource.EPSG); + } + + /** + * Skips this test because we do not support non-linear unit conversions. + */ + @Test + @Override + @Ignore("Non-linear unit conversions not supported.") + public void testSexagesimalDegree() { + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2002Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2002Test.java new file mode 100644 index 0000000..801e700 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2002Test.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Tests creation of ellipsoids from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2002Test extends org.opengis.test.referencing.gigs.GIGS2002 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2002Test() { + super(TestFactorySource.EPSG); + isStandardAliasSupported = false; + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2003Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2003Test.java new file mode 100644 index 0000000..83df77c --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2003Test.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Tests creation of prime meridians from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2003Test extends org.opengis.test.referencing.gigs.GIGS2003 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2003Test() { + super(TestFactorySource.EPSG); + isStandardAliasSupported = false; + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2004Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2004Test.java new file mode 100644 index 0000000..20fd605 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2004Test.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; +import org.opengis.referencing.IdentifiedObject; + + +/** + * Tests creation of geodetic (geographic or geocentric) CRS from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2004Test extends org.opengis.test.referencing.gigs.GIGS2004 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2004Test() { + super(TestFactorySource.EPSG, TestFactorySource.EPSG); + } + + /** + * Returns the name to compare against expected names. We temporarily override this method + * for taking in account changes in EPSG database compared to GIGS tests. + * + * @param object the object for which to get the name. + * @return the name to compare against expected values. + */ + @Override + protected String getVerifiableName(final IdentifiedObject object) { + return TestFactorySource.renameToPreviousVersion(super.getVerifiableName(object)); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2005Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2005Test.java new file mode 100644 index 0000000..7d02af5 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2005Test.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Tests creation of map projections from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2005Test extends org.opengis.test.referencing.gigs.GIGS2005 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2005Test() { + super(TestFactorySource.EPSG); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2006Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2006Test.java new file mode 100644 index 0000000..1f89ac1 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2006Test.java @@ -0,0 +1,71 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.Test; +import org.junit.Ignore; +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; +import org.opengis.referencing.IdentifiedObject; + + +/** + * Tests creation of projected CRS from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2006Test extends org.opengis.test.referencing.gigs.GIGS2006 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2006Test() { + super(TestFactorySource.EPSG); + } + + /** + * Returns the name to compare against expected names. We temporarily override this method + * for taking in account changes in EPSG database compared to GIGS tests. + * + * @param object the object for which to get the name. + * @return the name to compare against expected values. + */ + @Override + protected String getVerifiableName(final IdentifiedObject object) { + return TestFactorySource.renameToPreviousVersion(super.getVerifiableName(object)); + } + + /** + * Skips this test because of wrong axis order in the test. + */ + @Test + @Override + @Ignore("Wrong axis order in GeoAPI implementation of GIGS test.") + public void testTananarive_Paris() { + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2007Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2007Test.java new file mode 100644 index 0000000..a7f192e --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2007Test.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Tests creation horizontal coordinate transformations from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2007Test extends org.opengis.test.referencing.gigs.GIGS2007 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2007Test() { + super(TestFactorySource.EPSG); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2008Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2008Test.java new file mode 100644 index 0000000..4189e15 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2008Test.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Tests creation of vertical CRS from EPSG codes. + * This is part of Geospatial Integrity of Geoscience Software (GIGS) tests implemented in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2008Test extends org.opengis.test.referencing.gigs.GIGS2008 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2008Test() { + super(TestFactorySource.EPSG, TestFactorySource.EPSG); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS2009Test.java b/src/test/java/org/kortforsyningen/proj/GIGS2009Test.java new file mode 100644 index 0000000..673bd9b --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS2009Test.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Tests creation of vertical coordinate transformations from EPSG codes. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS2009Test extends org.opengis.test.referencing.gigs.GIGS2009 { + /** + * Creates a new test using the default authority factory. + */ + public GIGS2009Test() { + super(TestFactorySource.EPSG); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS3002Test.java b/src/test/java/org/kortforsyningen/proj/GIGS3002Test.java new file mode 100644 index 0000000..7587fc0 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS3002Test.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Runs the Geospatial Integrity of Geoscience Software tests on + * ellipsoid objects creation. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS3002Test extends org.opengis.test.referencing.gigs.GIGS3002 { + /** + * Creates a new test suite using the singleton factory instance. + */ + public GIGS3002Test() { + super(TestFactorySource.OBJECTS); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS3003Test.java b/src/test/java/org/kortforsyningen/proj/GIGS3003Test.java new file mode 100644 index 0000000..d424745 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS3003Test.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Runs the Geospatial Integrity of Geoscience Software tests on + * prime meridian objects creation. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS3003Test extends org.opengis.test.referencing.gigs.GIGS3003 { + /** + * Creates a new test suite using the singleton factory instance. + */ + public GIGS3003Test() { + super(TestFactorySource.OBJECTS); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/GIGS3004Test.java b/src/test/java/org/kortforsyningen/proj/GIGS3004Test.java new file mode 100644 index 0000000..23d69dd --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/GIGS3004Test.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; + + +/** + * Runs the Geospatial Integrity of Geoscience Software tests on datum objects creation. + * {@code GIGS3004} tests also geographic and geocentric CRS creations with the tested geodetic datum. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class GIGS3004Test extends org.opengis.test.referencing.gigs.GIGS3004 { + /** + * Creates a new test suite using the singleton factory instance. + */ + public GIGS3004Test() { + super(TestFactorySource.OBJECTS, TestFactorySource.OBJECTS, TestFactorySource.OBJECTS); + } +} diff --git a/src/test/java/org/kortforsyningen/proj/ObjectFactoryTest.java b/src/test/java/org/kortforsyningen/proj/ObjectFactoryTest.java index 127629d..4980ff9 100644 --- a/src/test/java/org/kortforsyningen/proj/ObjectFactoryTest.java +++ b/src/test/java/org/kortforsyningen/proj/ObjectFactoryTest.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Date; import java.util.List; -import java.util.HashMap; import javax.measure.Unit; import javax.measure.quantity.Length; import javax.measure.IncommensurableException; @@ -43,19 +42,17 @@ import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.CompoundCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.ReferenceIdentifier; -import org.opengis.metadata.citation.Citation; +import org.opengis.metadata.Identifier; import org.junit.Test; import static org.junit.Assert.*; -import static java.util.Collections.singletonMap; /** * Tests {@link ObjectFactory}. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ public final strictfp class ObjectFactoryTest { @@ -114,7 +111,7 @@ public void verifyPropertyIndices() { @Test public void testCoordinateSystemAxis() throws FactoryException { CoordinateSystemAxis axis = factory.createCoordinateSystemAxis( - singletonMap(CoordinateSystemAxis.NAME_KEY, "My axis"), + Map.of(CoordinateSystemAxis.NAME_KEY, "My axis"), "x", AxisDirection.NORTH_EAST, Units.METRE); assertEquals("My axis", axis.getName().getCode()); @@ -133,15 +130,15 @@ public void testCoordinateSystemAxis() throws FactoryException { public void testCartesianCS() throws FactoryException, IncommensurableException { final Unit foot = Units.METRE.multiply(0.3048); CoordinateSystemAxis axis0 = factory.createCoordinateSystemAxis( - singletonMap(CoordinateSystemAxis.NAME_KEY, "My axis"), + Map.of(CoordinateSystemAxis.NAME_KEY, "My axis"), "x", AxisDirection.WEST, foot); CoordinateSystemAxis axis1 = factory.createCoordinateSystemAxis( - singletonMap(CoordinateSystemAxis.NAME_KEY, "My other axis"), + Map.of(CoordinateSystemAxis.NAME_KEY, "My other axis"), "y", AxisDirection.SOUTH, foot); CartesianCS cs = factory.createCartesianCS( - singletonMap(CartesianCS.NAME_KEY, "My CS"), + Map.of(CartesianCS.NAME_KEY, "My CS"), axis0, axis1); assertEquals("My CS", cs.getName().getCode()); @@ -159,18 +156,14 @@ public void testCartesianCS() throws FactoryException, IncommensurableException */ @Test public void testEllipsoid() throws FactoryException { - final ReferenceIdentifier id = new ReferenceIdentifier() { + final Identifier id = new Identifier() { @Override public String getCode() {return "My code";} @Override public String getCodeSpace() {return "My codespace";} - @Override public Citation getAuthority() {return null;} - @Override public String getVersion() {return null;} }; semiMajorAxis = 12.1 + 4*StrictMath.random(); - HashMap properties = new HashMap<>(4); - properties.put(Ellipsoid.NAME_KEY, "My ellipsoid"); - properties.put(Ellipsoid.IDENTIFIERS_KEY, id); Ellipsoid ellipsoid = factory.createEllipsoid( - properties, + Map.of(Ellipsoid.NAME_KEY, "My ellipsoid", + Ellipsoid.IDENTIFIERS_KEY, id), semiMajorAxis, 12, Units.METRE); assertEquals("My ellipsoid", ellipsoid.getName().getCode()); @@ -179,7 +172,7 @@ public void testEllipsoid() throws FactoryException { assertSame ( Units.METRE, ellipsoid.getAxisUnit()); assertFalse (ellipsoid.isIvfDefinitive()); - final ReferenceIdentifier firstID = ellipsoid.getIdentifiers().iterator().next(); + final Identifier firstID = ellipsoid.getIdentifiers().iterator().next(); assertEquals("My code", firstID.getCode()); assertEquals("My codespace", firstID.getCodeSpace()); } @@ -203,7 +196,7 @@ public void testFlattenedSphere() throws FactoryException { private Ellipsoid createFlattenedSphere() throws FactoryException { semiMajorAxis = 10 + 4*StrictMath.random(); return factory.createFlattenedSphere( - singletonMap(Ellipsoid.NAME_KEY, "My ellipsoid"), + Map.of(Ellipsoid.NAME_KEY, "My ellipsoid"), semiMajorAxis, 300, Units.METRE); } @@ -239,7 +232,7 @@ public void testPrimeMeridian() throws FactoryException { private PrimeMeridian createPrimeMeridian() throws FactoryException { greenwichLongitude = 1 + 2*StrictMath.random(); return factory.createPrimeMeridian( - singletonMap(PrimeMeridian.NAME_KEY, "My meridian"), + Map.of(PrimeMeridian.NAME_KEY, "My meridian"), greenwichLongitude, Units.DEGREE); } @@ -271,7 +264,7 @@ public void testGeodeticReferenceFrame() throws FactoryException { * @throws FactoryException if creation of the datum failed. */ private GeodeticDatum createGeodeticReferenceFrame() throws FactoryException { - return factory.createGeodeticDatum(singletonMap(GeodeticDatum.NAME_KEY, "My datum"), + return factory.createGeodeticDatum(Map.of(GeodeticDatum.NAME_KEY, "My datum"), createFlattenedSphere(), createPrimeMeridian()); } @@ -306,7 +299,7 @@ public void testTemporalDatum() throws FactoryException { private TemporalDatum createTemporalDatum() throws FactoryException { origin = new Date(); return factory.createTemporalDatum( - singletonMap(TemporalDatum.NAME_KEY, "My datum"), origin); + Map.of(TemporalDatum.NAME_KEY, "My datum"), origin); } /** @@ -337,19 +330,19 @@ public void testGeographicCRS() throws FactoryException { */ private GeographicCRS createGeographicCRS() throws FactoryException { CoordinateSystemAxis axis0 = factory.createCoordinateSystemAxis( - singletonMap(CoordinateSystemAxis.NAME_KEY, "My first axis"), + Map.of(CoordinateSystemAxis.NAME_KEY, "My first axis"), "x", AxisDirection.WEST, Units.DEGREE); CoordinateSystemAxis axis1 = factory.createCoordinateSystemAxis( - singletonMap(CoordinateSystemAxis.NAME_KEY, "My other axis"), + Map.of(CoordinateSystemAxis.NAME_KEY, "My other axis"), "y", AxisDirection.SOUTH, Units.DEGREE); EllipsoidalCS cs = factory.createEllipsoidalCS( - singletonMap(EllipsoidalCS.NAME_KEY, "My ellipsoidal CS"), + Map.of(EllipsoidalCS.NAME_KEY, "My ellipsoidal CS"), axis0, axis1); return factory.createGeographicCRS( - singletonMap(GeographicCRS.NAME_KEY, "My geographic CRS"), + Map.of(GeographicCRS.NAME_KEY, "My geographic CRS"), createGeodeticReferenceFrame(), cs); } @@ -391,15 +384,15 @@ public void testTemporalCRS() throws FactoryException { */ private TemporalCRS createTemporalCRS() throws FactoryException { CoordinateSystemAxis axis = factory.createCoordinateSystemAxis( - singletonMap(CoordinateSystemAxis.NAME_KEY, "My temporal axis"), + Map.of(CoordinateSystemAxis.NAME_KEY, "My temporal axis"), "t", AxisDirection.FUTURE, Units.YEAR); TimeCS cs = factory.createTimeCS( - singletonMap(EllipsoidalCS.NAME_KEY, "My temporal CS"), + Map.of(EllipsoidalCS.NAME_KEY, "My temporal CS"), axis); return factory.createTemporalCRS( - singletonMap(TemporalDatum.NAME_KEY, "My temporal CRS"), + Map.of(TemporalDatum.NAME_KEY, "My temporal CRS"), createTemporalDatum(), cs); } @@ -439,7 +432,7 @@ public void testCompoundCRS() throws FactoryException { */ private CompoundCRS createCompoundCRS() throws FactoryException { return factory.createCompoundCRS( - singletonMap(TemporalDatum.NAME_KEY, "My compound CRS"), + Map.of(TemporalDatum.NAME_KEY, "My compound CRS"), createGeographicCRS(), createTemporalCRS()); } diff --git a/src/test/java/org/kortforsyningen/proj/UnitProvider.java b/src/test/java/org/kortforsyningen/proj/UnitProvider.java new file mode 100644 index 0000000..ad9ebce --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/UnitProvider.java @@ -0,0 +1,168 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import java.util.Set; +import java.util.Collection; +import java.util.Collections; +import javax.measure.Unit; +import javax.measure.Dimension; +import javax.measure.Quantity; +import javax.measure.quantity.Time; +import javax.measure.quantity.Angle; +import javax.measure.quantity.Length; +import javax.measure.quantity.Dimensionless; +import javax.measure.quantity.Pressure; +import javax.measure.spi.QuantityFactory; +import javax.measure.spi.ServiceProvider; +import javax.measure.spi.SystemOfUnits; +import javax.measure.spi.SystemOfUnitsService; +import javax.measure.spi.UnitFormatService; + + +/** + * Services provider for units of measurement, for testing purpose only. + * This is required for running GeoAPI tests. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +public final class UnitProvider extends ServiceProvider implements SystemOfUnitsService, SystemOfUnits { + /** + * Creates a new provider of units of measurements. + */ + public UnitProvider() { + } + + /** + * Returns a name for the system of units provided by this class. + * The name shall be different than {@code "SI"} for preventing + * {@link Units} to select this provider. + * + * @return an arbitrary name different than {@code "SI"}. + */ + @Override + public String getName() { + return "Proj fallback"; + } + + /** + * Returns the default unit for the specified quantity or {@code null} if none. + * + * @param the compile-time quantity type. + * @param type the quantity type. + * @return the unit for the specified quantity. + */ + @Override + @SuppressWarnings("unchecked") + public> UnitgetUnit(final Classtype) { + if (Length .class.equals(type)) return (Unit) Units.METRE; + if (Angle .class.equals(type)) return (Unit) Units.RADIAN; + if (Time .class.equals(type)) return (Unit) Units.SECOND; + if (Dimensionless.class.equals(type)) return (Unit) Units.SCALE_UNITY; + if (Pressure .class.equals(type)) return (Unit) new UnitOfMeasure<>(Pressure.class, 1); + return null; + } + + /** + * Returns the units explicitly defined by this system. + * + * @return all predefined units. + */ + @Override + public Set> getUnits() { + return Units.predefined(); + } + + /** + * Returns the units defined in this system having the specified dimension (convenience method). + * + * @param dim the dimension of the units to be returned. + * @return the units of specified dimension. + */ + @Override + public Set > getUnits(final Dimension dim) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the only system of units services provided by this implementation. + * + * @return {@code this}. + */ + @Override + public SystemOfUnits getSystemOfUnits() { + return this; + } + + /** + * Returns the system of units having the specified name or {@code null} if none. + * + * @param name the system of unit name. + * @return the system of units for the given name. + */ + @Override + public SystemOfUnits getSystemOfUnits(final String name) { + return getName().equals(name) ? this : null; + } + + /** + * Returns the only system of units services provided by this implementation. + * + * @return {@code this} as a singleton. + */ + @Override + public Collection getAvailableSystemsOfUnits() { + return Collections.singleton(this); + } + + /** + * Returns the only system of units services provided by this implementation. + * + * @return {@code this}. + */ + @Override + public SystemOfUnitsService getSystemOfUnitsService() { + return this; + } + + /** + * Unsupported in this implementation. + * + * @return {@code null}. + */ + @Override + public UnitFormatService getUnitFormatService() { + return null; + } + + /** + * Unsupported in this implementation. + * + * @return {@code null}. + */ + @Override + public > QuantityFactorygetQuantityFactory(Classtype) { + return null; + } +} diff --git a/src/test/java/org/kortforsyningen/proj/WKTParserTest.java b/src/test/java/org/kortforsyningen/proj/WKTParserTest.java new file mode 100644 index 0000000..3c8a652 --- /dev/null +++ b/src/test/java/org/kortforsyningen/proj/WKTParserTest.java @@ -0,0 +1,146 @@ +/* + * Copyright © 2019 Agency for Data Supply and Efficiency + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kortforsyningen.proj; + +import org.junit.FixMethodOrder; +import org.junit.Ignore; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; +import org.opengis.test.wkt.CRSParserTest; + + + +/** + * Tests Well-Known Text parser using the tests defined in GeoAPI. + * + * @author Martin Desruisseaux (Geomatys) + * @version 2.0 + * @since 2.0 + */ +@RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness +public final strictfp class WKTParserTest extends CRSParserTest { + /** + * Creates a new test case using the default {@code CRSFactory} implementation. + */ + public WKTParserTest() { + super(ObjectFactory.INSTANCE); + /* + * ISO 19111:2007 said that axis names shall be "geodetic latitude" and "geodetic longitude", + * but PROJ keep "latitude" and "longitude" names as they appear in the WKT string. + */ + validators.crs.enforceStandardNames = false; + } + + /** + * Skip test having a PROJ error. Error message is: + * {@literal "Missing EDATUM / ENGINEERINGDATUM node"}. + */ + @Ignore + @Override + public void testTemporal() { + } + + /** + * Skip test having a PROJ error. Error message is: + * {@literal "unexpected TIMEUNIT"}. + */ + @Ignore + @Override + public void testCompoundWithTime() { + } + + /** + * Skip test having a PROJ error. Error message is: + * {@literal "Missing EDATUM / ENGINEERINGDATUM node"}. + */ + @Ignore + @Override + public void testDerivedEngineeringFromGeodetic() { + } + + /** + * Skip test having a PROJ error. Error message is: + * {@literal "Missing EDATUM / ENGINEERINGDATUM node"}. + */ + @Ignore + @Override + public void testDerivedEngineeringFromProjected() { + } + + /** + * Skip test having a PROJ error. Error message is: + * {@literal "Parsing error : syntax error, unexpected PRIMEM, expecting ID"}. + */ + @Ignore + @Override + public void testProjectedWithImplicitParameterUnits() { + } + + /** + * Skip test failing validation. Error message is: + * {@literal "(…) is of type Geographic while the expected type was DerivedCRS or a subtype"}. + */ + @Ignore + @Override + public void testDerivedGeodetic() { + } + + /** + * Skip test failing validation. Error message is: + * {@literal "CoordinateSystemAxis: abbreviation is mandatory"}. + */ + @Ignore + @Override + public void testEngineeringRotated() { + } + + /** + * Skip test having a GeoAPI test failure. Error message is: + * {@literal "CoordinateSystem.getAxis(*).getUnit() expected:but was: "}. + */ + @Ignore + @Override + public void testProjectedWithFootUnits() { + } + + /** + * Skip test having a PROJ-JNI limitation. Error message is: + * {@literal "The PROJ-JNI binding provides only minimal support for Unit of Measurement operations. + * For more advanced operations, a JSR-363 implementation should be added to the classpath."}. + */ + @Ignore + @Override + public void testParametric() { + } + + /** + * Skip test having a PROJ-JNI limitation. Error message is: + * {@literal "The PROJ-JNI binding provides only minimal support for Unit of Measurement operations. + * For more advanced operations, a JSR-363 implementation should be added to the classpath."}. + */ + @Ignore + @Override + public void testCompoundWithParametric() { + } +} diff --git a/src/test/resources/META-INF/services/javax.measure.spi.ServiceProvider b/src/test/resources/META-INF/services/javax.measure.spi.ServiceProvider new file mode 100644 index 0000000..94ebb4f --- /dev/null +++ b/src/test/resources/META-INF/services/javax.measure.spi.ServiceProvider @@ -0,0 +1,2 @@ +# For testing purpose only. +org.kortforsyningen.proj.UnitProvider