From 755fd520e150e4a1b4e971a6a2e06f5a57691dc7 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 20 Oct 2024 02:37:59 +0200 Subject: =?UTF-8?q?Add=20layers=20for=20Riksintressen,=20naturv=C3=A5rd=20?= =?UTF-8?q?och=20friluftsliv.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 374 insertions(+) (limited to 'main.js') diff --git a/main.js b/main.js index fc92195..4917e79 100644 --- a/main.js +++ b/main.js @@ -2335,6 +2335,351 @@ const layers = { }), }, + ri_naturvard: { + popoverTitle: 'Riksintresse naturvård', + popover: [ + ['Namn', 'NAMN'], + ['Skydd', 'SKYDD'], + ['Ämnesområde', 'AMNESOMRAD'], + ['Beskrivning', 'BESKRIVNIN', { fn: function(v) { + if (v === undefined || v === null || !(v.startsWith('http://') || v.startsWith('https://'))) { + return v; + } + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Lagrum', 'LAGRUM'], + ['Beslutsdatum', 'BESLUTSDAT'], + ['Original-ID', 'ORGINALID', { classes: ['feature-objid'] }], + ['Riks-ID', 'RIKSID', { classes: ['feature-objid'] }], + ['Areal', 'GeomArea', { fn: 'area' }], + ], + style: [8, 16, 32, 32, 64, 64, 128, 128, 128, 256, 256, 256].map(function(width, z) { + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + patternCanvas.width = width; + patternCanvas.height = patternCanvas.width; + patternContext.fillStyle = 'transparent'; + patternContext.strokeStyle = 'rgba(154, 230, 0, 1)'; + patternContext.lineWidth = z < 4 ? .5 : z <= 5 ? 1 : 2; + patternContext.beginPath(); + patternContext.moveTo(0, 0); + patternContext.lineTo(patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(0, -patternCanvas.height); + patternContext.lineTo(2*patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(-patternCanvas.width, 0); + patternContext.lineTo(patternCanvas.width, 2*patternCanvas.height); + patternContext.stroke(); + + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return new Style({ + zIndex: 8, + fill: new Fill({ + color: context.createPattern(patternCanvas, 'repeat'), + }), + stroke: width === 0 ? undefined : new Stroke({ + width: z < 2 ? 1 : z < 4 ? 2 : z <= 5 ? 4 : 8, + color: [154, 230, 0, 1], + }), + }); + }), + }, + ri_friluftsliv: { + popoverTitle: 'Riksintresse friluftsliv', + popover: [ + ['Namn', 'NAMN'], + ['Skydd', 'SKYDD'], + ['Ämnesområde', 'AMNESOMR'], + ['Områdesnummer', 'OMRADESNR', { classes: ['feature-objid'] }], + ['Länk värdebeskrivning', 'LANK_VARDE', { fn: function(v) { + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Lagrum', 'LAGRUM'], + ['Beslutsdatum', 'BESLDATUM'], + ['Ärendenummer', 'ARENDENR', { classes: ['feature-attr-dnr'] }], + ['Länk, beslut', 'LANK_BESLU', { fn: function(v) { + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Aktivitet', 'AKTIVITET'], + ['Naturtyp', 'NATURTYP'], + ['Areal', 'GeomArea', { fn: 'area' }], + ['Areal land', 'AREA_LAND_', { unit: 'ha' }], + ['Areal vatten', 'AREA_VATTE', { unit: 'ha' }], + ], + style: [8, 16, 32, 32, 64, 64, 128, 128, 128, 256, 256, 256].map(function(width, z) { + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + patternCanvas.width = width; + patternCanvas.height = patternCanvas.width; + patternContext.fillStyle = 'transparent'; + patternContext.strokeStyle = 'rgba(0, 127, 232, 1)'; + patternContext.lineWidth = z < 4 ? .5 : z <= 5 ? 1 : 2; + patternContext.beginPath(); + patternContext.moveTo(0, 0); + patternContext.lineTo(patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(0, -patternCanvas.height); + patternContext.lineTo(2*patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(-patternCanvas.width, 0); + patternContext.lineTo(patternCanvas.width, 2*patternCanvas.height); + patternContext.stroke(); + + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return new Style({ + zIndex: 8, + fill: new Fill({ + color: context.createPattern(patternCanvas, 'repeat'), + }), + stroke: width === 0 ? undefined : new Stroke({ + width: z < 2 ? 1 : z < 4 ? 2 : z <= 5 ? 4 : 8, + color: [0, 127, 232, 1], + }), + }); + }), + }, + ri_rorligt_friluftsliv: { + popoverTitle: 'Riksintresse rörligt friluftsliv (MB 4 kap 1§ och 2§)', + popover: [ + ['Namn', 'NAMN'], + //['Original-ID', 'ORIGINALID', { classes: ['feature-objid'] }], + ['Beskrivning', 'BESKRIVNIN'], + //['Metodbeskrivning', 'METODBESKR'], + //['Tillk. datum', 'TILLKDATUM'], + //['Rev. datum', 'REVDATUM'], + ['Anmärkning', 'ANM'], + ['Länk', 'OBJEKTLANK', { fn: function(v) { + if (v === null) { + return; + } + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Areal', 'GeomArea', { fn: 'area' }], + ['Referens', 'REFERENS'], + ], + style: [8, 16, 32, 32, 64, 64, 128, 128, 128, 256, 256, 256].map(function(width, z) { + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + patternCanvas.width = width; + patternCanvas.height = patternCanvas.width; + patternContext.fillStyle = 'rgba(187, 227, 212, .25)'; + patternContext.fillRect(0, 0, patternCanvas.width, patternCanvas.height); + patternContext.strokeStyle = 'rgba(56, 151, 117, 1)'; + patternContext.lineWidth = z < 4 ? .5 : z <= 5 ? 1 : 2; + patternContext.beginPath(); + patternContext.moveTo(0, patternCanvas.height); + patternContext.lineTo(patternCanvas.width, 0); + patternContext.stroke(); + patternContext.moveTo(-patternCanvas.width, patternCanvas.height); + patternContext.lineTo(patternCanvas.width, -patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(0, 2*patternCanvas.height); + patternContext.lineTo(2*patternCanvas.width, 0); + patternContext.stroke(); + + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return new Style({ + zIndex: 8, + fill: new Fill({ + color: context.createPattern(patternCanvas, 'repeat'), + }), + stroke: width === 0 ? undefined : new Stroke({ + width: z < 2 ? 2 : z < 4 ? 4 : z <= 5 ? 8 : 16, + color: [56, 151, 117, 1], + lineDash: [width/4, width/3], + }), + }); + }), + }, + ri_obruten_kust: { + popoverTitle: 'Riksintresse obruten kust (MB 4 kap 3§)', + popover: [ + ['Namn', 'NAMN'], + //['Original-ID', 'ORIGINALID', { classes: ['feature-objid'] }], + ['Beskrivning', 'BESKRIVNIN'], + //['Metodbeskrivning', 'METODBESKR'], + //['Tillk. datum', 'TILLKDATUM'], + //['Rev. datum', 'REVDATUM'], + ['Anmärkning', 'ANM'], + ['Objekttyp', 'OBJTYP'], + ['Länk', 'OBJEKTLANK', { fn: function(v) { + if (v === null) { + return; + } + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Areal', 'GeomArea', { fn: 'area' }], + ['Referens', 'REFERENS'], + ], + style: [8, 16, 32, 32, 64, 64, 128, 128, 128, 256, 256, 256].map(function(width, z) { + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + patternCanvas.width = width; + patternCanvas.height = patternCanvas.width; + patternContext.fillStyle = 'rgba(227, 227, 187, .25)'; + patternContext.fillRect(0, 0, patternCanvas.width, patternCanvas.height); + patternContext.strokeStyle = 'rgba(156, 158, 56, 1)'; + patternContext.lineWidth = z < 4 ? .5 : z <= 5 ? 1 : 2; + patternContext.beginPath(); + patternContext.moveTo(0, 0); + patternContext.lineTo(patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(0, -patternCanvas.height); + patternContext.lineTo(2*patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(-patternCanvas.width, 0); + patternContext.lineTo(patternCanvas.width, 2*patternCanvas.height); + patternContext.stroke(); + + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return new Style({ + zIndex: 8, + fill: new Fill({ + color: context.createPattern(patternCanvas, 'repeat'), + }), + stroke: width === 0 ? undefined : new Stroke({ + width: z < 2 ? 2 : z < 4 ? 4 : z <= 5 ? 8 : 16, + color: [156, 158, 56, 1], + lineDash: [width/4, width/3], + }), + }); + }), + }, + ri_obrutet_fjall: { + popoverTitle: 'Riksintresse obrutet fjäll (MB 4 kap 5§)', + popover: [ + ['Namn', 'NAMN'], + //['Original-ID', 'ORIGINALID', { classes: ['feature-objid'] }], + ['Beskrivning', 'BESKRIVNIN'], + ['Metodbeskrivning', 'METODBESKR'], + ['Tillk. datum', 'TILLKDATUM'], + //['Rev. datum', 'REVDATUM'], + ['Länk', 'OBJEKTLANK', { fn: function(v) { + if (v === null) { + return; + } + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Areal', 'GeomArea', { fn: 'area' }], + ['Referens', 'REFERENS'], + ], + style: [8, 16, 32, 32, 64, 64, 128, 128, 128, 256, 256, 256].map(function(width, z) { + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + patternCanvas.width = width; + patternCanvas.height = patternCanvas.width; + patternContext.fillStyle = 'rgba(255, 255, 209, .25)'; + patternContext.fillRect(0, 0, patternCanvas.width, patternCanvas.height); + patternContext.strokeStyle = 'rgba(219, 183, 60, 1)'; + patternContext.lineWidth = z < 4 ? .5 : z <= 5 ? 1 : 2; + patternContext.beginPath(); + patternContext.moveTo(0, 0); + patternContext.lineTo(patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(0, -patternCanvas.height); + patternContext.lineTo(2*patternCanvas.width, patternCanvas.height); + patternContext.stroke(); + patternContext.moveTo(-patternCanvas.width, 0); + patternContext.lineTo(patternCanvas.width, 2*patternCanvas.height); + patternContext.stroke(); + + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return new Style({ + zIndex: 8, + fill: new Fill({ + color: context.createPattern(patternCanvas, 'repeat'), + }), + stroke: width === 0 ? undefined : new Stroke({ + width: z < 2 ? 2 : z < 4 ? 4 : z <= 5 ? 8 : 16, + color: [219, 183, 60, 1], + lineDash: [width/4, width/3], + }), + }); + }), + }, + ri_skyddade_vattendrag: { + popoverTitle: 'Riksintresse skyddade vattendrag (MB 4 kap 6§)', + popover: [ + ['Namn', 'NAMN'], + //['Original-ID', 'ORIGINALID', { classes: ['feature-objid'] }], + ['Beskrivning', 'BESKRIVNIN'], + ['Metodbeskrivning', 'METODBESKR'], + ['Tillk. datum', 'TILLKDATUM'], + ['Rev. datum', 'REVDATUM'], + ['Anmärkning', 'ANM'], + ['Digitaliseringsskala', 'DIG_SKALA'], + ['Länk', 'OBJEKTLANK', { fn: function(v) { + if (v === null) { + return; + } + const a = document.createElement('a'); + a.href = v; + a.target = '_blank'; + const i = document.createElement('i'); + i.classList.add('bi', 'bi-box-arrow-up-right'); + a.appendChild(i); + return a; + }}], + ['Areal', 'GeomArea', { fn: 'area' }], + ['Referens', 'REFERENS'], + ], + style: [8, 16, 32, 32, 64, 64, 128, 128, 128, 256, 256, 256].map(function(width, z) { + return new Style({ + zIndex: 8, + fill: new Fill({ + color: [102, 157, 240, .25], + }), + stroke: width === 0 ? undefined : new Stroke({ + width: z < 2 ? 2 : z < 4 ? 4 : z <= 5 ? 8 : 16, + color: [41, 109, 197, 1], + lineDash: [width/4, width/3], + }), + }); + }), + }, + ren_betesomraden: { popoverTitle: 'Samebyarnas betesområde', popover: [ @@ -2805,6 +3150,35 @@ const layerHierarchy = [ } ] }, + { + text: 'Riksintressen, naturvård och friluftsliv', + children: [ + { + text: 'Naturvård', + layer: 'ri_naturvard', + }, + { + text: 'Friluftsliv', + layer: 'ri_friluftsliv', + }, + { + text: 'Rörligt friluftsliv', + layer: 'ri_rorligt_friluftsliv', + }, + { + text: 'Obruten kust', + layer: 'ri_obruten_kust', + }, + { + text: 'Obrutet fjäll', + layer: 'ri_obrutet_fjall', + }, + { + text: 'Skyddade vattendrag', + layer: 'ri_skyddade_vattendrag', + }, + ] + }, { /* Definitions at * https://ext-dokument.lansstyrelsen.se/Gemensamt/Geodata/Datadistribution/Information,%20Skiktf%C3%B6rteckning%20och%20f%C3%B6rklaringar.pdf */ -- cgit v1.2.3