@corpsmap/corpsmap 4.1.27 → 4.1.29

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.27",
3
+ "version": "4.1.29",
4
4
  "main": "dist/corpsmap.umd.js",
5
5
  "module": "dist/corpsmap.es.js",
6
6
  "type": "module",
@@ -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
  {
@@ -0,0 +1,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
+ function buildGeoserverUrl(lyr, extent) {
13
+ return [
14
+ `${lyr.url}`,
15
+ `?service=WFS`,
16
+ `&version=1.1.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: "geoserverIdent",
26
+
27
+ getReducer() {
28
+ const initialData = {
29
+ shouldRegister: true,
30
+ };
31
+
32
+ return (state = initialData, { type, payload }) => {
33
+ switch (type) {
34
+ case "GEOSERVER_IDENT_REGISTERED":
35
+ return Object.assign({}, state, payload);
36
+ default:
37
+ return state;
38
+ }
39
+ };
40
+ },
41
+
42
+ doGeoserverIdentRegister:
43
+ () =>
44
+ ({ dispatch, store }) => {
45
+ dispatch({
46
+ type: "GEOSERVER_IDENT_REGISTERED",
47
+ payload: { shouldRegister: false },
48
+ });
49
+ store.doIdentifyAddCollection({
50
+ onIdentify: store.doGeoserverIdentFire,
51
+ });
52
+ },
53
+
54
+ doGeoserverIdentFire:
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 === "ORM-GEOSERVER") {
65
+ const url = buildGeoserverUrl(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
+ reactGeoserverIdentShouldRegister: (state) => {
156
+ if (state.geoserverIdent.shouldRegister)
157
+ return { actionCreator: "doGeoserverIdentRegister" };
158
+ },
159
+ };
@@ -0,0 +1,10 @@
1
+ import bundle from "./bundle";
2
+
3
+ const plugin = {
4
+ pluginName: "Identify GeoServer",
5
+ enabled: true,
6
+ bundle: bundle,
7
+ components: [],
8
+ };
9
+
10
+ export default plugin;
@@ -0,0 +1,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
+ 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
+ };
@@ -0,0 +1,10 @@
1
+ import bundle from "./bundle";
2
+
3
+ const plugin = {
4
+ pluginName: "Identify Map Server",
5
+ enabled: true,
6
+ bundle: bundle,
7
+ components: [],
8
+ };
9
+
10
+ export default plugin;
package/src/index.jsx CHANGED
@@ -38,6 +38,8 @@ import geocoder from "./core-plugins/geocoder";
38
38
  import geojsonIdent from "./core-plugins/identify-geojson";
39
39
  import esriIdent from "./core-plugins/identify-arcgis-rest";
40
40
  import identify from "./core-plugins/identify";
41
+ import geoserverIdent from "./core-plugins/identify-geoserver";
42
+ import mapServerIdent from "./core-plugins/identify-map-server";
41
43
  import legend from "./core-plugins/legend";
42
44
  // import login from './core-plugins/login';
43
45
  import measureTools from "./core-plugins/measure-tools";
@@ -93,6 +95,8 @@ export {
93
95
  geojsonIdent,
94
96
  esriIdent,
95
97
  identify,
98
+ geoserverIdent,
99
+ mapServerIdent,
96
100
  legend,
97
101
  // // login,
98
102
  mapLoadingIndicator,