Display housenumbers above icons and main captions #5700

Merged
root merged 2 commits from pastk-drape-housenumbers-priority into master 2023-09-19 11:55:20 +00:00
22 changed files with 561 additions and 360 deletions

Binary file not shown.

View file

@ -5936,23 +5936,6 @@ cont {
}
cont {
name: "amenity-loading_dock"
element {
scale: 18
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
is_optional: true
}
priority: -10000
}
}
element {
scale: 19
symbol {
@ -5963,7 +5946,6 @@ cont {
primary {
height: 10
color: 4473924
offset_x: 1
offset_y: 1
is_optional: true
}
@ -13882,7 +13864,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13897,7 +13879,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13912,7 +13894,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13927,7 +13909,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
}
@ -15293,15 +15275,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 6381914
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -10000
@ -15310,23 +15289,6 @@ cont {
}
cont {
name: "entrance-exit"
element {
scale: 18
symbol {
name: "exit-s"
priority: -10000
}
caption {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
is_optional: true
}
priority: -10000
}
}
element {
scale: 19
symbol {
@ -15337,15 +15299,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 6381914
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -10000
@ -15364,8 +15323,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 6381914
is_optional: true
}
priority: -9780
@ -15381,15 +15344,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 6381914
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -9780

Binary file not shown.

View file

@ -5902,23 +5902,6 @@ cont {
}
cont {
name: "amenity-loading_dock"
element {
scale: 18
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
is_optional: true
}
priority: -10000
}
}
element {
scale: 19
symbol {
@ -5929,7 +5912,6 @@ cont {
primary {
height: 10
color: 4473924
offset_x: 1
offset_y: 1
is_optional: true
}
@ -13740,7 +13722,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13755,7 +13737,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13770,7 +13752,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13785,7 +13767,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 200
priority: -9970
}
}
}
@ -15151,15 +15133,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 6381914
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -10000
@ -15168,23 +15147,6 @@ cont {
}
cont {
name: "entrance-exit"
element {
scale: 18
symbol {
name: "exit-s"
priority: -10000
}
caption {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
is_optional: true
}
priority: -10000
}
}
element {
scale: 19
symbol {
@ -15195,15 +15157,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 6381914
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -10000
@ -15222,8 +15181,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 6381914
is_optional: true
}
priority: -9780
@ -15239,15 +15202,12 @@ cont {
primary {
height: 10
color: 6381914
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 6381914
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -9780

Binary file not shown.

View file

@ -5902,23 +5902,6 @@ cont {
}
cont {
name: "amenity-loading_dock"
element {
scale: 18
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 10
color: 5592405
offset_x: 1
text: "ref"
is_optional: true
}
priority: -10000
}
}
element {
scale: 19
symbol {
@ -5929,7 +5912,6 @@ cont {
primary {
height: 10
color: 5592405
offset_x: 1
offset_y: 1
is_optional: true
}
@ -13740,7 +13722,7 @@ cont {
color: 5263440
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13755,7 +13737,7 @@ cont {
color: 5263440
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13770,7 +13752,7 @@ cont {
color: 5263440
offset_y: 1
}
priority: 200
priority: -9970
}
}
element {
@ -13785,7 +13767,7 @@ cont {
color: 5263440
offset_y: 1
}
priority: 200
priority: -9970
}
}
}
@ -15151,15 +15133,12 @@ cont {
primary {
height: 10
color: 5592405
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 5592405
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -10000
@ -15168,23 +15147,6 @@ cont {
}
cont {
name: "entrance-exit"
element {
scale: 18
symbol {
name: "exit-s"
priority: -10000
}
caption {
primary {
height: 10
color: 5592405
offset_x: 1
text: "ref"
is_optional: true
}
priority: -10000
}
}
element {
scale: 19
symbol {
@ -15195,15 +15157,12 @@ cont {
primary {
height: 10
color: 5592405
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 5592405
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -10000
@ -15222,8 +15181,12 @@ cont {
primary {
height: 10
color: 5592405
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 5592405
is_optional: true
}
priority: -9780
@ -15239,15 +15202,12 @@ cont {
primary {
height: 10
color: 5592405
offset_x: 1
text: "ref"
offset_y: 1
is_optional: true
}
secondary {
height: 10
height: 8
color: 5592405
offset_y: 10
text: "addr:flats"
is_optional: true
}
priority: -9780

Binary file not shown.

View file

@ -1689,6 +1689,25 @@ cont {
}
}
}
cont {
name: "amenity-loading_dock"
element {
scale: 19
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 13
color: 6381914
offset_y: 1
is_optional: true
}
priority: -10000
}
}
}
cont {
name: "amenity-motorcycle_parking"
element {
@ -6010,7 +6029,11 @@ cont {
primary {
height: 13
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 12
color: 6381914
offset_y: 1
}
priority: 50
}
@ -6029,7 +6052,11 @@ cont {
primary {
height: 14
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 13
color: 6381914
offset_y: 1
}
priority: 50
}
@ -6049,7 +6076,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 30
priority: 150
}
}
element {
@ -6064,7 +6091,7 @@ cont {
color: 6645086
offset_y: 1
}
priority: 30
priority: 150
}
}
}
@ -6117,7 +6144,11 @@ cont {
primary {
height: 13
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 12
color: 6381914
offset_y: 1
}
priority: 30
}
@ -6136,7 +6167,11 @@ cont {
primary {
height: 14
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 13
color: 6381914
offset_y: 1
}
priority: 30
}
@ -6191,7 +6226,11 @@ cont {
primary {
height: 13
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 12
color: 6381914
offset_y: 1
}
priority: 50
}
@ -6210,7 +6249,11 @@ cont {
primary {
height: 14
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 13
color: 6381914
offset_y: 1
}
priority: 50
}
@ -6265,7 +6308,11 @@ cont {
primary {
height: 13
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 12
color: 6381914
offset_y: 1
}
priority: 550
}
@ -6284,7 +6331,11 @@ cont {
primary {
height: 14
color: 6381914
text: "addr:housenumber"
}
secondary {
height: 13
color: 6381914
offset_y: 1
}
priority: 550
}
@ -6337,6 +6388,99 @@ cont {
}
}
}
cont {
name: "entrance"
element {
scale: 19
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 13
color: 6381914
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 6381914
is_optional: true
}
priority: -10000
}
}
}
cont {
name: "entrance-exit"
element {
scale: 19
symbol {
name: "exit-s"
priority: -10000
}
caption {
primary {
height: 13
color: 6381914
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 6381914
is_optional: true
}
priority: -10000
}
}
}
cont {
name: "entrance-main"
element {
scale: 18
symbol {
name: "main_entrance-s"
priority: 20
}
caption {
primary {
height: 13
color: 6381914
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 6381914
is_optional: true
}
priority: -9980
}
}
element {
scale: 19
symbol {
name: "main_entrance-s"
priority: 20
}
caption {
primary {
height: 13
color: 6381914
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 6381914
is_optional: true
}
priority: -9980
}
}
}
cont {
name: "highway-bridleway"
element {

Binary file not shown.

View file

@ -1689,6 +1689,25 @@ cont {
}
}
}
cont {
name: "amenity-loading_dock"
element {
scale: 19
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 13
color: 7566195
offset_y: 1
is_optional: true
}
priority: -10000
}
}
}
cont {
name: "amenity-motorcycle_parking"
element {
@ -6010,7 +6029,11 @@ cont {
primary {
height: 13
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 12
color: 7566195
offset_y: 1
}
priority: 50
}
@ -6029,7 +6052,11 @@ cont {
primary {
height: 14
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 13
color: 7566195
offset_y: 1
}
priority: 50
}
@ -6049,7 +6076,7 @@ cont {
color: 7105644
offset_y: 1
}
priority: 30
priority: 150
}
}
element {
@ -6064,7 +6091,7 @@ cont {
color: 7105644
offset_y: 1
}
priority: 30
priority: 150
}
}
}
@ -6117,7 +6144,11 @@ cont {
primary {
height: 13
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 12
color: 7566195
offset_y: 1
}
priority: 30
}
@ -6136,7 +6167,11 @@ cont {
primary {
height: 14
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 13
color: 7566195
offset_y: 1
}
priority: 30
}
@ -6191,7 +6226,11 @@ cont {
primary {
height: 13
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 12
color: 7566195
offset_y: 1
}
priority: 50
}
@ -6210,7 +6249,11 @@ cont {
primary {
height: 14
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 13
color: 7566195
offset_y: 1
}
priority: 50
}
@ -6265,7 +6308,11 @@ cont {
primary {
height: 13
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 12
color: 7566195
offset_y: 1
}
priority: 550
}
@ -6284,7 +6331,11 @@ cont {
primary {
height: 14
color: 7566195
text: "addr:housenumber"
}
secondary {
height: 13
color: 7566195
offset_y: 1
}
priority: 550
}
@ -6337,6 +6388,99 @@ cont {
}
}
}
cont {
name: "entrance"
element {
scale: 19
symbol {
name: "entrance-s"
priority: -10000
}
caption {
primary {
height: 13
color: 7566195
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 7566195
is_optional: true
}
priority: -10000
}
}
}
cont {
name: "entrance-exit"
element {
scale: 19
symbol {
name: "exit-s"
priority: -10000
}
caption {
primary {
height: 13
color: 7566195
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 7566195
is_optional: true
}
priority: -10000
}
}
}
cont {
name: "entrance-main"
element {
scale: 18
symbol {
name: "main_entrance-s"
priority: 20
}
caption {
primary {
height: 13
color: 7566195
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 7566195
is_optional: true
}
priority: -9980
}
}
element {
scale: 19
symbol {
name: "main_entrance-s"
priority: 20
}
caption {
primary {
height: 13
color: 7566195
offset_y: 1
is_optional: true
}
secondary {
height: 8
color: 7566195
is_optional: true
}
priority: -9980
}
}
}
cont {
name: "highway-bridleway"
element {

View file

@ -610,20 +610,29 @@ area|z16-[building]::int_name,
node|z16-[building]::int_name,
{text:int_name;text-color: @building_label;text-position: center;}
/*
Housenumbers have a special display logic hardcoded in drape_frontend/stylist.cpp and apply_feature_functors.cpp.
They use a building-address ([addr:housenumber][addr:street]) style and are placed above icons or main captions when
- a feature has a housenumber stored in the feature header
- main feature type has a caption drule for a given zoom level
- there is a secondary caption drule or main text is absent
Housenumbers and main captions are displaced independently (e.g. a housenumber will stay if a building name is displaced),
but are bound to icons (e.g. a housenumber will disappear if a parent icon is displaced).
*/
node|z16-[addr:housenumber][addr:street],
{text: name; text-color: @housenumber; text-position: center;}
node|z16-[addr:housenumber][addr:street]::int_name,
{text: int_name; text-color: @housenumber; text-position: center;}
node|z19-[entrance],
node|z18-[entrance=main],
node|z18-[entrance=exit],
node|z18-[amenity=loading_dock],
{text-color: @building_label;}
node|z19-[entrance]::flats,
node|z19-[entrance],
node|z19-[entrance=exit],
node|z19-[amenity=loading_dock],
{text: name; text-color: @building_label;}
node|z18-[entrance=main]::flats,
node|z18-[entrance=exit]::flats,
{text-color: @building_label;}
node|z19-[entrance]::flats,
node|z19-[entrance=exit]::flats,
{text: int_name; text-color: @building_label; font-size: 8;}
/* 8.1 Pier */
area|z15-[waterway=dam],
@ -661,14 +670,12 @@ node|z16-[addr:housenumber][addr:street]::int_name,
{font-size: 8;}
node|z19-[entrance],
node|z18-[amenity=loading_dock],
{icon-image: entrance-s.svg;font-size: 10;text: ref;text-offset-x: 1;}
node|z18-[entrance=exit],
{icon-image: exit-s.svg;font-size: 10;text: ref;text-offset-x: 1;}
node|z19-[amenity=loading_dock],
{icon-image: entrance-s.svg; font-size: 10; text-offset: 1;}
node|z19-[entrance=exit],
{icon-image: exit-s.svg; font-size: 10; text-offset: 1;}
node|z18-[entrance=main],
{icon-image: main_entrance-s.svg;font-size: 10;text: ref;text-offset-x: 1;}
node|z19-[entrance]::flats
{text: "addr:flats";font-size: 10;text-offset-y: 10;}
{icon-image: main_entrance-s.svg; font-size: 10; text-offset: 1;}
/* 8.3 Airports */
area|z14-[aeroway=terminal]

View file

@ -1265,7 +1265,6 @@ historic-stone # icon z18- (also has captio
amenity-post_box # icon z18- (also has caption(optional) z18-)
amenity-recycling-container # icon z17- (also has caption(optional) z19-)
building-address # caption z16-
historic-memorial-stolperstein # icon z19- (also has caption(optional) z19-)
leisure-garden-residential # caption z18- (also has area z12-)
=== 200
@ -2186,6 +2185,7 @@ amenity-vending_machine-excrement_bags # icon z18- (also has captio
amenity-vending_machine-food # icon z18- (also has caption(optional) z18-)
amenity-vending_machine-newspapers # icon z18- (also has caption(optional) z18-)
amenity-vending_machine-sweets # icon z18- (also has caption(optional) z18-)
building-address # caption z16-
=== -9970
amenity-bench # icon z18- (also has caption(optional) z19-)
@ -2201,8 +2201,8 @@ power-substation # icon z19- (also has captio
=== -9990
# amenity-bench # caption(optional) z19- (also has icon z18-)
amenity-loading_dock # icon z18- (also has caption(optional) z18-)
# amenity-loading_dock # caption(optional) z18- (also has icon z18-)
amenity-loading_dock # icon z19- (also has caption(optional) z19-)
# amenity-loading_dock # caption(optional) z19- (also has icon z19-)
# amenity-parking_space-disabled # caption(optional) z19- (also has icon z18-)
# amenity-telephone # caption(optional) z19- (also has icon z17-)
# amenity-vending_machine # caption(optional) z18- (also has icon z18-)
@ -2220,8 +2220,8 @@ amenity-loading_dock # icon z18- (also has captio
# emergency-defibrillator # caption(optional) z18- (also has icon z18-)
# emergency-fire_hydrant # caption(optional) z19- (also has icon z19-)
# entrance # caption(optional) z19- (also has icon z19-)
entrance-exit # icon z18- (also has caption(optional) z18-)
# entrance-exit # caption(optional) z18- (also has icon z18-)
entrance-exit # icon z19- (also has caption(optional) z19-)
# entrance-exit # caption(optional) z19- (also has icon z19-)
# man_made-survey_point # caption(optional) z16- (also has icon z16-)
# power-substation # caption(optional) z19- (also has icon z19-)
# tourism-information # caption(optional) z16- (also has icon z16-)

View file

@ -488,18 +488,34 @@ node|z15-[landuse=quarry],
area|z18-[building],
node|z18-[building],
{text: name; text-color: @building_label; text-position: center;}
area|z18-[building]::int_name,
node|z18-[building]::int_name,
{text: addr:housenumber;text-color: @building_label;text-position: center;}
{text: int_name; text-color: @building_label; text-position: center;}
/*
Housenumbers have a special display logic hardcoded in drape_frontend/stylist.cpp and apply_feature_functors.cpp.
They use a building-address ([addr:housenumber][addr:street]) style and are placed above icons or main captions when
- a feature has a housenumber stored in the feature header
- main feature type has a caption drule for a given zoom level
- there is a secondary caption drule or main text is absent
Housenumbers and main captions are displaced independently (e.g. a housenumber will stay if a building name is displaced),
but are bound to icons (e.g. a housenumber will disappear if a parent icon is displaced).
*/
node|z18-[addr:housenumber][addr:street],
{text: name; text-color: @housenumber; text-position: center;}
node|z18-[addr:housenumber][addr:street]::int_name,
{text: int_name; text-color: @housenumber; text-position: center;}
node|z18-[entrance],
node|z18-[amenity=loading_dock],
{text-color: @building_label;}
node|z18-[entrance=main],
node|z19-[entrance],
node|z19-[entrance=exit],
node|z19-[amenity=loading_dock],
{text: name; text-color: @building_label;}
node|z18-[entrance=main]::flats,
node|z19-[entrance]::flats,
node|z19-[entrance=exit]::flats,
{text: int_name; text-color: @building_label; font-size: 8;}
/* 8.1 Pier */
@ -526,6 +542,14 @@ node|z19[addr:housenumber][addr:street],
node|z18-[addr:housenumber][addr:street]::int_name,
{font-size: 12;}
node|z19-[entrance],
node|z19-[amenity=loading_dock],
{icon-image: entrance-s.svg; font-size: 13; text-offset: 1;}
node|z19-[entrance=exit],
{icon-image: exit-s.svg; font-size: 13; text-offset: 1;}
node|z18-[entrance=main],
{icon-image: main_entrance-s.svg; font-size: 13; text-offset: 1;}
/* 8.3 Airports */
area|z14-[aeroway=terminal]
{fill-color: @building;}

View file

@ -688,6 +688,7 @@ amenity-post_office # icon z17- (also has captio
shop-motorcycle # icon z17-
=== 200
building-address # caption z18-
landuse-landfill # caption z15- (also has area z15-)
landuse-quarry # caption z15- (also has area z15-)
landuse-railway # caption z15- (also has area z15-)
@ -701,10 +702,12 @@ building # caption z18- (also has are
building-has_parts # caption z18- (also has area z15-)
=== 50
building-address # caption z18-
building-garage # caption z18- (also has area z15-)
=== 30
entrance-main # icon z18- (also has caption(optional) z18-)
=== 20
#
# All automatic optional captions priorities are below 0.
# They follow the order of their correspoding icons.
@ -1136,3 +1139,14 @@ building-garage # caption z18- (also has are
# leisure-park-no-access # caption(optional) z14- (also has icon z14-, area z10-)
# leisure-park-private # caption(optional) z14- (also has icon z14-, area z10-)
# === -9900
# entrance-main # caption(optional) z18- (also has icon z18-)
# === -9980
amenity-loading_dock # icon z19- (also has caption(optional) z19-)
# amenity-loading_dock # caption(optional) z19- (also has icon z19-)
entrance # icon z19- (also has caption(optional) z19-)
# entrance # caption(optional) z19- (also has icon z19-)
entrance-exit # icon z19- (also has caption(optional) z19-)
# entrance-exit # caption(optional) z19- (also has icon z19-)
=== -10000

View file

@ -80,7 +80,7 @@ world 00000000000000000000 +
kindergarten 00000000000000000000 -
language_school 00000000000000000000 -
library 00000000000000000000 -
loading_dock 00000000000000000000 -
loading_dock 00000000000000000001 -
marketplace 00000000000000000000 -
money_transfer 00000000000000000000 -
motorcycle_parking 00000000000000000111 -
@ -368,9 +368,9 @@ world 00000000000000000000 +
fire_hydrant 00000000000000000000 -
phone 00000000000000000000 -
{}
entrance 00000000000000000000 +
exit 00000000000000000000 -
main 00000000000000000000 -
entrance 00000000000000000001 +
exit 00000000000000000001 -
main 00000000000000000011 -
{}
healthcare 00000000000000000000 +
alternative 00000000000000000000 -

View file

@ -369,27 +369,24 @@ void BaseApplyFeature::ExtractCaptionParams(CaptionDefProto const * primaryProto
CaptionDefProto const * secondaryProto,
TextViewParams & params) const
{
auto & titleDecl = params.m_titleDecl;
dp::FontDecl decl;
CaptionDefProtoToFontDecl(primaryProto, decl);
params.m_featureId = m_id;
auto & titleDecl = params.m_titleDecl;
titleDecl.m_anchor = GetAnchor(primaryProto->offset_x(), primaryProto->offset_y());
titleDecl.m_primaryText = m_captions.GetMainText();
titleDecl.m_primaryTextFont = decl;
titleDecl.m_anchor = GetAnchor(primaryProto->offset_x(), primaryProto->offset_y());
// TODO: remove offsets processing as de-facto "text-offset: *" is used to define anchors only.
titleDecl.m_primaryOffset = GetOffset(primaryProto->offset_x(), primaryProto->offset_y());
titleDecl.m_primaryOptional = primaryProto->is_optional();
// Secondary captions are optional always.
titleDecl.m_secondaryOptional = true;
if (secondaryProto)
if (!titleDecl.m_secondaryText.empty())
{
ASSERT(secondaryProto != nullptr, ());
dp::FontDecl auxDecl;
CaptionDefProtoToFontDecl(secondaryProto, auxDecl);
titleDecl.m_secondaryText = m_captions.GetAuxText();
titleDecl.m_secondaryTextFont = auxDecl;
// Secondary captions are optional always.
titleDecl.m_secondaryOptional = true;
}
}
@ -417,7 +414,7 @@ void ApplyPointFeature::operator()(m2::PointD const & point, bool hasArea)
m_centerPoint = point;
}
void ApplyPointFeature::ProcessPointRule(Stylist::TRuleWrapper const & rule)
void ApplyPointFeature::ProcessPointRule(TRuleWrapper const & rule)
{
if (!m_hasPoint)
return;
@ -427,15 +424,29 @@ void ApplyPointFeature::ProcessPointRule(Stylist::TRuleWrapper const & rule)
{
m_symbolDepth = rule.m_depth;
m_symbolRule = symRule;
return;
}
CaptionDefProto const * capRule = rule.m_rule->GetCaption(0);
if (capRule)
{
CaptionDefProto const * auxRule = rule.m_rule->GetCaption(1);
TextViewParams params;
params.m_tileCenter = m_tileRect.Center();
ExtractCaptionParams(capRule, rule.m_rule->GetCaption(1), params);
if (rule.m_isHouseNumber)
params.m_titleDecl.m_primaryText = m_captions.GetHouseNumberText();
else
{
params.m_titleDecl.m_primaryText = m_captions.GetMainText();
if (auxRule != nullptr)
params.m_titleDecl.m_secondaryText = m_captions.GetAuxText();
}
ASSERT(!params.m_titleDecl.m_primaryText.empty(), ());
ExtractCaptionParams(capRule, auxRule, params);
params.m_depth = rule.m_depth;
params.m_featureId = m_id;
params.m_tileCenter = m_tileRect.Center();
params.m_depthLayer = DepthLayer::OverlayLayer;
params.m_depthTestEnabled = false;
params.m_rank = m_rank;
@ -443,9 +454,10 @@ void ApplyPointFeature::ProcessPointRule(Stylist::TRuleWrapper const & rule)
params.m_hasArea = m_hasArea;
params.m_createdByEditor = m_createdByEditor;
auto const & titleDecl = params.m_titleDecl;
if (!titleDecl.m_primaryText.empty() || !titleDecl.m_secondaryText.empty())
m_textParams.push_back(params);
if (rule.m_isHouseNumber)
m_hnParams = params;
else
m_textParams = params;
}
}
@ -453,10 +465,10 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng)
{
m2::PointF symbolSize(0.0f, 0.0f);
bool const hasPOI = m_symbolRule != nullptr;
bool const hasIcon = m_symbolRule != nullptr;
auto const & visualParams = df::VisualParams::Instance();
double const mainScale = visualParams.GetVisualScale();
if (hasPOI)
if (hasIcon)
{
double const poiExtendScale = visualParams.GetPoiExtendScale();
@ -486,18 +498,38 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng)
LOG(LERROR, ("Style error. Symbol name must be valid for feature", m_id));
}
for (auto textParams : m_textParams)
bool const hasText = !m_textParams.m_titleDecl.m_primaryText.empty();
bool const hasHouseNumber = !m_hnParams.m_titleDecl.m_primaryText.empty();
if (hasText)
{
/// @todo Hardcoded styles-bug patch. The patch is ok, but probably should enhance (or fire assert) styles?
/// @see https://github.com/organicmaps/organicmaps/issues/2573
if (hasPOI && textParams.m_titleDecl.m_anchor == dp::Anchor::Center)
if ((hasIcon || hasHouseNumber) && m_textParams.m_titleDecl.m_anchor == dp::Anchor::Center)
{
textParams.m_titleDecl.m_anchor = GetAnchor(0, 1);
textParams.m_titleDecl.m_primaryOffset = GetOffset(0, 1);
ASSERT(!hasIcon, ("A `text-offset: *` is not set in styles.", m_id, m_textParams.m_titleDecl.m_primaryText));
m_textParams.m_titleDecl.m_anchor = GetAnchor(0, 1);
}
textParams.m_startOverlayRank = hasPOI ? dp::OverlayRank1 : dp::OverlayRank0;
m_insertShape(make_unique_dp<TextShape>(m2::PointD(m_centerPoint), textParams, m_tileKey, symbolSize,
m_textParams.m_startOverlayRank = hasIcon ? dp::OverlayRank1 : dp::OverlayRank0;
auto shape = make_unique_dp<TextShape>(m2::PointD(m_centerPoint), m_textParams, m_tileKey, symbolSize,
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
dp::Center /* symbolAnchor */, 0 /* textIndex */);
m_insertShape(std::move(shape));
}
if (hasHouseNumber)
{
// If icon or main text exists then put housenumber above them.
if (hasIcon || hasText)
{
m_hnParams.m_titleDecl.m_anchor = GetAnchor(0, -1);
if (hasIcon)
{
m_hnParams.m_titleDecl.m_primaryOptional = true;
m_hnParams.m_startOverlayRank = dp::OverlayRank1;
}
}
m_insertShape(make_unique_dp<TextShape>(m2::PointD(m_centerPoint), m_hnParams, m_tileKey, symbolSize,
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
dp::Center /* symbolAnchor */, 0 /* textIndex */));
}
@ -672,7 +704,7 @@ void ApplyAreaFeature::CalculateBuildingOutline(bool calculateNormals, BuildingO
}
}
void ApplyAreaFeature::ProcessAreaRule(Stylist::TRuleWrapper const & rule)
void ApplyAreaFeature::ProcessAreaRule(TRuleWrapper const & rule)
{
AreaRuleProto const * areaRule = rule.m_rule->GetArea();
if (areaRule && !m_triangles.empty())
@ -762,7 +794,7 @@ bool ApplyLineFeatureGeometry::HasGeometry() const
return m_spline->IsValid();
}
void ApplyLineFeatureGeometry::ProcessLineRule(Stylist::TRuleWrapper const & rule)
void ApplyLineFeatureGeometry::ProcessLineRule(TRuleWrapper const & rule)
{
ASSERT(HasGeometry(), ());
@ -849,7 +881,7 @@ ApplyLineFeatureAdditional::ApplyLineFeatureAdditional(TileKey const & tileKey,
, m_shieldRule(nullptr)
{}
void ApplyLineFeatureAdditional::ProcessLineRule(Stylist::TRuleWrapper const & rule)
void ApplyLineFeatureAdditional::ProcessLineRule(TRuleWrapper const & rule)
{
if (m_clippedSplines.empty())
return;

View file

@ -65,7 +65,7 @@ public:
uint8_t rank, CaptionDescription const & captions, float posZ);
void operator()(m2::PointD const & point, bool hasArea);
void ProcessPointRule(Stylist::TRuleWrapper const & rule);
void ProcessPointRule(TRuleWrapper const & rule);
void Finish(ref_ptr<dp::TextureManager> texMng);
protected:
@ -79,7 +79,8 @@ private:
float m_symbolDepth;
SymbolRuleProto const * m_symbolRule;
m2::PointF m_centerPoint;
std::vector<TextViewParams> m_textParams;
TextViewParams m_textParams;
TextViewParams m_hnParams;
};
class ApplyAreaFeature : public ApplyPointFeature
@ -95,7 +96,7 @@ public:
using TBase::operator ();
void operator()(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3);
void ProcessAreaRule(Stylist::TRuleWrapper const & rule);
void ProcessAreaRule(TRuleWrapper const & rule);
struct Edge
{
@ -155,7 +156,7 @@ public:
void operator() (m2::PointD const & point);
bool HasGeometry() const;
void ProcessLineRule(Stylist::TRuleWrapper const & rule);
void ProcessLineRule(TRuleWrapper const & rule);
void Finish();
std::vector<m2::SharedSpline> const & GetClippedSplines() const { return m_clippedSplines; }
@ -186,7 +187,7 @@ public:
uint8_t rank, CaptionDescription const & captions,
std::vector<m2::SharedSpline> const & clippedSplines);
void ProcessLineRule(Stylist::TRuleWrapper const & rule);
void ProcessLineRule(TRuleWrapper const & rule);
void Finish(ref_ptr<dp::TextureManager> texMng, ftypes::RoadShieldsSetT const & roadShields,
GeneratedRoadShields & generatedRoadShields);

View file

@ -314,7 +314,7 @@ void RuleDrawer::ProcessAreaStyle(FeatureType & f, Stylist const & s, TInsertSha
#ifdef DEBUG
// Check that we have max 2 area styles (hatching and filling).
s.ForEachRule([count = 0](Stylist::TRuleWrapper const & rule) mutable
s.ForEachRule([count = 0](TRuleWrapper const & rule) mutable
{
if (rule.m_rule->GetArea())
{

View file

@ -110,9 +110,7 @@ public:
Aggregator(FeatureType & f, feature::GeomType const type, int const zoomLevel, size_t const keyCount)
: m_pointStyleFound(false)
, m_lineStyleFound(false)
, m_auxCaptionFound(false)
, m_mainTextType(drule::text_type_name)
, m_captionRule({ nullptr, 0, false })
, m_captionRule({ nullptr, 0, false, false })
, m_f(f)
, m_geomType(type)
, m_zoomLevel(zoomLevel)
vng commented 2023-09-17 21:48:38 +00:00 (Migrated from github.com)
Review

Does m_captionRule != nullptr means m_mainCaptionFound == true ?
Also I think that m_auxCaptionFound flag also not needed.
Can replace with TRuleWrapper::HasMainCaption, TRuleWrapper::HasAuxCaption

Does m_captionRule != nullptr means m_mainCaptionFound == true ? Also I think that m_auxCaptionFound flag also not needed. Can replace with TRuleWrapper::HasMainCaption, TRuleWrapper::HasAuxCaption
Review

good catch, thanks!

good catch, thanks!
@ -140,10 +138,8 @@ public:
bool m_pointStyleFound;
bool m_lineStyleFound;
bool m_auxCaptionFound;
drule::text_type_t m_mainTextType;
buffer_vector<Stylist::TRuleWrapper, 8> m_rules;
Stylist::TRuleWrapper m_captionRule;
TRuleWrapper m_captionRule;
buffer_vector<TRuleWrapper, 8> m_rules;
private:
void ProcessKey(drule::Key const & key)
@ -185,12 +181,10 @@ private:
drule::BaseRule const * const dRule = drule::rules().Find(key);
if (dRule == nullptr)
return;
Stylist::TRuleWrapper const rule = { dRule, static_cast<float>(depth), key.m_hatching };
TRuleWrapper const rule({ dRule, static_cast<float>(depth), key.m_hatching, false });
if (dRule->GetCaption(0) != nullptr)
{
m_mainTextType = dRule->GetCaptionTextType(0);
m_auxCaptionFound |= (dRule->GetCaption(1) != nullptr);
// Don't add a caption rule to m_rules immediately, put aside for further processing.
m_captionRule = rule;
}
@ -265,88 +259,49 @@ bool IsHatchingTerritoryChecker::IsMatched(uint32_t type) const
}
void CaptionDescription::Init(FeatureType & f, int8_t deviceLang, int const zoomLevel,
feature::GeomType const type, drule::text_type_t const mainTextType,
bool const auxCaptionExists)
feature::GeomType const type, bool const auxCaptionExists)
{
feature::NameParamsOut out;
vng commented 2023-09-17 22:05:07 +00:00 (Migrated from github.com)
Review

ASSERT(m_auxText.empty() || !m_mainText.empty())

ASSERT(m_auxText.empty() || !m_mainText.empty())
Review

fixed, thanks!

fixed, thanks!
if (auxCaptionExists || type == feature::GeomType::Line)
// TODO: remove forced secondary text for all lines and set it via styles for major roads and rivers only.
// ATM even minor paths/streams/etc use secondary which makes their pathtexts take much more space.
if (zoomLevel > scales::GetUpperWorldScale() && (auxCaptionExists || type == feature::GeomType::Line))
{
// Get both primary and secondary/aux names.
f.GetPreferredNames(true /* allowTranslit */, deviceLang, out);
m_auxText = out.secondary;
}
else
{
// Returns primary name only.
f.GetReadableName(true /* allowTranslit */, deviceLang, out);
}
m_mainText = out.GetPrimary();
m_auxText = out.secondary;
ASSERT(m_auxText.empty() || !m_mainText.empty(), ("auxText without mainText"));
uint8_t constexpr kLongCaptionsMaxZoom = 4;
size_t constexpr kLowWorldMaxTextSize = 50;
if (zoomLevel <= kLongCaptionsMaxZoom && m_mainText.size() > kLowWorldMaxTextSize)
{
m_mainText.clear();
m_auxText.clear();
return;
}
// Set max text size to avoid VB/IB overflow in rendering.
size_t constexpr kMaxTextSize = 200;
if (m_mainText.size() > kMaxTextSize)
m_mainText = m_mainText.substr(0, kMaxTextSize) + "...";
m_houseNumber = f.GetHouseNumber();
ProcessZoomLevel(zoomLevel);
ProcessMainTextType(mainTextType);
}
std::string const & CaptionDescription::GetMainText() const
{
return m_mainText;
}
std::string const & CaptionDescription::GetAuxText() const
{
return m_auxText;
}
bool CaptionDescription::IsNameExists() const
{
return !m_mainText.empty() || !m_houseNumber.empty();
}
void CaptionDescription::ProcessZoomLevel(int const zoomLevel)
{
if (zoomLevel <= scales::GetUpperWorldScale() && !m_auxText.empty())
// TODO : its better to determine housenumbers minZoom once upon drules load and cache it,
// but it'd mean a lot of housenumbers-specific logic in otherwise generic RulesHolder..
uint8_t constexpr kHousenumbersMinZoom = 16;
if (zoomLevel >= kHousenumbersMinZoom && (auxCaptionExists || m_mainText.empty()))
{
m_auxText.clear();
// TODO: its not obvious that a housenumber display is dependent on a secondary caption drule existance in styles.
m_houseNumberText = f.GetHouseNumber();
if (!m_houseNumberText.empty() && !m_mainText.empty() && m_houseNumberText.find(m_mainText) != std::string::npos)
m_mainText.clear();
}
if (zoomLevel < 5 && m_mainText.size() > 50)
{
m_mainText.clear();
m_auxText.clear();
}
}
void CaptionDescription::ProcessMainTextType(drule::text_type_t const & mainTextType)
{
if (m_houseNumber.empty())
return;
if (mainTextType == drule::text_type_housenumber)
{
/// @todo this code path is never used, probably need to have e.g. "text: housenumber" in styles for it.
m_mainText.swap(m_houseNumber);
m_houseNumber.clear();
m_isHouseNumberInMainText = true;
}
else if (mainTextType == drule::text_type_name)
{
if (m_mainText.empty() || m_houseNumber.find(m_mainText) != std::string::npos)
{
m_houseNumber.swap(m_mainText);
m_isHouseNumberInMainText = true;
}
}
}
CaptionDescription const & Stylist::GetCaptionDescription() const
{
return m_captionDescriptor;
}
bool Stylist::IsEmpty() const
{
return m_rules.empty();
}
bool InitStylist(FeatureType & f, int8_t deviceLang, int const zoomLevel, bool buildings3d, Stylist & s)
@ -429,13 +384,15 @@ bool InitStylist(FeatureType & f, int8_t deviceLang, int const zoomLevel, bool b
Aggregator aggregator(f, geomType, zoomLevel, keys.size());
aggregator.AggregateKeys(keys);
s.m_captionDescriptor.Init(f, deviceLang, zoomLevel, geomType, aggregator.m_mainTextType, aggregator.m_auxCaptionFound);
if (aggregator.m_captionRule.m_rule != nullptr)
{
if (!s.m_captionDescriptor.IsHouseNumberInMainText())
s.m_captionDescriptor.Init(f, deviceLang, zoomLevel, geomType,
aggregator.m_captionRule.m_rule->GetCaption(1) != nullptr);
if (s.m_captionDescriptor.IsNameExists())
aggregator.m_rules.push_back(aggregator.m_captionRule);
else
vng commented 2023-09-17 22:15:09 +00:00 (Migrated from github.com)
Review

Looks like a good optimization. Better not to hardcode, but take out for example into RulesHolder and calculate this scale once. Like RulesHolder::GetMinHNZoom().

Looks like a good optimization. Better not to hardcode, but take out for example into RulesHolder and calculate this scale once. Like RulesHolder::GetMinHNZoom().
Review

Yes, it'll be more flexible for sure.
But it'll also pollute RulesHolder loading logic with the housenumbers exception. So instead of a single line hardcoded housenumbers zoom level we'll have many hardcoded lines for a way to get this housenumbers zoom level...
And we have a hardcoded z18- min zoom for point housenumbers anyway....
So I just left a TODO for now.

Yes, it'll be more flexible for sure. But it'll also pollute RulesHolder loading logic with the housenumbers exception. So instead of a single line hardcoded housenumbers zoom level we'll have many hardcoded lines for a way to get this housenumbers zoom level... And we have a hardcoded z18- min zoom for point housenumbers anyway.... So I just left a TODO for now.
if (s.m_captionDescriptor.IsHouseNumberExists())
{
bool isGood = true;
if (zoomLevel < scales::GetUpperStyleScale())
@ -467,13 +424,15 @@ bool InitStylist(FeatureType & f, int8_t deviceLang, int const zoomLevel, bool b
("building-address should contain a caption drule only"));
drule::BaseRule const * const dRule = drule::rules().Find(addressKeys[0]);
ASSERT(dRule != nullptr, ());
aggregator.m_rules.push_back({ dRule, static_cast<float>(addressKeys[0].m_priority), false });
TRuleWrapper const hnRule({ dRule, static_cast<float>(addressKeys[0].m_priority),
false, true /* m_isHouseNumber*/ });
aggregator.m_rules.push_back(hnRule);
biodranik commented 2023-08-11 23:10:38 +00:00 (Migrated from github.com)
Review
  1. Won't it slow down the rendering?
  2. Cache bools.
1. Won't it slow down the rendering? 2. Cache bools.
Review

They're calculated once. Its just getting a stored bool value from the object.

They're calculated once. Its just getting a stored bool value from the object.
}
}
}
}
aggregator.AggregateStyleFlags(keys, s.m_captionDescriptor.IsNameExists());
aggregator.AggregateStyleFlags(keys, s.m_captionDescriptor.IsNameExists() || s.m_captionDescriptor.IsHouseNumberExists());
if (aggregator.m_pointStyleFound)
s.m_pointStyleExists = true;

View file

@ -26,26 +26,30 @@ private:
size_t m_type3end;
};
struct TRuleWrapper
{
drule::BaseRule const * m_rule;
float m_depth;
bool m_hatching;
bool m_isHouseNumber;
};
struct CaptionDescription
{
void Init(FeatureType & f, int8_t deviceLang, int const zoomLevel, feature::GeomType const type,
drule::text_type_t const mainTextType, bool const auxCaptionExists);
void Init(FeatureType & f, int8_t deviceLang, int const zoomLevel,
feature::GeomType const type, bool const auxCaptionExists);
std::string const & GetMainText() const;
std::string const & GetAuxText() const;
bool IsNameExists() const;
bool IsHouseNumberInMainText() const { return m_isHouseNumberInMainText; }
std::string const & GetMainText() const { return m_mainText; }
std::string const & GetAuxText() const { return m_auxText; }
std::string const & GetHouseNumberText() const { return m_houseNumberText; }
bool IsNameExists() const { return !m_mainText.empty(); }
bool IsHouseNumberExists() const { return !m_houseNumberText.empty(); }
private:
// Clear aux name on high zoom and clear long main name on low zoom.
void ProcessZoomLevel(int const zoomLevel);
// Try to use house number as name of the object.
void ProcessMainTextType(drule::text_type_t const & mainTextType);
std::string m_mainText;
std::string m_auxText;
std::string m_houseNumber;
bool m_isHouseNumberInMainText = false;
std::string m_houseNumberText;
};
class Stylist
@ -56,15 +60,7 @@ public:
bool m_lineStyleExists = false;
bool m_pointStyleExists = false;
public:
CaptionDescription const & GetCaptionDescription() const;
struct TRuleWrapper
{
drule::BaseRule const * m_rule;
float m_depth;
bool m_hatching;
};
CaptionDescription const & GetCaptionDescription() const { return m_captionDescriptor; }
template <class ToDo> void ForEachRule(ToDo && toDo) const
{
@ -72,12 +68,12 @@ public:
toDo(r);
}
bool IsEmpty() const;
bool IsEmpty() const { return m_rules.empty(); }
private:
friend bool InitStylist(FeatureType & f, int8_t deviceLang, int const zoomLevel, bool buildings3d,
Stylist & s);
private:
typedef buffer_vector<TRuleWrapper, 8> rules_t;
rules_t m_rules;

View file

@ -38,7 +38,7 @@ int32_t constexpr kOverlaysMaxPriority = 10000;
/// drawing type of rule - can be one of ...
enum rule_type_t { line, area, symbol, caption, circle, pathtext, waymarker, shield, count_of_rules };
/// text field type - can be one of ...
/// @todo not used.
enum text_type_t { text_type_name = 0, text_type_housename, text_type_housenumber };
typedef buffer_vector<Key, 16> KeysT;

View file

@ -168,7 +168,7 @@ void ReadTransitTask::Do()
df::Stylist stylist;
if (df::InitStylist(ft, 0, 19, false, stylist))
{
stylist.ForEachRule([&](df::Stylist::TRuleWrapper const & rule)
stylist.ForEachRule([&](df::TRuleWrapper const & rule)
{
auto const * symRule = rule.m_rule->GetSymbol();
if (symRule != nullptr)