mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-22 08:03:07 +01:00
😄 adding support for points, using emoji utf8 symbols
This commit is contained in:
parent
29d6a084fb
commit
d3ddc23de4
@ -16,9 +16,30 @@ width = null
|
|||||||
height = null
|
height = null
|
||||||
|
|
||||||
config =
|
config =
|
||||||
drawOrder: ["admin", "water", "landuse", "building", "road"]
|
drawOrder: ["admin", "water", "landuse", "building", "road", "poi_label"]
|
||||||
|
|
||||||
|
icons:
|
||||||
|
car: "🚗"
|
||||||
|
school: "🏫"
|
||||||
|
marker: "⭐"
|
||||||
|
'art-gallery': "🎨"
|
||||||
|
attraction: "❕"
|
||||||
|
stadium: "🏈"
|
||||||
|
toilet: "🚽"
|
||||||
|
cafe: "☕"
|
||||||
|
laundry: "👚"
|
||||||
|
bus: "🚌"
|
||||||
|
restaurant: "🍕"
|
||||||
|
lodging: "🏨"
|
||||||
|
'fire-station': "🚒"
|
||||||
|
shop: "🏬"
|
||||||
|
pharmacy: "💊"
|
||||||
|
beer: "🍺"
|
||||||
|
cinema: "🎦"
|
||||||
|
|
||||||
layers:
|
layers:
|
||||||
|
poi_label:
|
||||||
|
color: "red"
|
||||||
road:
|
road:
|
||||||
color: "white"
|
color: "white"
|
||||||
landuse:
|
landuse:
|
||||||
@ -53,7 +74,7 @@ zlib.gunzip data, (err, buffer) ->
|
|||||||
for i in [0...layer.length]
|
for i in [0...layer.length]
|
||||||
feature = layer.feature i
|
feature = layer.feature i
|
||||||
features[name].push
|
features[name].push
|
||||||
type: feature.type
|
type: [undefined, "point", "line", "polygon"][feature.type]
|
||||||
id: feature.id
|
id: feature.id
|
||||||
properties: feature.properties
|
properties: feature.properties
|
||||||
points: feature.loadGeometry()
|
points: feature.loadGeometry()
|
||||||
@ -80,25 +101,29 @@ draw = ->
|
|||||||
for layer in config.drawOrder
|
for layer in config.drawOrder
|
||||||
continue unless features[layer]
|
continue unless features[layer]
|
||||||
|
|
||||||
canvas.strokeStyle = config.layers[layer].color
|
canvas.strokeStyle = canvas.fillStyle = config.layers[layer].color
|
||||||
for feature in features[layer]
|
|
||||||
for line in feature.points
|
|
||||||
found = false
|
|
||||||
points = for point in line
|
|
||||||
p = [point.x/scale, point.y/scale]
|
|
||||||
if not found and p[0]+view[0]>=0 and p[0]+view[0]<width and p[1]+view[1]>=0 and p[1]+view[1]<height
|
|
||||||
found = true
|
|
||||||
p
|
|
||||||
continue unless found
|
|
||||||
|
|
||||||
|
for feature in features[layer]
|
||||||
|
for points in feature.points
|
||||||
|
|
||||||
|
visible = false
|
||||||
|
points = for point in points
|
||||||
|
p = [point.x/scale, point.y/scale]
|
||||||
|
if not visible and p[0]+view[0]>=4 and p[0]+view[0]<width-4 and p[1]+view[1]>=0 and p[1]+view[1]<height
|
||||||
|
visible = true
|
||||||
|
p
|
||||||
|
continue unless visible
|
||||||
|
|
||||||
|
switch feature.type
|
||||||
|
when "polygon", "line"
|
||||||
canvas.beginPath()
|
canvas.beginPath()
|
||||||
canvas.moveTo points.shift()...
|
canvas.moveTo points.shift()...
|
||||||
canvas.lineTo point... for point in points
|
canvas.lineTo point... for point in points
|
||||||
canvas.stroke()
|
canvas.stroke()
|
||||||
|
|
||||||
canvas.fillStyle = "white"
|
when "point"
|
||||||
canvas.fillText "test", 0, 0
|
canvas.fillText (config.icons[feature.properties.maki] or "X"), point... for point in points
|
||||||
canvas.stroke()
|
|
||||||
canvas.restore()
|
canvas.restore()
|
||||||
|
|
||||||
flush()
|
flush()
|
||||||
|
Loading…
Reference in New Issue
Block a user