prantogg commented on code in PR #1121:
URL: https://github.com/apache/sedona/pull/1121#discussion_r1393008810
##########
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/raster/PixelFunctions.scala:
##########
@@ -30,7 +30,9 @@ import org.apache.spark.sql.types.{AbstractDataType,
ArrayType, DataType, Double
import
org.apache.spark.sql.sedona_sql.expressions.InferrableFunctionConverter._
import org.apache.spark.sql.sedona_sql.expressions.InferredExpression
-case class RS_Value(inputExpressions: Seq[Expression]) extends
InferredExpression(PixelFunctions.value _) {
+case class RS_Value(inputExpressions: Seq[Expression]) extends
InferredExpression(
Review Comment:
@jiayuasu @Kontinuation This test fails with datatype mismatch error
##########
common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java:
##########
@@ -41,6 +42,32 @@ public static Double value(GridCoverage2D rasterGeom,
Geometry geometry, int ban
return values(rasterGeom, Collections.singletonList(geometry),
band).get(0);
}
+ public static Double value(GridCoverage2D rasterGeom, int colX, int rowY,
int band) throws TransformException {
+ int numBands = rasterGeom.getNumSampleDimensions();
+ if (band < 1 || band > numBands) {
+ // Invalid band index. Return nulls.
+ return null;
+ }
Review Comment:
Using RasterUtil.ensureBand will throw an IllegalArgumentException. For
RS_Value we expect to return null for invalid bands.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]