This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 0a7d84270a [CALCITE-5417] Upgrade Proj4J from 1.1.5 to 1.2.2, and
restore it as an included dependency
0a7d84270a is described below
commit 0a7d84270a0e23c1631a2732d41c1a0dd71527f2
Author: Julian Hyde <[email protected]>
AuthorDate: Sat Dec 10 16:57:44 2022 -0800
[CALCITE-5417] Upgrade Proj4J from 1.1.5 to 1.2.2, and restore it as an
included dependency
In [CALCITE-5399] we removed Proj4J as a dependency due to
licensing issues with the EPSG data set. In this change we
upgrade Proj4J to version 1.2.2, which no longer includes
the EPSG data set and therefore can be distributed under the
Apache license.
This change mostly consists of a reversal of [CALCITE-5399],
but also upgrades Proj4J.
---
bom/build.gradle.kts | 1 +
core/build.gradle.kts | 10 +++++-----
.../main/java/org/apache/calcite/runtime/CalciteResource.java | 3 +++
.../java/org/apache/calcite/runtime/ProjectionTransformer.java | 8 --------
.../java/org/apache/calcite/runtime/SpatialTypeFunctions.java | 10 +++++++---
.../org/apache/calcite/runtime/CalciteResource.properties | 1 +
gradle.properties | 2 +-
site/_docs/howto.md | 2 --
site/_docs/reference.md | 10 ++++------
site/_docs/spatial.md | 9 ---------
10 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts
index 438b8b15a2..670afb5ce1 100644
--- a/bom/build.gradle.kts
+++ b/bom/build.gradle.kts
@@ -58,6 +58,7 @@ dependencies {
apiv("org.locationtech.jts:jts-core")
apiv("org.locationtech.jts.io:jts-io-common")
apiv("org.locationtech.proj4j:proj4j")
+ apiv("org.locationtech.proj4j:proj4j-epsg", "proj4j")
apiv("com.fasterxml.jackson.core:jackson-databind")
apiv("com.github.kstyrc:embedded-redis")
apiv("com.github.stephenc.jcip:jcip-annotations")
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index 2a5a6eb365..a447f25c48 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -48,11 +48,7 @@ dependencies {
api("org.locationtech.jts:jts-core")
api("org.locationtech.jts.io:jts-io-common")
-
- // Due to restricting terms of use, we cannot include Proj4J as an API
dependency.
- compileOnly("org.locationtech.proj4j:proj4j")
- testRuntimeOnly("org.locationtech.proj4j:proj4j")
-
+ api("org.locationtech.proj4j:proj4j")
api("com.fasterxml.jackson.core:jackson-annotations")
api("com.google.errorprone:error_prone_annotations")
api("com.google.guava:guava")
@@ -102,6 +98,10 @@ dependencies {
testImplementation(kotlin("stdlib-jdk8"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit5"))
+
+ // proj4j-epsg must not be converted to 'implementation' due to its license
+ testRuntimeOnly("org.locationtech.proj4j:proj4j-epsg")
+
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
}
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
index 3a6b5ffbb5..3f7df4cfd9 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
@@ -66,6 +66,9 @@ public interface CalciteResource {
@BaseMessage("Geo-spatial extensions and the GEOMETRY data type are not
enabled")
ExInst<SqlValidatorException> geometryDisabled();
+ @BaseMessage("Proj4J EPSG is missing from the classpath; to resolve this
problem, download the EPSG data set and agree to its terms of use")
+ ExInst<CalciteException> proj4jEpsgIsMissing();
+
@BaseMessage("Illegal INTERVAL literal {0}; at {1}")
@Property(name = "SQLSTATE", value = "42000")
ExInst<CalciteException> illegalIntervalLiteral(String a0, String a1);
diff --git
a/core/src/main/java/org/apache/calcite/runtime/ProjectionTransformer.java
b/core/src/main/java/org/apache/calcite/runtime/ProjectionTransformer.java
index f199ebeb50..825d5e7de1 100644
--- a/core/src/main/java/org/apache/calcite/runtime/ProjectionTransformer.java
+++ b/core/src/main/java/org/apache/calcite/runtime/ProjectionTransformer.java
@@ -40,14 +40,6 @@ import java.util.stream.Stream;
/**
* Transforms the projection of a geometry.
- *
- * This class uses Proj4J to transform the projection of a geometry
- * and should not be used beyond the scope of the Spatial Type Extensions.
- * Proj4J is released under the Apache License 2.0, however, it also uses the
EPSG dataset,
- * which has restricting <a href="https://epsg.org/terms-of-use.html">terms of
use</a>.
- * As a result, Proj4J is not suitable for inclusion in Apache Calcite
- * and this class will throw {@code ClassNotFoundException}s
- * if Proj4J is not added to the classpath by the user.
*/
public class ProjectionTransformer extends GeometryTransformer {
diff --git
a/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
b/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
index b8242f406e..35478bbe2b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
@@ -81,6 +81,7 @@ import static
org.apache.calcite.runtime.SpatialTypeUtils.fromGeoJson;
import static org.apache.calcite.runtime.SpatialTypeUtils.fromGml;
import static org.apache.calcite.runtime.SpatialTypeUtils.fromWkb;
import static org.apache.calcite.runtime.SpatialTypeUtils.fromWkt;
+import static org.apache.calcite.util.Static.RESOURCE;
/**
* Helper methods to implement spatial type (ST) functions in generated code.
@@ -1201,9 +1202,12 @@ public class SpatialTypeFunctions {
* {@code srid}.
*/
public static Geometry ST_Transform(Geometry geom, int srid) {
- ProjectionTransformer projectionTransformer =
- new ProjectionTransformer(geom.getSRID(), srid);
- return projectionTransformer.transform(geom);
+ try {
+ ProjectionTransformer projectionTransformer = new
ProjectionTransformer(geom.getSRID(), srid);
+ return projectionTransformer.transform(geom);
+ } catch (IllegalStateException e) {
+ throw RESOURCE.proj4jEpsgIsMissing().ex();
+ }
}
/**
diff --git
a/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
b/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
index 77d74c10b2..86aad977e9 100644
---
a/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
+++
b/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
@@ -30,6 +30,7 @@ IdentifierTooLong=Length of identifier ''{0}'' must be less
than or equal to {1,
BadFormat=not in format ''{0}''
BetweenWithoutAnd=BETWEEN operator has no terminating AND
GeometryDisabled=Geo-spatial extensions and the GEOMETRY data type are not
enabled
+Proj4jEpsgIsMissing=Proj4J EPSG is missing from the classpath; to resolve this
problem, download the EPSG data set and agree to its terms of use
IllegalIntervalLiteral=Illegal INTERVAL literal {0}; at {1}
IllegalMinusDate=Illegal expression. Was expecting "(DATETIME - DATETIME)
INTERVALQUALIFIER"
IllegalOverlaps=Illegal overlaps expression. Was expecting expression on the
form "(DATETIME, EXPRESSION) OVERLAPS (DATETIME, EXPRESSION)"
diff --git a/gradle.properties b/gradle.properties
index b8de08d7be..e5b2863be0 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -98,7 +98,7 @@ elasticsearch.version=7.10.2
embedded-redis.version=0.6
jts-core.version=1.19.0
jts-io-common.version=1.19.0
-proj4j.version=1.1.5
+proj4j.version=1.2.2
foodmart-data-hsqldb.version=0.5
foodmart-data-json.version=0.4
foodmart-queries.version=0.4.1
diff --git a/site/_docs/howto.md b/site/_docs/howto.md
index a3833997a1..921a962ce9 100644
--- a/site/_docs/howto.md
+++ b/site/_docs/howto.md
@@ -841,8 +841,6 @@ your key to the keyservers used by Nexus, see above.
that the `META-INF` directory contains `LICENSE`,
`NOTICE`
* Check PGP, per [this](https://httpd.apache.org/dev/verification.html)
-* Check that Proj4J is not among the api and implementation dependencies,
- as the EPSG database is not redistributable.
Verify the staged artifacts in the Nexus repository:
diff --git a/site/_docs/reference.md b/site/_docs/reference.md
index f51badec51..423fd338c3 100644
--- a/site/_docs/reference.md
+++ b/site/_docs/reference.md
@@ -2438,12 +2438,10 @@ Not implemented:
#### Geometry projection functions
-Projection functions rely on Proj4J to transform the geometries.
-Proj4J is released under the Apache License 2.0, however, it also uses the
EPSG dataset,
-which has restricting [terms of use](https://epsg.org/terms-of-use.html).
-As a result, Proj4J is not suitable for inclusion in Apache Calcite
-and some of these functions may throw `ClassNotFoundException`s.
-Users can still use these functions by including Proj4J in their classpath.
+The EPSG dataset is released separately from Proj4J due
+to its restrictive [terms of use](https://epsg.org/terms-of-use.html).
+In order to use the projection functions in Apache Calcite,
+users must include the EPSG dataset in their dependencies.
| C | Operator syntax | Description
|:- |:-------------------- |:-----------
diff --git a/site/_docs/spatial.md b/site/_docs/spatial.md
index 2fe588e789..d0b2ec85d4 100644
--- a/site/_docs/spatial.md
+++ b/site/_docs/spatial.md
@@ -148,15 +148,6 @@ These rewrites are worth performing because they are much
quicker to apply,
and often allow range scans on the Hilbert index.
But for safety, Calcite applies the original predicate, to remove false
positives.
-## Limitations
-
-Some spatial functions rely on Proj4J to transform the projection of spatial
objects.
-Proj4J is released under the Apache License 2.0, however, it also uses the
EPSG dataset,
-which has restricting [terms of use](https://epsg.org/terms-of-use.html).
-As a result, Proj4J is not suitable for inclusion in Apache Calcite
-and these functions will throw `ClassNotFoundException`s.
-Users can still use these functions by including Proj4J in their classpath.
-
## Acknowledgements
Calcite's OpenGIS implementation uses the