@corpsmap/corpsmap 4.1.23 → 4.1.24

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.23",
3
+ "version": "4.1.24",
4
4
  "main": "dist/corpsmap.umd.js",
5
5
  "module": "dist/corpsmap.es.js",
6
6
  "type": "module",
@@ -0,0 +1,163 @@
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 buildOrmGeoserverUrl(lyr, extent) {
13
+ const version = lyr.identifyType === "MAP" ? "1.0.0" : "1.1.0";
14
+ return [
15
+ `${lyr.url}`,
16
+ `?service=WFS`,
17
+ `&version=${version}`,
18
+ `&request=GetFeature`,
19
+ `&bbox=${extent[0]},${extent[1]},${extent[2]},${extent[3]},EPSG:4326`,
20
+ `&typeName=${lyr.layerList}`,
21
+ `&outputFormat=application%2Fjson`,
22
+ ].join("");
23
+ }
24
+
25
+ export default {
26
+ name: "ormGeoserverIdent",
27
+
28
+ getReducer() {
29
+ const initialData = {
30
+ shouldRegister: true,
31
+ };
32
+
33
+ return (state = initialData, { type, payload }) => {
34
+ switch (type) {
35
+ case "ORM_GEOSERVER_IDENT_REGISTERED":
36
+ return Object.assign({}, state, payload);
37
+ default:
38
+ return state;
39
+ }
40
+ };
41
+ },
42
+
43
+ doOrmGeoserverIdentRegister:
44
+ () =>
45
+ ({ dispatch, store }) => {
46
+ dispatch({
47
+ type: "ORM_GEOSERVER_IDENT_REGISTERED",
48
+ payload: { shouldRegister: false },
49
+ });
50
+ store.doIdentifyAddCollection({
51
+ onIdentify: store.doOrmGeoserverIdentFire,
52
+ });
53
+ },
54
+
55
+ doOrmGeoserverIdentFire:
56
+ (callback) =>
57
+ ({ store, anonGet }) => {
58
+ const visibleLayers = store.selectVisibleLayers();
59
+ const identifyFeature = store.doSetIdentifyFeature();
60
+ const extent = bbox(identifyFeature);
61
+ const excludedColumns = store.selectIdentifyColumnsExclude();
62
+ const queries = [];
63
+
64
+ visibleLayers.forEach((lyr) => {
65
+ if (
66
+ lyr.identifyType &&
67
+ (lyr.identifyType === "ORM-GEOSERVER" || lyr.identifyType === "MAP")
68
+ ) {
69
+ const url = buildOrmGeoserverUrl(lyr, extent);
70
+
71
+ queries.push((cb) => {
72
+ anonGet(url, (err, response, body) => {
73
+ if (err || response.statusCode !== 200) {
74
+ return cb(null, {
75
+ dataset: lyr.uid,
76
+ layerName: lyr.displayName,
77
+ err: `Error for ${lyr.displayName}`,
78
+ result: { [lyr.uid]: {} },
79
+ });
80
+ }
81
+ try {
82
+ const data = JSON.parse(body);
83
+ let outFeatures = data.features
84
+ .filter((feature) => !disjoint(feature, identifyFeature))
85
+ .map((feature) => {
86
+ if (feature.properties.LATITUDE) {
87
+ feature.properties.LATITUDE = Number(
88
+ feature.properties.LATITUDE
89
+ ).toFixed(6);
90
+ }
91
+ if (feature.properties.LONGITUDE) {
92
+ feature.properties.LONGITUDE = Number(
93
+ feature.properties.LONGITUDE
94
+ ).toFixed(6);
95
+ }
96
+ return feature;
97
+ });
98
+
99
+ outFeatures = identifyExcludeColumnsArcgisvector(
100
+ outFeatures,
101
+ excludedColumns
102
+ );
103
+
104
+ if (lyr.identifyFields) {
105
+ outFeatures = identifyIncludeColumnsArcgisvector(
106
+ outFeatures,
107
+ lyr.identifyFields
108
+ );
109
+ }
110
+
111
+ const identifyRenameColumns =
112
+ lyr.identifyRenameColumns ?? lyr.identifyRenameColums;
113
+ if (identifyRenameColumns) {
114
+ outFeatures = identifyRenameColumnsArcgisvector(
115
+ outFeatures,
116
+ identifyRenameColumns
117
+ );
118
+ }
119
+
120
+ if (lyr.identifyFormatColumns) {
121
+ outFeatures = identifyFormatColumnsArcgisvector(
122
+ outFeatures,
123
+ lyr.identifyFormatColumns
124
+ );
125
+ }
126
+
127
+ outFeatures = formatArcgisVector(outFeatures);
128
+
129
+ return cb(null, {
130
+ dataset: lyr.uid,
131
+ layerName: lyr.displayName,
132
+ err: null,
133
+ result: {
134
+ [lyr.uid]: {
135
+ type: "FeatureCollection",
136
+ features: outFeatures,
137
+ },
138
+ },
139
+ });
140
+ } catch (parseErr) {
141
+ console.log(parseErr);
142
+ return cb(null, {
143
+ dataset: lyr.uid,
144
+ layerName: lyr.displayName,
145
+ err: `Error for ${lyr.displayName}`,
146
+ result: { [lyr.uid]: {} },
147
+ });
148
+ }
149
+ });
150
+ });
151
+ }
152
+ });
153
+
154
+ async.parallel(queries, (err, results) => {
155
+ callback(err, results);
156
+ });
157
+ },
158
+
159
+ reactOrmGeoserverIdentShouldRegister: (state) => {
160
+ if (state.ormGeoserverIdent.shouldRegister)
161
+ return { actionCreator: "doOrmGeoserverIdentRegister" };
162
+ },
163
+ };
@@ -0,0 +1,10 @@
1
+ import bundle from "./bundle";
2
+
3
+ const plugin = {
4
+ pluginName: "Identify ORM GeoServer",
5
+ enabled: true,
6
+ bundle: bundle,
7
+ components: [],
8
+ };
9
+
10
+ export default plugin;
package/src/index.jsx CHANGED
@@ -38,6 +38,7 @@ 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 ormGeoserverIdent from "./core-plugins/identify-orm-geoserver";
41
42
  import legend from "./core-plugins/legend";
42
43
  // import login from './core-plugins/login';
43
44
  import measureTools from "./core-plugins/measure-tools";
@@ -93,6 +94,7 @@ export {
93
94
  geojsonIdent,
94
95
  esriIdent,
95
96
  identify,
97
+ ormGeoserverIdent,
96
98
  legend,
97
99
  // // login,
98
100
  mapLoadingIndicator,