]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.geo.js/OpenLayerTileSources.js
Prepare next development cycle
[gpl/argeo-suite.git] / org.argeo.app.geo.js / OpenLayerTileSources.js
1
2 import WMTS from 'ol/source/WMTS.js';
3 import WMTSTileGrid from 'ol/tilegrid/WMTS';
4 import { getTopLeft } from 'ol/extent';
5 import { getWidth } from 'ol/extent';
6 import { get as getProjection } from 'ol/proj';
7
8 export class SentinelCloudless extends WMTS {
9 static source_s2CL2019;
10 static EPSG4326 = getProjection('EPSG:4326');
11
12 static resolutions;
13 static matrixIds;
14
15 static {
16 let min_zoom = 6;
17 let max_zoom = 17;
18 let zoomOffset = 1;
19
20 // from https://s2maps.eu/
21 let size = getWidth(this.EPSG4326.getExtent()) / 512;
22 this.resolutions = new Array(max_zoom + zoomOffset);
23 this.matrixIds = new Array(max_zoom + zoomOffset);
24 for (let z = min_zoom; z <= max_zoom; ++z) {
25 // generate resolutions and matrixIds arrays for this WMTS
26 this.resolutions[z] = size / Math.pow(2, z);
27 this.matrixIds[z] = z;
28 }
29 }
30
31 constructor() {
32 super({
33 urls: [
34 "//a.s2maps-tiles.eu/wmts/",
35 "//b.s2maps-tiles.eu/wmts/",
36 "//c.s2maps-tiles.eu/wmts/",
37 "//d.s2maps-tiles.eu/wmts/",
38 "//e.s2maps-tiles.eu/wmts/"
39 ],
40 layer: 's2cloudless-2021',
41 matrixSet: 'WGS84',
42 format: 'image/jpeg',
43 projection: SentinelCloudless.EPSG4326,
44 tileGrid: new WMTSTileGrid({
45 origin: getTopLeft(SentinelCloudless.EPSG4326.getExtent()),
46 resolutions: SentinelCloudless.resolutions,
47 matrixIds: SentinelCloudless.matrixIds,
48 }),
49 style: 'default',
50 transition: 0,
51 wrapX: true
52 });
53 }
54 }