forked from locationtech/rasterframes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/gt-3.0
* develop: PR feedback. PR feedback. Regression fix. Release notes update. Added forced truncation of WKT types in Markdown/HTML rendering. Ensure default tile size is applied to `raster` reader. Fix nodata doc Doc supervised, set tile size to 256 for visual Update doc to use rf_local_is_in when masking; fix locationtech#351 Close locationtech#310 move reference to static rf_local_is_in python implementation Updated intro section. Added additional raster-read section. Applying pre-partitioning to DataSources. Expanded RasterRefSpec to ensure lazy tiles provide metadata without I/O. Fix unit tests for rf_local_is_in Attempting to keep TravisCI from timing out by using jobs. Add rf_local_is_in function
- Loading branch information
Showing
26 changed files
with
343 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
core/src/main/scala/org/locationtech/rasterframes/expressions/localops/IsIn.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* This software is licensed under the Apache 2 license, quoted below. | ||
* | ||
* Copyright 2019 Astraea, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* [http://www.apache.org/licenses/LICENSE-2.0] | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.locationtech.rasterframes.expressions.localops | ||
|
||
import geotrellis.raster.Tile | ||
import geotrellis.raster.mapalgebra.local.IfCell | ||
import org.apache.spark.sql.Column | ||
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult | ||
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess} | ||
import org.apache.spark.sql.types.{ArrayType, DataType} | ||
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback | ||
import org.apache.spark.sql.catalyst.expressions.{BinaryExpression, Expression, ExpressionDescription} | ||
import org.apache.spark.sql.catalyst.util.ArrayData | ||
import org.apache.spark.sql.rf.TileUDT | ||
import org.locationtech.rasterframes.encoders.CatalystSerializer._ | ||
import org.locationtech.rasterframes.expressions.DynamicExtractors._ | ||
import org.locationtech.rasterframes.expressions._ | ||
|
||
@ExpressionDescription( | ||
usage = "_FUNC_(tile, rhs) - In each cell of `tile`, return true if the value is in rhs.", | ||
arguments = """ | ||
Arguments: | ||
* tile - tile column to apply abs | ||
* rhs - array to test against | ||
""", | ||
examples = """ | ||
Examples: | ||
> SELECT _FUNC_(tile, array(lit(33), lit(66), lit(99))); | ||
...""" | ||
) | ||
case class IsIn(left: Expression, right: Expression) extends BinaryExpression with CodegenFallback { | ||
override val nodeName: String = "rf_local_is_in" | ||
|
||
override def dataType: DataType = left.dataType | ||
|
||
@transient private lazy val elementType: DataType = right.dataType.asInstanceOf[ArrayType].elementType | ||
|
||
override def checkInputDataTypes(): TypeCheckResult = | ||
if(!tileExtractor.isDefinedAt(left.dataType)) { | ||
TypeCheckFailure(s"Input type '${left.dataType}' does not conform to a raster type.") | ||
} else right.dataType match { | ||
case _: ArrayType ⇒ TypeCheckSuccess | ||
case _ ⇒ TypeCheckFailure(s"Input type '${right.dataType}' does not conform to ArrayType.") | ||
} | ||
|
||
override protected def nullSafeEval(input1: Any, input2: Any): Any = { | ||
implicit val tileSer = TileUDT.tileSerializer | ||
val (childTile, childCtx) = tileExtractor(left.dataType)(row(input1)) | ||
|
||
val arr = input2.asInstanceOf[ArrayData].toArray[AnyRef](elementType) | ||
|
||
childCtx match { | ||
case Some(ctx) => ctx.toProjectRasterTile(op(childTile, arr)).toInternalRow | ||
case None => op(childTile, arr).toInternalRow | ||
} | ||
|
||
} | ||
|
||
protected def op(left: Tile, right: IndexedSeq[AnyRef]): Tile = { | ||
def fn(i: Int): Boolean = right.contains(i) | ||
IfCell(left, fn(_), 1, 0) | ||
} | ||
|
||
} | ||
|
||
object IsIn { | ||
def apply(left: Column, right: Column): Column = | ||
new Column(IsIn(left.expr, right.expr)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 0 additions & 92 deletions
92
core/src/test/resources/MCD43A4.A2019111.h30v06.006.2019120033434_01.mrf.aux.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.