Repository navigation
Story: Report collections of empty members as empty #65
Description
Report collections of empty members as empty
As a consumer of spatial collections,
I want a collection containing only EMPTY members to report itself as EMPTY,
so that isEmpty() describes the represented geometry independently of stored member count.
Context
This Story addresses finding R4 in
Story #26.
Current collection implementations use stored-member count for emptiness.
A MultiPoint containing one EMPTY Point therefore reports isEmpty() === false.
On 2026-10-30, Alexandre confirmed that a collection composed only of EMPTY
members remains EMPTY. Members must still be preserved, including their order
and cardinality. A collection with a non-EMPTY member is not EMPTY.
The correction concerns MultiPoint, MultiLineString, MultiPolygon and
GeometryCollection, including nested GeometryCollections, wherever those types
are supported. It does not define new EMPTY rules for invalid polygon
boundaries, point sequences, CompoundCurve or other non-collection structures.
Member emptiness uses the applicable member's existing contract.
Acceptance Criteria
- A collection with zero members reports
isEmpty() === true. - A collection containing one or several members that all report EMPTY returns
isEmpty() === true. - A collection containing at least one non-EMPTY member returns
isEmpty() === false, regardless of EMPTY members or their positions. - Nested GeometryCollections containing only EMPTY descendants report EMPTY; a non-EMPTY descendant makes each containing GeometryCollection non-EMPTY.
- Calling
isEmpty()preserves every stored member, its identity, order and collection cardinality. - A mutable collection reflects changes between EMPTY and non-EMPTY caused by adding, removing or replacing members.
- A collection holding mutable members reflects subsequent changes to a member's EMPTY state, including through nested collections and shared members, without requiring reinsertion.
- Immutable replacement operations report the appropriate EMPTY state for the replacement while preserving the original collection and its members.
- The behavior is consistent for all supported collection types, coordinate layouts, Geometry/Geography families and mutable/immutable variants.
- EMPTY classification does not reject or remove members whose family, dimension, reference or geometric validity remains a consumer validation concern.
Constraints
- Preserve the approved EMPTY-member storage contracts from Stories Story: fix: allow empty points as MultiPoint elements #8–Story: test: ensure MultiPolygon accepts empty Polygon members #10; geometric emptiness and zero stored members are distinct concepts.
- The changed
isEmpty()result for nonzero all-EMPTY collections is explicitly approved observable behavior. No public signature or member-admission rule changes are included. - Do not introduce automatic functional validation or redefine non-collection members' EMPTY semantics.
Definition of Done
The project's common Definition of Done applies.
-
composer test-localpasses. -
composer qualitypasses. - Regression tests demonstrate the original all-EMPTY failure and cover zero, all-EMPTY and mixed members, nested collections, shared mutable members and immutable replacement preservation.
- Explicit tests cover XY, XYZ, XYM and XYZM and both families for the supported collection variants.
- Existing EMPTY-member tests are updated only where their
isEmpty()expectations contradict the approved correction; member-preservation assertions remain intact. -
docs/instantiable-spatial-types.mdand other affected public documentation distinguish geometric emptiness from cardinality and disclose the changed result. - The Story Story: Review normative conformance for
spatial-types1.0.0 #26 conformance matrix links this correction and its automated evidence to R4.
Activity
spatial-types1.0.0 #23spatial-types1.0.0 #26fix(types)!: report collections of empty members as empty