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

geosolutions-it / MapStore2 / 19933858499

04 Dec 2025 01:54PM UTC coverage: 76.636% (-0.03%) from 76.661%
19933858499

Pull #11648

github

web-flow
Update User Guide - Itinerary plugin (#11768)

* add_11664

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

---------

Co-authored-by: Suren <dsuren1@gmail.com>
Pull Request #11648: #11644: Implement dynamic request configurations

32316 of 50296 branches covered (64.25%)

132 of 155 new or added lines in 40 files covered. (85.16%)

283 existing lines in 32 files now uncovered.

40207 of 52465 relevant lines covered (76.64%)

37.89 hits per line

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

6.25
/web/client/components/map/openlayers/plugins/TMSLayer.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
import { get, isEqual } from 'lodash';
9
import axios from 'axios';
10
import XYZ from 'ol/source/XYZ';
11
import TileGrid from 'ol/tilegrid/TileGrid';
12
import TileLayer from 'ol/layer/Tile';
13

14
import Layers from '../../../../utils/openlayers/Layers';
15
import { getCredentials } from '../../../../utils/SecurityUtils';
16

17
const tileLoadFunction = options => (image, src) => {
1✔
NEW
18
    const storedProtectedService = getCredentials(options.security?.sourceId) || {};
×
UNCOV
19
    axios.get(src, {
×
20
        headers: {
21
            "Authorization": `Basic ${btoa(storedProtectedService.username + ":" + storedProtectedService.password)}`
22
        },
23
        responseType: 'blob'
24
    }).then(response => {
UNCOV
25
        image.getImage().src = URL.createObjectURL(response.data);
×
26
    }).catch(e => {
UNCOV
27
        image.getImage().src = null;
×
UNCOV
28
        console.error(e);
×
29
    });
30
};
31

32
function tileXYZToOpenlayersOptions(options = {}) {
×
UNCOV
33
    const { minx, miny, maxx, maxy } = get(options, "bbox.bounds", {});
×
UNCOV
34
    const sourceOpt = {
×
35
        projection: options.srs,
36
        url: `${options.tileMapUrl}/{z}/{x}/{-y}.${options.extension}`, // TODO use resolutions
37
        attributions: options.attribution ? [options.attribution] : []
×
38
    };
39
    if (options.security) {
×
40
        sourceOpt.tileLoadFunction = tileLoadFunction(options);
×
41
    }
42

43
    let source = new XYZ(sourceOpt);
×
44
    const defaultTileGrid = source.getTileGrid();
×
45

UNCOV
46
    if (options.forceDefaultTileGrid) {
×
UNCOV
47
        const defaultExtent = defaultTileGrid.getExtent();
×
UNCOV
48
        const newOrigin = [defaultExtent[0], defaultExtent[1]]; // minx, miny instead of top left corner, origin is bottom left.
×
UNCOV
49
        const newTileGrid = new TileGrid({
×
50
            // origin must be overridden because GeoServer uses the tile-set origin and OL uses by default extent corner.
51
            origin: newOrigin,
52
            extent: options.bbox && [minx, miny, maxx, maxy],
×
53
            resolutions: defaultTileGrid.getResolutions(),
54
            tileSize: options.tileSize
55
        });
56
        source.setTileGridForProjection(options.srs, newTileGrid);
×
57
        if (options.srs === "EPSG:3857") {
×
UNCOV
58
            source.setTileGridForProjection("EPSG:900913", newTileGrid);
×
59
        }
60
    } else if (options.tileSets) {
×
UNCOV
61
        source.setTileGridForProjection(options.srs, new TileGrid({
×
62
            origin: options.origin,
63
            extent: options.bbox && [minx, miny, maxx, maxy],
×
64
            resolutions: options.tileSets.map(({ resolution }) => resolution),
×
65
            tileSize: options.tileSize
66
        }));
67
    }
UNCOV
68
    let olOpt = {
×
69
        msId: options.id,
70
        extent: options.bbox && [minx, miny, maxx, maxy],
×
71
        opacity: options.opacity !== undefined ? options.opacity : 1,
×
72
        visible: options.visibility !== false,
73
        zIndex: options.zIndex,
74
        source: source,
75
        minResolution: options.minResolution,
76
        maxResolution: options.maxResolution
77
    };
UNCOV
78
    return olOpt;
×
79
}
80

81
Layers.registerType('tms', {
1✔
82
    create: (options) => {
83
        return new TileLayer(tileXYZToOpenlayersOptions(options));
×
84
    },
85
    update: (layer, newOptions, oldOptions) => {
86
        if (oldOptions.minResolution !== newOptions.minResolution) {
×
UNCOV
87
            layer.setMinResolution(newOptions.minResolution === undefined ? 0 : newOptions.minResolution);
×
88
        }
NEW
89
        if (oldOptions.maxResolution !== newOptions.maxResolution) {
×
UNCOV
90
            layer.setMaxResolution(newOptions.maxResolution === undefined ? Infinity : newOptions.maxResolution);
×
91
        }
UNCOV
92
        if (!isEqual(oldOptions.security, newOptions.security)) {
×
UNCOV
93
            layer.getSource().setTileLoadFunction(tileLoadFunction(newOptions));
×
94
        }
95
    }
96
});
97

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

© 2026 Coveralls, Inc