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