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

JTS 1.18, GeoTools 25.0 #3437

Merged
merged 5 commits into from
Dec 2, 2021
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Disambiguate withBufferTileFocalMethods implicit preserving bin compatibility [#3422](https://github.com/locationtech/geotrellis/pull/3422)
- Specialize Grid for Int and Long [#3428](https://github.com/locationtech/geotrellis/pull/3428)
- Move GeoWave and GeoMesa subproject to their own repositories [#3439](https://github.com/locationtech/geotrellis/pull/3439)
- Use JTS 1.18, GeoTools 25.0 [#3437](https://github.com/locationtech/geotrellis/pull/3437)

## [3.6.0] - 2021-04-30

Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sbt._

object Version {
val geotools = "23.3"
val geotools = "25.0"
val spire = "0.17.0"
val accumulo = "1.9.3"
val cassandra = "3.7.2"
Expand Down Expand Up @@ -72,7 +72,7 @@ object Dependencies {
val scalatest = "org.scalatest" %% "scalatest" % "3.2.5"
val scalacheck = "org.scalacheck" %% "scalacheck" % "1.15.2"
val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0"
val jts = "org.locationtech.jts" % "jts-core" % "1.17.0"
val jts = "org.locationtech.jts" % "jts-core" % "1.18.1"
val proj4j = "org.locationtech.proj4j" % "proj4j" % "1.1.3"
val openCSV = "com.opencsv" % "opencsv" % "5.3"
val spire = "org.typelevel" %% "spire" % Version.spire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ trait Implicits {
Either.catchNonFatal(Try(CRS.fromName(str)) getOrElse CRS.fromString(str)).leftMap(_ => "CRS")
}

implicit val layoutDefinitionEncoder: Encoder[LayoutDefinition] = deriveEncoder
implicit val layoutDefinitionDecoder: Decoder[LayoutDefinition] = deriveDecoder
implicit val layoutDefinitionEncoder: Encoder[LayoutDefinition] = deriveConfiguredEncoder
implicit val layoutDefinitionDecoder: Decoder[LayoutDefinition] = deriveConfiguredDecoder

implicit val layoutSchemeEncoder: Encoder[LayoutScheme] =
Encoder.instance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package object pipeline extends json.Implicits with ast.untyped.Implicits {
}

implicit class withPipelinePrettyPrint(that: Node[_]) {
def prettyPrint: String = that.asJson.asJson.pretty(pipelineJsonPrinter)
def prettyPrint: String = that.asJson.asJson.printWith(pipelineJsonPrinter)
}

implicit class withGetCRS[T <: { def crs: String }](o: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import geotrellis.raster.buffer.{BufferSizes, BufferedTile}
import geotrellis.raster.crop._
import geotrellis.raster.merge._
import geotrellis.raster.prototype._
import geotrellis.raster.reproject._
import geotrellis.raster.reproject.{ReprojectRasterExtent, RasterRegionReproject}
import geotrellis.raster.stitch._
import geotrellis.spark._
import geotrellis.spark.buffer.BufferTilesRDD
import geotrellis.spark.reproject.Reproject
import geotrellis.vector._
import geotrellis.util._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object RDDPolygonalSummary {
val extent: Extent = layout.mapTransform.keyToExtent(spatialKey)
val raster: Raster[T] = Raster(tile, extent)
val result: PolygonalSummaryResult[R] =
raster.polygonalSummary(feature.geom, visitor.getClass.newInstance, options)
raster.polygonalSummary(feature.geom, visitor.getClass.getDeclaredConstructor().newInstance(), options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@echeipesh what is the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#newInstance--

Deprecated. This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException.

(feature.data, Feature(feature.geom, result))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,18 @@ class TileRDDMaskMethodsSpec extends AnyFunSpec with Matchers with TestEnvironme
it ("should be masked by complex multipolygons") {
val cases = Seq(
MultiPolygon(
Polygon(LineString(Seq[(Double,Double)]((29, 15), (110, 15), (110, 96), (29, 15))),
Polygon(LineString(Seq[(Double,Double)]((50, 30), (110, 15), (110, 96), (50, 30))),
LineString(Seq[(Double,Double)]((69, 42), (96, 42), (96, 69), (69, 42)))),
Polygon(LineString(Seq[(Double,Double)]((-77, -78), (46, -78), (46, 45), (-77, -78))),
LineString(Seq[(Double,Double)]((-16, -37), (25, -37), (25, 4), (-16, -37))))),
MultiPolygon(
Polygon(LineString(Seq[(Double,Double)]((-41, -17), (0, -17), (0, 24), (-41, -17))),
LineString(Seq[(Double,Double)]((-21, -4), (-8, -4), (-8, 9), (-21, -4)))),
Polygon(LineString(Seq[(Double,Double)]((-83, -76), (-13, -76), (-13, -6), (-83, -76))),
Polygon(LineString(Seq[(Double,Double)]((-83, -76), (-13, -76), (-13, -20), (-83, -76))),
LineString(Seq[(Double,Double)]((-48, -53), (-25, -53), (-25, -30), (-48, -53)))))
)
cases foreach { multipoly =>
require(multipoly.isValid(), s"Invalid Geom: ${multipoly.toWKT()}")
val masked = rdd.mask(multipoly, options = opts).stitch()
val expected = tile.mask(worldExt, multipoly)
masked.tile.toArray() shouldEqual expected.toArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object HdfsUtils {
if(!fs.exists(path))
fs.mkdirs(path)
else
if(!fs.isDirectory(path)) sys.error(s"Directory $path does not exist on ${fs.getUri}")
if(!fs.getFileStatus(path).isDirectory()) sys.error(s"Directory $path does not exist on ${fs.getUri}")
}

def deletePath(path: Path, conf: Configuration): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HilbertSpaceTimeKeyIndex(
val minKey = keyBounds.minKey.spatialKey

@transient lazy val chc = {
val dimensionSpec = new MultiDimensionalSpec(List(xResolution, yResolution, temporalResolution).map(new java.lang.Integer(_)).asJava)
val dimensionSpec = new MultiDimensionalSpec(List(xResolution, yResolution, temporalResolution).map(java.lang.Integer.valueOf(_)).asJava)
new CompactHilbertCurve(dimensionSpec)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HilbertSpatialKeyIndex(val keyBounds: KeyBounds[SpatialKey], val xResoluti
val minKey = keyBounds.minKey

@transient lazy val chc = {
val dimensionSpec = new MultiDimensionalSpec(List(xResolution, yResolution).map(new java.lang.Integer(_)).asJava)
val dimensionSpec = new MultiDimensionalSpec(List(xResolution, yResolution).map(java.lang.Integer.valueOf(_)).asJava)
new CompactHilbertCurve(dimensionSpec)
}

Expand Down
4 changes: 4 additions & 0 deletions vector/src/main/scala/geotrellis/vector/Results.scala
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ object MultiPointMultiLineStringUnionResult {
geom match {
case g: Geometry if g.isEmpty => NoResult
case l: LineString => LineStringResult(l)
case pt: Point => PointResult(pt)
case mp: MultiPoint => MultiPointResult(mp)
case ml: MultiLineString => MultiLineStringResult(ml)
case gc: GeometryCollection => GeometryCollectionResult(gc)
Expand Down Expand Up @@ -331,6 +332,7 @@ object MultiPointMultiPolygonUnionResult {
geom match {
case g: Geometry if g.isEmpty => NoResult
case p: Polygon => PolygonResult(p)
case pt: Point => PointResult(pt)
case mpt: MultiPoint => MultiPointResult(mpt)
case mp: MultiPolygon => MultiPolygonResult(mp)
case gc: GeometryCollection => GeometryCollectionResult(gc)
Expand Down Expand Up @@ -780,6 +782,8 @@ case class PointResult(geom: Point) extends GeometryResult
with MultiLineStringMultiLineStringDifferenceResult
with MultiPointMultiPointDifferenceResult
with MultiPolygonMultiPolygonDifferenceResult
with MultiPointMultiPolygonUnionResult
with MultiPointMultiLineStringUnionResult
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paging @jpolchlo -- seems like JTS got a bit better at simplifying the results of union. I was pretty mechanical about this, could use your 👀 as the vector master.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to look. Got any specific concerns? These Result types are pretty labyrinthine.

with PointOrNoResult {
def toGeometry(): Option[Geometry] = Some(geom)
}
Expand Down
6 changes: 3 additions & 3 deletions vector/src/test/scala/geotrellis/vector/MultiPointSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class MultiPointSpec extends AnyFunSpec with Matchers {
it ("should union with an empty MultiPoint and return a MultiPointResult") {
val mp1 = MultiPoint(Point(1,1))
val mp2 = MultiPoint.EMPTY
mp1 | mp2 should be (MultiPointResult(Seq(Point(1,1)).toMultiPoint))
mp1 | mp2 shouldBe PointResult(Point(1,1))
}

it ("should union with a MultiPoint and return a PointResult") {
Expand Down Expand Up @@ -158,7 +158,7 @@ class MultiPointSpec extends AnyFunSpec with Matchers {
it ("should union with an empty MultiLineString and return a MultiPointResult") {
val mp = MultiPoint(Seq(Point(1,1)))
val ml = MultiLineString(Seq())
mp | ml should be (MultiPointResult(Seq(Point(1,1)).toMultiPoint))
mp | ml shouldBe PointResult(Point(1,1))
}

it ("should union with a MultiLineString and return a MultiPoint") {
Expand Down Expand Up @@ -188,7 +188,7 @@ class MultiPointSpec extends AnyFunSpec with Matchers {
it ("should union with an empty MultiPolygon and return a MultiPointResult") {
val mpt = MultiPoint(Seq(Point(1,1)))
val mp = MultiPolygon(Seq())
mpt | mp should be (MultiPointResult(Seq(Point(1,1)).toMultiPoint))
mpt | mp shouldBe PointResult(Point(1,1))
}

it ("should union with a MultiPolygon and return a PolygonResult") {
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "3.6.1-SNAPSHOT"
ThisBuild / version := "3.7.0-SNAPSHOT"