GEOS allows relate ops on GeometryCollection, while JTS and PostGIS do not
|Reported by:||Mike Taves||Owned by:||sirsigurd|
GEOS currently allows relate ops on GEOMETRYCOLLECTION geometries, e.g. with Shapely:
from shapely.wkt import loads g1 = loads('GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))') g2 = loads('GEOMETRYCOLLECTION(POINT(3 4),POINT(1 2))') print(g1.equals(g2)) # True print(g1.relate(g2)) # 0FFFFFFF2
or with R
library(rgeos) g1 <- readWKT("GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4, 5 6))") g2 <- readWKT("GEOMETRYCOLLECTION(LINESTRING(3 4, 5 6),POINT(1 2))") g3 <- readWKT("GEOMETRYCOLLECTION(LINESTRING(3 4, 5 6),POINT(1 1))") gEquals(g1, g2) #  TRUE gRelate(g1, g2) #  "1FFF0FFF2" gRelate(g1, g3) #  "1F0F0F0F2"
PostGIS and JTS do not allow these operations, see email threads:
In particular, the rationale for the restriction in JTS from Martin Davis:
It's because GeometryCollection have no inherent topology. In other words, geometry components can overlap. To compute relationships with a geometry with overlapping components the components have to be merged to form a topologically valid arrangement. This is more complex and more computationally expensive than the rest of the relate algorithm. So basically it just didn't get done. (It would also introduce potential robustness issues, which I was hoping to avoid in the relate code.
A few relationships (eg intersects and disjoint) could be computed more easily, so they could have special case code added for them more easily.
This task is to assess the situation for GEOS, whether a similar restriction should be set for relate ops, or any other changes. Note that I haven't found a case that returns a bad result, but I haven't looked hard.