• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 19060241474

04 Nov 2025 06:46AM UTC coverage: 76.943% (+0.02%) from 76.92%
19060241474

Pull #11648

github

web-flow
Merge 763e0cf1e into 19e678788
Pull Request #11648: #11644: Implement dynamic request configurations

32057 of 49801 branches covered (64.37%)

201 of 222 new or added lines in 39 files covered. (90.54%)

4 existing lines in 3 files now uncovered.

39801 of 51728 relevant lines covered (76.94%)

39.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.25
/web/client/components/map/openlayers/plugins/COGLayer.js
1
/**
2
 * Copyright 2015, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
import Layers from '../../../../utils/openlayers/Layers';
10
import isEqual from 'lodash/isEqual';
11
import get from 'lodash/get';
12

13
import GeoTIFF from 'ol/source/GeoTIFF.js';
14
import TileLayer from 'ol/layer/WebGLTile.js';
15
import { isProjectionAvailable } from '../../../../utils/ProjectionUtils';
16
import { getRequestConfigurationByUrl } from '../../../../utils/SecurityUtils';
17

18
function create(options) {
NEW
19
    let sourceOptions = {};
×
NEW
20
    if (options.security && options.sources && options.sources.length > 0) {
×
NEW
21
        const firstSource = options.sources[0];
×
NEW
22
        const requestConfig = getRequestConfigurationByUrl(firstSource.url, null, options.security?.sourceId);
×
NEW
23
        if (requestConfig.headers) {
×
NEW
24
            sourceOptions.headers = requestConfig.headers;
×
25
        }
26
    }
27
    return new TileLayer({
×
28
        msId: options.id,
29
        style: get(options, 'style.body'),
30
        opacity: options.opacity !== undefined ? options.opacity : 1,
×
31
        visible: options.visibility,
32
        source: new GeoTIFF({
33
            convertToRGB: 'auto', // CMYK, YCbCr, CIELab, and ICCLab images will automatically be converted to RGB
34
            sources: options.sources,
35
            wrapX: true,
36
            sourceOptions
37
        }),
38
        zIndex: options.zIndex,
39
        minResolution: options.minResolution,
40
        maxResolution: options.maxResolution
41
    });
42
}
43

44
Layers.registerType('cog', {
1✔
45
    create,
46
    update(layer, newOptions, oldOptions, map) {
47
        if (newOptions.srs !== oldOptions.srs
×
48
            || !isEqual(newOptions.style, oldOptions.style)
49
            || !isEqual(newOptions.security, oldOptions.security)
50
            || !isEqual(newOptions.sources, oldOptions.sources) // min/max source data value can change
51
        ) {
52
            return create(newOptions, map);
×
53
        }
54
        if (oldOptions.minResolution !== newOptions.minResolution) {
×
55
            layer.setMinResolution(newOptions.minResolution === undefined ? 0 : newOptions.minResolution);
×
56
        }
57
        if (oldOptions.maxResolution !== newOptions.maxResolution) {
×
58
            layer.setMaxResolution(newOptions.maxResolution === undefined ? Infinity : newOptions.maxResolution);
×
59
        }
60
        return null;
×
61
    },
62
    isCompatible: (layer) => {
63
        return isProjectionAvailable(layer?.sourceMetadata?.crs);
×
64
    }
65
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc