Skip to content
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ trim_trailing_whitespace = true
indent_size = 2
indent_style = space

[*.scala]
indent_style = space

[*.xml]
indent_style = space

Expand Down
2 changes: 1 addition & 1 deletion examples/spark-sql/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object Main extends App {

SedonaVizRegistrator.registerAll(sedona)

val resourceFolder = System.getProperty("user.dir")+"/src/test/resources/"
val resourceFolder = System.getProperty("user.dir")+"/src/test/resources/"

// SQL-based spatial operations
println("=== Running SQL Examples ===")
Expand Down
34 changes: 17 additions & 17 deletions examples/spark-sql/src/main/scala/VizExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,32 +136,32 @@ object VizExample {
.filter("ST_Contains(ST_PolygonFromEnvelope(-126.790180,24.863836,-64.630926,50.000),shape)").createOrReplaceTempView("pointtable")
sedona.sql(
"""
|CREATE OR REPLACE TEMP VIEW pixels AS
|SELECT pixel, shape FROM pointtable
|LATERAL VIEW Explode(ST_Pixelize(shape, 256, 256, ST_PolygonFromEnvelope(-126.790180,24.863836,-64.630926,50.000))) AS pixel
""".stripMargin)
|CREATE OR REPLACE TEMP VIEW pixels AS
|SELECT pixel, shape FROM pointtable
|LATERAL VIEW Explode(ST_Pixelize(shape, 256, 256, ST_PolygonFromEnvelope(-126.790180,24.863836,-64.630926,50.000))) AS pixel
""".stripMargin)
sedona.sql(
"""
|CREATE OR REPLACE TEMP VIEW pixelaggregates AS
|SELECT pixel, count(*) as weight
|FROM pixels
|GROUP BY pixel
""".stripMargin)
|CREATE OR REPLACE TEMP VIEW pixelaggregates AS
|SELECT pixel, count(*) as weight
|FROM pixels
|GROUP BY pixel
""".stripMargin)
sedona.sql(
"""
|CREATE OR REPLACE TEMP VIEW images AS
|SELECT ST_Render(pixel, ST_Colorize(weight, (SELECT max(weight) FROM pixelaggregates), 'red')) AS image
|FROM pixelaggregates
""".stripMargin)
|CREATE OR REPLACE TEMP VIEW images AS
|SELECT ST_Render(pixel, ST_Colorize(weight, (SELECT max(weight) FROM pixelaggregates), 'red')) AS image
|FROM pixelaggregates
""".stripMargin)
val image = sedona.table("images").take(1)(0)(0).asInstanceOf[ImageSerializableWrapper].getImage
val imageGenerator = new ImageGenerator
imageGenerator.SaveRasterImageAsLocalFile(image, sqlApiOutputPath, ImageType.PNG)
sedona.sql(
"""
|CREATE OR REPLACE TEMP VIEW imagestring AS
|SELECT ST_EncodeImage(image)
|FROM images
""".stripMargin)
|CREATE OR REPLACE TEMP VIEW imagestring AS
|SELECT ST_EncodeImage(image)
|FROM images
""".stripMargin)
sedona.table("imagestring").show()
}

Expand Down
Loading