@corpsmap/corpsmap 3.2.68 → 3.2.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/corpsmap.css +9753 -9753
- package/lib/dev.js +59493 -63306
- package/lib/prod.js +47146 -49749
- package/package.json +19 -20
- package/rollup.config.js +22 -118
- package/src/core-plugins/change-log/bundle.js +3 -4
- package/src/core-plugins/identify/listeners/geojson.js +99 -106
- package/src/core-plugins/identify-geojson/bundle.js +109 -131
- package/lib/corpsmap.css +0 -10185
|
@@ -1,149 +1,129 @@
|
|
|
1
|
-
import buffer from
|
|
2
|
-
import { point } from
|
|
3
|
-
import { polygon } from
|
|
4
|
-
import disjoint from
|
|
5
|
-
|
|
6
|
-
// import { join } from 'path';
|
|
1
|
+
import buffer from '@turf/buffer';
|
|
2
|
+
import { point } from '@turf/helpers';
|
|
3
|
+
import { polygon } from '@turf/helpers';
|
|
4
|
+
import disjoint from '@turf/boolean-disjoint';
|
|
5
|
+
import { join } from 'path';
|
|
7
6
|
|
|
8
7
|
export default {
|
|
9
|
-
name:
|
|
8
|
+
name: 'geojsonIdent',
|
|
10
9
|
|
|
11
|
-
getReducer()
|
|
10
|
+
getReducer(){
|
|
12
11
|
const initialData = {
|
|
13
12
|
shouldRegister: false,
|
|
14
13
|
shouldHandleRemove: false,
|
|
15
14
|
removedUid: null,
|
|
16
|
-
data: {}
|
|
17
|
-
}
|
|
15
|
+
data: {}
|
|
16
|
+
}
|
|
18
17
|
|
|
19
18
|
return (state = initialData, { type, payload }) => {
|
|
20
|
-
switch
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
case
|
|
24
|
-
case
|
|
19
|
+
switch(type){
|
|
20
|
+
case 'GEOJSON_IDENT_REGISTERED':
|
|
21
|
+
case 'GEOJSON_IDENT_ADDED_FEATURES':
|
|
22
|
+
case 'GEOJSON_IDENT_REMOVED_FEATURES':
|
|
23
|
+
case 'GEOJSON_IDENT_HANDLED_REMOVE':
|
|
25
24
|
return Object.assign({}, state, payload);
|
|
26
|
-
case
|
|
25
|
+
case 'LAYER_REMOVED':
|
|
27
26
|
return Object.assign({}, state, {
|
|
28
27
|
removedUid: payload.uid,
|
|
29
|
-
shouldHandleRemove: true
|
|
30
|
-
})
|
|
31
|
-
default:
|
|
28
|
+
shouldHandleRemove: true
|
|
29
|
+
})
|
|
30
|
+
default:
|
|
32
31
|
return state;
|
|
33
32
|
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
doGeojsonIdentRegister: () => ({dispatch, store}) => {
|
|
37
|
+
dispatch({type: 'GEOJSON_IDENT_REGISTERED', payload: { shouldRegister: false }});
|
|
38
|
+
store.doIdentifyAddCollection({
|
|
39
|
+
onIdentify: store.doGeojsonIdentFire
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
doGeojsonIdentRemoveFeatures: (uid) => ({ dispatch, store }) => {
|
|
44
|
+
dispatch({ type: 'GEOJSON_IDENT_HANDLED_REMOVE', payload: { shouldHandleRemove: false }});
|
|
45
|
+
const uid = store.selectGeojsonRemovedUid();
|
|
46
|
+
const data = store.selectGeojsonIdentFeatures();
|
|
47
|
+
delete data[uid];
|
|
48
|
+
dispatch({ type: 'GEOJSON_IDENT_REMOVED_FEATURES', payload: { data: Object.assign({}, data), removedUid: null}});
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
doGeojsonIdentAddFeatures: (uid, geojson, mapLayer) => ({dispatch, store}) => {
|
|
52
|
+
const data = store.selectGeojsonIdentFeatures();
|
|
53
|
+
|
|
54
|
+
if(!data[uid]) data[uid] = {
|
|
55
|
+
features: [],
|
|
56
|
+
maplayer: null
|
|
34
57
|
};
|
|
58
|
+
|
|
59
|
+
if(geojson){
|
|
60
|
+
let newFeatures = [];
|
|
61
|
+
if(geojson.length){
|
|
62
|
+
newFeatures = geojson;
|
|
63
|
+
}else if(geojson.features){
|
|
64
|
+
newFeatures = geojson.features;
|
|
65
|
+
}else{
|
|
66
|
+
newFeatures = [ geojson ]
|
|
67
|
+
}
|
|
68
|
+
data[uid].features = [...data[uid].features, ...newFeatures];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if(mapLayer){
|
|
72
|
+
data[uid].mapLayer = mapLayer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
dispatch({ type: 'GEOJSON_IDENT_ADDED_FEATURES', payload: { data: Object.assign({}, data) }});
|
|
35
76
|
},
|
|
36
77
|
|
|
37
|
-
|
|
38
|
-
()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (geojson) {
|
|
77
|
-
let newFeatures = [];
|
|
78
|
-
if (geojson.length) {
|
|
79
|
-
newFeatures = geojson;
|
|
80
|
-
} else if (geojson.features) {
|
|
81
|
-
newFeatures = geojson.features;
|
|
82
|
-
} else {
|
|
83
|
-
newFeatures = [geojson];
|
|
78
|
+
doGeojsonIdentFire: (callback) => ({dispatch, store}) => {
|
|
79
|
+
const coords = store.selectIdentifyCoordinates();
|
|
80
|
+
const resolution = store.selectResolution();
|
|
81
|
+
const data = store.selectGeojsonIdentFeatures();
|
|
82
|
+
let identifyFeature = null;
|
|
83
|
+
|
|
84
|
+
if(typeof coords[0] === 'number'){
|
|
85
|
+
const pt = point(coords);
|
|
86
|
+
const radius = resolution * 5 / 1000;
|
|
87
|
+
identifyFeature = buffer(pt, radius, {
|
|
88
|
+
units: 'kilometers'
|
|
89
|
+
})
|
|
90
|
+
}else{
|
|
91
|
+
identifyFeature = polygon(coords);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
try{
|
|
95
|
+
const out = [];
|
|
96
|
+
|
|
97
|
+
Object.keys(data).forEach((key) => {
|
|
98
|
+
|
|
99
|
+
const outFeatures = [];
|
|
100
|
+
const inFeatures = data[key].features;
|
|
101
|
+
const mapLayer = data[key].mapLayer;
|
|
102
|
+
if(mapLayer.getVisible()){
|
|
103
|
+
inFeatures.forEach((feature) => {
|
|
104
|
+
if(!disjoint(identifyFeature, feature)) outFeatures.push(feature);
|
|
105
|
+
})
|
|
106
|
+
out.push({
|
|
107
|
+
dataset: key,
|
|
108
|
+
err: null,
|
|
109
|
+
result: {
|
|
110
|
+
[key]: {
|
|
111
|
+
type: 'FeatureCollection',
|
|
112
|
+
features: outFeatures
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
84
116
|
}
|
|
85
|
-
data[uid].features = [...data[uid].features, ...newFeatures];
|
|
86
|
-
}
|
|
87
117
|
|
|
88
|
-
|
|
89
|
-
data[uid].mapLayer = mapLayer;
|
|
90
|
-
}
|
|
118
|
+
})
|
|
91
119
|
|
|
92
|
-
|
|
93
|
-
type: "GEOJSON_IDENT_ADDED_FEATURES",
|
|
94
|
-
payload: { data: Object.assign({}, data) },
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
doGeojsonIdentFire:
|
|
99
|
-
(callback) =>
|
|
100
|
-
({ dispatch, store }) => {
|
|
101
|
-
const coords = store.selectIdentifyCoordinates();
|
|
102
|
-
const resolution = store.selectResolution();
|
|
103
|
-
const data = store.selectGeojsonIdentFeatures();
|
|
104
|
-
let identifyFeature = null;
|
|
105
|
-
|
|
106
|
-
if (typeof coords[0] === "number") {
|
|
107
|
-
const pt = point(coords);
|
|
108
|
-
const radius = (resolution * 5) / 1000;
|
|
109
|
-
identifyFeature = buffer(pt, radius, {
|
|
110
|
-
units: "kilometers",
|
|
111
|
-
});
|
|
112
|
-
} else {
|
|
113
|
-
identifyFeature = polygon(coords);
|
|
114
|
-
}
|
|
120
|
+
callback(null, out);
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const inFeatures = data[key].features;
|
|
122
|
-
const mapLayer = data[key].mapLayer;
|
|
123
|
-
if (mapLayer.getVisible()) {
|
|
124
|
-
inFeatures.forEach((feature) => {
|
|
125
|
-
if (!disjoint(identifyFeature, feature))
|
|
126
|
-
outFeatures.push(feature);
|
|
127
|
-
});
|
|
128
|
-
out.push({
|
|
129
|
-
dataset: key,
|
|
130
|
-
err: null,
|
|
131
|
-
result: {
|
|
132
|
-
[key]: {
|
|
133
|
-
type: "FeatureCollection",
|
|
134
|
-
features: outFeatures,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
callback(null, out);
|
|
142
|
-
} catch (err) {
|
|
143
|
-
console.log(err);
|
|
144
|
-
callback(err);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
122
|
+
}catch(err){
|
|
123
|
+
console.log(err);
|
|
124
|
+
callback(err);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
147
127
|
|
|
148
128
|
selectGeojsonIdentFeatures: (state) => {
|
|
149
129
|
return state.geojsonIdent.data;
|
|
@@ -154,12 +134,10 @@ export default {
|
|
|
154
134
|
},
|
|
155
135
|
|
|
156
136
|
reactGeojsonIdentShouldRegister: (state) => {
|
|
157
|
-
if
|
|
158
|
-
return { actionCreator: "doGeojsonIdentRegister" };
|
|
137
|
+
if(state.geojsonIdent.shouldRegister) return { actionCreator: 'doGeojsonIdentRegister' };
|
|
159
138
|
},
|
|
160
139
|
|
|
161
140
|
reactGeojsonIdentShouldHandleRemove: (state) => {
|
|
162
|
-
if
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
};
|
|
141
|
+
if(state.geojsonIdent.shouldHandleRemove) return { actionCreator: 'doGeojsonIdentRemoveFeatures' };
|
|
142
|
+
}
|
|
143
|
+
}
|