Skip to content

Commit

Permalink
Merge pull request #1636 from lossyrob/backport/0.10/1611
Browse files Browse the repository at this point in the history
Backport: [Polygonal Summary] Relax types to anything `Tile`d
  • Loading branch information
lossyrob authored Sep 26, 2016
2 parents c9f2658 + f9cb74e commit 5bc2e8a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package geotrellis.spark.summary.polygonal

import geotrellis.raster._
import geotrellis.spark._
import geotrellis.spark.tiling._
import geotrellis.vector._
import geotrellis.util._

import org.apache.spark.rdd._
import scala.reflect._

object Implicits extends Implicits

trait Implicits {
implicit class withZonalSummaryTileLayerRDDMethods[K](val self: TileLayerRDD[K])
implicit class withZonalSummaryTileLayerRDDMethods[
K,
M: GetComponent[?, LayoutDefinition]
](val self: RDD[(K, Tile)] with Metadata[M])
(implicit val keyClassTag: ClassTag[K], implicit val _sc: SpatialComponent[K])
extends PolygonalSummaryTileLayerRDDMethods[K] with Serializable
extends PolygonalSummaryTileLayerRDDMethods[K, M] with Serializable

implicit class withZonalSummaryFeatureRDDMethods[G <: Geometry, D](val featureRdd: RDD[Feature[G, D]])
extends PolygonalSummaryFeatureRDDMethods[G, D]
Expand All @@ -19,4 +26,4 @@ trait Implicits {
(implicit val keyClassTag: ClassTag[K])
extends PolygonalSummaryKeyedFeatureRDDMethods[K, G, D]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import geotrellis.raster.summary.polygonal._
import geotrellis.raster.histogram._
import geotrellis.raster._
import geotrellis.spark._
import geotrellis.spark.tiling._
import geotrellis.vector._
import geotrellis.util._

Expand All @@ -12,7 +13,10 @@ import org.apache.spark.rdd._

import scala.reflect.ClassTag

abstract class PolygonalSummaryTileLayerRDDMethods[K: ClassTag] extends MethodExtensions[TileLayerRDD[K]] {
abstract class PolygonalSummaryTileLayerRDDMethods[
K: ClassTag,
M: GetComponent[?, LayoutDefinition]
] extends MethodExtensions[RDD[(K, Tile)] with Metadata[M]] {
import Implicits._
protected implicit val _sc: SpatialComponent[K]

Expand All @@ -37,35 +41,41 @@ abstract class PolygonalSummaryTileLayerRDDMethods[K: ClassTag] extends MethodEx
.polygonalSummary(multiPolygon, zeroValue)(handler)

def polygonalSummaryByKey[T: ClassTag, L: ClassTag](
polygon: Polygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L): RDD[(L, T)] = polygonalSummaryByKey(polygon, zeroValue, handler, fKey, None)
polygon: Polygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L
): RDD[(L, T)] = {
polygonalSummaryByKey(polygon, zeroValue, handler, fKey, None)
}

def polygonalSummaryByKey[T: ClassTag, L: ClassTag](
polygon: Polygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L,
partitioner: Option[Partitioner]
polygon: Polygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L,
partitioner: Option[Partitioner]
): RDD[(L, T)] =
self
.asRasters
.map { case (key, raster) => (fKey(key), raster.asFeature) }
.polygonalSummaryByKey(polygon, zeroValue, partitioner)(handler)

def polygonalSummaryByKey[T: ClassTag, L: ClassTag](
multiPolygon: MultiPolygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L): RDD[(L, T)] = polygonalSummaryByKey(multiPolygon, zeroValue, handler, fKey, None)
multiPolygon: MultiPolygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L
): RDD[(L, T)] = {
polygonalSummaryByKey(multiPolygon, zeroValue, handler, fKey, None)
}

def polygonalSummaryByKey[T: ClassTag, L: ClassTag](
multiPolygon: MultiPolygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L,
partitioner: Option[Partitioner]
multiPolygon: MultiPolygon,
zeroValue: T,
handler: TilePolygonalSummaryHandler[T],
fKey: K => L,
partitioner: Option[Partitioner]
): RDD[(L, T)] =
self
.asRasters
Expand Down

0 comments on commit 5bc2e8a

Please sign in to comment.