mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 15:43:08 +01:00
🎨 optimizing telnet version
This commit is contained in:
parent
8edd70c5bb
commit
80f3b5e353
@ -140,10 +140,7 @@ module.exports = class Renderer
|
||||
@_drawFeature tile, feature, layer.scale
|
||||
|
||||
labels.sort (a, b) ->
|
||||
if a.feature.properties.localrank
|
||||
a.feature.properties.localrank-b.feature.properties.localrank
|
||||
else
|
||||
a.feature.properties.scalerank-b.feature.properties.scalerank
|
||||
a.feature.sorty-b.feature.sort
|
||||
|
||||
for label in labels
|
||||
@_drawFeature label.tile, label.feature, label.scale
|
||||
@ -178,10 +175,7 @@ module.exports = class Renderer
|
||||
@canvas.polygon points, feature.color
|
||||
|
||||
when "symbol"
|
||||
text = feature.properties["name_"+config.language] or
|
||||
feature.properties["name_en"] or
|
||||
feature.properties["name"] or
|
||||
feature.properties.house_num or
|
||||
text = feature.label or
|
||||
genericSymbol = "◉"
|
||||
|
||||
return false if @_seen[text] and not genericSymbol
|
||||
|
@ -42,12 +42,12 @@ module.exports = class Styler
|
||||
|
||||
return false
|
||||
|
||||
_replaceConstants: (constants, tree) ->
|
||||
_replaceConstants: (constants, tree, level=0) ->
|
||||
for id, node of tree
|
||||
switch typeof node
|
||||
when 'object'
|
||||
continue if node.constructor.name.match /Stream/
|
||||
@_replaceConstants constants, node
|
||||
continue if level>1
|
||||
@_replaceConstants constants, node, level+1
|
||||
|
||||
when 'string'
|
||||
if node.charAt(0) is '@'
|
||||
|
@ -13,6 +13,7 @@ rbush = require 'rbush'
|
||||
x256 = require 'x256'
|
||||
earcut = require 'earcut'
|
||||
|
||||
config = require "./config"
|
||||
utils = require "./utils"
|
||||
|
||||
class Tile
|
||||
@ -74,22 +75,34 @@ class Tile
|
||||
# use feature.loadGeometry() again as soon as we got a 512 extent tileset
|
||||
geometries = feature.loadGeometry() #@_reduceGeometry feature, 8
|
||||
|
||||
sort = feature.properties.localrank or feature.properties.scalerank
|
||||
label = if feature.properties.$type is "Point"
|
||||
feature.properties["name_"+config.language] or
|
||||
feature.properties.name_en or
|
||||
feature.properties.name or
|
||||
feature.properties.house_num
|
||||
else
|
||||
undefined
|
||||
|
||||
if style.type is "fill"
|
||||
nodes.push @_addBoundaries true,
|
||||
id: feature.id
|
||||
# id: feature.id
|
||||
layer: name
|
||||
style: style
|
||||
properties: feature.properties
|
||||
label: label
|
||||
sort: sort
|
||||
points: geometries
|
||||
color: colorCode
|
||||
|
||||
else
|
||||
|
||||
for points in geometries
|
||||
nodes.push @_addBoundaries false,
|
||||
id: feature.id
|
||||
# id: feature.id
|
||||
layer: name
|
||||
style: style
|
||||
properties: feature.properties
|
||||
label: label
|
||||
sort: sort
|
||||
points: points
|
||||
color: colorCode
|
||||
|
||||
|
@ -25,6 +25,7 @@ catch
|
||||
|
||||
module.exports = class TileSource
|
||||
cache: {}
|
||||
cached: []
|
||||
modes:
|
||||
MBTiles: 1
|
||||
VectorTile: 2
|
||||
@ -67,6 +68,10 @@ module.exports = class TileSource
|
||||
if cached = @cache[[z,x,y].join("-")]
|
||||
return Promise.resolve cached
|
||||
|
||||
if @cached.length > 4
|
||||
for tile in @cached.splice 0, Math.abs(4-@cached.length)
|
||||
delete @cache[tile]
|
||||
|
||||
switch @mode
|
||||
when @modes.MBTiles then @_getMBTile z, x, y
|
||||
when @modes.HTTP then @_getHTTP z, x, y
|
||||
@ -93,7 +98,10 @@ module.exports = class TileSource
|
||||
resolve @_createTile z, x, y, buffer
|
||||
|
||||
_createTile: (z, x, y, buffer) ->
|
||||
tile = @cache[[z,x,y].join("-")] = new Tile @styler
|
||||
name = [z,x,y].join("-")
|
||||
@cached.push name
|
||||
|
||||
tile = @cache[name] = new Tile @styler
|
||||
tile.load buffer
|
||||
|
||||
_initPersistence: ->
|
||||
|
@ -3,7 +3,7 @@ module.exports =
|
||||
|
||||
# TODO: adapt to osm2vectortiles successor openmaptiles v3)
|
||||
# mapscii.me hosts the last available version, 2016-06-20
|
||||
source: "http://mapscii.me/"
|
||||
source: "http://mapscii.me:1337/"
|
||||
|
||||
#source: __dirname+"/../mbtiles/regensburg.mbtiles"
|
||||
|
||||
@ -16,7 +16,7 @@ module.exports =
|
||||
simplifyPolylines: false
|
||||
|
||||
# Downloaded files get persisted in ~/.mapscii
|
||||
persistDownloadedTiles: true
|
||||
persistDownloadedTiles: false
|
||||
|
||||
tileRange: 14
|
||||
projectSize: 256
|
||||
|
Loading…
Reference in New Issue
Block a user