Skip to content

Commit a16ddb4

Browse files
committed
Incremental updates toward GT 3.0 compatibility.
1 parent 56e04b9 commit a16ddb4

File tree

9 files changed

+68
-13
lines changed

9 files changed

+68
-13
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* This software is licensed under the Apache 2 license, quoted below.
3+
*
4+
* Copyright 2019 Astraea, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
7+
* use this file except in compliance with the License. You may obtain a copy of
8+
* the License at
9+
*
10+
* [http://www.apache.org/licenses/LICENSE-2.0]
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
* License for the specific language governing permissions and limitations under
16+
* the License.
17+
*
18+
* SPDX-License-Identifier: Apache-2.0
19+
*
20+
*/
21+
22+
package org.locationtech.rasterframes.tiles
23+
import geotrellis.raster.{ArrayTile, DelegatingTile, Tile}
24+
25+
/**
26+
* Workaround for case where `combine` is invoked on two delegating tiles.
27+
* @since 8/22/18
28+
*/
29+
trait FixedDelegatingTile extends DelegatingTile {
30+
override def combine(r2: Tile)(f: (Int, Int) Int): Tile = (delegate, r2) match {
31+
case (del: ArrayTile, r2: DelegatingTile) del.combine(r2.toArrayTile())(f)
32+
case _ delegate.combine(r2)(f)
33+
}
34+
35+
override def combineDouble(r2: Tile)(f: (Double, Double) Double): Tile = (delegate, r2) match {
36+
case (del: ArrayTile, r2: DelegatingTile) del.combineDouble(r2.toArrayTile())(f)
37+
case _ delegate.combineDouble(r2)(f)
38+
}
39+
}

core/src/main/scala/org/locationtech/rasterframes/tiles/InternalRowTile.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ package org.locationtech.rasterframes.tiles
2323

2424
import java.nio.ByteBuffer
2525

26-
import org.locationtech.rasterframes.encoders.CatalystSerializer.CatalystIO
2726
import geotrellis.raster._
2827
import org.apache.spark.sql.catalyst.InternalRow
28+
import org.locationtech.rasterframes.encoders.CatalystSerializer.CatalystIO
2929
import org.locationtech.rasterframes.model.{Cells, TileDataContext}
3030

3131
/**
@@ -34,7 +34,7 @@ import org.locationtech.rasterframes.model.{Cells, TileDataContext}
3434
*
3535
* @since 11/29/17
3636
*/
37-
class InternalRowTile(val mem: InternalRow) extends DelegatingTile {
37+
class InternalRowTile(val mem: InternalRow) extends FixedDelegatingTile {
3838
import InternalRowTile._
3939

4040
override def toArrayTile(): ArrayTile = realizedTile.toArrayTile()

core/src/main/scala/org/locationtech/rasterframes/tiles/ProjectedRasterTile.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package org.locationtech.rasterframes.tiles
2323

2424
import geotrellis.proj4.CRS
2525
import geotrellis.raster.io.geotiff.SinglebandGeoTiff
26-
import geotrellis.raster.{CellType, DelegatingTile, ProjectedRaster, Tile}
26+
import geotrellis.raster.{CellType, ProjectedRaster, Tile}
2727
import geotrellis.vector.{Extent, ProjectedExtent}
2828
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
2929
import org.apache.spark.sql.rf.TileUDT
@@ -40,7 +40,7 @@ import org.locationtech.rasterframes.ref.RasterRef.RasterRefTile
4040
*
4141
* @since 9/5/18
4242
*/
43-
trait ProjectedRasterTile extends DelegatingTile with ProjectedRasterLike {
43+
trait ProjectedRasterTile extends FixedDelegatingTile with ProjectedRasterLike {
4444
def extent: Extent
4545
def crs: CRS
4646
def projectedExtent: ProjectedExtent = ProjectedExtent(extent, crs)

core/src/main/scala/org/locationtech/rasterframes/tiles/ShowableTile.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
package org.locationtech.rasterframes.tiles
2323
import org.locationtech.rasterframes._
24-
import geotrellis.raster.{DelegatingTile, Tile, isNoData}
24+
import geotrellis.raster.{Tile, isNoData}
2525

26-
class ShowableTile(val delegate: Tile) extends DelegatingTile {
26+
class ShowableTile(val delegate: Tile) extends FixedDelegatingTile {
2727
override def equals(obj: Any): Boolean = obj match {
2828
case st: ShowableTile => delegate.equals(st.delegate)
2929
case o => delegate.equals(o)

core/src/test/resources/log4j.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ log4j.logger.org.apache.parquet.hadoop.ParquetRecordReader=OFF
4545
log4j.logger.org.apache.hadoop.hive.metastore.RetryingHMSHandler=FATAL
4646
log4j.logger.org.apache.hadoop.hive.ql.exec.FunctionRegistry=ERROR
4747

48-
log4j.logger.org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator=ERROR
48+
log4j.logger.org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator=ERROR
49+
log4j.logger.org.apache.spark.sql.execution.WholeStageCodegenExec=ERROR

core/src/test/scala/org/locationtech/rasterframes/GeometryFunctionsSpec.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import geotrellis.proj4.{LatLng, Sinusoidal, WebMercator}
2525
import geotrellis.raster.Dimensions
2626
import geotrellis.vector._
2727
import org.locationtech.jts.geom.{Coordinate, GeometryFactory}
28-
import spray.json.JsNumber
2928

3029
/**
3130
* Test rig for operations providing interop with JTS types.

core/src/test/scala/org/locationtech/rasterframes/RasterJoinSpec.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ package org.locationtech.rasterframes
2424
import geotrellis.raster.resample.Bilinear
2525
import geotrellis.raster.testkit.RasterMatchers
2626
import geotrellis.raster.{IntConstantNoDataCellType, Raster, Tile}
27+
import geotrellis.vector.Extent
28+
import org.apache.spark.SparkConf
2729
import org.apache.spark.sql.functions._
2830
import org.locationtech.rasterframes.expressions.aggregates.TileRasterizerAggregate
2931
import org.locationtech.rasterframes.expressions.aggregates.TileRasterizerAggregate.ProjectedRasterDefinition
@@ -74,14 +76,16 @@ class RasterJoinSpec extends TestEnvironment with TestData with RasterMatchers {
7476
}
7577

7678
it("should join same scene in two projections, same tile size") {
77-
7879
// b4warpedRf source data is gdal warped b4nativeRf data; join them together.
7980
val joined = b4nativeRf.rasterJoin(b4warpedRf)
8081
// create a Raster from tile2 which should be almost equal to b4nativeTif
81-
val result = joined.agg(TileRasterizerAggregate(
82+
val agg = joined.agg(TileRasterizerAggregate(
8283
ProjectedRasterDefinition(b4nativeTif.cols, b4nativeTif.rows, b4nativeTif.cellType, b4nativeTif.crs, b4nativeTif.extent, Bilinear),
8384
$"crs", $"extent", $"tile2") as "raster"
84-
).select(col("raster").as[Raster[Tile]]).first()
85+
).select(col("raster").as[Raster[Tile]])
86+
87+
agg.printSchema()
88+
val result = agg.first()
8589

8690
result.extent shouldBe b4nativeTif.extent
8791

@@ -165,4 +169,6 @@ class RasterJoinSpec extends TestEnvironment with TestData with RasterMatchers {
165169
joined.columns should contain allElementsOf Seq("left_id", "right_id_agg")
166170
}
167171
}
172+
173+
override def additionalConf: SparkConf = super.additionalConf.set("spark.sql.codegen.comments", "true")
168174
}

core/src/test/scala/org/locationtech/rasterframes/encoders/EncodingSpec.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.net.URI
2626

2727
import geotrellis.layer._
2828
import geotrellis.proj4._
29-
import geotrellis.raster.{CellType, Tile}
29+
import geotrellis.raster.{ArrayTile, CellType, Raster, Tile}
3030
import geotrellis.vector.{Extent, ProjectedExtent}
3131
import org.apache.spark.SparkConf
3232
import org.apache.spark.sql.Row
@@ -145,6 +145,16 @@ class EncodingSpec extends TestEnvironment with TestData {
145145
write(ds)
146146
assert(ds.first === env)
147147
}
148+
149+
it("should code RDD[Raster[Tile]]") {
150+
import spark.implicits._
151+
val t: Tile = ArrayTile(Array.emptyDoubleArray, 0, 0)
152+
val e = Extent(1, 2 ,3, 4)
153+
val r = Raster(t, e)
154+
val ds = Seq(r).toDS()
155+
println(ds.first())
156+
}
157+
148158
}
149159
describe("Dataframe encoding ops on spatial types") {
150160

project/RFProjectPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object RFProjectPlugin extends AutoPlugin {
2828
"-Ywarn-unused-import"
2929
),
3030
scalacOptions in (Compile, doc) ++= Seq("-no-link-warnings"),
31-
console / scalacOptions := Seq("-feature"),
31+
Compile / console / scalacOptions := Seq("-feature"),
3232
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
3333
cancelable in Global := true,
3434
publishTo in ThisBuild := sonatypePublishTo.value,

0 commit comments

Comments
 (0)