From 6df30b93a8d70e0014b57f56f92344c751dbeffe Mon Sep 17 00:00:00 2001 From: Grigory Date: Sat, 11 May 2024 15:22:56 -0400 Subject: [PATCH] Bump GeoTools version up to 31.0 (#3521) * Bump GeoTools version up to 30.x-SNAPSHOT * Move to JDK11 builds only * Bump SBT version up * Exclude log4j out of deps * Bump geotools version up to 30-RC * Update GeoTools up to 31.0 --- .github/docker-compose.yml | 16 ------------- .github/workflows/ci.yml | 10 +++----- CHANGELOG.md | 1 + .../FeatureToSimpleFeatureMethods.scala | 3 +-- .../geotools/GeometryToSimpleFeature.scala | 5 ++-- .../GeometryToSimpleFeatureMethods.scala | 2 +- .../geotools/GridCoverage2DConverters.scala | 23 +++++++++---------- .../geotools/SimpleFeatureToFeature.scala | 2 +- .../SimpleFeatureToFeatureMethods.scala | 3 +-- .../SimpleFeatureToGeometryMethods.scala | 2 +- .../scala/geotrellis/geotools/package.scala | 2 +- project/Dependencies.scala | 3 +-- project/Settings.scala | 17 +++++++------- project/build.properties | 2 +- .../shapefile/ShapeFileReader.scala | 3 +-- 15 files changed, 35 insertions(+), 59 deletions(-) diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index be6b70a05a..3657810e35 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -30,22 +30,6 @@ services: - HBASE_DOCKER_HOSTNAME=localhost network_mode: host - test-jdk8: - image: quay.io/azavea/openjdk-gdal:3.1-jdk8-slim - working_dir: /usr/local/src - command: ./sbt ++$SCALA_VERSION test - environment: - - CI - - SCALA_VERSION - depends_on: - - nginx - - minio - - cassandra - - hbase - volumes: - - ./../:/usr/local/src - network_mode: host - test-jdk11: image: quay.io/azavea/openjdk-gdal:3.1-jdk11-slim working_dir: /usr/local/src diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e1e2cb1d9..97362b3144 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: scala: ["2.12.18", "2.13.12"] - java: ["8", "11"] + java: ["11"] runs-on: ubuntu-latest env: @@ -32,11 +32,7 @@ jobs: - name: run tests run: | - if [[ "$JAVA_VERSION" == "8" ]]; then - docker compose -f .github/docker-compose.yml up test-jdk8 --abort-on-container-exit --exit-code-from test-jdk8 - elif [[ "$JAVA_VERSION" == "11" ]]; then - docker compose -f .github/docker-compose.yml up test-jdk11 --abort-on-container-exit --exit-code-from test-jdk11 - fi + docker compose -f .github/docker-compose.yml up test-jdk11 --abort-on-container-exit --exit-code-from test-jdk11 publish: name: Publish Artifacts @@ -45,7 +41,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - java: [8] + java: [11] distribution: [temurin] runs-on: ${{ matrix.os }} steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 940523b4f3..c8d8271722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Regrid: force crop to avoid going out of memory [#3518](https://github.com/locationtech/geotrellis/pull/3518) - Fix rounding errors/numerical instability in GridExtent and LayoutTileSource [#3520](https://github.com/locationtech/geotrellis/pull/3520) - GeoTrellisPath.parse should preserve unrecognized uri parameters [#3529](https://github.com/locationtech/geotrellis/pull/3529) +- Bump GeoTools version up to 30.x [#3521](https://github.com/locationtech/geotrellis/pull/3521) ## [3.7.0] - 2023-02-26 diff --git a/geotools/src/main/scala/geotrellis/geotools/FeatureToSimpleFeatureMethods.scala b/geotools/src/main/scala/geotrellis/geotools/FeatureToSimpleFeatureMethods.scala index 98265fe2d7..e7be6bbaed 100644 --- a/geotools/src/main/scala/geotrellis/geotools/FeatureToSimpleFeatureMethods.scala +++ b/geotools/src/main/scala/geotrellis/geotools/FeatureToSimpleFeatureMethods.scala @@ -19,8 +19,7 @@ package geotrellis.geotools import geotrellis.proj4.CRS import geotrellis.util.MethodExtensions import geotrellis.vector._ - -import org.opengis.feature.simple.SimpleFeature +import org.geotools.api.feature.simple.SimpleFeature trait FeatureToSimpleFeatureMethods[G <: Geometry, T] extends MethodExtensions[Feature[G, T]] { diff --git a/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeature.scala b/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeature.scala index 2a1c6454e5..6996848df4 100644 --- a/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeature.scala +++ b/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeature.scala @@ -18,9 +18,8 @@ package geotrellis.geotools import geotrellis.vector._ import geotrellis.proj4.CRS - -import org.geotools.feature.simple.{SimpleFeatureTypeBuilder, SimpleFeatureBuilder} -import org.opengis.feature.simple.SimpleFeature +import org.geotools.api.feature.simple.SimpleFeature +import org.geotools.feature.simple.{SimpleFeatureBuilder, SimpleFeatureTypeBuilder} object GeometryToSimpleFeature { val geometryField = "the_geom" diff --git a/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeatureMethods.scala b/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeatureMethods.scala index ca86c119b1..e02c735e9a 100644 --- a/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeatureMethods.scala +++ b/geotools/src/main/scala/geotrellis/geotools/GeometryToSimpleFeatureMethods.scala @@ -20,7 +20,7 @@ import geotrellis.proj4._ import geotrellis.util.MethodExtensions import geotrellis.vector._ -import org.opengis.feature.simple.SimpleFeature +import org.geotools.api.feature.simple.SimpleFeature trait GeometryToSimpleFeatureMethods[G <: Geometry] extends MethodExtensions[G] { diff --git a/geotools/src/main/scala/geotrellis/geotools/GridCoverage2DConverters.scala b/geotools/src/main/scala/geotrellis/geotools/GridCoverage2DConverters.scala index 6e2d6a3c5b..9b378f66a3 100644 --- a/geotools/src/main/scala/geotrellis/geotools/GridCoverage2DConverters.scala +++ b/geotools/src/main/scala/geotrellis/geotools/GridCoverage2DConverters.scala @@ -20,17 +20,16 @@ import geotrellis.proj4.CRS import geotrellis.raster._ import geotrellis.raster.io.geotiff.util._ import geotrellis.vector.Extent - import it.geosolutions.imageio.utilities.ImageIOUtilities import org.geotools.coverage.Category import org.geotools.coverage.GridSampleDimension import org.geotools.coverage.grid._ -import org.geotools.geometry.Envelope2D import org.geotools.referencing.{CRS => GeoToolsCRS} import org.geotools.coverage.util.CoverageUtilities import org.geotools.util.NumberRange -import org.opengis.coverage.SampleDimensionType -import org.opengis.referencing.crs.CoordinateReferenceSystem +import org.geotools.geometry.jts.ReferencedEnvelope +import org.geotools.api.coverage._ +import org.geotools.api.referencing.crs.CoordinateReferenceSystem import spire.syntax.cfor._ import java.awt.Color @@ -198,18 +197,18 @@ object GridCoverage2DConverters { } /** - * A function to produce a GeoTools Envelope2D from a Geotrellis + * A function to produce a GeoTools ReferencedEnvelope from a Geotrellis * Extent and CRS. * * @param extent The Geotrellis Extent * @param crs The CRS of the raster * - * @return A GeoTools Envelope2D + * @return A GeoTools ReferencedEnvelope */ - def getEnvelope2D(extent: Extent): Envelope2D = { + def getEnvelope2D(extent: Extent): ReferencedEnvelope = { val Extent(xmin, ymin, xmax, ymax) = extent - new Envelope2D(null, xmin, ymin, (xmax - xmin), (ymax - ymin)) + ReferencedEnvelope.rect(xmin, ymin, xmax - xmin, ymax - ymin, null) } def getGeotoolsCRS(crs: CRS): CoordinateReferenceSystem = { @@ -222,20 +221,20 @@ object GridCoverage2DConverters { } /** - * A function to produce a GeoTools Envelope2D from a Geotrellis + * A function to produce a GeoTools ReferencedEnvelope from a Geotrellis * Extent and CRS. If the CRS cannot be converted, a null GeoTools * CRS is used. * * @param extent The Geotrellis Extent * @param crs The CRS of the raster * - * @return A GeoTools Envelope2D + * @return A GeoTools ReferencedEnvelope */ - def getEnvelope2D(extent: Extent, crs: CRS): Envelope2D = { + def getEnvelope2D(extent: Extent, crs: CRS): ReferencedEnvelope = { val Extent(xmin, ymin, xmax, ymax) = extent val geoToolsCRS = getGeotoolsCRS(crs) - new Envelope2D(geoToolsCRS, xmin, ymin, (xmax - xmin), (ymax - ymin)) + ReferencedEnvelope.rect(xmin, ymin, xmax - xmin, ymax - ymin, geoToolsCRS) } def getValueRange(cellType: CellType): (Double, Double) = diff --git a/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeature.scala b/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeature.scala index 53d69c2e8c..407ebf97f8 100644 --- a/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeature.scala +++ b/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeature.scala @@ -17,7 +17,7 @@ package geotrellis.geotools import geotrellis.vector._ -import org.opengis.feature.simple.SimpleFeature +import org.geotools.api.feature.simple.SimpleFeature import scala.collection._ import scala.collection.JavaConverters._ diff --git a/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeatureMethods.scala b/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeatureMethods.scala index 170ce22d03..c801101199 100644 --- a/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeatureMethods.scala +++ b/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToFeatureMethods.scala @@ -18,8 +18,7 @@ package geotrellis.geotools import geotrellis.util.MethodExtensions import geotrellis.vector._ - -import org.opengis.feature.simple.SimpleFeature +import org.geotools.api.feature.simple.SimpleFeature import scala.reflect.ClassTag diff --git a/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToGeometryMethods.scala b/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToGeometryMethods.scala index 9c60c1d50e..4240f636db 100644 --- a/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToGeometryMethods.scala +++ b/geotools/src/main/scala/geotrellis/geotools/SimpleFeatureToGeometryMethods.scala @@ -19,7 +19,7 @@ package geotrellis.geotools import geotrellis.util.MethodExtensions import geotrellis.vector._ -import org.opengis.feature.simple.SimpleFeature +import org.geotools.api.feature.simple.SimpleFeature import scala.reflect.ClassTag diff --git a/geotools/src/main/scala/geotrellis/geotools/package.scala b/geotools/src/main/scala/geotrellis/geotools/package.scala index 172ee2764f..3ec9597bed 100644 --- a/geotools/src/main/scala/geotrellis/geotools/package.scala +++ b/geotools/src/main/scala/geotrellis/geotools/package.scala @@ -20,8 +20,8 @@ import geotrellis.raster._ import geotrellis.util.MethodExtensions import geotrellis.vector._ +import org.geotools.api.feature.simple.SimpleFeature import org.geotools.coverage.grid.GridCoverage2D -import org.opengis.feature.simple.SimpleFeature package object geotools { implicit class withSinglebandRasterToGridCoverage2DMethods(val self: Raster[Tile]) extends MethodExtensions[Raster[Tile]] diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 2d7f972960..506486b8d5 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -17,7 +17,7 @@ import sbt._ object Version { - val geotools = "25.4" + val geotools = "31.0" val spire = "0.17.0" val accumulo = "1.10.4" val cassandra = "4.17.0" @@ -106,7 +106,6 @@ object Dependencies { val geotoolsGeoTiff = "org.geotools" % "gt-geotiff" % Version.geotools val geotoolsShapefile = "org.geotools" % "gt-shapefile" % Version.geotools val geotoolsMetadata = "org.geotools" % "gt-metadata" % Version.geotools - val geotoolsOpengis = "org.geotools" % "gt-opengis" % Version.geotools val scalaArm = "com.jsuereth" %% "scala-arm" % "2.0" diff --git a/project/Settings.scala b/project/Settings.scala index 78982dcf15..56fa498531 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -32,13 +32,14 @@ object Settings { val apacheSnapshots = "apache-snapshots" at "https://repository.apache.org/content/repositories/snapshots/" val eclipseReleases = "eclipse-releases" at "https://repo.eclipse.org/content/groups/releases" val osgeoReleases = "osgeo-releases" at "https://repo.osgeo.org/repository/release/" + val osgeoSnapshots = "osgeo-snapshots" at "https://repo.osgeo.org/repository/snapshot/" val geosolutions = "geosolutions" at "https://maven.geo-solutions.it/" val jitpack = "jitpack" at "https://jitpack.io" // for https://github.com/everit-org/json-schema val ivy2Local = Resolver.file("local", file(Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns) val mavenLocal = Resolver.mavenLocal val maven = DefaultMavenRepository val local = Seq(ivy2Local, mavenLocal) - val external = Seq(osgeoReleases, maven, eclipseReleases, geosolutions, jitpack, apacheSnapshots) + val external = Seq(osgeoReleases, maven, eclipseReleases, geosolutions, jitpack, apacheSnapshots, osgeoSnapshots) val all = external ++ local } @@ -289,8 +290,7 @@ object Settings { geotoolsHsql, geotoolsMain, geotoolsReferencing, - geotoolsMetadata, - geotoolsOpengis + geotoolsMetadata ).map(_ excludeAll(excludedDependencies: _*)), libraryDependencies ++= Seq( unitApi, @@ -313,11 +313,13 @@ object Settings { lazy val hbase = Seq( name := "geotrellis-hbase", - libraryDependencies += + libraryDependencies ++= Seq( hbaseMapReduce exclude("javax.servlet", "servlet-api") - exclude("org.mortbay.jetty", "servlet-api-2.5"), - libraryDependencies += jacksonCoreAsl, + exclude("org.mortbay.jetty", "servlet-api-2.5") + exclude("log4j", "log4j"), // CVE-2021-4104, CVE-2020-8908 + jacksonCoreAsl + ), console / initialCommands := """ import geotrellis.raster._ @@ -465,7 +467,6 @@ object Settings { name := "geotrellis-shapefile", libraryDependencies ++= Seq( geotoolsMain, - geotoolsOpengis, geotoolsShapefile ).map(_ excludeAll(excludedDependencies: _*)), libraryDependencies ++= Seq(scalatest % Test) ++ worksWithDependencies, @@ -611,7 +612,7 @@ object Settings { apacheIO, scaffeine, caffeine, - uzaygezenCore exclude("log4j", "log4j"), + uzaygezenCore exclude("log4j", "log4j"), // CVE-2021-4104, CVE-2020-8908 scalaXml, apacheLang3, fs2("core").value, diff --git a/project/build.properties b/project/build.properties index e8a1e246e8..081fdbbc76 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.7 +sbt.version=1.10.0 diff --git a/shapefile/src/main/scala/geotrellis/shapefile/ShapeFileReader.scala b/shapefile/src/main/scala/geotrellis/shapefile/ShapeFileReader.scala index 33fca32500..5749895d6c 100644 --- a/shapefile/src/main/scala/geotrellis/shapefile/ShapeFileReader.scala +++ b/shapefile/src/main/scala/geotrellis/shapefile/ShapeFileReader.scala @@ -17,9 +17,8 @@ package geotrellis.shapefile import geotrellis.vector._ - +import org.geotools.api.feature.simple.SimpleFeature import org.geotools.data.simple._ -import org.opengis.feature.simple._ import org.geotools.data.shapefile._ import java.net.URL