@corpsmap/corpsmap 3.1.0 → 3.1.3

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.
@@ -5,6 +5,7 @@ import disjoint from "@turf/boolean-disjoint";
5
5
  import bbox from "@turf/bbox";
6
6
  import GeoJSON from "ol/format/GeoJSON";
7
7
  import { transformExtent } from "ol/proj";
8
+ import formatUtilities from "../../openlayers-utils/format-utilities";
8
9
 
9
10
  const geoJSON = new GeoJSON();
10
11
 
@@ -26,67 +27,71 @@ export default {
26
27
  };
27
28
  },
28
29
 
29
- doVectorIdentRegister: () => ({ dispatch, store }) => {
30
- dispatch({
31
- type: "VECTOR_IDENT_REGISTERED",
32
- payload: { shouldRegister: false },
33
- });
34
- store.doIdentifyAddCollection({
35
- onIdentify: store.doVectorIdentFire,
36
- });
37
- },
30
+ doVectorIdentRegister:
31
+ () =>
32
+ ({ dispatch, store }) => {
33
+ dispatch({
34
+ type: "VECTOR_IDENT_REGISTERED",
35
+ payload: { shouldRegister: false },
36
+ });
37
+ store.doIdentifyAddCollection({
38
+ onIdentify: store.doVectorIdentFire,
39
+ });
40
+ },
38
41
 
39
- doVectorIdentFire: (callback) => ({ dispatch, store }) => {
40
- const layers = store.selectVisibleLayers();
41
- const coords = store.selectIdentifyCoordinates();
42
- const resolution = store.selectResolution();
43
- let identifyFeature = {};
44
- const out = [];
42
+ doVectorIdentFire:
43
+ (callback) =>
44
+ ({ dispatch, store }) => {
45
+ const layers = store.selectVisibleLayers();
46
+ const coords = store.selectIdentifyCoordinates();
47
+ const resolution = store.selectResolution();
48
+ let identifyFeature = {};
49
+ const out = [];
45
50
 
46
- if (typeof coords[0] === "number") {
47
- const pt = point(coords);
48
- const radius = (resolution * 5) / 1000;
49
- identifyFeature = buffer(pt, radius, {
50
- units: "kilometers",
51
- });
52
- } else {
53
- identifyFeature = polygon(coords);
54
- }
51
+ if (typeof coords[0] === "number") {
52
+ const pt = point(coords);
53
+ const radius = (resolution * 5) / 1000;
54
+ identifyFeature = buffer(pt, radius, {
55
+ units: "kilometers",
56
+ });
57
+ } else {
58
+ identifyFeature = polygon(coords);
59
+ }
55
60
 
56
- const identifyExtent = transformExtent(
57
- bbox(identifyFeature),
58
- "EPSG:4326",
59
- "EPSG:3857"
60
- );
61
+ const identifyExtent = transformExtent(
62
+ bbox(identifyFeature),
63
+ "EPSG:4326",
64
+ "EPSG:3857"
65
+ );
61
66
 
62
- layers.forEach((lyr) => {
63
- if (lyr.identifyType === "arcgisvector") {
64
- const { mapLayer } = lyr;
65
- const outFeatures = [];
66
- const src = mapLayer.getSource();
67
- src.forEachFeatureIntersectingExtent(identifyExtent, (f) => {
68
- const geoJsonFeature = geoJSON.writeFeatureObject(f, {
69
- featureProjection: "EPSG:3857",
70
- dataProjection: "EPSG:4326",
67
+ layers.forEach((lyr) => {
68
+ if (lyr.identifyType === "arcgisvector") {
69
+ const { mapLayer } = lyr;
70
+ const outFeatures = [];
71
+ const src = mapLayer.getSource();
72
+ src.forEachFeatureIntersectingExtent(identifyExtent, (f) => {
73
+ const geoJsonFeature = geoJSON.writeFeatureObject(f, {
74
+ featureProjection: "EPSG:3857",
75
+ dataProjection: "EPSG:4326",
76
+ });
77
+ if (!disjoint(identifyFeature, geoJsonFeature))
78
+ outFeatures.push(geoJsonFeature);
71
79
  });
72
- if (!disjoint(identifyFeature, geoJsonFeature))
73
- outFeatures.push(geoJsonFeature);
74
- });
75
- out.push({
76
- dataset: lyr.uid,
77
- layerName: lyr.displayName,
78
- err: null,
79
- result: {
80
- [lyr.uid]: {
81
- type: "FeatureCollection",
82
- features: outFeatures,
80
+ out.push({
81
+ dataset: lyr.uid,
82
+ layerName: lyr.displayName,
83
+ err: null,
84
+ result: {
85
+ [lyr.uid]: {
86
+ type: "FeatureCollection",
87
+ features: formatUtilities.formatArcgisVector(outFeatures),
88
+ },
83
89
  },
84
- },
85
- });
86
- }
87
- });
88
- return callback(null, out);
89
- },
90
+ });
91
+ }
92
+ });
93
+ return callback(null, out);
94
+ },
90
95
 
91
96
  reactVectorIdentShouldRegister: (state) => {
92
97
  if (state.vectorIdent.shouldRegister)
@@ -12,4 +12,23 @@ const formatArcgisrest = function (attributes) {
12
12
  return attributes;
13
13
  };
14
14
 
15
- export default formatArcgisrest;
15
+ const formatArcgisVector = function (results) {
16
+ results.map((feat) => {
17
+ for (const [key, value] of Object.entries(feat.properties)) {
18
+ const result =
19
+ String(value).includes("https:") || String(value).includes("http:")
20
+ ? value
21
+ : null;
22
+
23
+ if (result) {
24
+ feat.properties[
25
+ key
26
+ ] = `<a href="${value}" target="_new" > ${value} </a>`;
27
+ }
28
+ }
29
+ // results.properties = feat.properties;
30
+ });
31
+ return results;
32
+ };
33
+
34
+ export default { formatArcgisVector, formatArcgisrest };
@@ -71,7 +71,8 @@ function getXyzSource(options) {
71
71
  url: url,
72
72
  crossOrigin: isCrossOrigin(options.url),
73
73
  // CWBI-13636 Prevent horizontal wrapping.
74
- wrapX: false,
74
+ // Line may no longer be needed.
75
+ // wrapX: false,
75
76
  });
76
77
  }
77
78
 
@@ -168,8 +169,9 @@ function getEsriVectorSource(options) {
168
169
  }
169
170
 
170
171
  function getTileLayer(options, source) {
171
- // CWBI-13636 Prevent horizontal wrapping.
172
- source.wrapX = false;
172
+ // CWBI-13636 Prevent horizontal wrapping.
173
+ // Line may no longer be needed.
174
+ // source.wrapX = false;
173
175
  return new Tile({
174
176
  source: source,
175
177
  visible: options.visible,
@@ -182,7 +184,8 @@ function getTileLayer(options, source) {
182
184
 
183
185
  function getImageLayer(options, source) {
184
186
  // CWBI-13636 Prevent horizontal wrapping.
185
- source.wrapX = false;
187
+ // Line may no longer be needed.
188
+ // source.wrapX = false;
186
189
  return new Image({
187
190
  source: source,
188
191
  visible: options.visible,