Add casing-width-add support #5

Merged
root merged 2 commits from pastk-noeval into master 2023-01-20 14:29:46 +00:00
Owner

To be able to use e.g.

{casing-width-add: 1;}

instead of

{casing-width: eval(prop("width")+1);}

To solve issue with eval()'s use https://github.com/organicmaps/organicmaps/issues/4258
and to simplify mapcss files' syntax too.

To be able to use e.g. ``` {casing-width-add: 1;} ``` instead of ``` {casing-width: eval(prop("width")+1);} ``` To solve issue with eval()'s use https://github.com/organicmaps/organicmaps/issues/4258 and to simplify mapcss files' syntax too.
Author
Owner

Made casing-width to have precedence over casing-width-add as its more logical. Has no effect on current styles.

Made `casing-width` to have precedence over `casing-width-add` as its more logical. Has no effect on current styles.
biodranik (Migrated from github.com) approved these changes 2023-01-18 14:11:11 +00:00
biodranik (Migrated from github.com) left a comment

@vng

@vng
vng (Migrated from github.com) reviewed 2023-01-18 15:45:27 +00:00
vng (Migrated from github.com) commented 2023-01-18 15:40:44 +00:00

lets keep 4 spaces tab

lets keep 4 spaces tab
@ -362,3 +374,4 @@
dr_line.width = round((base_width + st.get('casing-width') * 2) * WIDTH_SCALE, 2)
dr_line.color = mwm_encode_color(colors, st, "casing")
if '-x-me-casing-line-priority' in st:
dr_line.priority = int(st.get('-x-me-casing-line-priority'))
vng (Migrated from github.com) commented 2023-01-18 15:44:58 +00:00

Hm, looks strange here. Why does width depend from ::dash or ::default ?

Hm, looks strange here. Why does width depend from ::dash or ::default ?
pastk reviewed 2023-01-18 19:49:22 +00:00
@ -362,3 +374,4 @@
dr_line.width = round((base_width + st.get('casing-width') * 2) * WIDTH_SCALE, 2)
dr_line.color = mwm_encode_color(colors, st, "casing")
if '-x-me-casing-line-priority' in st:
dr_line.priority = int(st.get('-x-me-casing-line-priority'))
Author
Owner

Because railways have inner ::dash line and outer ::default line. And railway bridge evals were taking it from the first one. If there are several style object with the same param (e.g. width) then the eval() code was taking the last one - probably in order they were declared in the file (::dash lines are declared later).
I think it'll be better to hardcode it to take width from ::default always but that would mean rewriting all railway bridges casing-width-add params which were inherited from evals. And it could possibly break some other declarations that were relying on this order. So I preferred not to touch it for now.

Because railways have inner ::dash line and outer ::default line. And railway bridge evals were taking it from the first one. If there are several style object with the same param (e.g. width) then the eval() code was taking the last one - probably in order they were declared in the file (::dash lines are declared later). I think it'll be better to hardcode it to take width from ::default always but that would mean rewriting all railway bridges casing-width-add params which were inherited from evals. And it could possibly break some other declarations that were relying on this order. So I preferred not to touch it for now.
pastk reviewed 2023-01-18 19:53:04 +00:00
Author
Owner

fixed!

fixed!
vng (Migrated from github.com) reviewed 2023-01-19 14:02:02 +00:00
@ -362,3 +374,4 @@
dr_line.width = round((base_width + st.get('casing-width') * 2) * WIDTH_SCALE, 2)
dr_line.color = mwm_encode_color(colors, st, "casing")
if '-x-me-casing-line-priority' in st:
dr_line.priority = int(st.get('-x-me-casing-line-priority'))
vng (Migrated from github.com) commented 2023-01-19 14:02:02 +00:00

Hm, the logic looks very unclear here. What about taking max width (for all ::XXX tags) when referencing?

Hm, the logic looks very unclear here. What about taking max width (for all ::XXX tags) when referencing?
pastk reviewed 2023-01-19 17:30:24 +00:00
@ -362,3 +374,4 @@
dr_line.width = round((base_width + st.get('casing-width') * 2) * WIDTH_SCALE, 2)
dr_line.color = mwm_encode_color(colors, st, "casing")
if '-x-me-casing-line-priority' in st:
dr_line.priority = int(st.get('-x-me-casing-line-priority'))
Author
Owner

Yeap its possible, an ultimate question is how we define the base/core width - is it the first/default defined line? Or the inner-most (narrowest) line? Or the outer-most (widest) one?

Yeap its possible, an ultimate question is how we define the base/core width - is it the first/default defined line? Or the inner-most (narrowest) line? Or the outer-most (widest) one?
pastk reviewed 2023-01-20 13:29:55 +00:00
@ -362,3 +374,4 @@
dr_line.width = round((base_width + st.get('casing-width') * 2) * WIDTH_SCALE, 2)
dr_line.color = mwm_encode_color(colors, st, "casing")
if '-x-me-casing-line-priority' in st:
dr_line.priority = int(st.get('-x-me-casing-line-priority'))
Author
Owner

ATM railways' bridge rules are based on ::dash lines which are narrower, so we'll have to re-do them if we change to the widest line. Hence I left it as is.

ATM railways' bridge rules are based on `::dash` lines which are narrower, so we'll have to re-do them if we change to the widest line. Hence I left it as is.
Author
Owner

Change: look up for base_width in other style objects if its missing for use in simple casing-width calculation.

PTAL!

Change: look up for base_width in other style objects if its missing for use in simple `casing-width` calculation. PTAL!
vng (Migrated from github.com) approved these changes 2023-01-20 14:21:43 +00:00
biodranik (Migrated from github.com) approved these changes 2023-01-20 14:28:20 +00:00
Sign in to join this conversation.
No description provided.