Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geoapi 4.0 #34

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
27 changes: 23 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<groupId>org.kortforsyningen</groupId>
<artifactId>proj</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<name>PROJ bindings</name>
<url>https://github.com/Kortforsyningen/PROJ-JNI</url>
<description>
Expand Down Expand Up @@ -73,12 +73,12 @@
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi</artifactId>
<version>3.0.1</version>
<version>4.0-M12</version>
</dependency>
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi-conformance</artifactId>
<version>3.0.1</version>
<version>4.0-M12</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -96,11 +96,13 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>8</release>
<release>11</release>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<useIncrementalCompilation>false</useIncrementalCompilation>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xdoclint:all</arg>
<arg>--doclint-format</arg> <arg>html5</arg>
<arg>-h</arg> <arg>${project.build.sourceDirectory}/../cpp</arg>
</compilerArgs>
Expand Down Expand Up @@ -210,4 +212,21 @@
</plugin>
</plugins>
</build>


<!--
The following repository is temporary. We use that only for getting GeoAPI 4.0 milestone.
We should not release a PROJ-JNI based on this GeoAPI version, and we should delete this
block after a formal GeoAPI 4.0 release become available.
-->
<repositories>
<repository>
<id>geotk</id>
<name>Geotk repository</name>
<url>http://maven.geotoolkit.org</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
2 changes: 1 addition & 1 deletion src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 32 additions & 6 deletions src/main/cpp/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;");
}
}
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -600,6 +605,7 @@ again: switch (type) {
else if (dynamic_cast<GeographicCRS *>(rp)) type = org_kortforsyningen_proj_Type_GEOGRAPHIC_CRS;
else if (dynamic_cast<VerticalCRS *>(rp)) type = org_kortforsyningen_proj_Type_VERTICAL_CRS;
else if (dynamic_cast<TemporalCRS *>(rp)) type = org_kortforsyningen_proj_Type_TEMPORAL_CRS;
else if (dynamic_cast<ParametricCRS *>(rp)) type = org_kortforsyningen_proj_Type_PARAMETRIC_CRS;
else if (dynamic_cast<EngineeringCRS *>(rp)) type = org_kortforsyningen_proj_Type_ENGINEERING_CRS;
else {
GeodeticCRS *gc = dynamic_cast<GeodeticCRS*>(rp);
Expand All @@ -618,12 +624,14 @@ again: switch (type) {
else if (dynamic_cast<EllipsoidalCS *>(rp)) type = org_kortforsyningen_proj_Type_ELLIPSOIDAL_CS;
else if (dynamic_cast<VerticalCS *>(rp)) type = org_kortforsyningen_proj_Type_VERTICAL_CS;
else if (dynamic_cast<TemporalCS *>(rp)) type = org_kortforsyningen_proj_Type_TEMPORAL_CS;
else if (dynamic_cast<ParametricCS *>(rp)) type = org_kortforsyningen_proj_Type_PARAMETRIC_CS;
break;
}
case org_kortforsyningen_proj_Type_DATUM: {
if (dynamic_cast<GeodeticReferenceFrame *>(rp)) type = org_kortforsyningen_proj_Type_GEODETIC_REFERENCE_FRAME;
else if (dynamic_cast<VerticalReferenceFrame *>(rp)) type = org_kortforsyningen_proj_Type_VERTICAL_REFERENCE_FRAME;
else if (dynamic_cast<TemporalDatum *>(rp)) type = org_kortforsyningen_proj_Type_TEMPORAL_DATUM;
else if (dynamic_cast<ParametricDatum *>(rp)) type = org_kortforsyningen_proj_Type_PARAMETRIC_DATUM;
else if (dynamic_cast<EngineeringDatum *>(rp)) type = org_kortforsyningen_proj_Type_ENGINEERING_DATUM;
break;
}
Expand Down Expand Up @@ -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<CoordinateSystemAxis>(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: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<ParametricDatum>(env, components, 0);
ParametricCSNNPtr cs = get_component<ParametricCS> (env, components, 1);
object = ParametricCRS::create(propertyMap, datum, cs).as_nullable();
break;
}
case org_kortforsyningen_proj_Type_ENGINEERING_CRS: {
EngineeringDatumNNPtr datum = get_component<EngineeringDatum>(env, components, 0);
CoordinateSystemNNPtr cs = get_component<CoordinateSystem>(env, components, 1);
Expand Down Expand Up @@ -2379,13 +2402,15 @@ 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.
case org_kortforsyningen_proj_Type_SPHERICAL_CS: // No specific function - use generic one.
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;
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/main/cpp/org_kortforsyningen_proj_Type.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion src/main/java/org/kortforsyningen/proj/AuthorityFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* same thread.</p>
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.0
* @version 2.0
* @since 1.0
*/
final class AuthorityFactory extends NativeResource {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
27 changes: 4 additions & 23 deletions src/main/java/org/kortforsyningen/proj/Axis.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -79,16 +78,9 @@ public AxisDirection getDirection() {
* @return the code list for the given UML identifier.
*/
private static <T extends CodeList<T>> T search(final Class<T> 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);
}

/**
Expand Down Expand Up @@ -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;
}
}
Loading