Skip to content

Commit

Permalink
rework new collision_priority function; add custom for roads and transit
Browse files Browse the repository at this point in the history
  • Loading branch information
nvkelso committed Aug 8, 2019
1 parent 68bc27f commit 92afcab
Showing 1 changed file with 144 additions and 35 deletions.
179 changes: 144 additions & 35 deletions bubble-wrap-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,20 @@ global:
building_extrude_height: | # building extrude height logic
function() { return feature.height || 20; }
collision_priority: | # label collision priority logic
function() {
return (feature['min_zoom'] + (1 - 1 / feature['collision_rank']) * 0.1) || (feature['min_zoom'] + 0.9999);
}
collision_priority_roads: | # show labels later in the lines
function() {
return (feature['min_zoom'] + (6 - 1 / feature['collision_rank']) * 0.1) || (feature['min_zoom'] + 5.9999);
}
collision_priority_transit_pois: | # show labels earlier than normal
function(feature, default_priority) {
return (feature['min_zoom'] + (1 - 1 / feature['collision_rank']) * 0.1) || default_priority;
return (feature['min_zoom'] - 3 +
(1 - 1 / ( default_priority +
(feature['tile_kind_rank'] || 100 ) * 0.1 +
feature['collision_rank'] * 0.01) * 0.1 ))
|| (feature['min_zoom'] + 0.9999);
}
textures:
Expand Down Expand Up @@ -1439,7 +1451,7 @@ layers:
text-blend-order:
text_source: global.ux_language_text_source
visible: false # labels are enabled by each layer below
priority: function() { return global.collision_priority(feature, 65); }
priority: global.collision_priority_roads
font:
family: global.text_font_family
weight: normal
Expand Down Expand Up @@ -2355,7 +2367,7 @@ layers:
}
sprite_default: generic_shield_5char
size: [[7,[75%,75%]],[12,[100%,100%]],[15,[110%,110%]]]
priority: function() { return global.collision_priority(feature, 58); }
priority: global.collision_priority
# Size is specified below, and limited to 5 char in another filter
repeat_group: shields
repeat_distance: [[8,90px],[10,40px],[13,30px]]
Expand Down Expand Up @@ -3303,7 +3315,7 @@ layers:
filter: { name: true, $zoom: { min: 8 } }
draw:
text-blend-order:
priority: function() { return global.collision_priority(feature, 65); }
priority: global.collision_priority
visible: global.text_visible_admin
text_source: global.ux_language_text_source_boundary_lines_left_right
offset: [0px, 5px]
Expand Down Expand Up @@ -3397,7 +3409,7 @@ layers:
filter: { name: true, $zoom: { min: 8 } }
draw:
text-blend-order:
priority: function() { return global.collision_priority(feature, 65); }
priority: global.collision_priority
visible: global.text_visible_admin
text_source: global.ux_language_text_source_boundary_lines_left_right
offset: [0px, 5px]
Expand Down Expand Up @@ -3442,7 +3454,7 @@ layers:
draw:
mapzen_icon_library:
visible: false
priority: function() { return global.collision_priority(feature, 65); }
priority: global.collision_priority
text:
text_source: global.ux_language_text_source
visible: false # labels are enabled by each layer below
Expand All @@ -3455,7 +3467,7 @@ layers:
text_source: global.ux_language_text_source
visible: false # labels are enabled by each layer below
buffer: 3px
priority: function() { return global.collision_priority(feature, 65); }
priority: global.collision_priority
font:
family: Varela
fill: global.text_fill
Expand Down Expand Up @@ -4119,7 +4131,7 @@ layers:
sprite: function() { return feature.kind; }
sprite_default: generic
interactive: global.sdk_interactive
priority: function() { return global.collision_priority(feature, 65); }
priority: global.collision_priority
repeat_group: abc
buffer: 3px
text:
Expand Down Expand Up @@ -5305,7 +5317,7 @@ layers:
- ref: true
draw:
mapzen_icon_library:
priority: function() { return global.collision_priority(feature, 20); }
priority: 10.5
# you need to match any custom shield to the vector tile `network` values
sprite: function() { return ('sdk_shield-' + feature.ref.length + 'char'); }
sprite_default: sdk_shield_5char
Expand Down Expand Up @@ -5391,28 +5403,125 @@ layers:
style: italic
stroke: { color: white, width: 3px }

# transit-bus-roads:
# data: { source: mapzen, layer: roads }
# filter: { is_bus_route: true }
# draw:
# lines:
# visible: global.sdk_transit_overlay
# interactive: false
# color: [[13,[0,0,1,0.5]],[15,blue]]
# width: [[11,0.5px],[12,0.8px],[16,1.25px],[18,1m]]
# # let roads sort themselves past zoom 14
# order: 488
# # but give them all the same outline
# outline:
# order: 487
transit-bus-roads:
data: { source: mapzen, layer: roads }
filter: { is_bus_route: true }
draw:
lines:
visible: global.sdk_transit_overlay
interactive: false
color: [[13,[0,0,0.5,0.25]],[15,[0,0,0.5,0.8]]]
width: [[11,0.5px],[12,0.8px],[16,1.5px],[18,1.5m]]
# let roads sort themselves past zoom 14
order: 488
# but give them all the same outline
outline:
order: 487

labels-bus-lines:
filter:
all:
- function() { return global.sdk_transit_overlay; }
- all:
- $zoom: { min: 18 }
- bus_shield_text: true
draw:
mapzen_icon_library:
priority: 10.8
# you need to match any custom shield to the vector tile `network` values
sprite: function() { return ('sdk_shield-' + feature.bus_shield_text.length + 'char'); }
sprite_default: sdk_shield_5char
color: [0,0,0.5,0.8]
# Size is specified below, and limited to 5 char in another filter
repeat_group: shields
repeat_distance: [[8,90px],[10,40px],[13,30px]]
placement: midpoint
placement_min_length_ratio:
- [8, 0.1]
- [9, 0.25]
- [10, 0.25]
- [11, 0.15]
- [12, 1]
- [13, 1.50]
- [14, 2.0]
# visible: false
text:
offset: [0px, -0.5px]
repeat_distance: 200px
anchor: center
text_source: function() { if( feature.bus_shield_text.length < 6 ) { return feature.bus_shield_text; } else { return ''; } }
font:
family: Montserrat
fill: white
weight: 700
size: [[7,7px],[12,8px],[16,11px]]
stroke: { width: 0px }

width_1char:
filter: function() { return (feature.bus_shield_text.length === 1); }
draw:
mapzen_icon_library:
size: [[6,[16px,16px]],[13,[18px,18px]],[16,[21px,21px]]]
width_2char:
filter: function() { return (feature.bus_shield_text.length === 2); }
draw:
mapzen_icon_library:
size: [[6,[21px,16px]],[13,[24px,18px]],[16,[28px,21px]]]
width_3char:
filter: function() { return (feature.bus_shield_text.length === 3); }
draw:
mapzen_icon_library:
size: [[6,[27px,16px]],[13,[31px,18px]],[16,[36px,21px]]]
width_4char:
filter: function() { return (feature.bus_shield_text.length === 4); }
draw:
mapzen_icon_library:
size: [[6,[32px,16px]],[13,[36px,18px]],[16,[41px,21px]]]
# London sucks
early:
filter: { $zoom: { max: 14 } }
draw:
mapzen_icon_library:
visible: false
width_5char:
filter: function() { return (feature.bus_shield_text.length === 5); }
draw:
mapzen_icon_library:
size: [[6,[37px,16px]],[13,[41px,18px]],[16,[48px,21px]]]
# London sucks
early:
filter: { $zoom: { max: 14 } }
draw:
mapzen_icon_library:
visible: false
# this is kinda a hack
width_longggggg:
filter: function() { return (feature.bus_shield_text.length > 5); }
draw:
mapzen_icon_library:
visible: false

z19-show-operator-name:
filter:
all:
- function() { return global.sdk_transit_overlay; }
- $zoom: { min: 19 }
draw:
text:
text_source: function() { return (feature.bus_network); }
priority: 10.99
font:
fill: [0,0,0.5,0.8]
style: italic
size: 14px
stroke: { color: white, width: 3px }

transit-overlay-station-labels:
data: { source: mapzen, layer: pois }
filter:
kind: [station, tram_stop, bus_station, subway_entrance, halt, stop, platform, bus_stop, stop_position ]
any:
- area: false
all:
- area: true
all:
- $geometry: point
Expand All @@ -5422,13 +5531,13 @@ layers:
visible: global.sdk_transit_overlay
size: [[13, 12px], [16, 16px], [19, 20px]]
interactive: global.sdk_interactive
priority: 15
priority: function() { return global.collision_priority_transit_pois(feature, 15); }
text:
buffer: 4px
#anchor: bottom
#offset: [[13, [0, 6px]], [16, [0, 8px]], [19, [0, 10px]]] # offset tracks alongside icon size (half icon height)
interactive: global.sdk_interactive
priority: 16
#priority: 10.16
font:
fill: black
weight: normal
Expand All @@ -5452,10 +5561,10 @@ layers:
mapzen_icon_library:
sprite: train_station
size: [[13, '65%'], [16, '100%']]
priority: 11
text:
priority: function() { return global.collision_priority_transit_pois(feature, 11); }
#text:
#offset: [[13, [0, 6px]], [14, [0, 7px]],[15, [0, 8px]], [17, [0, 10px]]]
priority: 12
#priority: 10.12
low-priority-early:
filter: { kind_tile_rank: { min: 3 }, $zoom: { min: 0, max: 12 } }
draw:
Expand Down Expand Up @@ -5490,8 +5599,8 @@ layers:
mapzen_icon_library:
size: [[12, '40%'], [15, '50%']]
#visible: false
text:
visible: false
#text:
# visible: false
late:
filter: { $zoom: { min: 16 } }
draw:
Expand Down Expand Up @@ -5563,10 +5672,10 @@ layers:
mapzen_icon_library:
size: [[13, 12px], [16, 18px]]
sprite: bus_station
priority: 17
priority: function() { return global.collision_priority_transit_pois(feature, 17); }
text:
interactive: global.sdk_interactive
priority: 18
#priority: 10.18
font:
fill: black
size: 12px
Expand All @@ -5587,10 +5696,10 @@ layers:
mapzen_icon_library:
sprite: subway_entrance
size: [[17, 12px], [19, 14px]]
priority: 19
priority: function() { return global.collision_priority_transit_pois(feature, 19); }
text:
#offset: [[17, [0, 6px]], [19, [0, 7px]]] # offset tracks alongside icon size (half icon height)
priority: 20
#priority: 10.20
interactive: global.sdk_interactive
text_source: function() { if( feature.ref || feature.name ) { if( feature.ref && feature.name ) { return '[' + feature.ref + ']\n' + feature.name; } else { return feature.name; } } else { return "Entrance"; } }
font:
Expand Down

0 comments on commit 92afcab

Please sign in to comment.