Currently, Intersection returns GEOMETRYCOLLECTION EMPTY when one or both inputs are empty:
if a.IsEmpty() || b.IsEmpty() {
return Geometry{}, nil
}
However, when envelopes are disjoint (but inputs are non-empty), it returns a dimension-appropriate empty geometry:
if envelopesDisjoint(a, b) {
return createEmptyResult(minInt(a.Dimension(), b.Dimension())), nil
}
For consistency, the empty input case should also return createEmptyResult(minInt(a.Dimension(), b.Dimension())). This would allow combining the two conditions:
if a.IsEmpty() || b.IsEmpty() || envelopesDisjoint(a, b) {
return createEmptyResult(minInt(a.Dimension(), b.Dimension())), nil
}
The existing tests expect GEOMETRYCOLLECTION EMPTY for empty inputs, so they would need to be updated.