Abeeujah commented on PR #298:
URL: https://github.com/apache/sedona-db/pull/298#issuecomment-3530211986
At a closer look, POSTGIS does actually support `GeometryCollection` as an
input to `ST_Boundary`, what it does is, it calculates the boundary for
individual geometries in the collection and returns them, here's a series of
tests
```sh
postgres=# SELECT ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(LINESTRING(1 1,2
2),GEOMETRYCOLLECTION(POLYGON((3 3,4 4,5 5,3
3)),GEOMETRYCOLLECTION(LINESTRING(6 6,7 7),POLYGON((8 8,9 9,10 10,8 8)))))'));
st_astext
----------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(MULTIPOINT((1 1),(2 2),(6 6),(7 7)),MULTILINESTRING((3
3,4 4,5 5,3 3),(8 8,9 9,10 10,8 8)))
(1 row)
postgres=# SELECT ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(POLYGON ((0 0, 0
1, 1 1, 1 0, 0 0)), GEOMETRYCOLLECTION(LINESTRING(10 10, 10 20)))'));
st_astext
---------------------------------------------------------------------------------
GEOMETRYCOLLECTION(MULTIPOINT((10 10),(10 20)),LINESTRING(0 0,0 1,1 1,1 0,0
0))
(1 row)
postgres=# SELECT ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(LINESTRING(10
10,20 20),GEOMETRYCOLLECTION(POLYGON((30 30,40 40,50 50,30
30)),GEOMETRYCOLLECTION(LINESTRING(60 60,70 70),LINESTRING(80 80,90 90))))'));
st_astext
---------------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(MULTIPOINT((10 10),(20 20),(60 60),(70 70),(80 80),(90
90)),LINESTRING(30 30,40 40,50 50,30 30))
(1 row)
postgres=# SELECT ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(POLYGON((1 1,2
2,3 3,1 1)),GEOMETRYCOLLECTION(LINESTRING(4 4,5
5),GEOMETRYCOLLECTION(POLYGON((6 6,7 7,8 8,6 6)),LINESTRING(9 9,10 10))))'));
st_astext
----------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(MULTIPOINT((4 4),(5 5),(9 9),(10 10)),MULTILINESTRING((1
1,2 2,3 3,1 1),(6 6,7 7,8 8,6 6)))
(1 row)
postgres=# SELECT ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(LINESTRING(1 1,1
10,10 10,10 1,1 1),GEOMETRYCOLLECTION(LINESTRING(2 2,2 9,9 9,9 2,2
2),GEOMETRYCOLLECTION(POLYGON((3 3,3 8,8 8,8 3,3 3)),POLYGON((4 4,4 7,7 7,7 4,4
4)))))'));
st_astext
--------------------------------------------------------------
MULTILINESTRING((3 3,3 8,8 8,8 3,3 3),(4 4,4 7,7 7,7 4,4 4))
(1 row)
postgres=# SELECT ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(POLYGON((0 0,10
0,10 10,0 10,0 0)),GEOMETRYCOLLECTION(LINESTRING(1 1,9
9),GEOMETRYCOLLECTION(LINESTRING(1 9,9 1),POLYGON((2 2,8 2,8 8,2 8,2 2)))))'));
st_astext
--------------------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(MULTIPOINT((1 1),(9 9),(1 9),(9 1)),MULTILINESTRING((0
0,10 0,10 10,0 10,0 0),(2 2,8 2,8 8,2 8,2 2)))
(1 row)
postgres=# SELECT
ST_AsText(ST_Boundary('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1
2,3 4),POLYGON((5 6,7 8,9 10,5 6))),POLYGON((11 12,13 14,15 16,11
12))),LINESTRING(17 18,19 20))'));
st_astext
---------------------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(MULTIPOINT((1 2),(3 4),(17 18),(19
20)),MULTILINESTRING((5 6,7 8,9 10,5 6),(11 12,13 14,15 16,11 12)))
(1 row)
postgres=#
```
This shaped the implementation, to support `GeometryCollection`, I had to
introduce the recursive call, to compute the boundary for the individual
geometries.
To be fully POSTGIS compliant, I had to group/aggregate the return the way
POSTGIS does
Might be a lot, but it's POSTGIS Compliant.
--
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]