@corpsmap/corpsmap 4.1.28 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corpsmap/corpsmap",
3
- "version": "4.1.28",
3
+ "version": "4.1.30",
4
4
  "main": "dist/corpsmap.umd.js",
5
5
  "module": "dist/corpsmap.es.js",
6
6
  "type": "module",
@@ -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
- identifyRenameColums: options.identifyRenameColums,
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;
@@ -182,26 +182,26 @@ const config = {
182
182
  "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community",
183
183
  visible: false,
184
184
  },
185
- {
186
- id: "CartoDBDarkMatter",
187
- name: "CartoDB Dark Matter",
188
- url: "https://cartodb-basemaps-{a-d}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png",
189
- attributions:
190
- '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; <a href="https://cartodb.com/attributionss">CartoDB</a>',
191
- subdomains: "abcd",
192
- maxZoom: 19,
193
- visible: false,
194
- },
195
- {
196
- id: "CartoDBPositron",
197
- name: "CartoDB Positron",
198
- url: "https://cartodb-basemaps-{a-d}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png",
199
- attributions:
200
- '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; <a href="https://cartodb.com/attributionss">CartoDB</a>',
201
- subdomains: "abcd",
202
- maxZoom: 19,
203
- visible: false,
204
- },
185
+ // {
186
+ // id: "CartoDBDarkMatter",
187
+ // name: "CartoDB Dark Matter",
188
+ // url: "https://cartodb-basemaps-{a-d}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png",
189
+ // attributions:
190
+ // '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; <a href="https://cartodb.com/attributionss">CartoDB</a>',
191
+ // subdomains: "abcd",
192
+ // maxZoom: 19,
193
+ // visible: false,
194
+ // },
195
+ // {
196
+ // id: "CartoDBPositron",
197
+ // name: "CartoDB Positron",
198
+ // url: "https://cartodb-basemaps-{a-d}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png",
199
+ // attributions:
200
+ // '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; <a href="https://cartodb.com/attributionss">CartoDB</a>',
201
+ // subdomains: "abcd",
202
+ // maxZoom: 19,
203
+ // visible: false,
204
+ // },
205
205
  ],
206
206
  datasetsDontUse: [
207
207
  {
@@ -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 ?? lyr.identifyRenameColums;
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.identifyRenameColums) {
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.identifyRenameColums)){
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 ?? lyr.identifyRenameColums;
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
- function buildMapServerUrl(lyr, extent) {
13
- return [
14
- `${lyr.url}`,
15
- `?service=WFS`,
16
- `&version=1.0.0`,
17
- `&request=GetFeature`,
18
- `&bbox=${extent[0]},${extent[1]},${extent[2]},${extent[3]},EPSG:4326`,
19
- `&typeName=${lyr.layerList}`,
20
- `&outputFormat=application%2Fjson`,
21
- ].join("");
22
- }
23
-
24
- export default {
25
- name: "mapServerIdent",
26
-
27
- getReducer() {
28
- const initialData = {
29
- shouldRegister: true,
30
- };
31
-
32
- return (state = initialData, { type, payload }) => {
33
- switch (type) {
34
- case "MAP_SERVER_IDENT_REGISTERED":
35
- return Object.assign({}, state, payload);
36
- default:
37
- return state;
38
- }
39
- };
40
- },
41
-
42
- doMapServerIdentRegister:
43
- () =>
44
- ({ dispatch, store }) => {
45
- dispatch({
46
- type: "MAP_SERVER_IDENT_REGISTERED",
47
- payload: { shouldRegister: false },
48
- });
49
- store.doIdentifyAddCollection({
50
- onIdentify: store.doMapServerIdentFire,
51
- });
52
- },
53
-
54
- doMapServerIdentFire:
55
- (callback) =>
56
- ({ store, anonGet }) => {
57
- const visibleLayers = store.selectVisibleLayers();
58
- const identifyFeature = store.doSetIdentifyFeature();
59
- const extent = bbox(identifyFeature);
60
- const excludedColumns = store.selectIdentifyColumnsExclude();
61
- const queries = [];
62
-
63
- visibleLayers.forEach((lyr) => {
64
- if (lyr.identifyType && lyr.identifyType === "MAP") {
65
- const url = buildMapServerUrl(lyr, extent);
66
-
67
- queries.push((cb) => {
68
- anonGet(url, (err, response, body) => {
69
- if (err || response.statusCode !== 200) {
70
- return cb(null, {
71
- dataset: lyr.uid,
72
- layerName: lyr.displayName,
73
- err: `Error for ${lyr.displayName}`,
74
- result: { [lyr.uid]: {} },
75
- });
76
- }
77
- try {
78
- const data = JSON.parse(body);
79
- let outFeatures = data.features
80
- .filter((feature) => !disjoint(feature, identifyFeature))
81
- .map((feature) => {
82
- if (feature.properties.LATITUDE) {
83
- feature.properties.LATITUDE = Number(
84
- feature.properties.LATITUDE
85
- ).toFixed(6);
86
- }
87
- if (feature.properties.LONGITUDE) {
88
- feature.properties.LONGITUDE = Number(
89
- feature.properties.LONGITUDE
90
- ).toFixed(6);
91
- }
92
- return feature;
93
- });
94
-
95
- outFeatures = identifyExcludeColumnsArcgisvector(
96
- outFeatures,
97
- excludedColumns
98
- );
99
-
100
- if (lyr.identifyFields) {
101
- outFeatures = identifyIncludeColumnsArcgisvector(
102
- outFeatures,
103
- lyr.identifyFields
104
- );
105
- }
106
-
107
- const identifyRenameColumns =
108
- lyr.identifyRenameColumns ?? lyr.identifyRenameColums;
109
- if (identifyRenameColumns) {
110
- outFeatures = identifyRenameColumnsArcgisvector(
111
- outFeatures,
112
- identifyRenameColumns
113
- );
114
- }
115
-
116
- if (lyr.identifyFormatColumns) {
117
- outFeatures = identifyFormatColumnsArcgisvector(
118
- outFeatures,
119
- lyr.identifyFormatColumns
120
- );
121
- }
122
-
123
- outFeatures = formatArcgisVector(outFeatures);
124
-
125
- return cb(null, {
126
- dataset: lyr.uid,
127
- layerName: lyr.displayName,
128
- err: null,
129
- result: {
130
- [lyr.uid]: {
131
- type: "FeatureCollection",
132
- features: outFeatures,
133
- },
134
- },
135
- });
136
- } catch (parseErr) {
137
- console.log(parseErr);
138
- return cb(null, {
139
- dataset: lyr.uid,
140
- layerName: lyr.displayName,
141
- err: `Error for ${lyr.displayName}`,
142
- result: { [lyr.uid]: {} },
143
- });
144
- }
145
- });
146
- });
147
- }
148
- });
149
-
150
- async.parallel(queries, (err, results) => {
151
- callback(err, results);
152
- });
153
- },
154
-
155
- reactMapServerIdentShouldRegister: (state) => {
156
- if (state.mapServerIdent.shouldRegister)
157
- return { actionCreator: "doMapServerIdentRegister" };
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].identifyRenameColums) {
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].identifyRenameColums)){
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];
@@ -74,4 +74,3 @@ export default {
74
74
  },
75
75
  };
76
76
 
77
- //debugger
@@ -16,4 +16,3 @@ const plugin = {
16
16
 
17
17
  export default plugin;
18
18
 
19
- //debugger
@@ -20,4 +20,3 @@ const plugin = {
20
20
 
21
21
  export default plugin;
22
22
 
23
- //debugger
@@ -32,4 +32,3 @@ export default {
32
32
  },
33
33
  };
34
34
 
35
- // debugger
@@ -77,4 +77,3 @@ export default {
77
77
  },
78
78
  };
79
79
 
80
- //debugger