astraea.spark.rasterframes.expressions.GeomDeserializerSupport.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of raster-frames_2.11 Show documentation
Show all versions of raster-frames_2.11 Show documentation
RasterFrames brings the power of Spark DataFrames to geospatial raster data, empowered by the map algebra and tile layer operations of GeoTrellis
The newest version!
package astraea.spark.rasterframes.expressions
import com.vividsolutions.jts.geom.Geometry
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.jts.AbstractGeometryUDT
/**
* Support for deserializing JTS geometry inside expressions.
*
* @since 2/22/18
*/
trait GeomDeserializerSupport {
def extractGeometry(expr: Expression, input: Any): Geometry = {
input match {
case g: Geometry ⇒ g
case r: InternalRow ⇒
expr.dataType match {
case udt: AbstractGeometryUDT[_] ⇒ udt.deserialize(r)
}
}
}
}