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

geosolutions-it / MapStore2 / 13252859189

10 Feb 2025 11:57PM UTC coverage: 77.241% (+0.4%) from 76.854%
13252859189

Pull #10803

github

web-flow
Merge 83c682676 into 20c08cf3c
Pull Request #10803: #10799: Cesium map dark when opened in the evening

28604 of 44703 branches covered (63.99%)

23 of 50 new or added lines in 2 files covered. (46.0%)

1 existing line in 1 file now uncovered.

35703 of 46223 relevant lines covered (77.24%)

37.39 hits per line

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

25.0
/web/client/plugins/map/mapsettings/MapSettings.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 { connect } from 'react-redux';
11
import { FormGroup, Checkbox, ControlLabel } from 'react-bootstrap';
12
import Select from 'react-select';
13
import { createSelector } from 'reselect';
14
import Message from '../../../components/I18N/Message';
15
import { updateMapOptions } from '../../../actions/map';
16
import ConfigUtils from '../../../utils/ConfigUtils';
17

18
import { mapSelector } from '../../../selectors/map';
19
import { mapTypeSelector, isCesium as isCesiumSelector } from '../../../selectors/maptype';
20
import localizedProps from '../../../components/misc/enhancers/localizedProps';
21
import utcDateWrapper from '../../../components/misc/enhancers/utcDateWrapper';
22
import { DATE_TYPE } from '../../../utils/FeatureGridUtils';
23
import { getMessageById } from '../../../utils/LocaleUtils';
24
import PropTypes from 'prop-types';
25
import DateTimePicker from '../../../components/misc/datetimepicker';
26

27
const mapStateToProps = createSelector(
1✔
28
    mapSelector,
29
    mapTypeSelector,
30
    isCesiumSelector,
31
    (map, mapType, isCesium) => ( { map, mapType, isCesium })
×
32
);
33

34
const actions = {
1✔
35
    updateConfigAction: updateMapOptions
36
};
37

38
const UTCDateTimePicker = utcDateWrapper({
1✔
39
    dateProp: "value",
40
    dateTypeProp: "type",
41
    setDateProp: "onChange"
42
})(DateTimePicker);
43

44
const Component = ({
1✔
45
    map,
46
    mapType,
47
    isCesium,
48
    updateConfigAction,
49
    mapOptions: defaultMapOptions
50
}, { messages }) => {
NEW
51
    const SelectLocalized = localizedProps(["placeholder", "options"])(Select);
×
NEW
52
    const DEFAULT_QUICK_TIME_SELECTORS = [
×
53
        {
54
            "type": DATE_TYPE.DATE_TIME,
55
            "value": "{now}+P0D",
56
            "labelId": "queryform.attributefilter.datefield.quickSelectors.now"
57
        },
58
        {
59
            "type": DATE_TYPE.DATE_TIME,
60
            "value": "{now}-P1D",
61
            "labelId": "queryform.attributefilter.datefield.quickSelectors.yesterday"
62
        },
63
        {
64
            "type": DATE_TYPE.DATE_TIME,
65
            "value": "{now}+P1D",
66
            "labelId": "queryform.attributefilter.datefield.quickSelectors.tomorrow"
67
        }
68
    ];
69

70
    const mapOptions = {
×
71
        ...(defaultMapOptions && defaultMapOptions[mapType]
×
72
            || ConfigUtils.getConfigProp("defaultMapOptions") && ConfigUtils.getConfigProp("defaultMapOptions")[mapType] || {}),
73
        ...map?.mapOptions
74
    };
75

76
    const handleConfigUpdate = (options, key) => {
×
77
        updateConfigAction({[key]: !options[key]});
×
78
    };
79

80
    return isCesium ? (
×
81
        <form>
82
            <FormGroup>
83
                <ControlLabel>
84
                    <Message msgId="map.settings.title" />
85
                </ControlLabel>
86
            </FormGroup>
87
            <Checkbox
88
                checked={mapOptions.showSkyAtmosphere}
89
                onChange={() => handleConfigUpdate(mapOptions, 'showSkyAtmosphere')}
×
90
            >
91
                <Message msgId="map.settings.skyAtmosphere" />
92
            </Checkbox>
93
            <Checkbox
94
                checked={mapOptions.showGroundAtmosphere}
95
                onChange={() => handleConfigUpdate(mapOptions, 'showGroundAtmosphere')}
×
96
            >
97
                <Message msgId="map.settings.groundAtmosphere" />
98
            </Checkbox>
99
            <Checkbox
100
                checked={mapOptions.enableFog}
101
                onChange={() => handleConfigUpdate(mapOptions, 'enableFog')}
×
102
            >
103
                <Message msgId="map.settings.fog" />
104
            </Checkbox>
105
            <Checkbox
106
                checked={mapOptions.depthTestAgainstTerrain}
107
                onChange={() => handleConfigUpdate(mapOptions, 'depthTestAgainstTerrain')}
×
108
            >
109
                <Message msgId="map.settings.depthTest" />
110
            </Checkbox>
111
            <>
112
                <label className="control-label"><Message msgId="map.settings.lighting3DOptions.title"/></label>
113
                <SelectLocalized
114
                    options={[
115
                        {label: "map.settings.lighting3DOptions.flashlightOption", value: "flashlight"},
116
                        {label: "map.settings.lighting3DOptions.sunlightOption", value: "sunlight"},
117
                        {label: "map.settings.lighting3DOptions.dateTimeOption", value: "dateTime"}
118
                    ]}
119
                    wrapperStyle = {{ marginTop: "10px"}}
120
                    value={mapOptions && mapOptions.lighting3DOption?.value || ""}
×
121
                    clearable={false}
122
                    onChange={(val) => {
NEW
123
                        if (val !== 'dateTime') {
×
NEW
124
                            updateConfigAction({"lighting3DOption": {value: val.value}});
×
125
                        } else {
NEW
126
                            updateConfigAction({"lighting3DOption": {value: val.value, dateTime: new Date().toISOString()}});
×
127
                        }
128
                    }}
129
                    placeholder="map.settings.lighting3DOptions.placeholder"
130
                />
131
                {mapOptions?.lighting3DOption?.value === 'dateTime' ?
×
132
                    <UTCDateTimePicker
133
                        value={mapOptions.lighting3DOption?.dateTime ? new Date(mapOptions.lighting3DOption?.dateTime) : new Date()}
×
134
                        quickDateTimeSelectors={DEFAULT_QUICK_TIME_SELECTORS}
135
                        hideOperator
136
                        time
137
                        calendar
138
                        type={'date-time'}
139
                        onChange={(date) => {
NEW
140
                            updateConfigAction({"lighting3DOption": {...mapOptions.lighting3DOption, dateTime: date}});
×
141
                        }}
142
                        placeholder={getMessageById(messages, "map.settings.lighting3DOptions.dateTimePlaceholder")} /> :
143
                    null}
144
            </>
145
        </form>
146
    ) : null;
147
};
148
Component.contextTypes = {
1✔
149
    messages: PropTypes.object
150
};
151
export default connect(mapStateToProps, actions)(Component);
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