@corpsmap/corpsmap 3.2.36 → 3.2.38
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/lib/dev.js +65 -5
- package/lib/prod.js +65 -5
- package/package.json +1 -1
- package/src/core-plugins/legend/bundle.js +65 -2
- package/src/openlayers-utils/format-utilities.js +141 -138
package/lib/dev.js
CHANGED
|
@@ -106568,7 +106568,7 @@ var config = {
|
|
|
106568
106568
|
};
|
|
106569
106569
|
|
|
106570
106570
|
var name = "@corpsmap/corpsmap";
|
|
106571
|
-
var version$1 = "3.2.
|
|
106571
|
+
var version$1 = "3.2.38";
|
|
106572
106572
|
var description = "CorpsMap as React Components";
|
|
106573
106573
|
var main = "index.js";
|
|
106574
106574
|
var scripts = {
|
|
@@ -132987,6 +132987,10 @@ var formatColumns = function formatColumns(value, formatType) {
|
|
|
132987
132987
|
}
|
|
132988
132988
|
|
|
132989
132989
|
if (formatType === "UNIXDATE") {
|
|
132990
|
+
if (value === null || value === "null") {
|
|
132991
|
+
return null;
|
|
132992
|
+
}
|
|
132993
|
+
|
|
132990
132994
|
var unixTimestamp = value;
|
|
132991
132995
|
var milliseconds = unixTimestamp; // * 1000 in some cases.
|
|
132992
132996
|
|
|
@@ -159417,6 +159421,7 @@ var bundle$8 = {
|
|
|
159417
159421
|
break;
|
|
159418
159422
|
|
|
159419
159423
|
case "EsriFeatureService":
|
|
159424
|
+
// debugger
|
|
159420
159425
|
if (legendOverride === true) {
|
|
159421
159426
|
src = "".concat(src, "/legend?f=pjson");
|
|
159422
159427
|
} else {
|
|
@@ -159449,6 +159454,7 @@ var bundle$8 = {
|
|
|
159449
159454
|
if (legendOverride === true) {
|
|
159450
159455
|
store.doGenerateArcImages(data, lyr);
|
|
159451
159456
|
} else {
|
|
159457
|
+
// debugger
|
|
159452
159458
|
store.doGenerateEsriImages(data, lyr);
|
|
159453
159459
|
}
|
|
159454
159460
|
} else {
|
|
@@ -159571,6 +159577,7 @@ var bundle$8 = {
|
|
|
159571
159577
|
switch (data.geometryType) {
|
|
159572
159578
|
case "esriGeometryPolygon":
|
|
159573
159579
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSSolid") {
|
|
159580
|
+
// debugger
|
|
159574
159581
|
var img = new Image();
|
|
159575
159582
|
var outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
159576
159583
|
var fillColor = drawingInfo.renderer.symbol.color;
|
|
@@ -159669,10 +159676,15 @@ var bundle$8 = {
|
|
|
159669
159676
|
});
|
|
159670
159677
|
} //____________________________________________________________________________________________________________________________________
|
|
159671
159678
|
else if (drawingInfo.renderer.type === "uniqueValue" && drawingInfo.renderer.uniqueValueInfos) {
|
|
159679
|
+
// Compare
|
|
159672
159680
|
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159673
159681
|
var img = new Image();
|
|
159674
|
-
|
|
159682
|
+
console.log(val.value);
|
|
159683
|
+
|
|
159684
|
+
if (val.value === 'BOEM') ;
|
|
159685
|
+
|
|
159675
159686
|
var fillColor = val.symbol.color;
|
|
159687
|
+
var outlineColor = val.symbol.outline && val.symbol.outline.color ? val.symbol.outline.color : fillColor;
|
|
159676
159688
|
var canvas = document.createElement("canvas");
|
|
159677
159689
|
var ctx = canvas.getContext("2d");
|
|
159678
159690
|
var labelWidth = Number(ctx.measureText(val.label).width); //set canvas width & height
|
|
@@ -159815,6 +159827,7 @@ var bundle$8 = {
|
|
|
159815
159827
|
|
|
159816
159828
|
case "esriGeometryPoint":
|
|
159817
159829
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159830
|
+
// debugger
|
|
159818
159831
|
var _img3 = new Image();
|
|
159819
159832
|
|
|
159820
159833
|
_img3.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
@@ -159849,7 +159862,8 @@ var bundle$8 = {
|
|
|
159849
159862
|
dispatch({
|
|
159850
159863
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159851
159864
|
payload: {
|
|
159852
|
-
legendLayers: legendLayers
|
|
159865
|
+
legendLayers: legendLayers,
|
|
159866
|
+
loading: false
|
|
159853
159867
|
}
|
|
159854
159868
|
});
|
|
159855
159869
|
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
@@ -160004,8 +160018,8 @@ var bundle$8 = {
|
|
|
160004
160018
|
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
160005
160019
|
|
|
160006
160020
|
img.alt = "Style for ".concat(displayName);
|
|
160007
|
-
img.crossOrigin = "anonymous";
|
|
160008
|
-
|
|
160021
|
+
img.crossOrigin = "anonymous"; // debugger
|
|
160022
|
+
|
|
160009
160023
|
legendCanvases[uid].canvas.push(canvas);
|
|
160010
160024
|
dispatch({
|
|
160011
160025
|
type: "LEGEND_CANVAS_ADDED",
|
|
@@ -160035,6 +160049,52 @@ var bundle$8 = {
|
|
|
160035
160049
|
});
|
|
160036
160050
|
}
|
|
160037
160051
|
|
|
160052
|
+
break;
|
|
160053
|
+
|
|
160054
|
+
case "esriGeometryMultipoint":
|
|
160055
|
+
// debugger
|
|
160056
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
160057
|
+
// debugger
|
|
160058
|
+
var _img5 = new Image();
|
|
160059
|
+
|
|
160060
|
+
_img5.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
160061
|
+
|
|
160062
|
+
_img5.addEventListener("load", function () {
|
|
160063
|
+
var canvas = document.createElement("canvas");
|
|
160064
|
+
var ctx = canvas.getContext("2d");
|
|
160065
|
+
canvas.width = drawingInfo.renderer.symbol.width;
|
|
160066
|
+
canvas.height = drawingInfo.renderer.symbol.height; //store width & height for larger canvas calculation
|
|
160067
|
+
|
|
160068
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
160069
|
+
legendCanvases[uid].heights.push(canvas.height); //set background
|
|
160070
|
+
|
|
160071
|
+
ctx.fillStyle = "white";
|
|
160072
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
160073
|
+
ctx.drawImage(_img5, 0, 0); //add image to canvas
|
|
160074
|
+
|
|
160075
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
160076
|
+
dispatch({
|
|
160077
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
160078
|
+
payload: {
|
|
160079
|
+
legendCanvases: legendCanvases,
|
|
160080
|
+
loading: false
|
|
160081
|
+
}
|
|
160082
|
+
});
|
|
160083
|
+
}, false);
|
|
160084
|
+
|
|
160085
|
+
_img5.alt = "Style for ".concat(displayName);
|
|
160086
|
+
_img5.crossOrigin = "anonymous";
|
|
160087
|
+
legendLayers[uid] = [_img5]; //TODO: Update to possibly push multiple images into array
|
|
160088
|
+
|
|
160089
|
+
dispatch({
|
|
160090
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
160091
|
+
payload: {
|
|
160092
|
+
legendLayers: legendLayers,
|
|
160093
|
+
loading: false
|
|
160094
|
+
}
|
|
160095
|
+
});
|
|
160096
|
+
}
|
|
160097
|
+
|
|
160038
160098
|
break;
|
|
160039
160099
|
}
|
|
160040
160100
|
};
|
package/lib/prod.js
CHANGED
|
@@ -106482,7 +106482,7 @@ var config = {
|
|
|
106482
106482
|
};
|
|
106483
106483
|
|
|
106484
106484
|
var name = "@corpsmap/corpsmap";
|
|
106485
|
-
var version$1 = "3.2.
|
|
106485
|
+
var version$1 = "3.2.38";
|
|
106486
106486
|
var description = "CorpsMap as React Components";
|
|
106487
106487
|
var main = "index.js";
|
|
106488
106488
|
var scripts = {
|
|
@@ -132901,6 +132901,10 @@ var formatColumns = function formatColumns(value, formatType) {
|
|
|
132901
132901
|
}
|
|
132902
132902
|
|
|
132903
132903
|
if (formatType === "UNIXDATE") {
|
|
132904
|
+
if (value === null || value === "null") {
|
|
132905
|
+
return null;
|
|
132906
|
+
}
|
|
132907
|
+
|
|
132904
132908
|
var unixTimestamp = value;
|
|
132905
132909
|
var milliseconds = unixTimestamp; // * 1000 in some cases.
|
|
132906
132910
|
|
|
@@ -159331,6 +159335,7 @@ var bundle$8 = {
|
|
|
159331
159335
|
break;
|
|
159332
159336
|
|
|
159333
159337
|
case "EsriFeatureService":
|
|
159338
|
+
// debugger
|
|
159334
159339
|
if (legendOverride === true) {
|
|
159335
159340
|
src = "".concat(src, "/legend?f=pjson");
|
|
159336
159341
|
} else {
|
|
@@ -159363,6 +159368,7 @@ var bundle$8 = {
|
|
|
159363
159368
|
if (legendOverride === true) {
|
|
159364
159369
|
store.doGenerateArcImages(data, lyr);
|
|
159365
159370
|
} else {
|
|
159371
|
+
// debugger
|
|
159366
159372
|
store.doGenerateEsriImages(data, lyr);
|
|
159367
159373
|
}
|
|
159368
159374
|
} else {
|
|
@@ -159485,6 +159491,7 @@ var bundle$8 = {
|
|
|
159485
159491
|
switch (data.geometryType) {
|
|
159486
159492
|
case "esriGeometryPolygon":
|
|
159487
159493
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSSolid") {
|
|
159494
|
+
// debugger
|
|
159488
159495
|
var img = new Image();
|
|
159489
159496
|
var outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
159490
159497
|
var fillColor = drawingInfo.renderer.symbol.color;
|
|
@@ -159583,10 +159590,15 @@ var bundle$8 = {
|
|
|
159583
159590
|
});
|
|
159584
159591
|
} //____________________________________________________________________________________________________________________________________
|
|
159585
159592
|
else if (drawingInfo.renderer.type === "uniqueValue" && drawingInfo.renderer.uniqueValueInfos) {
|
|
159593
|
+
// Compare
|
|
159586
159594
|
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159587
159595
|
var img = new Image();
|
|
159588
|
-
|
|
159596
|
+
console.log(val.value);
|
|
159597
|
+
|
|
159598
|
+
if (val.value === 'BOEM') ;
|
|
159599
|
+
|
|
159589
159600
|
var fillColor = val.symbol.color;
|
|
159601
|
+
var outlineColor = val.symbol.outline && val.symbol.outline.color ? val.symbol.outline.color : fillColor;
|
|
159590
159602
|
var canvas = document.createElement("canvas");
|
|
159591
159603
|
var ctx = canvas.getContext("2d");
|
|
159592
159604
|
var labelWidth = Number(ctx.measureText(val.label).width); //set canvas width & height
|
|
@@ -159729,6 +159741,7 @@ var bundle$8 = {
|
|
|
159729
159741
|
|
|
159730
159742
|
case "esriGeometryPoint":
|
|
159731
159743
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159744
|
+
// debugger
|
|
159732
159745
|
var _img3 = new Image();
|
|
159733
159746
|
|
|
159734
159747
|
_img3.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
@@ -159763,7 +159776,8 @@ var bundle$8 = {
|
|
|
159763
159776
|
dispatch({
|
|
159764
159777
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159765
159778
|
payload: {
|
|
159766
|
-
legendLayers: legendLayers
|
|
159779
|
+
legendLayers: legendLayers,
|
|
159780
|
+
loading: false
|
|
159767
159781
|
}
|
|
159768
159782
|
});
|
|
159769
159783
|
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
@@ -159918,8 +159932,8 @@ var bundle$8 = {
|
|
|
159918
159932
|
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
159919
159933
|
|
|
159920
159934
|
img.alt = "Style for ".concat(displayName);
|
|
159921
|
-
img.crossOrigin = "anonymous";
|
|
159922
|
-
|
|
159935
|
+
img.crossOrigin = "anonymous"; // debugger
|
|
159936
|
+
|
|
159923
159937
|
legendCanvases[uid].canvas.push(canvas);
|
|
159924
159938
|
dispatch({
|
|
159925
159939
|
type: "LEGEND_CANVAS_ADDED",
|
|
@@ -159949,6 +159963,52 @@ var bundle$8 = {
|
|
|
159949
159963
|
});
|
|
159950
159964
|
}
|
|
159951
159965
|
|
|
159966
|
+
break;
|
|
159967
|
+
|
|
159968
|
+
case "esriGeometryMultipoint":
|
|
159969
|
+
// debugger
|
|
159970
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159971
|
+
// debugger
|
|
159972
|
+
var _img5 = new Image();
|
|
159973
|
+
|
|
159974
|
+
_img5.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
159975
|
+
|
|
159976
|
+
_img5.addEventListener("load", function () {
|
|
159977
|
+
var canvas = document.createElement("canvas");
|
|
159978
|
+
var ctx = canvas.getContext("2d");
|
|
159979
|
+
canvas.width = drawingInfo.renderer.symbol.width;
|
|
159980
|
+
canvas.height = drawingInfo.renderer.symbol.height; //store width & height for larger canvas calculation
|
|
159981
|
+
|
|
159982
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
159983
|
+
legendCanvases[uid].heights.push(canvas.height); //set background
|
|
159984
|
+
|
|
159985
|
+
ctx.fillStyle = "white";
|
|
159986
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
159987
|
+
ctx.drawImage(_img5, 0, 0); //add image to canvas
|
|
159988
|
+
|
|
159989
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
159990
|
+
dispatch({
|
|
159991
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159992
|
+
payload: {
|
|
159993
|
+
legendCanvases: legendCanvases,
|
|
159994
|
+
loading: false
|
|
159995
|
+
}
|
|
159996
|
+
});
|
|
159997
|
+
}, false);
|
|
159998
|
+
|
|
159999
|
+
_img5.alt = "Style for ".concat(displayName);
|
|
160000
|
+
_img5.crossOrigin = "anonymous";
|
|
160001
|
+
legendLayers[uid] = [_img5]; //TODO: Update to possibly push multiple images into array
|
|
160002
|
+
|
|
160003
|
+
dispatch({
|
|
160004
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
160005
|
+
payload: {
|
|
160006
|
+
legendLayers: legendLayers,
|
|
160007
|
+
loading: false
|
|
160008
|
+
}
|
|
160009
|
+
});
|
|
160010
|
+
}
|
|
160011
|
+
|
|
159952
160012
|
break;
|
|
159953
160013
|
}
|
|
159954
160014
|
};
|
package/package.json
CHANGED
|
@@ -58,6 +58,7 @@ export default {
|
|
|
58
58
|
src = `${src}/legend?bandIds=&renderingRule=&f=pjson`;
|
|
59
59
|
break;
|
|
60
60
|
case "EsriFeatureService":
|
|
61
|
+
// debugger
|
|
61
62
|
if (legendOverride === true) {
|
|
62
63
|
src = `${src}/legend?f=pjson`;
|
|
63
64
|
}
|
|
@@ -91,6 +92,7 @@ export default {
|
|
|
91
92
|
if (legendOverride === true) {
|
|
92
93
|
store.doGenerateArcImages(data, lyr);
|
|
93
94
|
} else {
|
|
95
|
+
// debugger
|
|
94
96
|
store.doGenerateEsriImages(data, lyr);
|
|
95
97
|
}
|
|
96
98
|
} else {
|
|
@@ -218,6 +220,7 @@ export default {
|
|
|
218
220
|
drawingInfo.renderer.symbol.type === "esriSFS" &&
|
|
219
221
|
drawingInfo.renderer.symbol.style === "esriSFSSolid"
|
|
220
222
|
) {
|
|
223
|
+
// debugger
|
|
221
224
|
let img = new Image();
|
|
222
225
|
const outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
223
226
|
const fillColor = drawingInfo.renderer.symbol.color;
|
|
@@ -325,10 +328,17 @@ export default {
|
|
|
325
328
|
drawingInfo.renderer.type === "uniqueValue" &&
|
|
326
329
|
drawingInfo.renderer.uniqueValueInfos
|
|
327
330
|
) {
|
|
331
|
+
// Compare
|
|
328
332
|
drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
|
|
329
333
|
let img = new Image();
|
|
330
|
-
|
|
334
|
+
console.log(val.value)
|
|
335
|
+
if (val.value === 'BOEM') {
|
|
336
|
+
// debugger
|
|
337
|
+
}
|
|
338
|
+
|
|
331
339
|
const fillColor = val.symbol.color;
|
|
340
|
+
const outlineColor = val.symbol.outline && val.symbol.outline.color ? val.symbol.outline.color : fillColor;
|
|
341
|
+
|
|
332
342
|
|
|
333
343
|
let canvas = document.createElement("canvas");
|
|
334
344
|
let ctx = canvas.getContext("2d");
|
|
@@ -487,6 +497,7 @@ export default {
|
|
|
487
497
|
break;
|
|
488
498
|
case "esriGeometryPoint":
|
|
489
499
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
500
|
+
// debugger
|
|
490
501
|
let img = new Image();
|
|
491
502
|
img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
|
|
492
503
|
img.addEventListener(
|
|
@@ -528,6 +539,7 @@ export default {
|
|
|
528
539
|
type: "LEGEND_LAYERS_UPDATED",
|
|
529
540
|
payload: {
|
|
530
541
|
legendLayers: legendLayers,
|
|
542
|
+
loading: false,
|
|
531
543
|
},
|
|
532
544
|
});
|
|
533
545
|
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
@@ -702,7 +714,7 @@ export default {
|
|
|
702
714
|
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
703
715
|
img.alt = `Style for ${displayName}`;
|
|
704
716
|
img.crossOrigin = "anonymous";
|
|
705
|
-
debugger
|
|
717
|
+
// debugger
|
|
706
718
|
|
|
707
719
|
legendCanvases[uid].canvas.push(canvas);
|
|
708
720
|
dispatch({
|
|
@@ -735,6 +747,57 @@ export default {
|
|
|
735
747
|
});
|
|
736
748
|
}
|
|
737
749
|
break;
|
|
750
|
+
case "esriGeometryMultipoint" :
|
|
751
|
+
// debugger
|
|
752
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
753
|
+
// debugger
|
|
754
|
+
let img = new Image();
|
|
755
|
+
img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
|
|
756
|
+
img.addEventListener(
|
|
757
|
+
"load",
|
|
758
|
+
function () {
|
|
759
|
+
let canvas = document.createElement("canvas");
|
|
760
|
+
let ctx = canvas.getContext("2d");
|
|
761
|
+
|
|
762
|
+
canvas.width = drawingInfo.renderer.symbol.width;
|
|
763
|
+
canvas.height = drawingInfo.renderer.symbol.height;
|
|
764
|
+
|
|
765
|
+
//store width & height for larger canvas calculation
|
|
766
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
767
|
+
legendCanvases[uid].heights.push(canvas.height);
|
|
768
|
+
|
|
769
|
+
//set background
|
|
770
|
+
ctx.fillStyle = "white";
|
|
771
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
772
|
+
|
|
773
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
774
|
+
|
|
775
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
776
|
+
|
|
777
|
+
dispatch({
|
|
778
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
779
|
+
payload: {
|
|
780
|
+
legendCanvases: legendCanvases,
|
|
781
|
+
loading: false,
|
|
782
|
+
},
|
|
783
|
+
});
|
|
784
|
+
},
|
|
785
|
+
false
|
|
786
|
+
);
|
|
787
|
+
|
|
788
|
+
img.alt = `Style for ${displayName}`;
|
|
789
|
+
img.crossOrigin = "anonymous";
|
|
790
|
+
legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
791
|
+
dispatch({
|
|
792
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
793
|
+
payload: {
|
|
794
|
+
legendLayers: legendLayers,
|
|
795
|
+
loading: false,
|
|
796
|
+
},
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
break;
|
|
800
|
+
|
|
738
801
|
default:
|
|
739
802
|
break;
|
|
740
803
|
}
|
|
@@ -1,139 +1,142 @@
|
|
|
1
|
-
const formatArcgisrest = function (attributes) {
|
|
2
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
3
|
-
const result =
|
|
4
|
-
String(value).includes("https:") || String(value).includes("http:")
|
|
5
|
-
? value
|
|
6
|
-
: null;
|
|
7
|
-
|
|
8
|
-
if (result) {
|
|
9
|
-
attributes[key] = `<a href="${value}" target="_new" > ${value} </a>`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return attributes;
|
|
13
|
-
};
|
|
14
|
-
|
|
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
|
-
// Format UNIX Date
|
|
29
|
-
|
|
30
|
-
// if ((key === "fromdate" || key === "todate" || key === "referencedate") && Number.isInteger(feat.properties[key])) {
|
|
31
|
-
// const unixTimestamp = feat.properties[key];
|
|
32
|
-
// const milliseconds = unixTimestamp // * 1000 in some cases.
|
|
33
|
-
// const dateObject = new Date(milliseconds);
|
|
34
|
-
// feat.properties[key] = dateObject.toLocaleString();
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return results;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const identifyColumnsArcgisrest = function (data, excludedColumns) {
|
|
43
|
-
data.results.forEach((result) => {
|
|
44
|
-
if(result.attributes){
|
|
45
|
-
excludedColumns.forEach((column) => {
|
|
46
|
-
delete result.attributes[column];
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return result.attributes;
|
|
50
|
-
});
|
|
51
|
-
return data;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const identifyExcludeColumnsArcgisvector = function (data, excludedColumns) {
|
|
55
|
-
data.forEach((feature) => {
|
|
56
|
-
if(feature.properties){
|
|
57
|
-
excludedColumns.forEach((column) => {
|
|
58
|
-
delete feature.properties[column];
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return feature.properties
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const identifyIncludeColumnsArcgisvector = function (data, identifyFields) {
|
|
68
|
-
data.forEach((feature) => {
|
|
69
|
-
console.log(feature, feature.properties)
|
|
70
|
-
if(feature.properties){
|
|
71
|
-
for (const [key, value] of Object.entries(feature.properties)) {
|
|
72
|
-
let reducedProperties = {};
|
|
73
|
-
identifyFields.forEach((property) => {
|
|
74
|
-
if (feature.properties[property]) {
|
|
75
|
-
reducedProperties[property] =
|
|
76
|
-
feature.properties[property];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
feature.properties = reducedProperties;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
return data;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const identifyRenameColumnsArcgisvector = function (data, identifyRenameColums) {
|
|
88
|
-
|
|
89
|
-
data.forEach((feature) => {
|
|
90
|
-
if(feature.properties){
|
|
91
|
-
let wkData = {};
|
|
92
|
-
for (const [featureKey, featureValue] of Object.entries(feature.properties)) {
|
|
93
|
-
for (const [key, value] of Object.entries(identifyRenameColums)){
|
|
94
|
-
if (featureKey === key) {
|
|
95
|
-
// feature.properties[value] = feature.properties[featureKey];
|
|
96
|
-
wkData[value] = feature.properties[featureKey];
|
|
97
|
-
delete feature.properties[featureKey];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
feature.properties = Object.assign(wkData, feature.properties)
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
return data;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const identifyFormatColumnsArcgisvector = function (data, identifyFormatColumns) {
|
|
109
|
-
data.forEach((feature) => {
|
|
110
|
-
if(feature.properties){
|
|
111
|
-
for (const [key, value] of Object.entries(identifyFormatColumns)){
|
|
112
|
-
console.log(key, value);
|
|
113
|
-
if(feature.properties.hasOwnProperty(key)){
|
|
114
|
-
feature.properties[key] = formatColumns(feature.properties[key], value)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
return data;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const formatColumns = function (value, formatType) {
|
|
124
|
-
if (formatType === "PERCENT") {
|
|
125
|
-
value = (value * 100).toFixed(0) + '%'
|
|
126
|
-
}
|
|
127
|
-
if (formatType === "BOOLEAN") {
|
|
128
|
-
value = value === 0 ? "No" : "Yes"
|
|
129
|
-
}
|
|
130
|
-
if (formatType === "UNIXDATE") {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
const formatArcgisrest = function (attributes) {
|
|
2
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
3
|
+
const result =
|
|
4
|
+
String(value).includes("https:") || String(value).includes("http:")
|
|
5
|
+
? value
|
|
6
|
+
: null;
|
|
7
|
+
|
|
8
|
+
if (result) {
|
|
9
|
+
attributes[key] = `<a href="${value}" target="_new" > ${value} </a>`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return attributes;
|
|
13
|
+
};
|
|
14
|
+
|
|
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
|
+
// Format UNIX Date
|
|
29
|
+
|
|
30
|
+
// if ((key === "fromdate" || key === "todate" || key === "referencedate") && Number.isInteger(feat.properties[key])) {
|
|
31
|
+
// const unixTimestamp = feat.properties[key];
|
|
32
|
+
// const milliseconds = unixTimestamp // * 1000 in some cases.
|
|
33
|
+
// const dateObject = new Date(milliseconds);
|
|
34
|
+
// feat.properties[key] = dateObject.toLocaleString();
|
|
35
|
+
// }
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return results;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const identifyColumnsArcgisrest = function (data, excludedColumns) {
|
|
43
|
+
data.results.forEach((result) => {
|
|
44
|
+
if(result.attributes){
|
|
45
|
+
excludedColumns.forEach((column) => {
|
|
46
|
+
delete result.attributes[column];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return result.attributes;
|
|
50
|
+
});
|
|
51
|
+
return data;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const identifyExcludeColumnsArcgisvector = function (data, excludedColumns) {
|
|
55
|
+
data.forEach((feature) => {
|
|
56
|
+
if(feature.properties){
|
|
57
|
+
excludedColumns.forEach((column) => {
|
|
58
|
+
delete feature.properties[column];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return feature.properties
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return data;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const identifyIncludeColumnsArcgisvector = function (data, identifyFields) {
|
|
68
|
+
data.forEach((feature) => {
|
|
69
|
+
console.log(feature, feature.properties)
|
|
70
|
+
if(feature.properties){
|
|
71
|
+
for (const [key, value] of Object.entries(feature.properties)) {
|
|
72
|
+
let reducedProperties = {};
|
|
73
|
+
identifyFields.forEach((property) => {
|
|
74
|
+
if (feature.properties[property]) {
|
|
75
|
+
reducedProperties[property] =
|
|
76
|
+
feature.properties[property];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
feature.properties = reducedProperties;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
return data;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const identifyRenameColumnsArcgisvector = function (data, identifyRenameColums) {
|
|
88
|
+
|
|
89
|
+
data.forEach((feature) => {
|
|
90
|
+
if(feature.properties){
|
|
91
|
+
let wkData = {};
|
|
92
|
+
for (const [featureKey, featureValue] of Object.entries(feature.properties)) {
|
|
93
|
+
for (const [key, value] of Object.entries(identifyRenameColums)){
|
|
94
|
+
if (featureKey === key) {
|
|
95
|
+
// feature.properties[value] = feature.properties[featureKey];
|
|
96
|
+
wkData[value] = feature.properties[featureKey];
|
|
97
|
+
delete feature.properties[featureKey];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
feature.properties = Object.assign(wkData, feature.properties)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
return data;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const identifyFormatColumnsArcgisvector = function (data, identifyFormatColumns) {
|
|
109
|
+
data.forEach((feature) => {
|
|
110
|
+
if(feature.properties){
|
|
111
|
+
for (const [key, value] of Object.entries(identifyFormatColumns)){
|
|
112
|
+
console.log(key, value);
|
|
113
|
+
if(feature.properties.hasOwnProperty(key)){
|
|
114
|
+
feature.properties[key] = formatColumns(feature.properties[key], value)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
return data;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const formatColumns = function (value, formatType) {
|
|
124
|
+
if (formatType === "PERCENT") {
|
|
125
|
+
value = (value * 100).toFixed(0) + '%'
|
|
126
|
+
}
|
|
127
|
+
if (formatType === "BOOLEAN") {
|
|
128
|
+
value = value === 0 ? "No" : "Yes"
|
|
129
|
+
}
|
|
130
|
+
if (formatType === "UNIXDATE") {
|
|
131
|
+
if (value === null || value === "null") {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const unixTimestamp = value;
|
|
135
|
+
const milliseconds = unixTimestamp // * 1000 in some cases.
|
|
136
|
+
const dateObject = new Date(milliseconds);
|
|
137
|
+
value = dateObject.toLocaleString();
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
};
|
|
141
|
+
|
|
139
142
|
export { formatArcgisVector, formatArcgisrest, identifyColumnsArcgisrest, identifyExcludeColumnsArcgisvector, identifyIncludeColumnsArcgisvector, identifyRenameColumnsArcgisvector, identifyFormatColumnsArcgisvector };
|