From 8f06904da54bc99cea997dd110085ec6a5ad23e8 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 30 Jan 2024 06:49:31 +0100 Subject: =?UTF-8?q?Add=20layer=20for=20Renn=C3=A4ringen=20(from=20Sameting?= =?UTF-8?q?et).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 ++ main.js | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) diff --git a/index.html b/index.html index 70a849c..b240a44 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,10 @@ Länsstyrelserna och Energimyndigheten, CC0 (öppna data). +
  • Rennäringen skikt från + Sametinget, + CC-BY-4.0 (öppna data). +
  • Bakgrund kartor från © Lantmäteriet, CC0 (öppna data). diff --git a/main.js b/main.js index b3463ac..c065815 100644 --- a/main.js +++ b/main.js @@ -1104,6 +1104,127 @@ const layers = { }); }), }, + + st_renbete: { + popoverTitle: 'Samebyarnas betesområde', + popover: [ + ['Sameby', 'NAMN'], + ['Samebys typ', 'SAMEBY_TYP'], + ['Objekt-ID', 'OBJECTID', { classes: ['feature-objid'] }], + ['Sameby-ID', 'SAMEBY_ID', { classes: ['feature-objid'] }], + ['By-ID', 'BY_ID', { classes: ['feature-objid'] }], + ['Signatur', 'SIGNATUR'], + ['Aktualitet', 'AKTUALITET'], + ], + style: [1, 1.5, 2, 3, 3.5, 4, 5, 5, 6, 7, 8, 10].map(function(width, z) { + return new Style({ + zIndex: 4, + fill: new Fill({ + /* transparent fill so clicking the inside of the polygon triggers a popover */ + /* XXX could also use a custom renderer but that doesn't seem to work */ + color: [0, 0, 0, 0], + }), + stroke: width === 0 ? undefined : new Stroke({ + width: width, + color: [179, 153, 102, 1], + }), + }); + }), + }, + st_flyttled: { + popoverTitle: 'Samebyarnas markanvändningsredovisning \u2013 flyttled', + popover: [ + ['Sameby #1', 'SAMEBY1'], + ['Sameby #2', 'SAMEBY2'], + ['Sameby #3', 'SAMEBY3'], + ['Beskrivning', 'BESKRIVNIN'], + ['Årstid', 'ARSTID'], + ['Sameby #1 Nr', 'BYNR1', { classes: ['feature-objid'], fn: (v) => v === 0 ? '' : v }], + ['Sameby #2 Nr', 'BYNR2', { classes: ['feature-objid'], fn: (v) => v === 0 ? '' : v }], + ['Sameby #3 Nr', 'BYNR3', { classes: ['feature-objid'], fn: (v) => v === 0 ? '' : v }], + ['Led-ID', 'LED_ID', { classes: ['feature-objid'], fn: (v) => v === 0 ? '' : v }], + ['Objekt-ID', 'OBJECTID', { classes: ['feature-objid'] }], + ['Riksintresse', 'RIKSINTR'], + ['Fast led', 'FAST_LED'], + ['Aktualitet', 'AKTUALITET'], + ['Signatur', 'SIGNATUR'], + ['Globalt ID', 'GlobalID', { classes: ['feature-objid'] }], + ], + style: [.75, 1, 1.5, 2, 3, 4, 5, 5, 6, 7, 8, 10].map(function(width, z) { + return new Style({ + zIndex: 7, + stroke: new Stroke({ + width: 2*width, + color: [119, 99, 59, 1], + lineDash: [4 * width], + }), + }); + }), + }, + st_riks_ren: { + popoverTitle: 'Riksintresse rennäring', + popover: [ + ['Objekt-ID', 'OBJECTID', { classes: ['feature-objid'] }], + ['Lagrum', 'LAGRUM'], + ['Aktualitet', 'AKTUALITET'], + ['Signatur', 'SIGNATUR'], + ['Globalt ID', 'GlobalID', { classes: ['feature-objid'] }], + ], + style: [.5, 1, 1.5, 1.5, 2, 2, 2.5, 2.5, 3, 3.5, 4, 5].map(function(width, z) { + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + patternCanvas.width = z < 4 ? 4 : z <= 5 ? 8 : Math.pow(2, Math.round(Math.log2(width) + 3)); + patternCanvas.height = patternCanvas.width; + patternContext.fillStyle = 'transparent'; + patternContext.strokeStyle = 'rgba(179, 153, 102, 1)'; + patternContext.lineWidth = Math.max(1, width/2); + patternContext.beginPath(); + patternContext.moveTo(0, 0); + patternContext.lineTo(patternCanvas.width, 0); + patternContext.stroke(); + + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return new Style({ + zIndex: 6, + fill: new Fill({ + color: context.createPattern(patternCanvas, 'repeat'), + }), + stroke: width === 0 ? undefined : new Stroke({ + width: width, + color: [179, 153, 102, 1], + }), + }); + }), + }, + st_riks_ren_core: { + popoverTitle: '(Kärn)områden av riksintresse rennäring', + popover: [ + ['Objekt-ID', 'OBJECTID', { classes: ['feature-objid'] }], + ['Områdes-ID', 'OMR_NR', { classes: ['feature-objid'] }], + ['Länk', 'LANK'], + ['Årets runt', 'ARET_RUNT'], + ['Sameby', 'SAMEBY'], + ['Ansvarig', 'ANSVARIG'], + ['Aktualitet', 'AKTUALITET'], + ['Signatur', 'SIGNATUR'], + ['Globalt ID', 'GlobalID', { classes: ['feature-objid'] }], + ['Area', 'AREA_HA', { unit: 'ha' }], + ['Länskod', 'LANSKOD'], + ], + style: [.5, .5, 1, 1, 1, 1.5, 1.5, 1.5, 2, 2, 2, 2].map(function(width, z) { + return new Style({ + zIndex: 5, + fill: new Fill({ + color: [203, 190, 163, Math.max((.3-.5)/8 * z + .5, 0)], + }), + stroke: width === 0 ? undefined : new Stroke({ + width: width, + color: [179, 153, 102, 1], + }), + }); + }), + }, }; const layerHierarchy = [ @@ -1227,6 +1348,29 @@ const layerHierarchy = [ }, ] }, + { + /* Definitions at + * https://ext-dokument.lansstyrelsen.se/Gemensamt/Geodata/Datadistribution/Information,%20Skiktf%C3%B6rteckning%20och%20f%C3%B6rklaringar.pdf */ + text: 'Rennäringen', + children: [ + { + text: 'Betesområden', + layer: 'st_renbete', + }, + { + text: 'Flyttled', + layer: 'st_flyttled', + }, + { + text: 'Riksintressen', + layer: 'st_riks_ren', + }, + { + text: '(Kärn)områden av riksintresse', + layer: 'st_riks_ren_core', + }, + ] + } ]; const vectorSource = new VectorTile({ -- cgit v1.2.3