Skip to content

fix(xodr): round-trip virtual-junction linkage and connection internals (#537) - #558

Merged
JArmandoAnaya merged 1 commit into
mainfrom
feat/537-virtual-junction
Aug 2, 2026
Merged

fix(xodr): round-trip virtual-junction linkage and connection internals (#537)#558
JArmandoAnaya merged 1 commit into
mainfrom
feat/537-virtual-junction

Conversation

@JArmandoAnaya

Copy link
Copy Markdown
Contributor

Three fidelity holes, all in modeled scopes that #453's preservation sweep
deliberately does not cover. Built on #534's junction test scaffolding, as the
issue intended.

1. @elementS/@elementDir were read nowhere

asam.net:xodr:1.7.0:road.linkage.virtjunc_link_attribute_usage requires
both on a <link> pointing at a virtual junction. read_link took only
elementType/elementId/contactPoint, with no diagnostic, and
write_link_element never emitted them — so a spec-conformant file lost its
virtual-junction linkage on the first save.

They ride RoadLink now (element_s as an optional, element_dir verbatim —
it is a two-value enumeration whose spelling is the whole content) and are
written back only when the source carried them. An ordinary road link, where
the standard forbids them, stays byte-identical; there is a test for exactly
that, because "write them always" would churn every fixture in the suite and
assert something the spec disallows.

2. A virtual junction's own <connection>s were deleted

§12.7 permits them, but the arms-xor-spans policy cleared the list — warned, and
then destroyed the data.

They are preserved now, in Junction::preserved_connections: held out of
connections so nothing tries to build geometry from them, and re-emitted
unchanged. Worth being precise about why that is not a contradiction —
arms-xor-spans is about generation. A span junction never cuts its main
road, so there is nothing to derive; that stays true. What was wrong was
concluding the file's data must therefore be discarded.

3. <connection> @type and non-<laneLink> children were dropped

The reader iterated children("laneLink") only. @id regeneration is benign —
the writer renumbers connections deterministically — but @type (§12.3
Table 61) carries meaning the file owns, and anything a later revision adds was
vanishing too.

Tests

New corpus seed virtual_junction_links.xodr: a road linking into a virtual
junction with @elementS/@elementDir on both ends, and a junction
declaring a connection that carries @type and an unmodeled child — so cases 2
and 3 ride together.

VirtualJunctionLinkageAndConnectionsSurviveWriteParseWrite asserts the model,
then the bytes (a model-only check passes on a writer that emits none of
it), then the fixed point. AnOrdinaryRoadLinkWritesNoElementSOrDir pins the
byte-stability of every other link.

Sabotage-verified: re-deleting the virtual junction's connections failed the
round-trip test.

Verification

  • ctest --preset ci-macos3283/3283 pass
  • pytest python/tests541 passed, 1 skipped
  • clang-format clean

Fixes #537

…ls (#537)

Three holes, all in MODELED scopes that #453's preservation sweep deliberately
does not cover.

@elementS/@elementDir were read nowhere.
asam.net:xodr:1.7.0:road.linkage.virtjunc_link_attribute_usage REQUIRES both on
a <link> pointing at a virtual junction; read_link took only
elementType/elementId/contactPoint, with no diagnostic, so a conformant file
lost its virtual-junction linkage on the first save. They ride RoadLink now and
are written back only when the source carried them — an ordinary road link,
where the standard forbids them, stays byte-identical.

A virtual junction's own <connection>s were DELETED. §12.7 permits them, but
arms-xor-spans cleared the list: warned, then destroyed. They are preserved
instead — held out of `connections` so nothing tries to build geometry from
them (arms-xor-spans still holds for GENERATION, which is what it is actually
about) and re-emitted unchanged.

<connection> @type and non-<laneLink> children were dropped. @id regeneration
is benign because the writer renumbers deterministically; @type is not.

Built on #534's junction test scaffolding, as the issue intended.

Fixes #537
@JArmandoAnaya
JArmandoAnaya merged commit 9e9bce2 into main Aug 2, 2026
16 checks passed
@JArmandoAnaya
JArmandoAnaya deleted the feat/537-virtual-junction branch August 2, 2026 01:47
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.

xodr: virtual-junction fidelity — link @elementS/@elementDir dropped, foreign connections deleted, connection children dropped

1 participant