From 576ed43e4c7990300c8466e901bc080665b827e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Reppen?= Date: Thu, 13 Feb 2020 15:05:23 +0100 Subject: [PATCH] Ultramafisk berggrunn - magler i kartet #1667 (#1668) * Ultramafisk berggrunn - fra punkter til polygon, en mulig forbedring? Relatert til #1667 * Fix Line 113:15: 'farge' is assigned a value but never used no-unused-vars --- src/Funksjoner/config.js | 5 +- .../scene/visualisering/polygon.js | 125 ++++++++++++------ 2 files changed, 88 insertions(+), 42 deletions(-) diff --git a/src/Funksjoner/config.js b/src/Funksjoner/config.js index 22548b8d1..db81a6a37 100644 --- a/src/Funksjoner/config.js +++ b/src/Funksjoner/config.js @@ -51,9 +51,10 @@ class config { static hack(kode) { // TODO: Erstatt denne med kode.split("-").pop() if ( - kode.indexOf("AO") === 0 || + kode.indexOf("AO-TO-FL") === 0 || kode.indexOf("VV") === 0 || - kode.indexOf("NN-NA-BS-3EL") === 0 + kode.indexOf("NN-NA-BS-3EL") === 0 || + kode.indexOf("NN-NA-LKM-BK") === 0 ) return kode.split("-").pop(); if (kode.indexOf("NN-") !== 0) return kode; diff --git a/src/Kart/LeafletTangram/scene/visualisering/polygon.js b/src/Kart/LeafletTangram/scene/visualisering/polygon.js index 191870b00..33866c60c 100644 --- a/src/Kart/LeafletTangram/scene/visualisering/polygon.js +++ b/src/Kart/LeafletTangram/scene/visualisering/polygon.js @@ -10,62 +10,59 @@ function drawAll(drawArgs) { let barnkode = dac.kode; if (dac.hasOwnProperty("erSynlig") && !dac.erSynlig) return; const visEtiketter = barnkode === opplystKode; - layer[barnkode] = draw({ + layer[barnkode] = drawLines({ kode: barnkode, forelderkode: kode, farge: dac.farge, opplystKode: opplystKode, visEtiketter: visEtiketter }); + if (true) { + const points = drawPoints({ + kode: barnkode, + forelderkode: kode, + farge: dac.farge, + opplystKode: opplystKode, + visEtiketter: false + }); + // points.filter["$zoom"] = { min: 0, max: 6 } + layer[barnkode + "_points"] = points; + } + }); + } else + layer[sysconfig.hack(kode)] = drawLines({ + kode: kode, + forelderkode: kode, + farge: farge, + opplystKode: opplystKode, + visEtiketter: visEtiketter }); - } - layer[sysconfig.hack(kode)] = draw({ - // layer[sysconfig.hack(kode)] = draw({ - kode: kode, - forelderkode: kode, - farge: farge, - opplystKode: opplystKode, - visEtiketter: visEtiketter - }); return { [kode]: { layer, data: { source: kode, layer: "polygons" } } }; } -function draw(args) { +function drawLines(args) { let { kode, farge, opplystKode, visEtiketter } = args; farge = opplyst(kode, opplystKode, farge); - const layer = { - draw: { - mu_polygons: { - order: 800, - color: tinycolor(farge) - // .darken(30) - // .saturate(60) - .toHexString() - }, - lines: { - order: 800, - color: tinycolor(farge) - .darken(50) - .toHexString(), - width: "1.0px" - }, - points: { - order: 850, - size: 10, - collide: false, - color: farge, - interactive: true, - outline: { - width: 2, - color: "rgba(0,0,0,30%)" - } - } - } + const layer = drawBase(args); + layer.draw.lines = { + order: 800, + color: tinycolor(farge) + .darken(50) + .toHexString(), + width: "1.0px" }; - layer.filter = { kode: sysconfig.hack(kode) }; + layer.draw.mu_polygons = { + order: 800, + blend: "multiply", + color: tinycolor(farge) + // .darken(30) + // .saturate(60) + .toHexString() + }; + if (kode === opplystKode) { const lines = layer.draw.lines; lines.width = "2px"; @@ -84,6 +81,54 @@ function draw(args) { return layer; } +function drawPoints(args) { + let { kode, farge, opplystKode } = args; + farge = opplyst(kode, opplystKode, farge); + const layer = drawBase(args); + layer.draw.translucent_points = { + order: 850, + size: [ + [0, 7], + [5, 10], + [10, 0] + ], + collide: false, + color: farge, + // color: [[0,farge], [8,"#f00"],[10, "#ffffff"]], + interactive: true + /* outline: { + width: [[0,2],[10,0]], + color: "rgba(0,0,0,30%)" +// color: [[0,"rgba(0,0,0,60%)"],[10, "rgba(0,0,0,0%)"]] +// color: [[0,"rgba(0,0,0,30%)"], [10, "#ffffff"]] + } +// filter: { $geometry: "point" } +*/ + }; + + return layer; +} + +function drawBase(args) { + let { kode, visEtiketter } = args; + const layer = { + draw: {} + }; + layer.filter = { kode: sysconfig.hack(kode) }; + if (visEtiketter) { + layer.draw.text = { + text_source: ["name", "title"], + font: { + family: "Roboto", + fill: "hsla(0, 0%, 100%, 1.0)", + stroke: { color: "hsla(0, 0%, 0%, 0.7)", width: 2 }, + size: "13px" + } + }; + } + return layer; +} + function lagSource({ url, zoom }, { bbox }) { return sysconfig.createTileSource(url, "MVT", zoom, bbox); }