[ https://issues.apache.org/jira/browse/SEDONA-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515358#comment-17515358 ]
Martin Andersson commented on SEDONA-96: ---------------------------------------- I would be happy to provide a patch. I can create a PR tonight. > ST_MakeValid returning multiple geometries for polygons with holes > ------------------------------------------------------------------ > > Key: SEDONA-96 > URL: https://issues.apache.org/jira/browse/SEDONA-96 > Project: Apache Sedona > Issue Type: Bug > Reporter: Russell W > Priority: Major > Attachments: Screen Shot 2022-03-29 at 2.17.43 PM.png, Screen Shot > 2022-03-29 at 2.19.37 PM.png > > > When pass a polygon with holes, ST_MakeValid is returning new rows for each > hole. This can lead to significant incorrectness when using ST_MakeValid > prior to a spatial join. > Example: > {code:java} > polygon = spark.createDataFrame([['{"type": "Polygon", "coordinates": [[[3, > 3], [3, -3], [-3, -3], [-3, 3], [3, 3]], [[1, 1], [1, -1], [-1, -1], [-1, 1], > [1, 1]]]}']], ['geometry']) > polygon = polygon.withColumn('geometry', > F.expr('ST_MakeValid(ST_GeomFromGeoJSON(geometry), false)')) > polygon = polygon.withColumn('geometry', F.expr('ST_AsGeoJSON(geometry)')) > polygon > geometry > -------------------------------------------------------------------------------------------------------------------------------------------------- > {"type":"Polygon","coordinates":[[[3.0,3.0],[3.0,-3.0],[-3.0,-3.0],[-3.0,3.0],[3.0,3.0]],[[1.0,1.0],[-1.0,1.0],[-1.0,-1.0],[1.0,-1.0],[1.0,1.0]]]} > {"type":"Polygon","coordinates":[[[-1.0,1.0],[1.0,1.0],[1.0,-1.0],[-1.0,-1.0],[-1.0,1.0]]]}{code} > Input: > !Screen Shot 2022-03-29 at 2.17.43 PM.png|width=458,height=379! > Output: > !Screen Shot 2022-03-29 at 2.19.37 PM.png|width=457,height=378! -- This message was sent by Atlassian Jira (v8.20.1#820001)