Skip to content

Fix duplicate self-check triples in all modes if more than 2 objects are reference-collapsed - #25

Merged
patrickbr merged 2 commits into
masterfrom
remaining-triple-duplicates
Aug 19, 2026
Merged

Fix duplicate self-check triples in all modes if more than 2 objects are reference-collapsed#25
patrickbr merged 2 commits into
masterfrom
remaining-triple-duplicates

Conversation

@patrickbr

Copy link
Copy Markdown
Member

Will fix the "NOTE" in #24

@patrickbr

patrickbr commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

Fixed now two problems:

1.) A geometry G may have "references", that is, other objects that have the exact same geometry as G which are then not stored explicitly. If some pair (A, B) is found during the sweep, A and B are expanded, that is, every relation is written e.g. not only for (A, B), but also for (A, B'), where B' is referencing B. But if A and B have refererrers, we first expanded B with A and the recursion then expanded A. Afterwards, A was again explicitely expanded on the original call level, leading to duplicates. With this PR, the expansion is only allowed to continue "into one side". That is, in the example above, we first expand 'B' with 'A', but we do not continue the expansion of A in the recursion.

2.) For symmetric relations, we always write both sides (A equals B and B equals A). When we do self checks (checks of a referenced geometry A against "itself" to capture relations between A and its references), the expansion described in (1) would e.g. produce the pairs (A, B) and (B, A). But for symmetric relations like equals, these pairs are equivalent and we would then write A equals B, B equals A, B equals A and A equals B. The solution is to handle the self-checks explicitly at the recursion start and pass that down during the recursion: if we are in a self-check, only write symmetric relations if for the IDs A < B holds (we can be sure that the other side is then found during the ref expansion)

Note that (2) was already done previously, but only at the lowest recursion level (where "is self check" can be trivially evaluated by checking whether A and B are the same ID). This is why self-check duplicates only materialized when more than 2 geometries were equivalent.

@patrickbr

patrickbr commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

Note that this still not fully eliminates duplicates from the output. For multigeometries, there is no internal bookkeeping for some relations of which triple was already produced, so if for a multigeometry A = {a1, a2, a3} and a geometry B a1 and B intersect, we write A intersects B. If at some later point we suddenly find that a3 also intersects B, we write A intersects B again. Note that this should not happen in DE9IM mode, as a "premature" write before the multigeometry was not fully inspected is not possible there.

Note that the "old" predicates are largely produced now by the DE9IM computation, so we should drop the remaining legacy code and bookkeeping for the old predicates. This would also further simplify the code. This will be another PR however.

@patrickbr
patrickbr merged commit d5c2f6e into master Aug 19, 2026
4 checks passed
@patrickbr
patrickbr deleted the remaining-triple-duplicates branch August 19, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant