Skip to content

Commit

Permalink
Evaluated removal of FixedDelegationTile, created (ignored) test
Browse files Browse the repository at this point in the history
to verify behavior, and filed locationtech/geotrellis#3153.
  • Loading branch information
metasim committed Nov 15, 2019
1 parent 9a4f156 commit 7345251
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
10 changes: 2 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ lazy val pyrasterframes = project
spark("core").value % Provided,
spark("mllib").value % Provided,
spark("sql").value % Provided
),
Test / test := (Test / test).dependsOn(experimental / Test / test).value
)
)


lazy val datasource = project
.configs(IntegrationTest)
.settings(Defaults.itSettings)
Expand All @@ -107,7 +105,6 @@ lazy val datasource = project
spark("mllib").value % Provided,
spark("sql").value % Provided
),
Test / test := (Test / test).dependsOn(core / Test / test).value,
initialCommands in console := (initialCommands in console).value +
"""
|import org.locationtech.rasterframes.datasource.geotrellis._
Expand All @@ -129,8 +126,7 @@ lazy val experimental = project
spark("sql").value % Provided
),
fork in IntegrationTest := true,
javaOptions in IntegrationTest := Seq("-Xmx2G"),
Test / test := (Test / test).dependsOn(datasource / Test / test).value
javaOptions in IntegrationTest := Seq("-Xmx2G")
)

lazy val docs = project
Expand Down Expand Up @@ -171,8 +167,6 @@ lazy val docs = project
addMappingsToSiteDir(Compile / paradox / mappings, paradox / siteSubdirName)
)

//ParadoxMaterialThemePlugin.paradoxMaterialThemeSettings(Paradox)

lazy val bench = project
.dependsOn(core % "compile->test")
.settings(publish / skip := true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import geotrellis.raster.{ArrayTile, DelegatingTile, Tile}

/**
* Workaround for case where `combine` is invoked on two delegating tiles.
* Remove after https://github.com/locationtech/geotrellis/issues/3153 is fixed and integrated
* @since 8/22/18
*/
abstract class FixedDelegatingTile extends DelegatingTile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
package org.locationtech.rasterframes

import geotrellis.raster._
import geotrellis.raster.mapalgebra.local.{Max, Min}
import geotrellis.raster.mapalgebra.local.{Add, Max, Min}
import geotrellis.spark._
import org.apache.spark.sql.Column
import org.apache.spark.sql.functions._
import org.locationtech.rasterframes.TestData.randomTile
import org.locationtech.rasterframes.stats.CellHistogram
import org.locationtech.rasterframes.util.DataBiasedOp.BiasedAdd

/**
* Test rig associated with computing statistics and other descriptive
Expand Down Expand Up @@ -318,6 +319,56 @@ class TileStatsSpec extends TestEnvironment with TestData {
val ndCount2 = ndTiles.select("*").where(rf_is_no_data_tile($"tiles")).count()
ndCount2 should be(count + 1)
}

// Awaiting https://github.com/locationtech/geotrellis/issues/3153 to be fixed and integrated
ignore("should allow NoData algebra to be changed via delegating tile") {
val t1 = ArrayTile(Array.fill(4)(1), 2, 2)
val t2 = {
val d = Array.fill(4)(2)
d(1) = geotrellis.raster.NODATA
ArrayTile(d, 2, 2)
}

val d1 = new DelegatingTile {
override def delegate: Tile = t1
}
val d2 = new DelegatingTile {
override def delegate: Tile = t2
}

/** Counts the number of non-NoData cells in a tile */
case object CountData {
def apply(t: Tile) = {
var count: Long = 0
t.dualForeach(
z if(isData(z)) count = count + 1
) (
z if(isData(z)) count = count + 1
)
count
}
}

// Confirm counts
CountData(t1) should be (4L)
CountData(t2) should be (3L)
CountData(d1) should be (4L)
CountData(d2) should be (3L)

// Standard Add evaluates `x + NoData` as `NoData`
CountData(Add(t1, t2)) should be (3L)
CountData(Add(d1, d2)) should be (3L)
// Is commutative
CountData(Add(t2, t1)) should be (3L)
CountData(Add(d2, d1)) should be (3L)

// With BiasedAdd, all cells should be data cells
CountData(BiasedAdd(t1, t2)) should be (4L) // <-- passes
CountData(BiasedAdd(d1, d2)) should be (4L) // <-- fails
// Should be commutative.
CountData(BiasedAdd(t2, t1)) should be (4L) // <-- passes
CountData(BiasedAdd(d2, d1)) should be (4L) // <-- fails
}
}

describe("proj_raster handling") {
Expand Down

0 comments on commit 7345251

Please sign in to comment.