Kontinuation commented on PR #745:
URL: https://github.com/apache/sedona/pull/745#issuecomment-1373869602

   > @Kontinuation What's your take on dropping support for empty geometry 
inside of multi-geometries in the new serialization format? They don't have 
representation in any other form so I'm not sure that supporting them provides 
any value.
   
   I think it is OK to ignore empty geometries inside geometry collections 
since it has no impact on the topological properties of the geometries, though 
it may change some structural properties of the geometry collection such as 
indices of geometry elements (`ST_GeometryN`) and number of geometries in the 
geometry collection (`ST_NumGeometries`).
   
   If I understand it correctly, both WKT and WKB support empty geometries in 
geometry collections according to the OGC standard [Simple Feature Access - 
Part 1: Common Architecture](https://www.ogc.org/standards/sfa). The standard 
does not explicitly forbid empty geometries inside geometry collections, and 
these kinds of geometries could be represented according to the BNF of WKT:
   
   ```
   <multilinestring tagged text> ::= multilinestring <multilinestring text>
   <multilinestring text> ::= <empty set> | <left parent> <linestring text> 
{<comma> <linestring text>}* <right parent>
   <linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* 
<right paren>
   <empty set> ::= EMPTY
   ```
   
   A MultiLineString containing 2 empty LineStrings could be represented as 
`MULTILINESTRING (EMPTY, EMPTY)`. Both JTS and Shapely could successfully parse 
it, though their behavior varies in various aspects:
   
   * JTS 1.19.0 parses it as a MultiLineString object containing 2 empty 
LineStrings.
   * Shapely 2.0 parses it as a MultiLineString object containing 2 empty 
LineStrings, though Shapely does not allow creating MultiLineString with empty 
components (`MultiLineString([LineString(), LineString()])` raises an 
exception).
   * Shapely 1.8 parses it as a MultiLineString containing no geometries.
   
   WKB may also represent `MULTILINESTRING (EMPTY, EMPTY)` as 
`b'\x00\x00\x00\x00\x05\x00\x00\x00\x02\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00'`,
 though some implementation failed to parse it.
   
   * JTS 1.19.0 raised a `ParseException` when parsing it
   * Shapely 2.0 and Shapely 1.8 parsed it without a problem. Shapely 2.0 
parsed it as a MultiLineString containing 2 empty LineStrings while Shapely 1.8 
parsed it as an empty MultiLineString.
   


-- 
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]

Reply via email to