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

compassinformatics / cpsi-mapview / 15022980938

14 May 2025 02:11PM UTC coverage: 26.333% (+0.04%) from 26.29%
15022980938

push

github

geographika
Move describe to test globals

492 of 2344 branches covered (20.99%)

Branch coverage included in aggregate %.

1464 of 5084 relevant lines covered (28.8%)

1.17 hits per line

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

16.67
/app/view/button/SpatialQueryButton.js
1
/**
2
 * This class is the button of cpsi mapview application that can be used to
3
 * query an assigned layer by a drawn geometry. After the button is toggled,
4
 * a draw interaction is activated on the map to define the query geometry.
5
 *
6
 * @class CpsiMapview.view.button.SpatialQueryButton
7
 */
8
Ext.define('CpsiMapview.view.button.SpatialQueryButton', {
1✔
9
    extend: 'Ext.button.Button',
10
    xtype: 'cmv_spatial_query_button',
11

12
    requires: [
13
        'CpsiMapview.model.button.SpatialQueryButton',
14
        'CpsiMapview.controller.button.SpatialQueryButtonController'
15
    ],
16

17
    statics: {
18
        /**
19
         * Finds the associated permanent layer of a layer that is
20
         * used for the spatial query. This is done by comparing the
21
         * layerKey of the layer to the associatedLayerKey property
22
         * of the permanent layer.
23
         * @param {ol.Map} map the map in which to look for the layer
24
         * @param {String} layerKey layerKey property of the layer
25
         */
26
        findAssociatedPermanentLayer: function (map, layerKey) {
27
            const layers = map.getLayers().getArray();
6✔
28
            const associatedPermanentLayer = layers.find(function (layer) {
6✔
29
                const isSpatialQueryLayer = layer.get('isSpatialQueryLayer');
×
30
                const associatedLayerKey = layer.get('associatedLayerKey');
×
31
                return isSpatialQueryLayer && associatedLayerKey === layerKey;
×
32
            });
33
            return associatedPermanentLayer;
6✔
34
        },
35

36
        /**
37
         * Clears the geometries of the associated permanent
38
         * layer of a layer that is used for the spatial query.
39
         * @param {ol.Map} map the map in which to look for the layer
40
         * @param {String} layerKey layerKey property of the layer
41
         */
42
        clearAssociatedPermanentLayer: function (map, layerKey) {
43
            const associatedPermanentLayer =
44
                CpsiMapview.view.button.SpatialQueryButton.findAssociatedPermanentLayer(
×
45
                    map,
46
                    layerKey
47
                );
48
            if (associatedPermanentLayer !== undefined) {
×
49
                associatedPermanentLayer.getSource().clear();
×
50
            }
51
        },
52

53
        /**
54
         * Shows the associated permanent layer of a layer that
55
         * is used for the spatial query.
56
         * @param {ol.Map} map the map in which to look for the layer
57
         * @param {String} layerKey layerKey property of the layer
58
         */
59
        showAssociatedPermanentLayer: function (map, layerKey) {
60
            const associatedPermanentLayer =
61
                CpsiMapview.view.button.SpatialQueryButton.findAssociatedPermanentLayer(
×
62
                    map,
63
                    layerKey
64
                );
65
            if (associatedPermanentLayer !== undefined) {
×
66
                associatedPermanentLayer.setVisible(true);
×
67
            }
68
        },
69

70
        /**
71
         * Hides the associated permanent layer of a layer that
72
         * is used for the spatial query.
73
         * @param {ol.Map} map the map in which to look for the layer
74
         * @param {String} layerKey layerKey property of the layer
75
         */
76
        hideAssociatedPermanentLayer: function (map, layerKey) {
77
            const associatedPermanentLayer =
78
                CpsiMapview.view.button.SpatialQueryButton.findAssociatedPermanentLayer(
×
79
                    map,
80
                    layerKey
81
                );
82
            if (associatedPermanentLayer !== undefined) {
×
83
                associatedPermanentLayer.setVisible(false);
×
84
            }
85
        }
86
    },
87

88
    config: {
89
        /**
90
         * The name of the layer to query
91
         * This property will be ignored if queryLayer is defined
92
         */
93
        queryLayerName: null,
94

95
        /**
96
         * The layerKey property of the layer to query
97
         */
98
        vectorLayerKey: null
99
    },
100

101
    /**
102
     * The viewModel for this class
103
     */
104
    viewModel: 'cmv_spatial_query_btn',
105

106
    /**
107
     * The controller for this class
108
     */
109
    controller: 'cmv_spatial_query_btn',
110

111
    /**
112
     * The name to be used e.g. in ComponentQueries
113
     */
114
    name: 'spatialQueryBtn',
115

116
    /**
117
     * The type of the geometry to draw / query with
118
     * (Polygon, LineString, Point)
119
     * Will be ignored if spatialOperator === 'bbox'
120
     */
121
    drawGeometryType: null,
122

123
    /**
124
     * The type of spatial operator to use, see GeoExt.util.OGCFilter.
125
     *                               topologicalOrSpatialFilterOperators
126
     */
127
    spatialOperator: null,
128

129
    /**
130
     * The layer to query
131
     */
132
    queryLayer: null,
133

134
    /**
135
     * The drawn feature to query with
136
     */
137
    queryFeatures: new ol.Collection(),
138

139
    /**
140
     * If true, the filter geometry will be displayed until filter was cleared
141
     * If false, the filter geometry will disappear after filtering
142
     */
143
    displayPermanently: false,
144

145
    /**
146
     * Enable toggle
147
     */
148
    enableToggle: true,
149

150
    /**
151
     * Register the listeners and redirect them
152
     * to their corresponding controller methods
153
     */
154
    listeners: {
155
        toggle: 'onSpatialQueryBtnToggle',
156
        clearAssociatedPermanentLayer: 'onClearAssociatedPermanentLayer',
157
        hideAssociatedPermanentLayer: 'onHideAssociatedPermanentLayer',
158
        showAssociatedPermanentLayer: 'onShowAssociatedPermanentLayer',
159
        beforedestroy: 'onBeforeDestroy'
160
    },
161

162
    bind: {
163
        tooltip: '{tooltip}'
164
    },
165

166
    /**
167
     * If set to true a Wfs GetFeatures request will be automatically triggered
168
     *
169
     * @cfg {Boolean} triggerWfsRequest Whether or not to trigger a Wfs GetFeatures request
170
     */
171
    triggerWfsRequest: true
172
});
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