mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 23:53:08 +01:00
🎨 supporting style based minzoom, adding sepertae admin_level_4 style
This commit is contained in:
parent
cc97cfd095
commit
ccad39cf77
@ -25,22 +25,22 @@ module.exports = class Renderer
|
||||
|
||||
tileSize: 4096
|
||||
projectSize: 256
|
||||
maxZoom: 14
|
||||
maxZoom: 4
|
||||
|
||||
#"poi_label", "water",
|
||||
drawOrder: [
|
||||
"admin"
|
||||
|
||||
"building"
|
||||
|
||||
"road"
|
||||
"water"
|
||||
"road:structure=bridge"
|
||||
"road"
|
||||
# "road:structure=bridge"
|
||||
|
||||
"country_label"
|
||||
"state_label"
|
||||
"place_label"
|
||||
"poi_label"
|
||||
"housenum_label"
|
||||
"country_label"
|
||||
"state_label"
|
||||
]
|
||||
|
||||
icons:
|
||||
@ -69,6 +69,9 @@ module.exports = class Renderer
|
||||
margin: 5
|
||||
cluster: true
|
||||
|
||||
place_label: cluster: true
|
||||
state_label: cluster: true
|
||||
|
||||
isDrawing: false
|
||||
lastDrawAt: 0
|
||||
|
||||
@ -139,7 +142,7 @@ module.exports = class Renderer
|
||||
position[1]>@height
|
||||
continue
|
||||
|
||||
tiles.push xyz: tile, position: position, scale: scale
|
||||
tiles.push xyz: tile, zoom: zoom, position: position, scale: scale
|
||||
|
||||
tiles
|
||||
|
||||
@ -194,7 +197,7 @@ module.exports = class Renderer
|
||||
continue if feature.data.id and drawn[feature.data.id]
|
||||
drawn[feature.data.id] = true
|
||||
|
||||
@_drawFeature short, feature, tile.scale, tile.xyz.z
|
||||
@_drawFeature short, feature, tile.scale, tile.zoom
|
||||
|
||||
@canvas.restore()
|
||||
|
||||
@ -232,7 +235,7 @@ module.exports = class Renderer
|
||||
feature.type = "LineString" if layer is "building" or layer is "road"
|
||||
|
||||
# TODO: zoom level
|
||||
unless style = @styler.getStyleFor layer, feature, 19-zoom
|
||||
unless style = @styler.getStyleFor layer, feature, zoom
|
||||
return false
|
||||
|
||||
toDraw = (@_scaleAndReduce points, scale for points in feature.points)
|
||||
|
@ -36,7 +36,7 @@ module.exports = class Styler
|
||||
return false unless @styleByLayer[layer]
|
||||
|
||||
for style in @styleByLayer[layer]
|
||||
if style.appliesTo(feature) and ((layer is "road") or (not style.minzoom) or style.minzoom <= zoom)
|
||||
if style.appliesTo(feature) and ((not style.minzoom) or style.minzoom <= zoom)
|
||||
return style
|
||||
|
||||
return false
|
||||
@ -77,5 +77,11 @@ module.exports = class Styler
|
||||
return false for value in filter[2..] when feature.properties[filter[1]] is value
|
||||
true
|
||||
|
||||
when ">="
|
||||
(feature) -> feature.properties[filter[1]] >= filter[2]
|
||||
|
||||
when "<="
|
||||
(feature) -> feature.properties[filter[1]] <= filter[2]
|
||||
|
||||
else
|
||||
-> true
|
||||
|
@ -32,6 +32,7 @@ module.exports = class Termap
|
||||
mouseDragging: false
|
||||
|
||||
tileSource: null
|
||||
renderer: null
|
||||
|
||||
zoom: 0
|
||||
rotation: 0
|
||||
@ -59,11 +60,9 @@ module.exports = class Termap
|
||||
@_initKeyboard()
|
||||
@_initMouse()
|
||||
|
||||
console.log "loading tilesource"
|
||||
@_initTileSource()
|
||||
|
||||
.then =>
|
||||
console.log "loaded"
|
||||
@_initRenderer()
|
||||
|
||||
.then =>
|
||||
|
@ -6,8 +6,9 @@
|
||||
"@country_label_2": "#ff0",
|
||||
"@country_label_3": "#ff0",
|
||||
"@country_label_4": "#ff0",
|
||||
"@admin_level_2": "#f00",
|
||||
"@admin_level_3": "#ccf"
|
||||
"@admin_level_2": "#fff",
|
||||
"@admin_level_3": "#aac",
|
||||
"@admin_level_4": "#777"
|
||||
},
|
||||
"layers": [
|
||||
{
|
||||
@ -281,14 +282,14 @@
|
||||
"minzoom": 11
|
||||
},
|
||||
{
|
||||
"type": "fill",
|
||||
"type": "line",
|
||||
"id": "building",
|
||||
"paint": {
|
||||
"fill-color": {
|
||||
"base": 1,
|
||||
"stops": [
|
||||
[
|
||||
15.5,
|
||||
14.5,
|
||||
"#525652"
|
||||
],
|
||||
[
|
||||
@ -299,7 +300,7 @@
|
||||
}
|
||||
},
|
||||
"source-layer": "building",
|
||||
"minzoom": 15.5
|
||||
"minzoom": 14.5
|
||||
},
|
||||
{
|
||||
"type": "line",
|
||||
@ -1425,26 +1426,10 @@
|
||||
},
|
||||
{
|
||||
"type": "line",
|
||||
"id": "admin_level_3",
|
||||
"id": "admin_level_4",
|
||||
"paint": {
|
||||
"line-color": "@admin_level_3",
|
||||
"line-width": {
|
||||
"base": 1,
|
||||
"stops": [
|
||||
[
|
||||
4,
|
||||
0.4
|
||||
],
|
||||
[
|
||||
5,
|
||||
1
|
||||
],
|
||||
[
|
||||
12,
|
||||
3
|
||||
]
|
||||
]
|
||||
}
|
||||
"line-color": "@admin_level_4",
|
||||
"line-width": 1
|
||||
},
|
||||
"source-layer": "admin",
|
||||
"filter": [
|
||||
@ -1452,6 +1437,28 @@
|
||||
[
|
||||
">=",
|
||||
"admin_level",
|
||||
4
|
||||
],
|
||||
[
|
||||
"==",
|
||||
"maritime",
|
||||
0
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "line",
|
||||
"id": "admin_level_3",
|
||||
"paint": {
|
||||
"line-color": "@admin_level_3",
|
||||
"line-width": 1
|
||||
},
|
||||
"source-layer": "admin",
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
"admin_level",
|
||||
3
|
||||
],
|
||||
[
|
||||
@ -1811,7 +1818,7 @@
|
||||
"paint": {
|
||||
"text-color": "#444"
|
||||
},
|
||||
"minzoom": 17.5,
|
||||
"minzoom": 16.5,
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user