@corpsmap/corpsmap 4.1.29 → 4.1.30
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/dist/corpsmap.es.js +848 -820
- package/dist/corpsmap.umd.js +17 -17
- package/package.json +1 -1
- package/src/application-bundles/map-layers-bundle.js +9 -2
- package/src/core-plugins/identify/listeners/vector.jsx +1 -1
- package/src/core-plugins/identify-arcgis-rest/bundle.js +2 -2
- package/src/core-plugins/identify-geoserver/bundle.js +1 -1
- package/src/core-plugins/identify-map-server/bundle.js +215 -159
- package/src/core-plugins/identify-vector/bundle.jsx +2 -2
- package/src/core-plugins/zoom-home/bundle.js +0 -1
- package/src/core-plugins/zoom-home/index.js +0 -1
- package/src/core-plugins/zoom-in-out/index.js +0 -1
- package/src/core-plugins/zoom-level/bundle.js +0 -1
- package/src/core-plugins/zoom-to-box/bundle.js +0 -1
package/package.json
CHANGED
|
@@ -16,6 +16,10 @@ const createNode = (options, map) => {
|
|
|
16
16
|
if (!options.minzoom) options.minzoom = scaleToMapZoom(options.maxscale, 0);
|
|
17
17
|
if (!options.maxzoom) options.maxzoom = scaleToMapZoom(options.minscale, 20);
|
|
18
18
|
|
|
19
|
+
// Accept the correct spelling and the legacy misspelled one (identifyRenameColums).
|
|
20
|
+
const renameColumns =
|
|
21
|
+
options.identifyRenameColumns ?? options.identifyRenameColums;
|
|
22
|
+
|
|
19
23
|
const node = {
|
|
20
24
|
id: options.id,
|
|
21
25
|
teamDatasetId: options.teamDatasetId,
|
|
@@ -41,8 +45,11 @@ const createNode = (options, map) => {
|
|
|
41
45
|
url: options.url,
|
|
42
46
|
info: options.info,
|
|
43
47
|
identifyType: options.identifyType,
|
|
48
|
+
identifyLayers: options.identifyLayers,
|
|
44
49
|
identifyFields: options.identifyFields,
|
|
45
|
-
|
|
50
|
+
identifyRenameColumns: renameColumns,
|
|
51
|
+
// Deprecated alias for the original misspelling; remove in the next major version.
|
|
52
|
+
identifyRenameColums: renameColumns,
|
|
46
53
|
identifyFormatColumns: options.identifyFormatColumns,
|
|
47
54
|
legend: options.legend,
|
|
48
55
|
legendOverride: !!options.legendOverride,
|
|
@@ -415,7 +422,7 @@ export default {
|
|
|
415
422
|
displayName: "New Folder",
|
|
416
423
|
type: "Folder",
|
|
417
424
|
},
|
|
418
|
-
map
|
|
425
|
+
map,
|
|
419
426
|
);
|
|
420
427
|
|
|
421
428
|
node.parent = newFolder;
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
56
56
|
const src = mapLayer.getSource();
|
|
57
57
|
let excludedColumns = store.selectIdentifyColumnsExclude();
|
|
58
58
|
const identifyFields = lyr.identifyFields;
|
|
59
|
-
const identifyRenameColumns = lyr.identifyRenameColumns
|
|
59
|
+
const identifyRenameColumns = lyr.identifyRenameColumns;
|
|
60
60
|
const identifyFormatColumns = lyr.identifyFormatColumns;
|
|
61
61
|
src.forEachFeatureIntersectingExtent(identifyExtent, (f) => {
|
|
62
62
|
const geoJsonFeature = geoJSON.writeFeatureObject(f, {
|
|
@@ -118,11 +118,11 @@ export default {
|
|
|
118
118
|
})
|
|
119
119
|
}
|
|
120
120
|
// Column Renaming
|
|
121
|
-
if (visibleLayer.
|
|
121
|
+
if (visibleLayer.identifyRenameColumns) {
|
|
122
122
|
data.results.forEach((result) => {
|
|
123
123
|
if(result.attributes){
|
|
124
124
|
for (const [featureKey, featureValue] of Object.entries(result.attributes)) {
|
|
125
|
-
for (const [key, value] of Object.entries(visibleLayer.
|
|
125
|
+
for (const [key, value] of Object.entries(visibleLayer.identifyRenameColumns)){
|
|
126
126
|
if (featureKey === key) {
|
|
127
127
|
result.attributes[value] = result.attributes[featureKey];
|
|
128
128
|
delete result.attributes[featureKey];
|
|
@@ -105,7 +105,7 @@ export default {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const identifyRenameColumns =
|
|
108
|
-
lyr.identifyRenameColumns
|
|
108
|
+
lyr.identifyRenameColumns;
|
|
109
109
|
if (identifyRenameColumns) {
|
|
110
110
|
outFeatures = identifyRenameColumnsArcgisvector(
|
|
111
111
|
outFeatures,
|
|
@@ -1,159 +1,215 @@
|
|
|
1
|
-
import async from "async";
|
|
2
|
-
import disjoint from "@turf/boolean-disjoint";
|
|
3
|
-
import bbox from "@turf/bbox";
|
|
4
|
-
import {
|
|
5
|
-
formatArcgisVector,
|
|
6
|
-
identifyExcludeColumnsArcgisvector,
|
|
7
|
-
identifyIncludeColumnsArcgisvector,
|
|
8
|
-
identifyRenameColumnsArcgisvector,
|
|
9
|
-
identifyFormatColumnsArcgisvector,
|
|
10
|
-
} from "../../openlayers-utils/format-utilities";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`&
|
|
18
|
-
`&
|
|
19
|
-
`&
|
|
20
|
-
`&
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
1
|
+
import async from "async";
|
|
2
|
+
import disjoint from "@turf/boolean-disjoint";
|
|
3
|
+
import bbox from "@turf/bbox";
|
|
4
|
+
import {
|
|
5
|
+
formatArcgisVector,
|
|
6
|
+
identifyExcludeColumnsArcgisvector,
|
|
7
|
+
identifyIncludeColumnsArcgisvector,
|
|
8
|
+
identifyRenameColumnsArcgisvector,
|
|
9
|
+
identifyFormatColumnsArcgisvector,
|
|
10
|
+
} from "../../openlayers-utils/format-utilities";
|
|
11
|
+
|
|
12
|
+
// typeName is passed in so one layer can issue several requests (see identifyLayers below).
|
|
13
|
+
function buildMapServerUrl(lyr, typeName, extent) {
|
|
14
|
+
return [
|
|
15
|
+
`${lyr.url}`,
|
|
16
|
+
`?service=WFS`,
|
|
17
|
+
`&version=1.0.0`,
|
|
18
|
+
`&request=GetFeature`,
|
|
19
|
+
`&bbox=${extent[0]},${extent[1]},${extent[2]},${extent[3]},EPSG:4326`,
|
|
20
|
+
`&typeName=${typeName}`,
|
|
21
|
+
`&outputFormat=application%2Fjson`,
|
|
22
|
+
].join("");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Work out which WFS requests to send for a layer.
|
|
27
|
+
*
|
|
28
|
+
* A layer with a non-empty `identifyLayers` array (e.g. a MapServer group such as a
|
|
29
|
+
* FUDS Top 10 site) sends one request per entry:
|
|
30
|
+
* identifyLayers: [{ layerList: "internal_property", displayName: "Property" }, ...]
|
|
31
|
+
* Results for those requests are keyed `${lyr.uid}:${displayName}`, which the identify
|
|
32
|
+
* UI splits on ":" to show "<layer name>:<displayName>".
|
|
33
|
+
*
|
|
34
|
+
* A layer without `identifyLayers` sends a single request using `layerList` and keeps
|
|
35
|
+
* the original result key (`lyr.uid`), so its behaviour is unchanged.
|
|
36
|
+
*/
|
|
37
|
+
function getIdentifyTargets(lyr) {
|
|
38
|
+
const hasIdentifyLayers =
|
|
39
|
+
Array.isArray(lyr.identifyLayers) && lyr.identifyLayers.length > 0;
|
|
40
|
+
|
|
41
|
+
if (!hasIdentifyLayers) {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
typeName: lyr.layerList,
|
|
45
|
+
resultKey: lyr.uid,
|
|
46
|
+
layerName: lyr.displayName,
|
|
47
|
+
label: lyr.id,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return lyr.identifyLayers
|
|
53
|
+
.filter((entry) => {
|
|
54
|
+
if (entry && entry.layerList) return true;
|
|
55
|
+
console.warn(
|
|
56
|
+
`[mapServerIdent] ${lyr.id}: identifyLayers entry has no layerList, skipping`,
|
|
57
|
+
entry
|
|
58
|
+
);
|
|
59
|
+
return false;
|
|
60
|
+
})
|
|
61
|
+
.map((entry) => {
|
|
62
|
+
const name = entry.displayName || entry.layerList;
|
|
63
|
+
return {
|
|
64
|
+
typeName: entry.layerList,
|
|
65
|
+
resultKey: `${lyr.uid}:${name}`,
|
|
66
|
+
layerName: `${lyr.displayName}:${name}`,
|
|
67
|
+
label: `${lyr.id}/${entry.layerList}`,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default {
|
|
73
|
+
name: "mapServerIdent",
|
|
74
|
+
|
|
75
|
+
getReducer() {
|
|
76
|
+
const initialData = {
|
|
77
|
+
shouldRegister: true,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (state = initialData, { type, payload }) => {
|
|
81
|
+
switch (type) {
|
|
82
|
+
case "MAP_SERVER_IDENT_REGISTERED":
|
|
83
|
+
return Object.assign({}, state, payload);
|
|
84
|
+
default:
|
|
85
|
+
return state;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
doMapServerIdentRegister:
|
|
91
|
+
() =>
|
|
92
|
+
({ dispatch, store }) => {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: "MAP_SERVER_IDENT_REGISTERED",
|
|
95
|
+
payload: { shouldRegister: false },
|
|
96
|
+
});
|
|
97
|
+
store.doIdentifyAddCollection({
|
|
98
|
+
onIdentify: store.doMapServerIdentFire,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
doMapServerIdentFire:
|
|
103
|
+
(callback) =>
|
|
104
|
+
({ store, anonGet }) => {
|
|
105
|
+
const visibleLayers = store.selectVisibleLayers();
|
|
106
|
+
const identifyFeature = store.doSetIdentifyFeature();
|
|
107
|
+
const extent = bbox(identifyFeature);
|
|
108
|
+
const excludedColumns = store.selectIdentifyColumnsExclude();
|
|
109
|
+
const queries = [];
|
|
110
|
+
|
|
111
|
+
visibleLayers.forEach((lyr) => {
|
|
112
|
+
if (lyr.identifyType && lyr.identifyType === "MAP") {
|
|
113
|
+
const targets = getIdentifyTargets(lyr);
|
|
114
|
+
|
|
115
|
+
targets.forEach((target) => {
|
|
116
|
+
const url = buildMapServerUrl(lyr, target.typeName, extent);
|
|
117
|
+
|
|
118
|
+
queries.push((cb) => {
|
|
119
|
+
anonGet(url, (err, response, body) => {
|
|
120
|
+
if (err || response.statusCode !== 200) {
|
|
121
|
+
return cb(null, {
|
|
122
|
+
dataset: lyr.uid,
|
|
123
|
+
layerName: target.layerName,
|
|
124
|
+
err: `Error for ${target.layerName}`,
|
|
125
|
+
result: { [target.resultKey]: {} },
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const data = JSON.parse(body);
|
|
130
|
+
let outFeatures = data.features
|
|
131
|
+
.filter((feature) => !disjoint(feature, identifyFeature))
|
|
132
|
+
.map((feature) => {
|
|
133
|
+
if (feature.properties.LATITUDE) {
|
|
134
|
+
feature.properties.LATITUDE = Number(
|
|
135
|
+
feature.properties.LATITUDE
|
|
136
|
+
).toFixed(6);
|
|
137
|
+
}
|
|
138
|
+
if (feature.properties.LONGITUDE) {
|
|
139
|
+
feature.properties.LONGITUDE = Number(
|
|
140
|
+
feature.properties.LONGITUDE
|
|
141
|
+
).toFixed(6);
|
|
142
|
+
}
|
|
143
|
+
return feature;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
outFeatures = identifyExcludeColumnsArcgisvector(
|
|
147
|
+
outFeatures,
|
|
148
|
+
excludedColumns
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
// Column options come from the parent layer; for FUDS Top 10 these are
|
|
152
|
+
// all null, so every sub-layer returns all of its columns.
|
|
153
|
+
if (lyr.identifyFields) {
|
|
154
|
+
outFeatures = identifyIncludeColumnsArcgisvector(
|
|
155
|
+
outFeatures,
|
|
156
|
+
lyr.identifyFields
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const identifyRenameColumns =
|
|
161
|
+
lyr.identifyRenameColumns;
|
|
162
|
+
if (identifyRenameColumns) {
|
|
163
|
+
outFeatures = identifyRenameColumnsArcgisvector(
|
|
164
|
+
outFeatures,
|
|
165
|
+
identifyRenameColumns
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (lyr.identifyFormatColumns) {
|
|
170
|
+
outFeatures = identifyFormatColumnsArcgisvector(
|
|
171
|
+
outFeatures,
|
|
172
|
+
lyr.identifyFormatColumns
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
outFeatures = formatArcgisVector(outFeatures);
|
|
177
|
+
|
|
178
|
+
// dataset stays lyr.uid (the UI looks the layer name up with it); the
|
|
179
|
+
// result key carries the sub-layer name for identifyLayers entries.
|
|
180
|
+
|
|
181
|
+
return cb(null, {
|
|
182
|
+
dataset: lyr.uid,
|
|
183
|
+
layerName: target.layerName,
|
|
184
|
+
err: null,
|
|
185
|
+
result: {
|
|
186
|
+
[target.resultKey]: {
|
|
187
|
+
type: "FeatureCollection",
|
|
188
|
+
features: outFeatures,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
} catch (parseErr) {
|
|
193
|
+
return cb(null, {
|
|
194
|
+
dataset: lyr.uid,
|
|
195
|
+
layerName: target.layerName,
|
|
196
|
+
err: `Error for ${target.layerName}`,
|
|
197
|
+
result: { [target.resultKey]: {} },
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
async.parallel(queries, (err, results) => {
|
|
207
|
+
callback(err, results);
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
reactMapServerIdentShouldRegister: (state) => {
|
|
212
|
+
if (state.mapServerIdent.shouldRegister)
|
|
213
|
+
return { actionCreator: "doMapServerIdentRegister" };
|
|
214
|
+
},
|
|
215
|
+
};
|
|
@@ -98,11 +98,11 @@ export default {
|
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
//Column Renaming
|
|
101
|
-
if (layers[0].
|
|
101
|
+
if (layers[0].identifyRenameColumns) {
|
|
102
102
|
outFeatures.forEach((feature) => {
|
|
103
103
|
if(feature.properties){
|
|
104
104
|
for (const [featureKey, featureValue] of Object.entries(feature.properties)) {
|
|
105
|
-
for (const [key, value] of Object.entries(layers[0].
|
|
105
|
+
for (const [key, value] of Object.entries(layers[0].identifyRenameColumns)){
|
|
106
106
|
if (featureKey === key) {
|
|
107
107
|
feature.properties[value] = feature.properties[featureKey];
|
|
108
108
|
delete feature.properties[featureKey];
|