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

geosolutions-it / MapStore2 / 13857751818

14 Mar 2025 01:35PM UTC coverage: 76.965% (-0.01%) from 76.975%
13857751818

push

github

web-flow
#10918: Fix issue with measure tool in Cesium map (#10933)

30975 of 48211 branches covered (64.25%)

0 of 3 new or added lines in 1 file covered. (0.0%)

4 existing lines in 3 files now uncovered.

38487 of 50006 relevant lines covered (76.96%)

35.79 hits per line

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

12.0
/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, useEffect, useRef } 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);
×
45
    const selectedAnnotationType = getGeometryType(feature);
×
46
    const drawGeometryType = getDrawGeometryType(feature);
×
47
    const isGeodesic = !!geodesic[selectedAnnotationType];
×
48

NEW
49
    const featureRef = useRef(feature);
×
NEW
50
    useEffect(() => {
×
51
        // to avoid stale closure in the callback
NEW
52
        featureRef.current = feature;
×
53
    }, [feature]);
54

UNCOV
55
    return (
×
56
        <Suspense fallback={null}>
57
            <>
58
                <DrawGeometrySupport
59
                    map={map}
60
                    active={active && feature.geometry === null}
×
61
                    depthTestAgainstTerrain={false}
62
                    geometryType={drawGeometryType}
63
                    geodesic={isGeodesic}
64
                    getObjectsToExcludeOnPick={() => []}
×
65
                    onDrawEnd={({ feature: newFeature }) => {
66
                        onChange({
×
67
                            ...featureRef.current,
68
                            properties: {
69
                                ...featureRef.current?.properties,
70
                                geodesic: isGeodesic,
71
                                ...(newFeature?.properties?.radius !== undefined && {
×
72
                                    radius: newFeature?.properties?.radius
73
                                })
74
                            },
75
                            geometry: newFeature.geometry
76
                        });
77
                    }}
78
                />
79
                <EditFeatureSupport
80
                    map={map}
81
                    active={active && isFeatureGeometryValid}
×
82
                    geojson={feature}
83
                    getGeometryType={getGeometryType}
84
                    onEditEnd={newFeature => onChange(newFeature)}
×
85
                />
86
            </>
87
        </Suspense>
88
    );
89
}
90

91
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

© 2026 Coveralls, Inc