Skip to content

Fixes#36

Open
biodranik wants to merge 2 commits into
masterfrom
fixes
Open

Fixes#36
biodranik wants to merge 2 commits into
masterfrom
fixes

Conversation

@biodranik
Copy link
Copy Markdown
Member

Fixes a bug with int names, needed for experiments with cycling and other map styles.

A single MapCSS rule block can have comma-separated selectors that target different ::object-id subparts:

node|z16-[addr:housenumber][addr:street],
node|z16-[addr:housenumber][addr:street]::int_name,
{text: none;}

StyleChooser.updateStyles previously asked testChains for the first
matching (rule, object_id) and applied the body only to that one. The
::int_name selector silently fell through and kept whatever value the
cascade had inherited from earlier choosers.

In Organic Maps this surfaces as:

ERROR: priority is not set for caption building-address::int_name

because the ::int_name entry retains the default text: int_name from
the imported base style, then hits the standalone-caption priority lookup
in libkomwm.py with no priority defined for that subpart.

This PR iterates every matching ruleChain (deduped by object_id) and
applies the body to each. Runtime conditions are now checked per rule
rather than per chooser, which is the correct semantic when individual
selectors carry different runtime conditions (verified that no current
Organic Maps style relies on the old "first rule's runtime cond gates
the whole chooser" behaviour — there are zero hits for runtime
conditions in data/styles/).

The previously-asserted "only first ::class wins" behaviour in
test_update_styles_by_class was an artefact of the bug; the test now
reflects standard MapCSS semantics.

Test plan

  • python3 -m unittest discover -s tests — 56 passed, 0 failed
  • ruff check --exclude=src/drules_struct_pb2.py --target-version=py39
    — clean
  • integration-tests/full_drules_gen.py -d ../../../data -o /tmp/drules --txt — generates all six default/outdoors/vehicle × light/dark
    binaries successfully (priority entries grow slightly: 1929 → 1935
    overlays, 365 → 374 FG — these are subpart overrides that the old
    bug silently dropped)
  • End-to-end with Organic Maps: a comma-separated addr:housenumber
    suppression of the form shown above now builds cleanly instead of
    raising the "priority not set for building-address::int_name"
    error
  • New regression test test_update_styles_multi_object_id covers
    the housenumber-style case directly

biodranik added 2 commits May 25, 2026 22:37
A single rule block can have comma-separated selectors that target
different ::object-id subparts, e.g.

    node|z16-[addr:housenumber][addr:street],
    node|z16-[addr:housenumber][addr:street]::int_name,
    {text: none;}

Previously StyleChooser.updateStyles asked testChains for the *first*
matching (rule, object_id) and applied the body only to that one. The
::int_name selector here would silently fall through, keeping whatever
text the cascade inherited from earlier choosers. In Organic Maps this
surfaced as:

    ERROR: priority is not set for caption building-address::int_name

because the ::int_name entry retained its default text=int_name and
then hit the standalone-caption priority lookup with no priority
defined for that subpart.

Iterate every matching ruleChain (deduped by object_id) and apply the
body to each. Runtime conditions are now also checked per-rule rather
than per-chooser, which is more correct when individual selectors carry
different runtime conditions.

The previously-asserted "only first ::class wins" behaviour in
test_update_styles_by_class was an artefact of the bug — the test now
reflects MapCSS-standard semantics.

Generated with LLM assistance.

Signed-off-by: Alexander Borsuk <me@alex.bio>
Signed-off-by: Alexander Borsuk <me@alex.bio>
@biodranik biodranik requested review from strump and vng May 25, 2026 21:13
@vng
Copy link
Copy Markdown
Member

vng commented May 26, 2026

Show the diff txt fragment when applied to the current OM master repo?

# Apply the body to every matching subpart (deduped by object-id), not
# just the first one — otherwise the other selectors silently keep
# whatever values the cascade brought in from earlier choosers.
seen_object_ids = set()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this seen_object_ids? Should we ignored repeated object_id ?

@strump
Copy link
Copy Markdown
Collaborator

strump commented May 27, 2026

@vng I ran tools/unix/generate_drules.sh with this branch on OrganicMaps master and see no diff.

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.

3 participants