@corpsmap/corpsmap 3.2.20 → 3.2.22
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
CHANGED
|
@@ -106567,7 +106567,7 @@ var config = {
|
|
|
106567
106567
|
};
|
|
106568
106568
|
|
|
106569
106569
|
var name = "@corpsmap/corpsmap";
|
|
106570
|
-
var version$1 = "3.2.
|
|
106570
|
+
var version$1 = "3.2.22";
|
|
106571
106571
|
var description = "CorpsMap as React Components";
|
|
106572
106572
|
var main = "index.js";
|
|
106573
106573
|
var scripts = {
|
|
@@ -132862,7 +132862,14 @@ var formatArcgisVector = function formatArcgisVector(results) {
|
|
|
132862
132862
|
|
|
132863
132863
|
if (result) {
|
|
132864
132864
|
feat.properties[key] = "<a href=\"".concat(value, "\" target=\"_new\" > ").concat(value, " </a>");
|
|
132865
|
-
}
|
|
132865
|
+
} // Format UNIX Date
|
|
132866
|
+
// if ((key === "fromdate" || key === "todate" || key === "referencedate") && Number.isInteger(feat.properties[key])) {
|
|
132867
|
+
// const unixTimestamp = feat.properties[key];
|
|
132868
|
+
// const milliseconds = unixTimestamp // * 1000 in some cases.
|
|
132869
|
+
// const dateObject = new Date(milliseconds);
|
|
132870
|
+
// feat.properties[key] = dateObject.toLocaleString();
|
|
132871
|
+
// }
|
|
132872
|
+
|
|
132866
132873
|
}
|
|
132867
132874
|
});
|
|
132868
132875
|
return results;
|
|
@@ -132881,7 +132888,7 @@ var identifyColumnsArcgisrest = function identifyColumnsArcgisrest(data, exclude
|
|
|
132881
132888
|
return data;
|
|
132882
132889
|
};
|
|
132883
132890
|
|
|
132884
|
-
var
|
|
132891
|
+
var identifyExcludeColumnsArcgisvector = function identifyExcludeColumnsArcgisvector(data, excludedColumns) {
|
|
132885
132892
|
data.forEach(function (feature) {
|
|
132886
132893
|
if (feature.properties) {
|
|
132887
132894
|
excludedColumns.forEach(function (column) {
|
|
@@ -132894,6 +132901,101 @@ var identifyColumnsArcgisvector = function identifyColumnsArcgisvector(data, exc
|
|
|
132894
132901
|
return data;
|
|
132895
132902
|
};
|
|
132896
132903
|
|
|
132904
|
+
var identifyIncludeColumnsArcgisvector = function identifyIncludeColumnsArcgisvector(data, identifyFields) {
|
|
132905
|
+
data.forEach(function (feature) {
|
|
132906
|
+
console.log(feature, feature.properties);
|
|
132907
|
+
|
|
132908
|
+
if (feature.properties) {
|
|
132909
|
+
var _loop = function _loop() {
|
|
132910
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
132911
|
+
key = _Object$entries3$_i[0],
|
|
132912
|
+
value = _Object$entries3$_i[1];
|
|
132913
|
+
|
|
132914
|
+
var reducedProperties = {};
|
|
132915
|
+
identifyFields.forEach(function (property) {
|
|
132916
|
+
if (feature.properties[property]) {
|
|
132917
|
+
reducedProperties[property] = feature.properties[property];
|
|
132918
|
+
}
|
|
132919
|
+
});
|
|
132920
|
+
feature.properties = reducedProperties;
|
|
132921
|
+
};
|
|
132922
|
+
|
|
132923
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(feature.properties); _i3 < _Object$entries3.length; _i3++) {
|
|
132924
|
+
_loop();
|
|
132925
|
+
}
|
|
132926
|
+
}
|
|
132927
|
+
});
|
|
132928
|
+
return data;
|
|
132929
|
+
};
|
|
132930
|
+
|
|
132931
|
+
var identifyRenameColumnsArcgisvector = function identifyRenameColumnsArcgisvector(data, identifyRenameColums) {
|
|
132932
|
+
data.forEach(function (feature) {
|
|
132933
|
+
if (feature.properties) {
|
|
132934
|
+
var wkData = {};
|
|
132935
|
+
|
|
132936
|
+
for (var _i4 = 0, _Object$entries4 = Object.entries(feature.properties); _i4 < _Object$entries4.length; _i4++) {
|
|
132937
|
+
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
132938
|
+
featureKey = _Object$entries4$_i[0],
|
|
132939
|
+
featureValue = _Object$entries4$_i[1];
|
|
132940
|
+
|
|
132941
|
+
for (var _i5 = 0, _Object$entries5 = Object.entries(identifyRenameColums); _i5 < _Object$entries5.length; _i5++) {
|
|
132942
|
+
var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2),
|
|
132943
|
+
key = _Object$entries5$_i[0],
|
|
132944
|
+
value = _Object$entries5$_i[1];
|
|
132945
|
+
|
|
132946
|
+
if (featureKey === key) {
|
|
132947
|
+
// feature.properties[value] = feature.properties[featureKey];
|
|
132948
|
+
wkData[value] = feature.properties[featureKey];
|
|
132949
|
+
delete feature.properties[featureKey];
|
|
132950
|
+
}
|
|
132951
|
+
}
|
|
132952
|
+
}
|
|
132953
|
+
|
|
132954
|
+
feature.properties = Object.assign(wkData, feature.properties);
|
|
132955
|
+
}
|
|
132956
|
+
});
|
|
132957
|
+
return data;
|
|
132958
|
+
};
|
|
132959
|
+
|
|
132960
|
+
var identifyFormatColumnsArcgisvector = function identifyFormatColumnsArcgisvector(data, identifyFormatColumns) {
|
|
132961
|
+
data.forEach(function (feature) {
|
|
132962
|
+
if (feature.properties) {
|
|
132963
|
+
for (var _i6 = 0, _Object$entries6 = Object.entries(identifyFormatColumns); _i6 < _Object$entries6.length; _i6++) {
|
|
132964
|
+
var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i6], 2),
|
|
132965
|
+
key = _Object$entries6$_i[0],
|
|
132966
|
+
value = _Object$entries6$_i[1];
|
|
132967
|
+
|
|
132968
|
+
console.log(key, value);
|
|
132969
|
+
|
|
132970
|
+
if (feature.properties.hasOwnProperty(key)) {
|
|
132971
|
+
feature.properties[key] = formatColumns(feature.properties[key], value);
|
|
132972
|
+
}
|
|
132973
|
+
}
|
|
132974
|
+
}
|
|
132975
|
+
});
|
|
132976
|
+
return data;
|
|
132977
|
+
};
|
|
132978
|
+
|
|
132979
|
+
var formatColumns = function formatColumns(value, formatType) {
|
|
132980
|
+
if (formatType === "PERCENT") {
|
|
132981
|
+
value = (value * 100).toFixed(0) + '%';
|
|
132982
|
+
}
|
|
132983
|
+
|
|
132984
|
+
if (formatType === "BOOLEAN") {
|
|
132985
|
+
value = value === 0 ? "No" : "Yes";
|
|
132986
|
+
}
|
|
132987
|
+
|
|
132988
|
+
if (formatType === "UNIXDATE") {
|
|
132989
|
+
var unixTimestamp = value;
|
|
132990
|
+
var milliseconds = unixTimestamp; // * 1000 in some cases.
|
|
132991
|
+
|
|
132992
|
+
var dateObject = new Date(milliseconds);
|
|
132993
|
+
value = dateObject.toLocaleString();
|
|
132994
|
+
}
|
|
132995
|
+
|
|
132996
|
+
return value;
|
|
132997
|
+
};
|
|
132998
|
+
|
|
132897
132999
|
function formatUrl(options) {
|
|
132898
133000
|
var url = "".concat(options.root, "/identify?");
|
|
132899
133001
|
var params = [];
|
|
@@ -143085,6 +143187,10 @@ var VectorListener = {
|
|
|
143085
143187
|
var mapLayer = lyr.mapLayer;
|
|
143086
143188
|
var outFeatures = [];
|
|
143087
143189
|
var src = mapLayer.getSource();
|
|
143190
|
+
var excludedColumns = store.selectIdentifyColumnsExclude();
|
|
143191
|
+
var identifyFields = lyr.identifyFields;
|
|
143192
|
+
var identifyRenameColums = lyr.identifyRenameColums;
|
|
143193
|
+
var identifyFormatColumns = lyr.identifyFormatColumns;
|
|
143088
143194
|
src.forEachFeatureIntersectingExtent(identifyExtent, function (f) {
|
|
143089
143195
|
var geoJsonFeature = geoJSON$2.writeFeatureObject(f, {
|
|
143090
143196
|
featureProjection: "EPSG:3857",
|
|
@@ -143092,6 +143198,20 @@ var VectorListener = {
|
|
|
143092
143198
|
});
|
|
143093
143199
|
if (!booleanDisjoint(identifyFeature, geoJsonFeature)) outFeatures.push(geoJsonFeature);
|
|
143094
143200
|
});
|
|
143201
|
+
outFeatures = identifyExcludeColumnsArcgisvector(outFeatures, excludedColumns);
|
|
143202
|
+
|
|
143203
|
+
if (identifyFields) {
|
|
143204
|
+
outFeatures = identifyIncludeColumnsArcgisvector(outFeatures, identifyFields);
|
|
143205
|
+
}
|
|
143206
|
+
|
|
143207
|
+
if (identifyRenameColums) {
|
|
143208
|
+
outFeatures = identifyRenameColumnsArcgisvector(outFeatures, identifyRenameColums);
|
|
143209
|
+
}
|
|
143210
|
+
|
|
143211
|
+
if (identifyFormatColumns) {
|
|
143212
|
+
outFeatures = identifyFormatColumnsArcgisvector(outFeatures, identifyFormatColumns);
|
|
143213
|
+
}
|
|
143214
|
+
|
|
143095
143215
|
out.push({
|
|
143096
143216
|
dataset: lyr.uid,
|
|
143097
143217
|
layerName: lyr.displayName,
|
package/lib/prod.js
CHANGED
|
@@ -106481,7 +106481,7 @@ var config = {
|
|
|
106481
106481
|
};
|
|
106482
106482
|
|
|
106483
106483
|
var name = "@corpsmap/corpsmap";
|
|
106484
|
-
var version$1 = "3.2.
|
|
106484
|
+
var version$1 = "3.2.22";
|
|
106485
106485
|
var description = "CorpsMap as React Components";
|
|
106486
106486
|
var main = "index.js";
|
|
106487
106487
|
var scripts = {
|
|
@@ -132776,7 +132776,14 @@ var formatArcgisVector = function formatArcgisVector(results) {
|
|
|
132776
132776
|
|
|
132777
132777
|
if (result) {
|
|
132778
132778
|
feat.properties[key] = "<a href=\"".concat(value, "\" target=\"_new\" > ").concat(value, " </a>");
|
|
132779
|
-
}
|
|
132779
|
+
} // Format UNIX Date
|
|
132780
|
+
// if ((key === "fromdate" || key === "todate" || key === "referencedate") && Number.isInteger(feat.properties[key])) {
|
|
132781
|
+
// const unixTimestamp = feat.properties[key];
|
|
132782
|
+
// const milliseconds = unixTimestamp // * 1000 in some cases.
|
|
132783
|
+
// const dateObject = new Date(milliseconds);
|
|
132784
|
+
// feat.properties[key] = dateObject.toLocaleString();
|
|
132785
|
+
// }
|
|
132786
|
+
|
|
132780
132787
|
}
|
|
132781
132788
|
});
|
|
132782
132789
|
return results;
|
|
@@ -132795,7 +132802,7 @@ var identifyColumnsArcgisrest = function identifyColumnsArcgisrest(data, exclude
|
|
|
132795
132802
|
return data;
|
|
132796
132803
|
};
|
|
132797
132804
|
|
|
132798
|
-
var
|
|
132805
|
+
var identifyExcludeColumnsArcgisvector = function identifyExcludeColumnsArcgisvector(data, excludedColumns) {
|
|
132799
132806
|
data.forEach(function (feature) {
|
|
132800
132807
|
if (feature.properties) {
|
|
132801
132808
|
excludedColumns.forEach(function (column) {
|
|
@@ -132808,6 +132815,101 @@ var identifyColumnsArcgisvector = function identifyColumnsArcgisvector(data, exc
|
|
|
132808
132815
|
return data;
|
|
132809
132816
|
};
|
|
132810
132817
|
|
|
132818
|
+
var identifyIncludeColumnsArcgisvector = function identifyIncludeColumnsArcgisvector(data, identifyFields) {
|
|
132819
|
+
data.forEach(function (feature) {
|
|
132820
|
+
console.log(feature, feature.properties);
|
|
132821
|
+
|
|
132822
|
+
if (feature.properties) {
|
|
132823
|
+
var _loop = function _loop() {
|
|
132824
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
132825
|
+
key = _Object$entries3$_i[0],
|
|
132826
|
+
value = _Object$entries3$_i[1];
|
|
132827
|
+
|
|
132828
|
+
var reducedProperties = {};
|
|
132829
|
+
identifyFields.forEach(function (property) {
|
|
132830
|
+
if (feature.properties[property]) {
|
|
132831
|
+
reducedProperties[property] = feature.properties[property];
|
|
132832
|
+
}
|
|
132833
|
+
});
|
|
132834
|
+
feature.properties = reducedProperties;
|
|
132835
|
+
};
|
|
132836
|
+
|
|
132837
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(feature.properties); _i3 < _Object$entries3.length; _i3++) {
|
|
132838
|
+
_loop();
|
|
132839
|
+
}
|
|
132840
|
+
}
|
|
132841
|
+
});
|
|
132842
|
+
return data;
|
|
132843
|
+
};
|
|
132844
|
+
|
|
132845
|
+
var identifyRenameColumnsArcgisvector = function identifyRenameColumnsArcgisvector(data, identifyRenameColums) {
|
|
132846
|
+
data.forEach(function (feature) {
|
|
132847
|
+
if (feature.properties) {
|
|
132848
|
+
var wkData = {};
|
|
132849
|
+
|
|
132850
|
+
for (var _i4 = 0, _Object$entries4 = Object.entries(feature.properties); _i4 < _Object$entries4.length; _i4++) {
|
|
132851
|
+
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
132852
|
+
featureKey = _Object$entries4$_i[0],
|
|
132853
|
+
featureValue = _Object$entries4$_i[1];
|
|
132854
|
+
|
|
132855
|
+
for (var _i5 = 0, _Object$entries5 = Object.entries(identifyRenameColums); _i5 < _Object$entries5.length; _i5++) {
|
|
132856
|
+
var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2),
|
|
132857
|
+
key = _Object$entries5$_i[0],
|
|
132858
|
+
value = _Object$entries5$_i[1];
|
|
132859
|
+
|
|
132860
|
+
if (featureKey === key) {
|
|
132861
|
+
// feature.properties[value] = feature.properties[featureKey];
|
|
132862
|
+
wkData[value] = feature.properties[featureKey];
|
|
132863
|
+
delete feature.properties[featureKey];
|
|
132864
|
+
}
|
|
132865
|
+
}
|
|
132866
|
+
}
|
|
132867
|
+
|
|
132868
|
+
feature.properties = Object.assign(wkData, feature.properties);
|
|
132869
|
+
}
|
|
132870
|
+
});
|
|
132871
|
+
return data;
|
|
132872
|
+
};
|
|
132873
|
+
|
|
132874
|
+
var identifyFormatColumnsArcgisvector = function identifyFormatColumnsArcgisvector(data, identifyFormatColumns) {
|
|
132875
|
+
data.forEach(function (feature) {
|
|
132876
|
+
if (feature.properties) {
|
|
132877
|
+
for (var _i6 = 0, _Object$entries6 = Object.entries(identifyFormatColumns); _i6 < _Object$entries6.length; _i6++) {
|
|
132878
|
+
var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i6], 2),
|
|
132879
|
+
key = _Object$entries6$_i[0],
|
|
132880
|
+
value = _Object$entries6$_i[1];
|
|
132881
|
+
|
|
132882
|
+
console.log(key, value);
|
|
132883
|
+
|
|
132884
|
+
if (feature.properties.hasOwnProperty(key)) {
|
|
132885
|
+
feature.properties[key] = formatColumns(feature.properties[key], value);
|
|
132886
|
+
}
|
|
132887
|
+
}
|
|
132888
|
+
}
|
|
132889
|
+
});
|
|
132890
|
+
return data;
|
|
132891
|
+
};
|
|
132892
|
+
|
|
132893
|
+
var formatColumns = function formatColumns(value, formatType) {
|
|
132894
|
+
if (formatType === "PERCENT") {
|
|
132895
|
+
value = (value * 100).toFixed(0) + '%';
|
|
132896
|
+
}
|
|
132897
|
+
|
|
132898
|
+
if (formatType === "BOOLEAN") {
|
|
132899
|
+
value = value === 0 ? "No" : "Yes";
|
|
132900
|
+
}
|
|
132901
|
+
|
|
132902
|
+
if (formatType === "UNIXDATE") {
|
|
132903
|
+
var unixTimestamp = value;
|
|
132904
|
+
var milliseconds = unixTimestamp; // * 1000 in some cases.
|
|
132905
|
+
|
|
132906
|
+
var dateObject = new Date(milliseconds);
|
|
132907
|
+
value = dateObject.toLocaleString();
|
|
132908
|
+
}
|
|
132909
|
+
|
|
132910
|
+
return value;
|
|
132911
|
+
};
|
|
132912
|
+
|
|
132811
132913
|
function formatUrl(options) {
|
|
132812
132914
|
var url = "".concat(options.root, "/identify?");
|
|
132813
132915
|
var params = [];
|
|
@@ -142999,6 +143101,10 @@ var VectorListener = {
|
|
|
142999
143101
|
var mapLayer = lyr.mapLayer;
|
|
143000
143102
|
var outFeatures = [];
|
|
143001
143103
|
var src = mapLayer.getSource();
|
|
143104
|
+
var excludedColumns = store.selectIdentifyColumnsExclude();
|
|
143105
|
+
var identifyFields = lyr.identifyFields;
|
|
143106
|
+
var identifyRenameColums = lyr.identifyRenameColums;
|
|
143107
|
+
var identifyFormatColumns = lyr.identifyFormatColumns;
|
|
143002
143108
|
src.forEachFeatureIntersectingExtent(identifyExtent, function (f) {
|
|
143003
143109
|
var geoJsonFeature = geoJSON$2.writeFeatureObject(f, {
|
|
143004
143110
|
featureProjection: "EPSG:3857",
|
|
@@ -143006,6 +143112,20 @@ var VectorListener = {
|
|
|
143006
143112
|
});
|
|
143007
143113
|
if (!booleanDisjoint(identifyFeature, geoJsonFeature)) outFeatures.push(geoJsonFeature);
|
|
143008
143114
|
});
|
|
143115
|
+
outFeatures = identifyExcludeColumnsArcgisvector(outFeatures, excludedColumns);
|
|
143116
|
+
|
|
143117
|
+
if (identifyFields) {
|
|
143118
|
+
outFeatures = identifyIncludeColumnsArcgisvector(outFeatures, identifyFields);
|
|
143119
|
+
}
|
|
143120
|
+
|
|
143121
|
+
if (identifyRenameColums) {
|
|
143122
|
+
outFeatures = identifyRenameColumnsArcgisvector(outFeatures, identifyRenameColums);
|
|
143123
|
+
}
|
|
143124
|
+
|
|
143125
|
+
if (identifyFormatColumns) {
|
|
143126
|
+
outFeatures = identifyFormatColumnsArcgisvector(outFeatures, identifyFormatColumns);
|
|
143127
|
+
}
|
|
143128
|
+
|
|
143009
143129
|
out.push({
|
|
143010
143130
|
dataset: lyr.uid,
|
|
143011
143131
|
layerName: lyr.displayName,
|
package/package.json
CHANGED
|
@@ -5,7 +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 { formatArcgisVector } from "../../../openlayers-utils/format-utilities";
|
|
8
|
+
import { formatArcgisVector, identifyExcludeColumnsArcgisvector, identifyIncludeColumnsArcgisvector, identifyRenameColumnsArcgisvector, identifyFormatColumnsArcgisvector } from "../../../openlayers-utils/format-utilities";
|
|
9
9
|
|
|
10
10
|
const geoJSON = new GeoJSON();
|
|
11
11
|
|
|
@@ -55,8 +55,12 @@ export default {
|
|
|
55
55
|
layers.forEach((lyr) => {
|
|
56
56
|
if (lyr.identifyType && lyr.identifyType === "arcgisvector") {
|
|
57
57
|
const { mapLayer } = lyr;
|
|
58
|
-
|
|
58
|
+
let outFeatures = [];
|
|
59
59
|
const src = mapLayer.getSource();
|
|
60
|
+
let excludedColumns = store.selectIdentifyColumnsExclude();
|
|
61
|
+
const identifyFields = lyr.identifyFields;
|
|
62
|
+
const identifyRenameColums = lyr.identifyRenameColums;
|
|
63
|
+
const identifyFormatColumns = lyr.identifyFormatColumns;
|
|
60
64
|
src.forEachFeatureIntersectingExtent(identifyExtent, (f) => {
|
|
61
65
|
const geoJsonFeature = geoJSON.writeFeatureObject(f, {
|
|
62
66
|
featureProjection: "EPSG:3857",
|
|
@@ -65,6 +69,20 @@ export default {
|
|
|
65
69
|
if (!disjoint(identifyFeature, geoJsonFeature))
|
|
66
70
|
outFeatures.push(geoJsonFeature);
|
|
67
71
|
});
|
|
72
|
+
outFeatures = identifyExcludeColumnsArcgisvector(outFeatures, excludedColumns);
|
|
73
|
+
|
|
74
|
+
if (identifyFields) {
|
|
75
|
+
outFeatures = identifyIncludeColumnsArcgisvector(outFeatures, identifyFields);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (identifyRenameColums) {
|
|
79
|
+
outFeatures = identifyRenameColumnsArcgisvector(outFeatures, identifyRenameColums);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (identifyFormatColumns) {
|
|
83
|
+
outFeatures = identifyFormatColumnsArcgisvector(outFeatures, identifyFormatColumns)
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
out.push({
|
|
69
87
|
dataset: lyr.uid,
|
|
70
88
|
layerName: lyr.displayName,
|
|
@@ -5,7 +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 { formatArcgisVector,
|
|
8
|
+
import { formatArcgisVector, identifyExcludeColumnsArcgisvector } from "../../openlayers-utils/format-utilities";
|
|
9
9
|
|
|
10
10
|
const geoJSON = new GeoJSON();
|
|
11
11
|
|
|
@@ -25,6 +25,15 @@ const formatArcgisVector = function (results) {
|
|
|
25
25
|
key
|
|
26
26
|
] = `<a href="${value}" target="_new" > ${value} </a>`;
|
|
27
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
|
+
|
|
28
37
|
}
|
|
29
38
|
});
|
|
30
39
|
return results;
|
|
@@ -42,7 +51,7 @@ const identifyColumnsArcgisrest = function (data, excludedColumns) {
|
|
|
42
51
|
return data;
|
|
43
52
|
};
|
|
44
53
|
|
|
45
|
-
const
|
|
54
|
+
const identifyExcludeColumnsArcgisvector = function (data, excludedColumns) {
|
|
46
55
|
data.forEach((feature) => {
|
|
47
56
|
if(feature.properties){
|
|
48
57
|
excludedColumns.forEach((column) => {
|
|
@@ -55,5 +64,76 @@ const identifyColumnsArcgisvector = function (data, excludedColumns) {
|
|
|
55
64
|
return data;
|
|
56
65
|
};
|
|
57
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
|
+
const unixTimestamp = value;
|
|
132
|
+
const milliseconds = unixTimestamp // * 1000 in some cases.
|
|
133
|
+
const dateObject = new Date(milliseconds);
|
|
134
|
+
value = dateObject.toLocaleString();
|
|
135
|
+
}
|
|
136
|
+
return value;
|
|
137
|
+
};
|
|
58
138
|
|
|
59
|
-
export { formatArcgisVector, formatArcgisrest, identifyColumnsArcgisrest,
|
|
139
|
+
export { formatArcgisVector, formatArcgisrest, identifyColumnsArcgisrest, identifyExcludeColumnsArcgisvector, identifyIncludeColumnsArcgisvector, identifyRenameColumnsArcgisvector, identifyFormatColumnsArcgisvector };
|