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

geosolutions-it / MapStore2 / 13560354468

27 Feb 2025 06:32AM UTC coverage: 76.792% (-0.01%) from 76.806%
13560354468

push

github

web-flow
Fix #10859 Share button on new dashbaord (#10879)

31292 of 48873 branches covered (64.03%)

4 of 5 new or added lines in 3 files covered. (80.0%)

13 existing lines in 3 files now uncovered.

38842 of 50581 relevant lines covered (76.79%)

35.74 hits per line

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

13.64
/web/client/plugins/Annotations/containers/AnnotationsMapInteractionsSupport.jsx
1
/*
2
 * Copyright 2023, 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, { lazy, Suspense } from 'react';
10
import { MapLibraries } from '../../../utils/MapTypeUtils';
11
import { validateFeature } from '../utils/AnnotationsUtils';
12

13
const drawGeometrySupportSupports = {
1✔
14
    [MapLibraries.OPENLAYERS]: lazy(() => import(/* webpackChunkName: 'supports/olDrawGeometrySupport' */ '../../../components/map/openlayers/DrawGeometrySupport')),
×
15
    [MapLibraries.CESIUM]: lazy(() => import(/* webpackChunkName: 'supports/cesiumDrawGeometrySupport' */ '../../../components/map/cesium/DrawGeometrySupport'))
×
16
};
17
const editGeoJSONSupportSupports = {
1✔
18
    [MapLibraries.OPENLAYERS]: lazy(() => import(/* webpackChunkName: 'supports/olEditGeoJSONSupport' */ '../../../components/map/openlayers/EditGeoJSONSupport')),
×
19
    [MapLibraries.CESIUM]: lazy(() => import(/* webpackChunkName: 'supports/cesiumEditGeoJSONSupport' */ '../../../components/map/cesium/EditGeoJSONSupport'))
×
20
};
21

22
export const areAnnotationsMapInteractionsSupported = (mapType) => {
1✔
23
    return drawGeometrySupportSupports[mapType] && editGeoJSONSupportSupports[mapType];
×
24
};
25

26
function AnnotationsMapInteractionsSupport({
27
    map,
28
    active,
29
    mapType,
30
    feature,
31
    geodesic = {},
×
32
    onChange = () => {}
×
33
}) {
34

35
    const getGeometryType = ({ properties } = {}) => properties?.annotationType === 'Text' ? 'Point' : properties?.annotationType;
×
36
    const getDrawGeometryType = ({ geometry, properties } = {}) => properties?.annotationType === 'Text'
×
37
    || (properties?.radius > 0 && !geometry) ? 'Point' : properties?.annotationType;
38

39
    if (!areAnnotationsMapInteractionsSupported(mapType)) {
×
40
        return null;
×
41
    }
42
    const DrawGeometrySupport = drawGeometrySupportSupports[mapType];
×
43
    const EditFeatureSupport = editGeoJSONSupportSupports[mapType];
×
44
    const isFeatureGeometryValid = validateFeature(feature, true);
×
UNCOV
45
    const selectedAnnotationType = getGeometryType(feature);
×
UNCOV
46
    const drawGeometryType = getDrawGeometryType(feature);
×
UNCOV
47
    const isGeodesic = !!geodesic[selectedAnnotationType];
×
UNCOV
48
    return (
×
49
        <Suspense fallback={null}>
50
            <>
51
                <DrawGeometrySupport
52
                    map={map}
53
                    active={active && feature.geometry === null}
×
54
                    depthTestAgainstTerrain={false}
55
                    geometryType={drawGeometryType}
56
                    geodesic={isGeodesic}
UNCOV
57
                    getObjectsToExcludeOnPick={() => []}
×
58
                    onDrawEnd={({ feature: newFeature }) => {
UNCOV
59
                        onChange({
×
60
                            ...feature,
61
                            properties: {
62
                                ...feature?.properties,
63
                                geodesic: isGeodesic,
64
                                ...(newFeature?.properties?.radius !== undefined && {
×
65
                                    radius: newFeature?.properties?.radius
66
                                })
67
                            },
68
                            geometry: newFeature.geometry
69
                        });
70
                    }}
71
                />
72
                <EditFeatureSupport
73
                    map={map}
74
                    active={active && isFeatureGeometryValid}
×
75
                    geojson={feature}
76
                    getGeometryType={getGeometryType}
UNCOV
77
                    onEditEnd={newFeature => onChange(newFeature)}
×
78
                />
79
            </>
80
        </Suspense>
81
    );
82
}
83

84
export default AnnotationsMapInteractionsSupport;
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