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 @@ org.kortforsyningen proj - 1.0-SNAPSHOT + 2.0-SNAPSHOT PROJ bindings https://github.com/Kortforsyningen/PROJ-JNI @@ -73,12 +73,12 @@ org.opengis geoapi - 3.0.1 + 4.0-M12 org.opengis geoapi-conformance - 3.0.1 + 4.0-M12 test @@ -96,11 +96,13 @@ maven-compiler-plugin 3.8.1 - 8 + 11 true true false + -Xlint:all + -Xdoclint:all --doclint-format html5 -h ${project.build.sourceDirectory}/../cpp @@ -210,4 +212,21 @@ + + + + + + geotk + Geotk repository + http://maven.geotoolkit.org + + false + + + diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt index 9327aab..e9c2aaa 100644 --- a/src/main/cpp/CMakeLists.txt +++ b/src/main/cpp/CMakeLists.txt @@ -51,7 +51,7 @@ cmake_minimum_required(VERSION 3.5) # Set the project name and version. -project(PROJ-JNI VERSION 1.0 LANGUAGES CXX) +project(PROJ-JNI VERSION 2.0 LANGUAGES CXX) # Specify the C++ standard. set(CMAKE_CXX_STANDARD 11) diff --git a/src/main/cpp/bindings.cpp b/src/main/cpp/bindings.cpp index 2a4469c..4c073d6 100644 --- a/src/main/cpp/bindings.cpp +++ b/src/main/cpp/bindings.cpp @@ -68,6 +68,7 @@ using osgeo::proj::crs::EngineeringCRS; using osgeo::proj::crs::GeodeticCRS; using osgeo::proj::crs::GeodeticCRSNNPtr; using osgeo::proj::crs::GeographicCRS; +using osgeo::proj::crs::ParametricCRS; using osgeo::proj::crs::ProjectedCRS; using osgeo::proj::crs::SingleCRS; using osgeo::proj::crs::SingleCRSPtr; @@ -85,6 +86,8 @@ using osgeo::proj::cs::CoordinateSystemNNPtr; using osgeo::proj::cs::CoordinateSystemPtr; using osgeo::proj::cs::EllipsoidalCS; using osgeo::proj::cs::EllipsoidalCSNNPtr; +using osgeo::proj::cs::ParametricCS; +using osgeo::proj::cs::ParametricCSNNPtr; using osgeo::proj::cs::SphericalCS; using osgeo::proj::cs::SphericalCSNNPtr; using osgeo::proj::cs::SphericalCSPtr; @@ -100,6 +103,8 @@ using osgeo::proj::datum::EngineeringDatum; using osgeo::proj::datum::EngineeringDatumNNPtr; using osgeo::proj::datum::GeodeticReferenceFrame; using osgeo::proj::datum::GeodeticReferenceFrameNNPtr; +using osgeo::proj::datum::ParametricDatum; +using osgeo::proj::datum::ParametricDatumNNPtr; using osgeo::proj::datum::PrimeMeridian; using osgeo::proj::datum::PrimeMeridianNNPtr; using osgeo::proj::datum::TemporalDatum; @@ -234,15 +239,15 @@ JNIEXPORT void JNICALL Java_org_kortforsyningen_proj_NativeResource_initialize(J * null. We use that as a sentinel value for determining that the * logging system is not available. */ - jclass c = env->FindClass("java/util/logging/Logger"); + jclass c = env->FindClass("java/lang/System$Logger"); if (c) { - java_method_log = env->GetMethodID(c, "log", "(Ljava/util/logging/Level;Ljava/lang/String;)V"); + java_method_log = env->GetMethodID(c, "log", "(Ljava/lang/System$Logger$Level;Ljava/lang/String;)V"); if (java_method_log) { - c = env->FindClass("java/util/logging/Level"); + c = env->FindClass("java/lang/System$Logger$Level"); if (c) { - java_field_debug_level = env->GetStaticFieldID(c, "FINE", "Ljava/util/logging/Level;"); + java_field_debug_level = env->GetStaticFieldID(c, "DEBUG", "Ljava/lang/System$Logger$Level;"); if (java_field_debug_level) { - java_method_getLogger = env->GetStaticMethodID(caller, "logger", "()Ljava/util/logging/Logger;"); + java_method_getLogger = env->GetStaticMethodID(caller, "logger", "()Ljava/lang/System$Logger;"); } } } @@ -349,7 +354,7 @@ void log(JNIEnv *env, const std::string &text) { if (c) { jobject logger = env->CallStaticObjectMethod(c, java_method_getLogger); if (!env->ExceptionCheck()) { // ExceptionCheck() must be always invoked. - c = env->FindClass("java/util/logging/Level"); + c = env->FindClass("java/lang/System$Logger$Level"); if (c) { jobject level = env->GetStaticObjectField(c, java_field_debug_level); jstring str = env->NewStringUTF(text.c_str()); @@ -600,6 +605,7 @@ again: switch (type) { else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_GEOGRAPHIC_CRS; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_VERTICAL_CRS; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_TEMPORAL_CRS; + else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_PARAMETRIC_CRS; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_ENGINEERING_CRS; else { GeodeticCRS *gc = dynamic_cast(rp); @@ -618,12 +624,14 @@ again: switch (type) { else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_ELLIPSOIDAL_CS; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_VERTICAL_CS; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_TEMPORAL_CS; + else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_PARAMETRIC_CS; break; } case org_kortforsyningen_proj_Type_DATUM: { if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_GEODETIC_REFERENCE_FRAME; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_VERTICAL_REFERENCE_FRAME; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_TEMPORAL_DATUM; + else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_PARAMETRIC_DATUM; else if (dynamic_cast(rp)) type = org_kortforsyningen_proj_Type_ENGINEERING_DATUM; break; } @@ -2139,6 +2147,11 @@ JNIEXPORT jobject JNICALL Java_org_kortforsyningen_proj_ObjectFactory_create object = TemporalMeasureCS::create(propertyMap, axis).as_nullable(); break; } + case org_kortforsyningen_proj_Type_PARAMETRIC_CS: { + CoordinateSystemAxisNNPtr axis = get_component(env, components, 0); + object = ParametricCS::create(propertyMap, axis).as_nullable(); + break; + } case org_kortforsyningen_proj_Type_CARTESIAN_CS: case org_kortforsyningen_proj_Type_SPHERICAL_CS: case org_kortforsyningen_proj_Type_ELLIPSOIDAL_CS: { @@ -2175,6 +2188,10 @@ JNIEXPORT jobject JNICALL Java_org_kortforsyningen_proj_ObjectFactory_create object = TemporalDatum::create(propertyMap, origin, TemporalDatum::CALENDAR_PROLEPTIC_GREGORIAN).as_nullable(); break; } + case org_kortforsyningen_proj_Type_PARAMETRIC_DATUM: { + object = ParametricDatum::create(propertyMap, anchor).as_nullable(); + break; + } case org_kortforsyningen_proj_Type_ENGINEERING_DATUM: { object = EngineeringDatum::create(propertyMap, anchor).as_nullable(); break; @@ -2209,6 +2226,12 @@ JNIEXPORT jobject JNICALL Java_org_kortforsyningen_proj_ObjectFactory_create object = TemporalCRS::create(propertyMap, datum, cs).as_nullable(); break; } + case org_kortforsyningen_proj_Type_PARAMETRIC_CRS: { + ParametricDatumNNPtr datum = get_component(env, components, 0); + ParametricCSNNPtr cs = get_component (env, components, 1); + object = ParametricCRS::create(propertyMap, datum, cs).as_nullable(); + break; + } case org_kortforsyningen_proj_Type_ENGINEERING_CRS: { EngineeringDatumNNPtr datum = get_component(env, components, 0); CoordinateSystemNNPtr cs = get_component(env, components, 1); @@ -2379,6 +2402,7 @@ JNIEXPORT jobject JNICALL Java_org_kortforsyningen_proj_AuthorityFactory_createG case org_kortforsyningen_proj_Type_GEODETIC_REFERENCE_FRAME: rp = pf->createGeodeticDatum (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_VERTICAL_REFERENCE_FRAME: rp = pf->createVerticalDatum (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_TEMPORAL_DATUM: // No specific function - use generic one. + case org_kortforsyningen_proj_Type_PARAMETRIC_DATUM: // No specific function - use generic one. case org_kortforsyningen_proj_Type_ENGINEERING_DATUM: // No specific function - use generic one. case org_kortforsyningen_proj_Type_DATUM: rp = pf->createDatum (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_CARTESIAN_CS: // No specific function - use generic one. @@ -2386,6 +2410,7 @@ JNIEXPORT jobject JNICALL Java_org_kortforsyningen_proj_AuthorityFactory_createG case org_kortforsyningen_proj_Type_ELLIPSOIDAL_CS: // No specific function - use generic one. case org_kortforsyningen_proj_Type_VERTICAL_CS: // No specific function - use generic one. case org_kortforsyningen_proj_Type_TEMPORAL_CS: // No specific function - use generic one. + case org_kortforsyningen_proj_Type_PARAMETRIC_CS: // No specific function - use generic one. case org_kortforsyningen_proj_Type_COORDINATE_SYSTEM: rp = pf->createCoordinateSystem (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_GEOCENTRIC_CRS: // Handled as GeodeticCRS by ISO 19111. case org_kortforsyningen_proj_Type_GEODETIC_CRS: rp = pf->createGeodeticCRS (code_str).as_nullable(); break; @@ -2394,6 +2419,7 @@ JNIEXPORT jobject JNICALL Java_org_kortforsyningen_proj_AuthorityFactory_createG case org_kortforsyningen_proj_Type_PROJECTED_CRS: rp = pf->createProjectedCRS (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_COMPOUND_CRS: rp = pf->createCompoundCRS (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_TEMPORAL_CRS: // No specific function - use generic one. + case org_kortforsyningen_proj_Type_PARAMETRIC_CRS: // No specific function - use generic one. case org_kortforsyningen_proj_Type_ENGINEERING_CRS: // No specific function - use generic one. case org_kortforsyningen_proj_Type_COORDINATE_REFERENCE_SYSTEM: rp = pf->createCoordinateReferenceSystem (code_str).as_nullable(); break; case org_kortforsyningen_proj_Type_CONVERSION: rp = pf->createConversion (code_str).as_nullable(); break; diff --git a/src/main/cpp/org_kortforsyningen_proj_Type.h b/src/main/cpp/org_kortforsyningen_proj_Type.h index 9fe466b..2a13922 100644 --- a/src/main/cpp/org_kortforsyningen_proj_Type.h +++ b/src/main/cpp/org_kortforsyningen_proj_Type.h @@ -71,6 +71,12 @@ extern "C" { #define org_kortforsyningen_proj_Type_PARAMETER 30L #undef org_kortforsyningen_proj_Type_PARAMETER_VALUE #define org_kortforsyningen_proj_Type_PARAMETER_VALUE 31L +#undef org_kortforsyningen_proj_Type_PARAMETRIC_CS +#define org_kortforsyningen_proj_Type_PARAMETRIC_CS 32L +#undef org_kortforsyningen_proj_Type_PARAMETRIC_CRS +#define org_kortforsyningen_proj_Type_PARAMETRIC_CRS 33L +#undef org_kortforsyningen_proj_Type_PARAMETRIC_DATUM +#define org_kortforsyningen_proj_Type_PARAMETRIC_DATUM 34L #ifdef __cplusplus } #endif diff --git a/src/main/java/org/kortforsyningen/proj/AuthorityFactory.java b/src/main/java/org/kortforsyningen/proj/AuthorityFactory.java index 9cd3dde..0ecf66a 100644 --- a/src/main/java/org/kortforsyningen/proj/AuthorityFactory.java +++ b/src/main/java/org/kortforsyningen/proj/AuthorityFactory.java @@ -47,7 +47,7 @@ * same thread.

* * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class AuthorityFactory extends NativeResource { @@ -359,6 +359,18 @@ public TimeCS createTimeCS(final String code) throws FactoryException { return createGeodeticObject(CS.Time.class, Type.TEMPORAL_CS, code); } + /** + * Returns a coordinate system which is expected to be parametric. + * + * @param code value allocated by authority. + * @return the coordinate system for the given code. + * @throws FactoryException if the object creation failed or the CS is another type. + */ + @Override + public ParametricCS createParametricCS(final String code) throws FactoryException { + return createGeodeticObject(CS.Parametric.class, Type.PARAMETRIC_CS, code); + } + /** * Returns a coordinate system which is expected to be polar. * PROJ does not yet support this type of coordinate system. @@ -457,6 +469,18 @@ public TemporalDatum createTemporalDatum(final String code) throws FactoryExcept return createGeodeticObject(Datum.Temporal.class, Type.TEMPORAL_DATUM, code); } + /** + * Returns a datum for parametric CRS. + * + * @param code value allocated by authority. + * @return the datum for the given code. + * @throws FactoryException if the object creation failed or the datum is another type. + */ + @Override + public ParametricDatum createParametricDatum(final String code) throws FactoryException { + return createGeodeticObject(Datum.Parametric.class, Type.PARAMETRIC_DATUM, code); + } + /** * Returns a datum for engineering CRS. * @@ -553,6 +577,18 @@ public TemporalCRS createTemporalCRS(final String code) throws FactoryException return createGeodeticObject(CRS.Temporal.class, Type.TEMPORAL_CRS, code); } + /** + * Returns a coordinate reference system which is expected to be parametric. + * + * @param code value allocated by authority. + * @return the CRS for the given code. + * @throws FactoryException if the object creation failed or the CRS is another type. + */ + @Override + public ParametricCRS createParametricCRS(final String code) throws FactoryException { + return createGeodeticObject(CRS.Parametric.class, Type.PARAMETRIC_CRS, code); + } + /** * Returns a coordinate reference system which is expected to be engineering. * diff --git a/src/main/java/org/kortforsyningen/proj/Axis.java b/src/main/java/org/kortforsyningen/proj/Axis.java index f428549..0735b30 100644 --- a/src/main/java/org/kortforsyningen/proj/Axis.java +++ b/src/main/java/org/kortforsyningen/proj/Axis.java @@ -25,14 +25,13 @@ import org.opengis.util.CodeList; import org.opengis.referencing.cs.CoordinateSystemAxis; import org.opengis.referencing.cs.AxisDirection; -import org.opengis.referencing.cs.RangeMeaning; /** * Wrappers around {@code osgeo::proj::cs::CoordinateSystemAxis}. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class Axis extends IdentifiableObject implements CoordinateSystemAxis { @@ -79,16 +78,9 @@ public AxisDirection getDirection() { * @return the code list for the given UML identifier. */ private static > T search(final Class type, final String code) { - return CodeList.valueOf(type, new CodeList.Filter() { - @Override public String codename() { - return code; - } - - @Override public boolean accept(final CodeList candidate) { - return code.equalsIgnoreCase(candidate.identifier()) || - code.equalsIgnoreCase(candidate.name()); - } - }); + return CodeList.valueOf(type, (candidate) -> + code.equalsIgnoreCase(candidate.identifier()) || + code.equalsIgnoreCase(candidate.name()), code); } /** @@ -124,15 +116,4 @@ public double getMaximumValue() { final double v = impl.getNumericProperty(Property.MAXIMUM); return Double.isNaN(v) ? Double.POSITIVE_INFINITY : v; } - - /** - * Returns the meaning of axis value range specified by the {@linkplain #getMinimumValue() - * minimum} and {@linkplain #getMaximumValue() maximum} values. - * - * @return the range meaning, or {@code null} in none. - */ - @Override - public RangeMeaning getRangeMeaning() { - return null; - } } diff --git a/src/main/java/org/kortforsyningen/proj/CRS.java b/src/main/java/org/kortforsyningen/proj/CRS.java index 7ed635a..9f9d94e 100644 --- a/src/main/java/org/kortforsyningen/proj/CRS.java +++ b/src/main/java/org/kortforsyningen/proj/CRS.java @@ -27,10 +27,12 @@ import org.opengis.referencing.cs.EllipsoidalCS; import org.opengis.referencing.cs.TimeCS; import org.opengis.referencing.cs.VerticalCS; +import org.opengis.referencing.cs.ParametricCS; // org.opengis.referencing.datum.Datum — Not imported because we use Datum class from this package. import org.opengis.referencing.datum.GeodeticDatum; import org.opengis.referencing.datum.VerticalDatum; import org.opengis.referencing.datum.TemporalDatum; +import org.opengis.referencing.datum.ParametricDatum; import org.opengis.referencing.datum.EngineeringDatum; import org.opengis.referencing.operation.Projection; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -40,6 +42,7 @@ import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.TemporalCRS; +import org.opengis.referencing.crs.ParametricCRS; import org.opengis.referencing.crs.EngineeringCRS; import org.opengis.referencing.crs.CompoundCRS; @@ -49,7 +52,7 @@ * Each subtype is represented by an inner class in this file. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ class CRS extends IdentifiableObject implements CoordinateReferenceSystem { @@ -236,6 +239,35 @@ public TemporalDatum getDatum() { } } + /** + * A coordinate reference system specialization. + */ + static final class Parametric extends CRS implements ParametricCRS { + /** + * Invoked by {@link AuthorityFactory#wrapGeodeticObject} only. + * @param ptr pointer to the wrapped PROJ object. + */ + Parametric(final long ptr) { + super(ptr); + } + + /** + * Returns the parametric specialization of the coordinate system. + */ + @Override + public ParametricCS getCoordinateSystem() { + return getCoordinateSystem(CS.Parametric.class); + } + + /** + * Returns the parametric specialization of the datum. + */ + @Override + public ParametricDatum getDatum() { + return getDatum(Datum.Parametric.class); + } + } + /** * A coordinate reference system specialization. */ diff --git a/src/main/java/org/kortforsyningen/proj/CS.java b/src/main/java/org/kortforsyningen/proj/CS.java index 9f88e7d..58dcb29 100644 --- a/src/main/java/org/kortforsyningen/proj/CS.java +++ b/src/main/java/org/kortforsyningen/proj/CS.java @@ -26,6 +26,7 @@ import org.opengis.referencing.cs.CartesianCS; import org.opengis.referencing.cs.SphericalCS; import org.opengis.referencing.cs.EllipsoidalCS; +import org.opengis.referencing.cs.ParametricCS; import org.opengis.referencing.cs.VerticalCS; import org.opengis.referencing.cs.TimeCS; @@ -35,7 +36,7 @@ * Each subtype is represented by an inner class in this file. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ class CS extends IdentifiableObject implements CoordinateSystem { @@ -135,4 +136,17 @@ static final class Time extends CS implements TimeCS { super(ptr); } } + + /** + * A coordinate system specialization. No new properties compared to parent CS. + */ + static final class Parametric extends CS implements ParametricCS { + /** + * Invoked by {@link AuthorityFactory#wrapGeodeticObject} only. + * @param ptr pointer to the wrapped PROJ object. + */ + Parametric(final long ptr) { + super(ptr); + } + } } diff --git a/src/main/java/org/kortforsyningen/proj/CleanerThread.java b/src/main/java/org/kortforsyningen/proj/CleanerThread.java index f641edf..68f4221 100644 --- a/src/main/java/org/kortforsyningen/proj/CleanerThread.java +++ b/src/main/java/org/kortforsyningen/proj/CleanerThread.java @@ -23,8 +23,6 @@ import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; -import java.util.logging.Level; -import java.util.logging.Logger; /** @@ -102,7 +100,7 @@ public final void run() { SharedObjects.CACHE.remove(ref); } } catch (Throwable exception) { - Logger.getLogger(NativeResource.LOGGER_NAME).log(Level.WARNING, exception.getLocalizedMessage(), exception); + System.getLogger(NativeResource.LOGGER_NAME).log(System.Logger.Level.WARNING, exception); } } // Do not log anything at this point, since the loggers may be shutdown now. diff --git a/src/main/java/org/kortforsyningen/proj/CompoundCS.java b/src/main/java/org/kortforsyningen/proj/CompoundCS.java index 6c884da..170d8b5 100644 --- a/src/main/java/org/kortforsyningen/proj/CompoundCS.java +++ b/src/main/java/org/kortforsyningen/proj/CompoundCS.java @@ -21,14 +21,9 @@ */ package org.kortforsyningen.proj; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.metadata.Identifier; import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.cs.CoordinateSystemAxis; -import org.opengis.util.GenericName; -import org.opengis.util.InternationalString; /** @@ -37,7 +32,7 @@ * but GeoAPI does for user convenience. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class CompoundCS implements CoordinateSystem { @@ -62,51 +57,10 @@ final class CompoundCS implements CoordinateSystem { * @return null. */ @Override - public ReferenceIdentifier getName() { + public Identifier getName() { return null; } - /** - * Returns an empty set since this coordinate system has no name. - * - * @return empty. - */ - @Override - public Collection getAlias() { - return Collections.emptySet(); - } - - /** - * Returns an empty set since this coordinate system has no identifier. - * - * @return empty. - */ - @Override - public Set getIdentifiers() { - return Collections.emptySet(); - } - - /** - * Returns {@code null} since this coordinate system has no remarks. - * - * @return null. - */ - @Override - public InternationalString getRemarks() { - return null; - } - - /** - * Always throws an exception since this coordinate system can not be formatted in WKT. - * - * @return never return - * @throws UnsupportedOperationException always thrown. - */ - @Override - public String toWKT() { - throw new UnsupportedOperationException(); - } - /** * Returns the number of dimensions in this coordinate system. * diff --git a/src/main/java/org/kortforsyningen/proj/Datum.java b/src/main/java/org/kortforsyningen/proj/Datum.java index c370454..433c416 100644 --- a/src/main/java/org/kortforsyningen/proj/Datum.java +++ b/src/main/java/org/kortforsyningen/proj/Datum.java @@ -34,6 +34,7 @@ import org.opengis.referencing.datum.VerticalDatum; import org.opengis.referencing.datum.VerticalDatumType; import org.opengis.referencing.datum.EngineeringDatum; +import org.opengis.referencing.datum.ParametricDatum; /** @@ -47,7 +48,7 @@ * implementation is offset by the user convenience.

* * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ class Datum extends IdentifiableObject implements org.opengis.referencing.datum.Datum { @@ -195,6 +196,19 @@ public Date getOrigin() { } } + /** + * A datum specialization. No new properties compared to parent CS. + */ + static final class Parametric extends Datum implements ParametricDatum { + /** + * Invoked by {@link AuthorityFactory#wrapGeodeticObject} only. + * @param ptr pointer to the wrapped PROJ object. + */ + Parametric(final long ptr) { + super(ptr); + } + } + /** * A datum specialization. No new properties compared to parent CS. */ diff --git a/src/main/java/org/kortforsyningen/proj/IdentifiableObject.java b/src/main/java/org/kortforsyningen/proj/IdentifiableObject.java index dd9c096..8cd9703 100644 --- a/src/main/java/org/kortforsyningen/proj/IdentifiableObject.java +++ b/src/main/java/org/kortforsyningen/proj/IdentifiableObject.java @@ -36,8 +36,8 @@ import javax.measure.Quantity; import org.opengis.util.GenericName; import org.opengis.util.InternationalString; -import org.opengis.referencing.ReferenceIdentifier; import org.opengis.metadata.extent.Extent; +import org.opengis.metadata.Identifier; /** @@ -49,7 +49,7 @@ * from EPSG codes. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ abstract class IdentifiableObject implements Formattable { @@ -128,7 +128,7 @@ String getNameString(final boolean alternate) { * * @return the primary name, or {@code null} if this object does not provide a name. */ - public ReferenceIdentifier getName() { + public Identifier getName() { if (impl.getBooleanProperty(Property.HAS_NAME)) { return ((ObjectIdentifier) impl.getObjectProperty(Property.NAME)).new PrimaryName(this); } else { @@ -150,7 +150,7 @@ public Collection getAlias() { * * @return this object identifiers, or an empty collection if there is none. */ - public Set getIdentifiers() { + public Set getIdentifiers() { return new PropertySet<>(ObjectIdentifier.class, Property.IDENTIFIER); } @@ -453,11 +453,9 @@ public final void formatTo(final Formatter formatter, final int flags, int width final String format; final Object[] args; if (width > length && (width -= value.codePointCount(0, length)) > 0) { - final char[] spaces = new char[Math.max(width, 0)]; - java.util.Arrays.fill(spaces, ' '); format = "%s%s"; args = new Object[] {value, value}; - args[(flags & FormattableFlags.LEFT_JUSTIFY) != 0 ? 1 : 0] = String.valueOf(spaces); + args[(flags & FormattableFlags.LEFT_JUSTIFY) != 0 ? 1 : 0] = " ".repeat(width); } else { format = isUpperCase ? "%S" : "%s"; args = new Object[] {value}; diff --git a/src/main/java/org/kortforsyningen/proj/NativeResource.java b/src/main/java/org/kortforsyningen/proj/NativeResource.java index d4b759e..1c31553 100644 --- a/src/main/java/org/kortforsyningen/proj/NativeResource.java +++ b/src/main/java/org/kortforsyningen/proj/NativeResource.java @@ -33,7 +33,6 @@ import java.lang.annotation.Native; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.logging.Logger; import org.opengis.util.FactoryException; import javax.measure.Unit; @@ -46,7 +45,7 @@ * by {@link #ptr} when no longer referenced. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ abstract class NativeResource { @@ -255,10 +254,12 @@ private IdentifiableObject wrapGeodeticObject(final short type, final long rawPo case Type.ELLIPSOIDAL_CS: obj = new CS.Ellipsoidal (rawPointer); break; case Type.VERTICAL_CS: obj = new CS.Vertical (rawPointer); break; case Type.TEMPORAL_CS: obj = new CS.Time (rawPointer); break; + case Type.PARAMETRIC_CS: obj = new CS.Parametric (rawPointer); break; case Type.DATUM: obj = new Datum (rawPointer); break; case Type.GEODETIC_REFERENCE_FRAME: obj = new Datum.Geodetic (rawPointer); break; case Type.VERTICAL_REFERENCE_FRAME: obj = new Datum.Vertical (rawPointer); break; case Type.TEMPORAL_DATUM: obj = new Datum.Temporal (rawPointer); break; + case Type.PARAMETRIC_DATUM: obj = new Datum.Parametric (rawPointer); break; case Type.ENGINEERING_DATUM: obj = new Datum.Engineering (rawPointer); break; case Type.ELLIPSOID: obj = new Datum.Ellipsoid (rawPointer); break; case Type.PRIME_MERIDIAN: obj = new Datum.PrimeMeridian (rawPointer); break; @@ -269,6 +270,7 @@ private IdentifiableObject wrapGeodeticObject(final short type, final long rawPo case Type.PROJECTED_CRS: obj = new CRS.Projected (rawPointer); break; case Type.VERTICAL_CRS: obj = new CRS.Vertical (rawPointer); break; case Type.TEMPORAL_CRS: obj = new CRS.Temporal (rawPointer); break; + case Type.PARAMETRIC_CRS: obj = new CRS.Parametric (rawPointer); break; case Type.ENGINEERING_CRS: obj = new CRS.Engineering (rawPointer); break; case Type.COMPOUND_CRS: obj = new CRS.Compound (rawPointer); break; case Type.COORDINATE_OPERATION: obj = new Operation (rawPointer); break; @@ -304,7 +306,7 @@ private static Unit getPredefinedUnit(final int ordinal, final double scale) * * @return the logger. */ - static Logger logger() { - return Logger.getLogger(LOGGER_NAME); + static System.Logger logger() { + return System.getLogger(LOGGER_NAME); } } diff --git a/src/main/java/org/kortforsyningen/proj/ObjectFactory.java b/src/main/java/org/kortforsyningen/proj/ObjectFactory.java index 041b89e..51f9042 100644 --- a/src/main/java/org/kortforsyningen/proj/ObjectFactory.java +++ b/src/main/java/org/kortforsyningen/proj/ObjectFactory.java @@ -33,7 +33,6 @@ import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.referencing.IdentifiedObject; -import org.opengis.referencing.ReferenceIdentifier; import org.opengis.referencing.operation.Conversion; import org.opengis.referencing.operation.CoordinateOperationFactory; import org.opengis.referencing.datum.*; @@ -45,7 +44,7 @@ * Creates geodetic objects from their components. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class ObjectFactory extends NativeResource implements DatumFactory, CSFactory, CRSFactory { @@ -167,9 +166,9 @@ private static String[] flat(final Map properties) { if (value == null) { continue; } - if (i == IDENTIFIER && id instanceof ReferenceIdentifier) { + if (i == IDENTIFIER) { if (array == null) array = new String[CODESPACE + 1]; - array[CODESPACE] = ((ReferenceIdentifier) id).getCodeSpace(); + array[CODESPACE] = id.getCodeSpace(); } } else if (value instanceof Date) { value = ((Date) value).toInstant(); // ISO 8601 representation. @@ -499,6 +498,23 @@ public TimeCS createTimeCS( components(axis), null, null, 0, Type.TEMPORAL_CS); } + /** + * Creates a parametric coordinate system. + * + * @param properties name and other properties to give to the new object. + * @param axis the axis. + * @return the coordinate system for the given properties and axes. + * @throws FactoryException if the object creation failed. + */ + @Override + public ParametricCS createParametricCS( + final Map properties, + final CoordinateSystemAxis axis) throws FactoryException + { + return (ParametricCS) create(flat(properties), + components(axis), null, null, 0, Type.PARAMETRIC_CS); + } + /** * Creates a linear coordinate system. * @@ -606,6 +622,21 @@ public TemporalDatum createTemporalDatum( null, new String[] {origin.toInstant().toString()}, null, 0, Type.TEMPORAL_DATUM); } + /** + * Creates a parametric datum from an enumerated type value. + * + * @param properties name and other properties to give to the new object. + * @return the datum for the given properties. + * @throws FactoryException if the object creation failed. + */ + @Override + public ParametricDatum createParametricDatum( + final Map properties) throws FactoryException + { + return (ParametricDatum) create(flat(properties), + null, null, null, 0, Type.PARAMETRIC_DATUM); + } + /** * Creates an engineering datum. * @@ -730,6 +761,25 @@ public TemporalCRS createTemporalCRS( components(datum, cs), null, null, 0, Type.TEMPORAL_CRS); } + /** + * Creates a parametric coordinate reference system. + * + * @param properties name and other properties to give to the new object. + * @param datum parametric datum to use in created CRS. + * @param cs the parametric coordinate system for the created CRS. + * @return the coordinate reference system for the given properties. + * @throws FactoryException if the object creation failed. + */ + @Override + public ParametricCRS createParametricCRS( + final Map properties, + final ParametricDatum datum, + final ParametricCS cs) throws FactoryException + { + return (ParametricCRS) create(flat(properties), + components(datum, cs), null, null, 0, Type.PARAMETRIC_CRS); + } + /** * Creates a engineering coordinate reference system. * diff --git a/src/main/java/org/kortforsyningen/proj/ObjectIdentifier.java b/src/main/java/org/kortforsyningen/proj/ObjectIdentifier.java index 4741a46..480ca06 100644 --- a/src/main/java/org/kortforsyningen/proj/ObjectIdentifier.java +++ b/src/main/java/org/kortforsyningen/proj/ObjectIdentifier.java @@ -24,7 +24,6 @@ import java.util.StringJoiner; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; -import org.opengis.referencing.ReferenceIdentifier; /** @@ -32,10 +31,10 @@ * around an {@code osgeo::proj::metadata::Identifier}. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ -final class ObjectIdentifier extends IdentifiableObject implements ReferenceIdentifier { +final class ObjectIdentifier extends IdentifiableObject implements Identifier { /** * Creates a new wrapper for the given {@code osgeo::proj::metadata::Identifier}. * @@ -116,7 +115,7 @@ public String getVersion() { * The identifier code should be mandatory, but PROJ does not always provide it. * This class is a workaround for the case where the code is missing. */ - final class PrimaryName implements ReferenceIdentifier { + final class PrimaryName implements Identifier { /** * The object from which to fetch {@link Property#NAME_STRING} if needed. */ @@ -210,7 +209,7 @@ public String toString() { * @param id the identifier for which to get string representation. * @return a pseudo-WKT for the given identifier. */ - private static String format(final ReferenceIdentifier id) { + private static String format(final Identifier id) { final StringBuilder buffer = new StringBuilder("ID[\""); String t = id.getCodeSpace(); if (t != null) { diff --git a/src/main/java/org/kortforsyningen/proj/Operation.java b/src/main/java/org/kortforsyningen/proj/Operation.java index e173ec5..4a6117c 100644 --- a/src/main/java/org/kortforsyningen/proj/Operation.java +++ b/src/main/java/org/kortforsyningen/proj/Operation.java @@ -27,11 +27,11 @@ import java.util.Collections; import java.util.Formattable; import java.util.Formatter; -import java.util.logging.Level; import java.security.AccessController; import java.security.PrivilegedAction; import org.opengis.util.GenericName; import org.opengis.util.InternationalString; +import org.opengis.metadata.Identifier; import org.opengis.geometry.DirectPosition; import org.opengis.geometry.MismatchedDimensionException; import org.opengis.metadata.citation.Citation; @@ -39,7 +39,8 @@ import org.opengis.metadata.quality.PositionalAccuracy; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterValueGroup; -import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.referencing.crs.GeographicCRS; +import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.GeneralDerivedCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.CoordinateOperation; @@ -56,7 +57,7 @@ * Each subtype is represented by an inner class in this file. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ class Operation extends ParameterGroup implements CoordinateOperation, MathTransform { @@ -82,7 +83,7 @@ class Operation extends ParameterGroup implements CoordinateOperation, MathTrans * If we do not have the authorization to read the property value, this is not a big issue. * We can work with the default value. */ - NativeResource.logger().log(Level.FINE, e.getLocalizedMessage(), e); + NativeResource.logger().log(System.Logger.Level.DEBUG, e.getLocalizedMessage(), e); } /* * The default value below (4) is arbitrary. If that default value is modified, @@ -322,9 +323,6 @@ static final class Method extends ParameterGroup implements OperationMethod, Par super(ptr); } - /** Removed from ISO 19111:2019. */ @Override public Integer getSourceDimensions() {return null;} - /** Removed from ISO 19111:2019. */ @Override public Integer getTargetDimensions() {return null;} - /** * The property to request for getting parameter descriptors. * This is the value of the fist argument to be given to @@ -440,9 +438,9 @@ static final class Projection implements org.opengis.referencing.operation.Proje this.op = op; } - @Override public ReferenceIdentifier getName() {return op.getName();} + @Override public Identifier getName() {return op.getName();} @Override public Collection getAlias() {return op.getAlias();} - @Override public Set getIdentifiers() {return op.getIdentifiers();} + @Override public Set getIdentifiers() {return op.getIdentifiers();} @Override public InternationalString getRemarks() {return op.getRemarks();} @Override public String getOperationVersion() {return op.getOperationVersion();} @Override public OperationMethod getMethod() {return op.getMethod();} @@ -453,8 +451,8 @@ static final class Projection implements org.opengis.referencing.operation.Proje @Override public MathTransform getMathTransform() {return op.getMathTransform();} @Override public String toWKT() {return op.toWKT();} @Override public String toString() {return op.toString();} - @Override public CoordinateReferenceSystem getTargetCRS() {return crs;} - @Override public CoordinateReferenceSystem getSourceCRS() {return crs.getBaseCRS();} + @Override public ProjectedCRS getTargetCRS() {return crs;} + @Override public GeographicCRS getSourceCRS() {return crs.getBaseCRS();} @Override public int hashCode() {return crs.hashCode() ^ 37;} @Override public boolean equals(final Object other) { // Since the conversion was obtained from the CRS, comparing the CRS is sufficient. diff --git a/src/main/java/org/kortforsyningen/proj/OperationFactory.java b/src/main/java/org/kortforsyningen/proj/OperationFactory.java index 53a4f7e..ce70924 100644 --- a/src/main/java/org/kortforsyningen/proj/OperationFactory.java +++ b/src/main/java/org/kortforsyningen/proj/OperationFactory.java @@ -28,6 +28,7 @@ import org.opengis.metadata.extent.GeographicExtent; import org.opengis.metadata.extent.GeographicBoundingBox; 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; @@ -41,7 +42,7 @@ * Creates coordinate operations from a pair of CRS, optionally with some contextual information. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class OperationFactory implements CoordinateOperationFactory { @@ -229,4 +230,35 @@ public Conversion createDefiningConversion(final Map properties, { throw new FactoryException("Not supported yet."); } + + /** + * Creates an operation method from a set of properties and a descriptor group. + * + * @param properties set of properties. Shall contains at least {@code "name"}. + * @param sourceDimension number of dimensions in the source CRS of the operation method, or {@code null}. + * @param targetDimension number of dimensions in the target CRS of the operation method, or {@code null}. + * @param parameters a description of the parameters for the operation method. + * @return the operation method. + * @throws FactoryException if the object creation failed. + * + * @since 2.0 + */ + @Override + public OperationMethod createOperationMethod(Map properties, + Integer sourceDimension, + Integer targetDimension, + ParameterDescriptorGroup parameters) throws FactoryException + { + throw new UnsupportedOperationException("Not supported yet."); + } + + /** + * Returns the build-in operation method of the given name. + * + * @since 2.0 + */ + @Override + public OperationMethod getOperationMethod(String name) throws FactoryException { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/src/main/java/org/kortforsyningen/proj/Parameter.java b/src/main/java/org/kortforsyningen/proj/Parameter.java index 83db768..4d3811f 100644 --- a/src/main/java/org/kortforsyningen/proj/Parameter.java +++ b/src/main/java/org/kortforsyningen/proj/Parameter.java @@ -23,10 +23,9 @@ import java.io.File; import java.net.URI; -import java.util.Set; import javax.measure.Unit; import javax.measure.IncommensurableException; -import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.metadata.Identifier; import org.opengis.parameter.InvalidParameterTypeException; import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterValue; @@ -44,7 +43,7 @@ * is known only in native code.

* * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ @SuppressWarnings("rawtypes") @@ -72,25 +71,6 @@ public Class getValueClass() { return Object.class; } - /** - * Returns the unit of numerical parameter values. This base class returns {@code null} because PROJ - * defines unit of measurement with the parameter value instead than with the parameter descriptor, - * so the expected unit of measurement is unknown. The {@link Value} subclass overrides this method. - * - * @return the unit of this parameter. - */ - @Override - public Unit getUnit() { - return null; - } - - @Override public int getMinimumOccurs() {return 1;} - @Override public int getMaximumOccurs() {return 1;} - @Override public Set getValidValues() {return null;} - @Override public Comparable getMinimumValue() {return null;} - @Override public Comparable getMaximumValue() {return null;} - @Override public Object getDefaultValue() {return null;} - /** * Read-only parameter value. */ @@ -321,7 +301,7 @@ public String toString() { final StringBuilder buffer = new StringBuilder("PARAMETER[\""); String name = getNameString(false); if (name == null) { - for (final ReferenceIdentifier id : getIdentifiers()) { + for (final Identifier id : getIdentifiers()) { name = id.getCode(); if (name != null) { final String cs = id.getCodeSpace(); diff --git a/src/main/java/org/kortforsyningen/proj/Proj.java b/src/main/java/org/kortforsyningen/proj/Proj.java index b7e5ffa..a02deb0 100644 --- a/src/main/java/org/kortforsyningen/proj/Proj.java +++ b/src/main/java/org/kortforsyningen/proj/Proj.java @@ -24,8 +24,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.logging.Level; -import java.util.logging.Logger; import org.opengis.util.Factory; import org.opengis.util.FactoryException; import org.opengis.geometry.DirectPosition; @@ -76,20 +74,20 @@ private Proj() { * @return the PROJ release string, or an empty value if the native library has not been found. */ public static Optional version() { - final Level level; + final System.Logger.Level level; final LinkageError error; try { return Optional.of(NativeResource.version()); } catch (UnsatisfiedLinkError | NoSuchFieldError e) { // Thrown the first time that we try to use the library. - level = Level.SEVERE; + level = System.Logger.Level.ERROR; error = e; } catch (NoClassDefFoundError e) { // Thrown on attempts after the first one if the exception was not caught. - level = Level.FINER; + level = System.Logger.Level.TRACE; error = e; } - Logger.getLogger(NativeResource.LOGGER_NAME).log(level, "Can not link PROJ native library.", error); + System.getLogger(NativeResource.LOGGER_NAME).log(level, "Can not link PROJ native library.", error); return Optional.empty(); } diff --git a/src/main/java/org/kortforsyningen/proj/SimpleAccuracy.java b/src/main/java/org/kortforsyningen/proj/SimpleAccuracy.java index 5486401..b2f600a 100644 --- a/src/main/java/org/kortforsyningen/proj/SimpleAccuracy.java +++ b/src/main/java/org/kortforsyningen/proj/SimpleAccuracy.java @@ -21,11 +21,9 @@ */ package org.kortforsyningen.proj; -import java.util.Date; import java.util.Collection; import java.util.Collections; import java.io.Serializable; -import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.quality.ConformanceResult; import org.opengis.metadata.quality.EvaluationMethodType; @@ -38,7 +36,7 @@ * A {@link PositionalAccuracy} containing only a description as a character string. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class SimpleAccuracy implements PositionalAccuracy, ConformanceResult, Serializable { @@ -61,26 +59,6 @@ final class SimpleAccuracy implements PositionalAccuracy, ConformanceResult, Ser this.result = result; } - /** - * Returns the name of the test applied to the data. - * - * @return name of the test applied to the data. - */ - @Override - public Collection getNamesOfMeasure() { - return Collections.emptySet(); - } - - /** - * Code identifying a registered standard procedure. - * - * @return {@code null}. - */ - @Override - public Identifier getMeasureIdentification() { - return null; - } - /** * Description of the measure being determined. * @@ -102,36 +80,6 @@ public EvaluationMethodType getEvaluationMethodType() { return EvaluationMethodType.INDIRECT; } - /** - * Description of the evaluation method. - * - * @return {@code null}. - */ - @Override - public InternationalString getEvaluationMethodDescription() { - return null; - } - - /** - * Reference to the procedure information. - * - * @return {@code null}. - */ - @Override - public Citation getEvaluationProcedure() { - return null; - } - - /** - * Date on which a data quality measure was applied. - * - * @return empty set. - */ - @Override - public Collection getDates() { - return Collections.emptySet(); - } - /** * Value that describe the accuracy. * diff --git a/src/main/java/org/kortforsyningen/proj/SimpleCitation.java b/src/main/java/org/kortforsyningen/proj/SimpleCitation.java index 51b36ff..2236ab0 100644 --- a/src/main/java/org/kortforsyningen/proj/SimpleCitation.java +++ b/src/main/java/org/kortforsyningen/proj/SimpleCitation.java @@ -21,18 +21,10 @@ */ package org.kortforsyningen.proj; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; import java.util.Locale; import java.util.Objects; import org.opengis.util.InternationalString; -import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; -import org.opengis.metadata.citation.CitationDate; -import org.opengis.metadata.citation.PresentationForm; -import org.opengis.metadata.citation.ResponsibleParty; -import org.opengis.metadata.citation.Series; /** @@ -44,7 +36,7 @@ * about the value represented by the citation or the international string.

* * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ class SimpleCitation implements Citation, InternationalString { @@ -165,131 +157,6 @@ public InternationalString getTitle() { return this; } - /** - * Short names or other language names by which the cited information is known. - * This implementation has none. - * - * @return an empty set. - */ - @Override - public Collection getAlternateTitles() { - return Collections.emptySet(); - } - - /** - * Common title with holdings note. This implementation has none. - * - * @return null. - */ - @Override - @Deprecated - public InternationalString getCollectiveTitle() { - return null; - } - - /** - * Reference dates for the cited resource. This implementation has none. - * - * @return an empty set. - */ - @Override - public Collection getDates() { - return Collections.emptySet(); - } - - /** - * Version of the cited resource. - * - * @return default to null. - */ - @Override - public InternationalString getEdition() { - return null; - } - - /** - * Date of the edition. This implementation has none. - * - * @return null. - */ - @Override - public Date getEditionDate() { - return null; - } - - /** - * Unique identifier for the resource. This implementation has none. - * - * @return an empty set. - */ - @Override - public Collection getIdentifiers() { - return Collections.emptySet(); - } - - /** - * Role, name, contact and position information for individuals or organizations - * that are responsible for the resource. This implementation has none. - * - * @return an empty set. - */ - @Override - public Collection getCitedResponsibleParties() { - return Collections.emptySet(); - } - - /** - * Mode in which the resource is represented. - * - * @return default to an empty set. - */ - @Override - public Collection getPresentationForms() { - return Collections.emptySet(); - } - - /** - * Information about the series, or aggregate dataset, of which the dataset is a part. - * This implementation has none. - * - * @return null. - */ - @Override - public Series getSeries() { - return null; - } - - /** - * Other information required to complete the citation that is not recorded elsewhere. - * This implementation has none. - * - * @return null. - */ - @Override - public InternationalString getOtherCitationDetails() { - return null; - } - - /** - * International Standard Book Number. This implementation has none. - * - * @return null. - */ - @Override - public String getISBN() { - return null; - } - - /** - * International Standard Serial Number. This implementation has none. - * - * @return null. - */ - @Override - public String getISSN() { - return null; - } - /** * Compares the {@linkplain #getTitle() title} with the string representation * of the given object for order. diff --git a/src/main/java/org/kortforsyningen/proj/SimpleExtent.java b/src/main/java/org/kortforsyningen/proj/SimpleExtent.java index 2de4402..bae95bf 100644 --- a/src/main/java/org/kortforsyningen/proj/SimpleExtent.java +++ b/src/main/java/org/kortforsyningen/proj/SimpleExtent.java @@ -28,9 +28,6 @@ import org.opengis.metadata.extent.Extent; import org.opengis.metadata.extent.GeographicExtent; import org.opengis.metadata.extent.GeographicBoundingBox; -import org.opengis.metadata.extent.TemporalExtent; -import org.opengis.metadata.extent.VerticalExtent; -import org.opengis.util.InternationalString; /** @@ -42,7 +39,7 @@ * The exact datum does not matter since this information is only approximate.

* * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class SimpleExtent implements GeographicBoundingBox, Extent, Serializable { @@ -129,16 +126,6 @@ final class SimpleExtent implements GeographicBoundingBox, Extent, Serializable this(elements[0], elements[1], elements[2], elements[3]); } - /** - * The spatial and temporal extent for the referring object. - * - * @return the spatial and temporal extent, or {@code null} in none. - */ - @Override - public InternationalString getDescription() { - return null; - } - /** * Returns the western-most coordinate of the limit of the dataset extent. * The value is expressed in longitude in decimal degrees (positive east). @@ -207,26 +194,6 @@ public Collection getGeographicElements() { return Collections.singleton(this); } - /** - * Provides vertical component of the extent of the referring object. - * - * @return the vertical extent, or an empty list if none. - */ - @Override - public Collection getVerticalElements() { - return Collections.emptyList(); - } - - /** - * Provides temporal component of the extent of the referring object. - * - * @return the temporal extent, or an empty list if none. - */ - @Override - public Collection getTemporalElements() { - return Collections.emptyList(); - } - /** * Returns {@code true} if the given floating point values are equal. * diff --git a/src/main/java/org/kortforsyningen/proj/Type.java b/src/main/java/org/kortforsyningen/proj/Type.java index 79ed202..887f57c 100644 --- a/src/main/java/org/kortforsyningen/proj/Type.java +++ b/src/main/java/org/kortforsyningen/proj/Type.java @@ -28,7 +28,7 @@ * Identification of object types. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class Type { @@ -74,5 +74,8 @@ private Type() { CONVERSION = 28, TRANSFORMATION = 29, PARAMETER = 30, - PARAMETER_VALUE = 31; + PARAMETER_VALUE = 31, + PARAMETRIC_CS = 32, // From ISO 19111:2019 + PARAMETRIC_CRS = 33, + PARAMETRIC_DATUM = 34; } diff --git a/src/main/java/org/kortforsyningen/proj/UnitOfMeasure.java b/src/main/java/org/kortforsyningen/proj/UnitOfMeasure.java index e99b20a..7aae5dd 100644 --- a/src/main/java/org/kortforsyningen/proj/UnitOfMeasure.java +++ b/src/main/java/org/kortforsyningen/proj/UnitOfMeasure.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.List; import java.util.Objects; -import java.util.Collections; import java.lang.annotation.Native; import javax.measure.Unit; import javax.measure.UnitConverter; @@ -42,7 +41,7 @@ * It is used only as a fallback when no JSR-363 implementation has been found on the classpath. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 2.0 * @since 1.0 */ final class UnitOfMeasure> 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 Class type, final double toSI) { + UnitOfMeasure(final Class type, 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 List getConversionSteps() {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 > Unit create(final Class type, 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 > Unit getUnit(final Class type) { + 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 > QuantityFactory getQuantityFactory(Class type) { + 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