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
|
* [`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
|
### TODOs
|
||||||
* [ ] mouse hover of POIs (maybe even polygons?)
|
* [ ] mouse hover
|
||||||
|
* [x] of POIs/labels
|
||||||
|
* [ ] maybe even polygons/-lines?
|
||||||
* [ ] termap-server - telnet and ssh access
|
* [ ] termap-server - telnet and ssh access
|
||||||
* [ ] cli linking
|
* [ ] cli linking
|
||||||
* [ ] mapping of view to tiles to show
|
* [ ] mapping of view to tiles to show
|
||||||
|
@ -3,13 +3,12 @@
|
|||||||
by Michael Strassburger <codepoet@cpan.org>
|
by Michael Strassburger <codepoet@cpan.org>
|
||||||
|
|
||||||
Using 2D spatial indexing to avoid overlapping labels and markers
|
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'
|
rbush = require 'rbush'
|
||||||
|
|
||||||
module.exports = class LabelBuffer
|
module.exports = class LabelBuffer
|
||||||
treeWithMargin: null
|
|
||||||
tree: null
|
tree: null
|
||||||
|
|
||||||
margin: 5
|
margin: 5
|
||||||
@ -20,7 +19,6 @@ module.exports = class LabelBuffer
|
|||||||
clear: ->
|
clear: ->
|
||||||
@tree.clear()
|
@tree.clear()
|
||||||
|
|
||||||
|
|
||||||
project: (x, y) ->
|
project: (x, y) ->
|
||||||
[Math.floor(x/2), Math.floor(y/4)]
|
[Math.floor(x/2), Math.floor(y/4)]
|
||||||
|
|
||||||
@ -42,6 +40,6 @@ module.exports = class LabelBuffer
|
|||||||
|
|
||||||
_calculateArea: (text, x, y, margin = 0) ->
|
_calculateArea: (text, x, y, margin = 0) ->
|
||||||
minX: x-margin
|
minX: x-margin
|
||||||
minY: y-margin/4
|
minY: y-margin/2
|
||||||
maxX: x+margin+text.length
|
maxX: x+margin+text.length
|
||||||
maxY: y+margin/4
|
maxY: y+margin/2
|
||||||
|
@ -54,11 +54,8 @@ module.exports = class Renderer
|
|||||||
|
|
||||||
layers:
|
layers:
|
||||||
housenum_label:
|
housenum_label:
|
||||||
minZoom: 1.5
|
|
||||||
margin: 3
|
margin: 3
|
||||||
building: minZoom: 3.8
|
|
||||||
poi_label:
|
poi_label:
|
||||||
minZoom: 3
|
|
||||||
margin: 5
|
margin: 5
|
||||||
cluster: true
|
cluster: true
|
||||||
|
|
||||||
@ -135,7 +132,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, 14
|
unless style = @styler.getStyleFor layer, feature, 19-@zoom
|
||||||
return false
|
return false
|
||||||
|
|
||||||
toDraw = (@_scaleAndReduce points, scale for points in feature.points)
|
toDraw = (@_scaleAndReduce points, scale for points in feature.points)
|
||||||
|
@ -34,7 +34,8 @@ module.exports = class Styler
|
|||||||
return false unless @styleByLayer[layer]
|
return false unless @styleByLayer[layer]
|
||||||
|
|
||||||
for style in @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
|
false
|
||||||
|
|
||||||
|
@ -146,7 +146,12 @@ module.exports = class Termap
|
|||||||
|
|
||||||
_getFooter: ->
|
_getFooter: ->
|
||||||
features = @renderer.featuresAt @mousePosition.x-1-(@view[0]>>1), @mousePosition.y-1-(@view[1]>>2)
|
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}"
|
"#{@mousePosition.x} #{@mousePosition.y}"
|
||||||
#"center: [#{utils.digits @center.lat, 2}, #{utils.digits @center.lng, 2}] zoom: #{utils.digits @zoom, 2}"
|
#"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(', ')}]"
|
#"bbox: [#{@_getBBox().map((z) -> utils.digits(z, 2)).join(', ')}]"
|
||||||
|
@ -289,7 +289,8 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"source-layer": "building"
|
"source-layer": "building",
|
||||||
|
"minzoom": 15.5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "line",
|
"type": "line",
|
||||||
@ -1801,6 +1802,7 @@
|
|||||||
"paint": {
|
"paint": {
|
||||||
"text-color": "#444"
|
"text-color": "#444"
|
||||||
},
|
},
|
||||||
|
"minzoom": 17.5,
|
||||||
"source-layer": "housenum_label"
|
"source-layer": "housenum_label"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user