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

geosolutions-it / MapStore2 / 14797665772

02 May 2025 02:55PM UTC coverage: 76.933% (-0.06%) from 76.991%
14797665772

Pull #11067

github

web-flow
Merge 99dcd7f92 into d28bf7035
Pull Request #11067: Fix #10966 basic auth for services

30858 of 48053 branches covered (64.22%)

104 of 172 new or added lines in 24 files covered. (60.47%)

3 existing lines in 3 files now uncovered.

38384 of 49893 relevant lines covered (76.93%)

35.93 hits per line

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

7.69
/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 { getCredentials } from '../../../../utils/SecurityUtils';
17

18
function create(options) {
19
    let sourceOptions;
NEW
20
    if (options.security) {
×
NEW
21
        const storedProtectedService = getCredentials(options.security?.sourceId) || {};
×
NEW
22
        sourceOptions.headers = {
×
23
            "Authorization": `Basic ${btoa(storedProtectedService.username + ":" + storedProtectedService.password)}`
24
        };
25
    }
UNCOV
26
    return new TileLayer({
×
27
        msId: options.id,
28
        style: get(options, 'style.body'),
29
        opacity: options.opacity !== undefined ? options.opacity : 1,
×
30
        visible: options.visibility,
31
        source: new GeoTIFF({
32
            convertToRGB: 'auto', // CMYK, YCbCr, CIELab, and ICCLab images will automatically be converted to RGB
33
            sources: options.sources,
34
            wrapX: true,
35
            sourceOptions
36
        }),
37
        zIndex: options.zIndex,
38
        minResolution: options.minResolution,
39
        maxResolution: options.maxResolution
40
    });
41
}
42

43
Layers.registerType('cog', {
1✔
44
    create,
45
    update(layer, newOptions, oldOptions, map) {
46
        if (newOptions.srs !== oldOptions.srs
×
47
            || !isEqual(newOptions.style, oldOptions.style)
48
            || !isEqual(newOptions.security, oldOptions.security)
49
            || !isEqual(newOptions.sources, oldOptions.sources) // min/max source data value can change
50
        ) {
51
            return create(newOptions, map);
×
52
        }
53
        if (oldOptions.minResolution !== newOptions.minResolution) {
×
54
            layer.setMinResolution(newOptions.minResolution === undefined ? 0 : newOptions.minResolution);
×
55
        }
56
        if (oldOptions.maxResolution !== newOptions.maxResolution) {
×
57
            layer.setMaxResolution(newOptions.maxResolution === undefined ? Infinity : newOptions.maxResolution);
×
58
        }
59
        return null;
×
60
    },
61
    isCompatible: (layer) => {
62
        return isProjectionAvailable(layer?.sourceMetadata?.crs);
×
63
    }
64
});
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