Skip to content

Apply a declaration block to every ::object-id it selects - #41

Merged
biodranik merged 1 commit into
masterfrom
ab/object-id-per-block
Aug 16, 2026
Merged

biodranik merged 1 commit into
masterfrom
ab/object-id-per-block

Conversation

@biodranik

Copy link
Copy Markdown
Member

Problem

updateStyles() took the first rule testChains() matched and applied the whole declaration block to that single ::object-id. In a selector group that mixes layers, only the first one was ever styled:

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

::default gets text: none, ::int_name keeps text: int_name. The surviving layer then owns the caption drule, so libkomwm looks up a priority for <type>::int_name — which no style defines — and generation dies with ERROR: priority is not set for caption building-address::int_name.

Which selector wins is purely positional: putting ::int_name first suppresses that one and leaves ::default rendered, so reordering the group only moves the hole.

This is what the

/* ToDo text: none; doesn't work here ..  */

comment in the main repo's data/styles/vehicle/include/Basemap_label.mapcss has been working around; adding text: none to that block reproduces the same failure.

Fix

testChainsAll() returns the first matching rule for each distinct ::object-id in the group, and updateStyles() applies the block to each. testChains() is untouched, so get_runtime_conditions() and the existing test call sites are unaffected.

Blast radius

22 of 3268 declaration blocks in the main repo mix object-ids (11 in default/Roads.mapcss ::cycleline, 8 in outdoors/Roads.mapcss, 2 ::bridgeblack/::bridgewhite, 1 the vehicle ToDo). Regenerating everything through generate_drules.sh:

same  drules_default.bin/.txt    same  drules_cycling.bin/.txt
same  drules_outdoors.bin/.txt   same  drules_vehicle.bin/.txt
same  drules_design.bin          same  drules_merged.bin/.txt
same  classificator.txt, types.txt, visibility.txt, colors.txt, patterns.txt
same  styles/ (priority files)

Byte-identical for all four families, light and dark. And the housenumber block above now produces exactly what the ::* workaround does — same drules_cycling.bin, 0 errors.

Testing

python -m unittest discover -s tests passes 57/57. test_update_styles_by_class pinned the old behaviour (its own comment read # This class is ignored by StyleChooser) and now asserts both selected classes are styled.

Note: CI on this branch is red for an unrelated reason — see #40, which restores it.

Unlocked follow-up

The vehicle ToDo can be resolved in the main repo once this is pinned.

Generated with LLM assistance.

@biodranik
biodranik force-pushed the ab/object-id-per-block branch from efc3b28 to 95aaaf1 Compare August 15, 2026 07:51

@strump strump left a comment

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.

LGTM.

Comment thread src/mapcss/StyleChooser.py Outdated
updateStyles() took the first rule testChains() matched and applied the
whole declaration block to that single ::object-id, so in a selector
group that mixes layers only the first one was ever styled:

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

muted ::default and left ::int_name rendered. The surviving layer then
owns the caption drule, so libkomwm asks for a priority of
`<type>::int_name`, which no style defines, and generation fails with
"ERROR: priority is not set". Which selector wins is positional, so
reordering the group only moves the hole. This is what the

  /* ToDo text: none; doesn't work here ..  */

comment in the main repo's vehicle style has been working around.

Match each distinct ::object-id of the group instead. Output is
byte-identical for all four style families of the main repo (default,
outdoors, cycling, vehicle; light and dark), and the block above now
produces exactly what the ::* workaround does.

test_update_styles_by_class pinned the old behaviour ("This class is
ignored by StyleChooser"); it now asserts that both selected classes
are styled.

Signed-off-by: Alexander Borsuk <me@alex.bio>
@biodranik
biodranik force-pushed the ab/object-id-per-block branch from 95aaaf1 to f2446d1 Compare August 16, 2026 14:54
@biodranik
biodranik merged commit 4228459 into master Aug 16, 2026
2 checks passed
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.

2 participants