mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-28 11:03:35 +01:00
🎨 respecting style.minzoom
This commit is contained in:
parent
bdfcae4fa0
commit
bc2d050581
@ -48,7 +48,9 @@ No web browser around? No worries - discover the planet in your console!
|
||||
* [`sphericalmercator`](https://github.com/mapbox/node-sphericalmercator) for [EPSG:3857](http://spatialreference.org/ref/sr-org/6864/) <> [WGS84](http://spatialreference.org/ref/epsg/wgs-84/) conversions
|
||||
|
||||
### TODOs
|
||||
* [ ] mouse hover of POIs (maybe even polygons?)
|
||||
* [ ] mouse hover
|
||||
* [x] of POIs/labels
|
||||
* [ ] maybe even polygons/-lines?
|
||||
* [ ] termap-server - telnet and ssh access
|
||||
* [ ] cli linking
|
||||
* [ ] mapping of view to tiles to show
|
||||
|
@ -3,13 +3,12 @@
|
||||
by Michael Strassburger <codepoet@cpan.org>
|
||||
|
||||
Using 2D spatial indexing to avoid overlapping labels and markers
|
||||
Future: to detect collision on mouse interaction
|
||||
and to find labels underneath a mouse cursor's position
|
||||
###
|
||||
|
||||
rbush = require 'rbush'
|
||||
|
||||
module.exports = class LabelBuffer
|
||||
treeWithMargin: null
|
||||
tree: null
|
||||
|
||||
margin: 5
|
||||
@ -20,7 +19,6 @@ module.exports = class LabelBuffer
|
||||
clear: ->
|
||||
@tree.clear()
|
||||
|
||||
|
||||
project: (x, y) ->
|
||||
[Math.floor(x/2), Math.floor(y/4)]
|
||||
|
||||
@ -42,6 +40,6 @@ module.exports = class LabelBuffer
|
||||
|
||||
_calculateArea: (text, x, y, margin = 0) ->
|
||||
minX: x-margin
|
||||
minY: y-margin/4
|
||||
minY: y-margin/2
|
||||
maxX: x+margin+text.length
|
||||
maxY: y+margin/4
|
||||
maxY: y+margin/2
|
||||
|
@ -54,11 +54,8 @@ module.exports = class Renderer
|
||||
|
||||
layers:
|
||||
housenum_label:
|
||||
minZoom: 1.5
|
||||
margin: 3
|
||||
building: minZoom: 3.8
|
||||
poi_label:
|
||||
minZoom: 3
|
||||
margin: 5
|
||||
cluster: true
|
||||
|
||||
@ -135,7 +132,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, 14
|
||||
unless style = @styler.getStyleFor layer, feature, 19-@zoom
|
||||
return false
|
||||
|
||||
toDraw = (@_scaleAndReduce points, scale for points in feature.points)
|
||||
|
@ -34,7 +34,8 @@ module.exports = class Styler
|
||||
return false unless @styleByLayer[layer]
|
||||
|
||||
for style in @styleByLayer[layer]
|
||||
return style if style.appliesTo feature
|
||||
if style.appliesTo(feature) and ((layer is "road") or (not style.minzoom) or style.minzoom <= zoom)
|
||||
return style
|
||||
|
||||
false
|
||||
|
||||
|
@ -146,7 +146,12 @@ module.exports = class Termap
|
||||
|
||||
_getFooter: ->
|
||||
features = @renderer.featuresAt @mousePosition.x-1-(@view[0]>>1), @mousePosition.y-1-(@view[1]>>2)
|
||||
"features: ["+features.map((f) -> f.feature.id).join(", ")+"] "+
|
||||
"features: ["+features.map((f) ->
|
||||
JSON.stringify
|
||||
name: f.feature.properties.name
|
||||
type: f.feature.properties.type
|
||||
rank: f.feature.properties.scalerank
|
||||
).join(", ")+"] "+
|
||||
"#{@mousePosition.x} #{@mousePosition.y}"
|
||||
#"center: [#{utils.digits @center.lat, 2}, #{utils.digits @center.lng, 2}] zoom: #{utils.digits @zoom, 2}"
|
||||
#"bbox: [#{@_getBBox().map((z) -> utils.digits(z, 2)).join(', ')}]"
|
||||
|
@ -289,7 +289,8 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"source-layer": "building"
|
||||
"source-layer": "building",
|
||||
"minzoom": 15.5
|
||||
},
|
||||
{
|
||||
"type": "line",
|
||||
@ -1801,6 +1802,7 @@
|
||||
"paint": {
|
||||
"text-color": "#444"
|
||||
},
|
||||
"minzoom": 17.5,
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user