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

Disambiguate withBufferTileFocalMethods implicit preserving bin compatibility #3422

Merged
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
9 changes: 9 additions & 0 deletions raster/src/main/scala/geotrellis/raster/BufferTile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package geotrellis.raster

import geotrellis.raster.mapalgebra.focal.BufferTileFocalMethods
import spire.syntax.cfor._

/**
Expand Down Expand Up @@ -438,3 +439,11 @@ case class BufferTile(

override def toString: String = s"BufferTile(${sourceTile.dimensions}, $gridBounds, $cellType)"
}

object BufferTile {
/**
* This implicit class is not a part of the [[geotrellis.raster.mapalgebra.focal.Implicits]]
* to disambiguate implicit classes application.
*/
implicit class withBufferTileFocalMethods(val self: BufferTile) extends BufferTileFocalMethods
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,10 @@

package geotrellis.raster.mapalgebra.focal

import geotrellis.raster.{BufferTile, Tile}
import shapeless.=:!=
import geotrellis.raster.Tile

object Implicits extends Implicits

trait Implicits {
/**
* TODO: think of a better way of organizing implicits with regards to possible Tile successors
*
* Apply withTileFocalMethods to all successors of the [[Tile]] type excluding the [[BufferTile]].
* It is required to disambiguate withBufferTileFocalMethods implicit.
*/
implicit class withTileFocalMethods[T](tile: T)(implicit t: T <:< Tile, nbt: T =:!= BufferTile) extends FocalMethods {
val self: Tile = t(tile)
}

/**
* [[BufferTile]] can't have successors (it is a case class).
* Limit this implicit to be applied to the [[BufferTile]] type only.
*/
implicit class withBufferTileFocalMethods[T](tile: T)(implicit bt: T =:= BufferTile) extends BufferTileFocalMethods {
val self: BufferTile = bt(tile)
}
implicit class withTileFocalMethods(val self: Tile) extends FocalMethods
}