jiayuasu commented on code in PR #2897:
URL: https://github.com/apache/sedona/pull/2897#discussion_r3178671093
##########
spark/common/src/test/scala/org/apache/sedona/sql/constructorTestScala.scala:
##########
@@ -138,6 +139,42 @@ class constructorTestScala extends TestBaseScala with
Matchers {
assert(polygonDF.count() == 1)
}
+ it("Passed ST_MakeBox2D") {
+ val df = sparkSession.sql("""
+ SELECT
+ ST_MakeBox2D(ST_Point(1.0, 2.0), ST_Point(4.0, 5.0)) AS
bbox,
+ ST_MakeBox2D(ST_Point(10.0, 20.0), ST_GeomFromText(NULL)) AS
bbox_null,
+ ST_MakeBox2D(ST_GeomFromText('POINT EMPTY'), ST_Point(1.0, 1.0)) AS
bbox_empty
+ """)
+ val row = df.collect()(0)
+ val bbox = row.getAs[Box2D]("bbox")
+ assert(bbox.getXMin == 1.0)
+ assert(bbox.getYMin == 2.0)
+ assert(bbox.getXMax == 4.0)
+ assert(bbox.getYMax == 5.0)
+ assert(row.isNullAt(1))
+ assert(row.isNullAt(2))
+ }
+
+ it("ST_MakeBox2D preserves swapped corners") {
+ // No swapping or reordering; lower-left/upper-right are taken verbatim.
+ // This leaves xmin > xmax / ymin > ymax available for future
antimeridian semantics.
+ val df = sparkSession.sql(
+ "SELECT ST_MakeBox2D(ST_Point(170.0, 10.0), ST_Point(-170.0, 20.0)) AS
bbox")
+ val bbox = df.collect()(0).getAs[Box2D]("bbox")
+ assert(bbox.getXMin == 170.0)
+ assert(bbox.getXMax == -170.0)
+ }
Review Comment:
Added in 16d91375. ST_PointZ inputs round-trip with Z ignored — Box2D gets
the supplied X/Y verbatim.
--
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]