You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2023/02/28 07:38:36 UTC

[sedona] branch master updated: [SEDONA-252] Fix RS_Base64 test (#776)

This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new b1886b05 [SEDONA-252] Fix RS_Base64 test (#776)
b1886b05 is described below

commit b1886b05449efb47cb01656e79d8f153c9060cb1
Author: Jia Yu <ji...@apache.org>
AuthorDate: Mon Feb 27 23:38:31 2023 -0800

    [SEDONA-252] Fix RS_Base64 test (#776)
---
 sql/src/test/scala/org/apache/sedona/sql/rasterIOTest.scala | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/sql/src/test/scala/org/apache/sedona/sql/rasterIOTest.scala b/sql/src/test/scala/org/apache/sedona/sql/rasterIOTest.scala
index 418daea4..7206ac38 100644
--- a/sql/src/test/scala/org/apache/sedona/sql/rasterIOTest.scala
+++ b/sql/src/test/scala/org/apache/sedona/sql/rasterIOTest.scala
@@ -117,11 +117,11 @@ class rasterIOTest extends TestBaseScala with BeforeAndAfter with GivenWhenThen
 
     it("should pass RS_Base64") {
       var df = sparkSession.read.format("geotiff").option("dropInvalid", true).load(resourceFolder + "raster/")
-      df = df.selectExpr("image.origin as origin","ST_GeomFromWkt(image.geometry) as Geom", "image.height as height", "image.width as width", "image.data as data", "image.nBands as bands")
-      df = df.selectExpr("RS_GetBand(data, 1, bands) as targetBand", "width","height")
+      df = df.selectExpr("image.origin as origin", "ST_GeomFromWkt(image.geometry) as Geom", "image.height as height", "image.width as width", "image.data as data", "image.nBands as bands")
+      df = df.selectExpr("RS_GetBand(data, 1, bands) as targetBand", "width", "height")
       df.createOrReplaceTempView("geotiff")
-      df = sparkSession.sql("Select RS_base64(height, width, targetBand, RS_Array(height*width, 0), RS_Array(height*width, 0)) as encodedstring from geotiff")
-//      printf(df.first().getAs[String](0))
+      df = sparkSession.sql("Select RS_base64(height, width, targetBand, RS_Array(height*width, 0.0), RS_Array(height*width, 0.0)) as encodedstring from geotiff")
+      assert(df.first().getAs[String](0).startsWith("iVBORw"))
     }
 
     it("should pass RS_HTML") {
@@ -131,9 +131,8 @@ class rasterIOTest extends TestBaseScala with BeforeAndAfter with GivenWhenThen
       df.createOrReplaceTempView("geotiff")
       df = sparkSession.sql("Select RS_base64(height, width, targetBand, RS_Array(height*width, 0.0), RS_Array(height*width, 0.0)) as encodedstring from geotiff")
       df = df.selectExpr("RS_HTML(encodedstring, '300') as htmlstring" )
-      assert(df.first().getAs[String](0).contains("img"))
-//      printf(df.first().getAs[String](0))
-    }
+      assert(df.first().getAs[String](0).startsWith("<img src=\"data:image/png;base64,iVBORw"))
+      assert(df.first().getAs[String](0).endsWith("/>"))    }
 
     it("should pass RS_GetBand for length of Band 2") {
       var df = sparkSession.read.format("geotiff").option("dropInvalid", true).load(resourceFolder + "raster/test3.tif")