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

geosolutions-it / MapStore2 / 12831531306

17 Jan 2025 03:01PM UTC coverage: 77.182% (+0.07%) from 77.115%
12831531306

Pull #10746

github

web-flow
Merge 501dbaeea into 4e4dabc03
Pull Request #10746: Fix #10739 Changing correctly resolutions limits when switching map CRS

30373 of 47156 branches covered (64.41%)

34 of 43 new or added lines in 2 files covered. (79.07%)

126 existing lines in 15 files now uncovered.

37769 of 48935 relevant lines covered (77.18%)

35.14 hits per line

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

17.86
/web/client/components/mapviews/MapViewSettings.jsx
1
/*
2
 * Copyright 2022, 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 React from 'react';
10
import { Alert } from 'react-bootstrap';
11
import DescriptionSection from './settings/DescriptionSection';
12
import PositionsSection from './settings/PositionsSection';
13
import AnimationSection from './settings/AnimationSection';
14
import MaskSection from './settings/MaskSection';
15
import GlobeTranslucencySection from './settings/GlobeTranslucencySection';
16
import LayersSection from './settings/LayersSection';
17
import { getResourceFromLayer } from '../../api/MapViews';
18
import { ViewSettingsTypes } from '../../utils/MapViewsUtils';
19
import Message from '../I18N/Message';
20

21
const sections = {
1✔
22
    [ViewSettingsTypes.DESCRIPTION]: DescriptionSection,
23
    [ViewSettingsTypes.POSITION]: PositionsSection,
24
    [ViewSettingsTypes.ANIMATION]: AnimationSection,
25
    [ViewSettingsTypes.MASK]: MaskSection,
26
    [ViewSettingsTypes.GLOBE_TRANSLUCENCY]: GlobeTranslucencySection,
27
    [ViewSettingsTypes.LAYERS_OPTIONS]: LayersSection
28
};
29

30
function ViewSettings({
31
    view,
32
    api,
33
    layers = [],
2✔
34
    groups = [],
2✔
35
    onChange,
36
    onUpdateResource = () => { },
2✔
37
    onCaptureView,
38
    locale,
39
    resources = [],
2✔
40
    expandedSections = {},
2✔
41
    onExpandSection = () => {},
2✔
42
    showClipGeometries,
43
    onShowClipGeometries = () => {}
2✔
44
}) {
45

46
    const availableVectorLayers = layers
2✔
47
        .filter(({ type, features }) => {
48
            if (type === 'wfs') {
×
UNCOV
49
                return true;
×
50
            }
51
            if (type === 'vector') {
×
UNCOV
52
                return !!features?.find(({ geometry }) => ['Polygon', 'MultiPolygon'].includes(geometry?.type));
×
53
            }
UNCOV
54
            return false;
×
55
        });
56

57
    function handleChange(options) {
UNCOV
58
        onChange({ ...view, ...options });
×
59
    }
60

61
    function handleChangeLayer(layerId, options) {
62
        const viewLayer = view?.layers?.find(vLayer => vLayer.id === layerId);
×
UNCOV
63
        const viewLayers = viewLayer
×
64
            ? (view?.layers || [])
×
UNCOV
65
                .map((vLayer) => vLayer.id === layerId ? ({ ...viewLayer, ...options }) : vLayer)
×
66
            : [...(view?.layers || []), { id: layerId, ...options }];
×
UNCOV
67
        onChange({
×
68
            ...view,
69
            layers: viewLayers
70
        });
71
    }
72

73
    function handleResetLayer(layerId) {
74
        const viewLayers = view?.layers?.filter(vLayer => vLayer.id !== layerId);
×
UNCOV
75
        onChange({
×
76
            ...view,
77
            layers: viewLayers
78
        });
79
    }
80

81
    function handleChangeGroup(groupId, options) {
UNCOV
82
        const viewGroup = view?.groups?.find(vGroup => vGroup.id === groupId);
×
UNCOV
83
        const viewGroups = viewGroup
×
84
            ? (view?.groups || [])
×
UNCOV
85
                .map((vGroup) => vGroup.id === groupId ? ({ ...viewGroup, ...options }) : vGroup)
×
86
            : [...(view?.groups || []), { id: groupId, ...options }];
×
87
        onChange({
×
88
            ...view,
89
            groups: viewGroups
90
        });
91
    }
92

93
    function handleResetGroup(groupId) {
UNCOV
94
        const viewGroups = view?.groups?.filter(vGroup => vGroup.id !== groupId);
×
UNCOV
95
        onChange({
×
96
            ...view,
97
            groups: viewGroups
98
        });
99
    }
100

101
    function updateLayerRequest({ layer, inverse = false, offset = 0 } = {}) {
×
UNCOV
102
        return getResourceFromLayer({
×
103
            layer,
104
            inverse,
105
            offset,
106
            resources
107
        }).then(({ updated, ...resource }) => {
UNCOV
108
            if (updated) {
×
UNCOV
109
                onUpdateResource(resource.id, resource.data);
×
110
            }
UNCOV
111
            return resource.id;
×
112
        });
113
    }
114

115
    return (
2✔
116
        <div className="ms-map-views-settings">
117
            <form>
118
                {api?.options?.settings?.map((key) => {
119
                    const SectionComponent = sections[key];
6✔
120
                    return (
6✔
121
                        <SectionComponent
122
                            key={key}
123
                            isTerrainAvailable={!(api?.options?.unsupportedLayers || []).includes('terrain')}
12✔
124
                            isClippingAvailable={!(api?.options?.unsupportedLayers || []).includes('3dtiles')}
12✔
125
                            computeViewCoordinates={api.computeViewCoordinates}
126
                            view={view}
127
                            expandedSections={expandedSections}
128
                            onExpandSection={onExpandSection}
129
                            onChange={handleChange}
130
                            resources={resources}
UNCOV
131
                            layers={layers.filter(({ type }) => !(api?.options?.unsupportedLayers || []).includes(type))}
×
132
                            groups={groups}
133
                            vectorLayers={availableVectorLayers}
134
                            updateLayerRequest={updateLayerRequest}
135
                            locale={locale}
136
                            onChangeLayer={handleChangeLayer}
137
                            onResetLayer={handleResetLayer}
138
                            onChangeGroup={handleChangeGroup}
139
                            onResetGroup={handleResetGroup}
140
                            showClipGeometries={showClipGeometries}
141
                            onShowClipGeometries={onShowClipGeometries}
142
                            onCaptureView={onCaptureView}
143
                        />
144
                    );
145
                })}
146
            </form>
147
            {(view?.globeTranslucency?.enabled && view?.mask?.enabled) &&
2!
148
                <Alert bsStyle="warning" style={{ bottom: 0, position: 'sticky', margin: 0, zIndex: 30 }}>
149
                    <Message msgId="mapViews.maskWithGlobeTranslucencyWarning" />
150
                </Alert>}
151
        </div>
152
    );
153
}
154

155
export default ViewSettings;
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