comaps/kothic
12
0
Fork
You've already forked kothic
2

[REVERTED] Allows keeping multiple styles at a given scale level #33

Merged
x7z4w merged 1 commit from skadge/kothic:style_fallbacks into master 2025年12月07日 18:53:57 +01:00
Contributor
Copy link

This make it possible to have properly 'cascading' styles, with more specific
selector taking the priority over less specific ones.

This make it possible to have properly 'cascading' styles, with more specific selector taking the priority over less specific ones.
This make it possible to have properly 'cascading' styles, with more specific
selector taking the priority over less specific ones
Owner
Copy link

Would this cause Z-fighting though?

Would this cause Z-fighting though?
Author
Contributor
Copy link

@x7z4w

Here a quick test with a simple mapcss file:

node|z14[amenity=fuel][prefs:engine_type!=ev],
{icon-image: fuel-s.svg;}
node|z15-[amenity=fuel][prefs:engine_type!=ev],
{icon-image: fuel-m.svg;}
node|z16-[amenity=fuel][prefs:engine_type=ev],
{icon-image: fuel-dispenser-m.svg;}

Running:

python3 ../tools/kothic/src/libkomwm.py --txt -s test.mapcss -o test_proto -p styles/default/include/

generates:

cont {
 name: "amenity-fuel"
 element {
 scale: 14
 symbol {
 name: "fuel-s"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 15
 symbol {
 name: "fuel-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 16
 symbol {
 name: "fuel-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 16
 symbol {
 name: "fuel-dispenser-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type=ev"
 }
 element {
 scale: 17
 symbol {
 name: "fuel-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 17
 symbol {
 name: "fuel-dispenser-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type=ev"
 }
 element {
 scale: 18
 symbol {
 name: "fuel-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 18
 symbol {
 name: "fuel-dispenser-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type=ev"
 }
 element {
 scale: 19
 symbol {
 name: "fuel-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 19
 symbol {
 name: "fuel-dispenser-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type=ev"
 }
 element {
 scale: 20
 symbol {
 name: "fuel-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type!=ev"
 }
 element {
 scale: 20
 symbol {
 name: "fuel-dispenser-m"
 priority: 4270
 }
 apply_if: "prefs:engine_type=ev"
 }
}

This looks ok to me, but maybe you had something specific in mind with 'z-figthing'?

@x7z4w Here a quick test with a simple mapcss file: ```css node|z14[amenity=fuel][prefs:engine_type!=ev], {icon-image: fuel-s.svg;} node|z15-[amenity=fuel][prefs:engine_type!=ev], {icon-image: fuel-m.svg;} node|z16-[amenity=fuel][prefs:engine_type=ev], {icon-image: fuel-dispenser-m.svg;} ``` Running: ``` python3 ../tools/kothic/src/libkomwm.py --txt -s test.mapcss -o test_proto -p styles/default/include/ ``` generates: ``` cont { name: "amenity-fuel" element { scale: 14 symbol { name: "fuel-s" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 15 symbol { name: "fuel-m" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 16 symbol { name: "fuel-m" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 16 symbol { name: "fuel-dispenser-m" priority: 4270 } apply_if: "prefs:engine_type=ev" } element { scale: 17 symbol { name: "fuel-m" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 17 symbol { name: "fuel-dispenser-m" priority: 4270 } apply_if: "prefs:engine_type=ev" } element { scale: 18 symbol { name: "fuel-m" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 18 symbol { name: "fuel-dispenser-m" priority: 4270 } apply_if: "prefs:engine_type=ev" } element { scale: 19 symbol { name: "fuel-m" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 19 symbol { name: "fuel-dispenser-m" priority: 4270 } apply_if: "prefs:engine_type=ev" } element { scale: 20 symbol { name: "fuel-m" priority: 4270 } apply_if: "prefs:engine_type!=ev" } element { scale: 20 symbol { name: "fuel-dispenser-m" priority: 4270 } apply_if: "prefs:engine_type=ev" } } ``` This looks ok to me, but maybe you had something specific in mind with 'z-figthing'?
Owner
Copy link

OK, after thinking a bit it doesn't matter, because this PR just allows overriding styles with specific tags.

@skadge wrote in #33 (comment):

priority: 4270

FYI, we have issues with two areas Z-fighting because they have the same priority+zoom level.
Maybe we can tweak kothic to bump the priority if the same priority+zoom level pair already exists?

OK, after thinking a bit it doesn't matter, because this PR just allows overriding styles with specific tags. @skadge wrote in https://codeberg.org/comaps/kothic/pulls/33#issuecomment-8778558: > priority: 4270 FYI, we have issues with two areas Z-fighting because they have the same priority+zoom level. Maybe we can tweak kothic to bump the priority if the same priority+zoom level pair already exists?
Author
Contributor
Copy link

thanks for merging!

thanks for merging!
Owner
Copy link

@skadge When I run generate_drules.sh on the current main style files it produces weird comment changes, e.g.

-leisure-garden # area z12- (also has icon z16-, caption(optional) z16-)
+leisure-garden # area z12- (also has icon z16-, caption(optional) z16-, caption z17-)

Could you please fix it?

@skadge When I run generate_drules.sh on the current main style files it produces weird comment changes, e.g. ```diff -leisure-garden # area z12- (also has icon z16-, caption(optional) z16-) +leisure-garden # area z12- (also has icon z16-, caption(optional) z16-, caption z17-) ``` Could you please fix it?
Author
Contributor
Copy link

@pastk -- looking into it, I think the new generated captions are actually correct...

Looking at leisure-garden:

This is the mapcss:

area|z17-[leisure],
{text: name;text-color: @poi_label;text-offset: 1;font-size: 10;}
area|z14-[leisure=park][name],
area|z14-[landuse=forest][name],
area|z16-[leisure=garden][garden:type!=residential][name]
{text: name;text-color: @park_label;text-halo-color: @halo_park_label;text-halo-radius: 0.5;text-halo-opacity: 0.8;icon-min-distance: 8;text-offset: 1;font-size: 10;}
area|z16-[leisure=park][name]::int_name,
area|z16-[landuse=forest][name]::int_name,
area|z16-[leisure=garden][garden:type!=residential][name]::int_name
{text: int_name;text-color: @park_label;text-halo-color: @halo_park_label;text-halo-radius: 0.5;text-halo-opacity: 0.8;text-offset: 1;font-size: 10;}
[...]

If I'm correct, at level 17 and above, the caption (name) will always be displayed (while it is optional at level 16 and below). So the updated comment is correct, no?

@pastk -- looking into it, I think the new generated captions are actually correct... Looking at `leisure-garden`: This is the `mapcss`: ``` area|z17-[leisure], {text: name;text-color: @poi_label;text-offset: 1;font-size: 10;} area|z14-[leisure=park][name], area|z14-[landuse=forest][name], area|z16-[leisure=garden][garden:type!=residential][name] {text: name;text-color: @park_label;text-halo-color: @halo_park_label;text-halo-radius: 0.5;text-halo-opacity: 0.8;icon-min-distance: 8;text-offset: 1;font-size: 10;} area|z16-[leisure=park][name]::int_name, area|z16-[landuse=forest][name]::int_name, area|z16-[leisure=garden][garden:type!=residential][name]::int_name {text: int_name;text-color: @park_label;text-halo-color: @halo_park_label;text-halo-radius: 0.5;text-halo-opacity: 0.8;text-offset: 1;font-size: 10;} [...] ``` If I'm correct, at level 17 and above, the caption (name) will always be displayed (while it is optional at level 16 and below). So the updated comment is correct, no?
Owner
Copy link

Thanks!

caption(optional) means there is also an icon which is the main handle for the POI and a caption becoming optional.

Indeed an icon is present on z16-17 for named gardens only and then z18- for all gardens (incl. no-name ones).
Hence caption(optional) z16- makes sense although it doesn't cover that z16-17 doesn't apply to no-name gardens.

caption z17- is confusing still.
I.e. on z18- all leisure-garden have an icon, so it can't apply to z18-.
And for no-name gardens there is no caption at all, so caption z17- also doesn't make sense.
And the named / no-name gardens distinction starts from z16- so its also not clear where does z17- comes from...

Perhaps caption z17- is somehow wrongly inferred from area|z17-[leisure], line.
Though captions for no-name gardens are explicitly removed by

area|z16-[leisure=garden][garden:type!=residential][!name],
{text: none}

So in the end caption z17- is wrong and confusing.

(please check data/drules_proto_default_light.txt to see actual drawing rules (drules) produced where its more clear if icon/caption are present on particular zooms etc.; I've also checked source mapcss and the drules seem to be generated right)

Thanks! `caption(optional)` means there is also an icon which is the main handle for the POI and a caption becoming optional. Indeed an icon is present on z16-17 for named gardens only and then z18- for all gardens (incl. no-name ones). Hence `caption(optional) z16-` makes sense although it doesn't cover that z16-17 doesn't apply to no-name gardens. `caption z17-` is confusing still. I.e. on z18- all `leisure-garden` have an icon, so it can't apply to z18-. And for no-name gardens there is no caption at all, so `caption z17-` also doesn't make sense. And the named / no-name gardens distinction starts from z16- so its also not clear where does z17- comes from... Perhaps `caption z17-` is somehow wrongly inferred from `area|z17-[leisure],` line. Though captions for no-name gardens are explicitly removed by ``` area|z16-[leisure=garden][garden:type!=residential][!name], {text: none} ``` So in the end `caption z17-` is wrong and confusing. (please check `data/drules_proto_default_light.txt` to see actual drawing rules (drules) produced where its more clear if icon/caption are present on particular zooms etc.; I've also checked source mapcss and the drules seem to be generated right)
pastk changed title from (削除) Allows keeping multiple styles at a given scale level (削除ここまで) to [REVERTED] Allows keeping multiple styles at a given scale level 2026年07月11日 21:19:59 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
comaps/kothic!33
Reference in a new issue
comaps/kothic
No description provided.
Delete branch "skadge/kothic:style_fallbacks"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?