Skip to content

Commit a7d85cf

Browse files
authored
Wv 2777 firms protected areas (#4755)
* initial work * disable snapshot * remove zoom constraint * remove non-geographic projections * prevent error message * add colormap * configure max zoom
1 parent 7667067 commit a7d85cf

File tree

4 files changed

+58
-9
lines changed

4 files changed

+58
-9
lines changed

config/default/common/colormaps/wdpa/World_Database_on_Protected_Areas.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
<ColorMapEntry rgb="34,154,0" transparent="false" ref="1" />
77
</Entries>
88
<Legend type="classification">
9-
<LegendEntry rgb="34,154,0" id="1" tooltip="Protected Area" label="Protected Area" showLabel="true" />
9+
<LegendEntry rgb="34,154,0" id="1" tooltip="Terrestrial Protected Area" label="Terrestrial Protected Area" showLabel="true" />
10+
</Legend>
11+
</ColorMap>
12+
<ColorMap title="Protected Area">
13+
<Entries>
14+
<ColorMapEntry rgb="0, 110, 255" transparent="false" ref="1" />
15+
</Entries>
16+
<Legend type="classification">
17+
<LegendEntry rgb="0, 110, 255" id="1" tooltip="Marine Protected Area" label="Marine Protected Area" showLabel="true" />
1018
</Legend>
1119
</ColorMap>
1220
</ColorMaps>

config/default/common/config/wv.json/layers/wdpa/World_Database_on_Protected_Areas.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
"World_Database_on_Protected_Areas": {
44
"id": "World_Database_on_Protected_Areas",
55
"layer": "0,1",
6+
"layerName": "pa_global",
67
"title": "Protected Areas",
78
"subtitle": "UNEP-WCMC and IUCN",
89
"description": "wdpa/World_Database_on_Protected_Areas",
910
"group": "overlays",
1011
"tags": "wdpa pa national park protected areas",
1112
"format": "image/png",
12-
"type": "wms",
13+
"type": "xyz",
14+
"disableSnapshot": true,
1315
"layergroup": "Reference",
1416
"wrapX": true,
17+
"maxZoom": 12,
1518
"projections": {
1619
"geographic": {
17-
"source": "WDPA:wms"
18-
},
19-
"arctic": {
20-
"source": "WDPA:wms"
21-
},
22-
"antarctic": {
23-
"source": "WDPA:wms"
20+
"source": "FIRMS:xyz"
2421
}
2522
},
2623
"palette": {

config/default/release/config/wv.json/sources.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"WDPA:wms": {
2222
"url": "https://gis.unep-wcmc.org/arcgis/services/wdpa/public/MapServer/WMSServer"
2323
},
24+
"FIRMS:xyz": {
25+
"url": "https://firms.modaps.eosdis.nasa.gov/layers"
26+
},
2427
"DDV": {
2528
"url": "https://kv9drwgv6l.execute-api.us-west-2.amazonaws.com/",
2629
"matrixSets": {

web/js/map/layerbuilder.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,44 @@ export default function mapLayerBuilder(config, cache, store) {
791791
return layer;
792792
};
793793

794+
const createXYZLayer = (def, options, day, state) => {
795+
const { proj: { selected }, date } = state;
796+
const { maxExtent, crs } = selected;
797+
798+
const source = config.sources[def.source];
799+
800+
const tileUrlFunction = (tileCoord) => {
801+
const z = tileCoord[0] - 1;
802+
const x = tileCoord[1];
803+
const y = tileCoord[2];
804+
805+
const urlParams = `${def.layerName}/${z}/${y}/${x}`;
806+
807+
return `${source?.url}/${urlParams}.png`;
808+
};
809+
810+
const xyzSourceOptions = {
811+
crossOrigin: 'anonymous',
812+
projection: get(crs),
813+
tileUrlFunction,
814+
maxZoom: def.maxZoom,
815+
};
816+
817+
const xyzSource = new OlSourceXYZ(xyzSourceOptions);
818+
819+
const requestDate = util.toISOStringSeconds(util.roundTimeOneMinute(date.selected)).slice(0, 10);
820+
const className = `${def.id} ${requestDate}`;
821+
822+
const layer = new OlLayerTile({
823+
source: xyzSource,
824+
className,
825+
extent: maxExtent,
826+
});
827+
828+
return layer;
829+
};
830+
831+
794832
/**
795833
* Create a new OpenLayers Layer
796834
* @param {object} def
@@ -853,6 +891,9 @@ export default function mapLayerBuilder(config, cache, store) {
853891
case 'ttiler':
854892
layer = await getLayer(createTtilerLayer, def, options, attributes, wrapLayer);
855893
break;
894+
case 'xyz':
895+
layer = getLayer(createXYZLayer, def, options, attributes, wrapLayer);
896+
break;
856897
default:
857898
throw new Error(`Unknown layer type: ${type}`);
858899
}

0 commit comments

Comments
 (0)