@evergis/common 1.0.1 → 1.0.2
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/LICENSE +21 -21
- package/README.md +1 -1
- package/dist/classification/combineInterpolateStops.d.ts +2 -0
- package/dist/classification/expressions/concat.d.ts +3 -0
- package/dist/classification/expressions/index.d.ts +1 -0
- package/dist/classification/getClassificationFromExpression.d.ts +2 -0
- package/dist/classification/getClassificationList.d.ts +3 -0
- package/dist/classification/getInterpolateStops.d.ts +2 -0
- package/dist/classification/getValuesFromExression.d.ts +2 -0
- package/dist/classification/index.d.ts +7 -0
- package/dist/classification/resyncStyleIcons.d.ts +2 -0
- package/dist/common.esm.js +481 -14
- package/dist/common.esm.js.map +1 -1
- package/dist/index.js +488 -12
- package/dist/index.js.map +1 -1
- package/dist/types/styling.d.ts +130 -0
- package/dist/utils/createEqualIntervals.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var mapboxGlStyleSpec = require('@mapbox/mapbox-gl-style-spec');
|
|
4
4
|
var lodash = require('lodash');
|
|
5
5
|
var uuid = require('uuid');
|
|
6
|
+
var api = require('@evergis/api');
|
|
6
7
|
var turf = require('@turf/turf');
|
|
7
8
|
var dateFns = require('date-fns');
|
|
8
9
|
var locale = require('date-fns/locale');
|
|
9
|
-
var api = require('@evergis/api');
|
|
10
10
|
var wkt = require('wkt');
|
|
11
11
|
|
|
12
12
|
/* ---------------------------------------------------------------------------------------------------------------- *
|
|
@@ -777,6 +777,51 @@ class ClientStyleValidator {
|
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
|
|
780
|
+
const ENCODE_REGEXP = /\{[a-zA-Z]+[a-zA-Z0-9_]+\}/g;
|
|
781
|
+
const encodeConcat = (value) => {
|
|
782
|
+
if (!value) {
|
|
783
|
+
return "";
|
|
784
|
+
}
|
|
785
|
+
const matches = value.match(ENCODE_REGEXP);
|
|
786
|
+
if (matches === null || matches.length === 0) {
|
|
787
|
+
return value;
|
|
788
|
+
}
|
|
789
|
+
const splits = value.split(ENCODE_REGEXP);
|
|
790
|
+
return [
|
|
791
|
+
"concat",
|
|
792
|
+
...splits.reduce((acc, curr, currentIndex) => {
|
|
793
|
+
if (currentIndex < splits.length - 1) {
|
|
794
|
+
return [...acc, curr, ["get", matches[currentIndex].slice(1, -1)]];
|
|
795
|
+
}
|
|
796
|
+
return [...acc, curr];
|
|
797
|
+
}, []),
|
|
798
|
+
];
|
|
799
|
+
};
|
|
800
|
+
const decodeConcat = (value) => {
|
|
801
|
+
if (!value) {
|
|
802
|
+
return "";
|
|
803
|
+
}
|
|
804
|
+
if (!Array.isArray(value)) {
|
|
805
|
+
return value;
|
|
806
|
+
}
|
|
807
|
+
if (value[0] !== "concat") {
|
|
808
|
+
return "";
|
|
809
|
+
}
|
|
810
|
+
return value.slice(1).reduce((acc, curr) => {
|
|
811
|
+
if (typeof curr === "string") {
|
|
812
|
+
return [...acc, curr];
|
|
813
|
+
}
|
|
814
|
+
if (Array.isArray(curr) && curr.length === 2 && curr[0] === "get") {
|
|
815
|
+
return [...acc, `{${curr[1]}}`];
|
|
816
|
+
}
|
|
817
|
+
return acc;
|
|
818
|
+
}, []).join("");
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
const combineInterpolateStops = (stops) => {
|
|
822
|
+
return stops.reduce((acc, curr) => [...acc, curr.input, curr.output], []);
|
|
823
|
+
};
|
|
824
|
+
|
|
780
825
|
const enrichStyleItemsWithIds = (style) => {
|
|
781
826
|
return {
|
|
782
827
|
...style,
|
|
@@ -836,6 +881,409 @@ const getActualExtrusionHeight = (paint) => {
|
|
|
836
881
|
: paint?.["fill-extrusion-height"];
|
|
837
882
|
};
|
|
838
883
|
|
|
884
|
+
exports.EditGeometryType = void 0;
|
|
885
|
+
(function (EditGeometryType) {
|
|
886
|
+
EditGeometryType["Raster"] = "raster";
|
|
887
|
+
})(exports.EditGeometryType || (exports.EditGeometryType = {}));
|
|
888
|
+
|
|
889
|
+
exports.StylingClassifierTypes = void 0;
|
|
890
|
+
(function (StylingClassifierTypes) {
|
|
891
|
+
// circle
|
|
892
|
+
StylingClassifierTypes["CircleColor"] = "circle-color";
|
|
893
|
+
StylingClassifierTypes["CircleOpacity"] = "circle-opacity";
|
|
894
|
+
StylingClassifierTypes["CircleStrokeColor"] = "circle-stroke-color";
|
|
895
|
+
StylingClassifierTypes["CircleStrokeOpacity"] = "circle-stroke-opacity";
|
|
896
|
+
StylingClassifierTypes["CircleRadius"] = "circle-radius";
|
|
897
|
+
StylingClassifierTypes["CircleStrokeWidth"] = "circle-stroke-width";
|
|
898
|
+
StylingClassifierTypes["CircleBlur"] = "circle-blur";
|
|
899
|
+
StylingClassifierTypes["CircleTranslate"] = "circle-translate";
|
|
900
|
+
// fill
|
|
901
|
+
StylingClassifierTypes["FillColor"] = "fill-color";
|
|
902
|
+
StylingClassifierTypes["FillOpacity"] = "fill-opacity";
|
|
903
|
+
// fill-extrusion
|
|
904
|
+
StylingClassifierTypes["FillExtrusionColor"] = "fill-extrusion-color";
|
|
905
|
+
StylingClassifierTypes["FillExtrusionOpacity"] = "fill-extrusion-opacity";
|
|
906
|
+
StylingClassifierTypes["FillExtrusionBase"] = "fill-extrusion-base";
|
|
907
|
+
StylingClassifierTypes["FillExtrusionHeight"] = "fill-extrusion-height";
|
|
908
|
+
// line
|
|
909
|
+
StylingClassifierTypes["LineColor"] = "line-color";
|
|
910
|
+
StylingClassifierTypes["LineOpacity"] = "line-opacity";
|
|
911
|
+
StylingClassifierTypes["LineWidth"] = "line-width";
|
|
912
|
+
StylingClassifierTypes["LineBlur"] = "line-blur";
|
|
913
|
+
StylingClassifierTypes["LineDasharray"] = "line-dasharray";
|
|
914
|
+
StylingClassifierTypes["LineCap"] = "line-cap";
|
|
915
|
+
StylingClassifierTypes["LineJoin"] = "line-join";
|
|
916
|
+
StylingClassifierTypes["LineTranslate"] = "line-translate";
|
|
917
|
+
// icon
|
|
918
|
+
StylingClassifierTypes["IconImage"] = "icon-image";
|
|
919
|
+
StylingClassifierTypes["IconSize"] = "icon-size";
|
|
920
|
+
StylingClassifierTypes["IconColor"] = "icon-color";
|
|
921
|
+
StylingClassifierTypes["IconOpacity"] = "icon-opacity";
|
|
922
|
+
StylingClassifierTypes["IconTranslate"] = "icon-translate";
|
|
923
|
+
StylingClassifierTypes["IconHaloColor"] = "icon-halo-color";
|
|
924
|
+
StylingClassifierTypes["IconHaloWidth"] = "icon-halo-width";
|
|
925
|
+
StylingClassifierTypes["IconHaloBlur"] = "icon-halo-blur";
|
|
926
|
+
StylingClassifierTypes["IconOverlap"] = "icon-overlap";
|
|
927
|
+
StylingClassifierTypes["IconAnchor"] = "icon-anchor";
|
|
928
|
+
StylingClassifierTypes["IconRotate"] = "icon-rotate";
|
|
929
|
+
StylingClassifierTypes["IconPadding"] = "icon-padding";
|
|
930
|
+
// text
|
|
931
|
+
StylingClassifierTypes["TextField"] = "text-field";
|
|
932
|
+
StylingClassifierTypes["TextColor"] = "text-color";
|
|
933
|
+
StylingClassifierTypes["TextOpacity"] = "text-opacity";
|
|
934
|
+
StylingClassifierTypes["TextFont"] = "text-font";
|
|
935
|
+
StylingClassifierTypes["TextSize"] = "text-size";
|
|
936
|
+
StylingClassifierTypes["TextTransform"] = "text-transform";
|
|
937
|
+
StylingClassifierTypes["TextAnchor"] = "text-anchor";
|
|
938
|
+
StylingClassifierTypes["TextJustify"] = "text-justify";
|
|
939
|
+
StylingClassifierTypes["TextTranslate"] = "text-translate";
|
|
940
|
+
StylingClassifierTypes["TextHaloColor"] = "text-halo-color";
|
|
941
|
+
StylingClassifierTypes["TextHaloWidth"] = "text-halo-width";
|
|
942
|
+
StylingClassifierTypes["TextHaloBlur"] = "text-halo-blur";
|
|
943
|
+
// symbol
|
|
944
|
+
StylingClassifierTypes["SymbolPlacement"] = "symbol-placement";
|
|
945
|
+
StylingClassifierTypes["SymbolSpacing"] = "symbol-spacing";
|
|
946
|
+
// heatmap
|
|
947
|
+
StylingClassifierTypes["HeatmapColor"] = "heatmap-color";
|
|
948
|
+
StylingClassifierTypes["HeatmapOpacity"] = "heatmap-opacity";
|
|
949
|
+
StylingClassifierTypes["HeatmapRadius"] = "heatmap-radius";
|
|
950
|
+
StylingClassifierTypes["HeatmapIntensity"] = "heatmap-intensity";
|
|
951
|
+
StylingClassifierTypes["HeatmapWeight"] = "heatmap-weight";
|
|
952
|
+
})(exports.StylingClassifierTypes || (exports.StylingClassifierTypes = {}));
|
|
953
|
+
exports.ClassificationExpressionType = void 0;
|
|
954
|
+
(function (ClassificationExpressionType) {
|
|
955
|
+
ClassificationExpressionType["Match"] = "match";
|
|
956
|
+
ClassificationExpressionType["Case"] = "case";
|
|
957
|
+
ClassificationExpressionType["Step"] = "step";
|
|
958
|
+
ClassificationExpressionType["Interpolate"] = "interpolate";
|
|
959
|
+
})(exports.ClassificationExpressionType || (exports.ClassificationExpressionType = {}));
|
|
960
|
+
exports.ClassificationExpressionSubtype = void 0;
|
|
961
|
+
(function (ClassificationExpressionSubtype) {
|
|
962
|
+
ClassificationExpressionSubtype["Linear"] = "linear";
|
|
963
|
+
ClassificationExpressionSubtype["Exponential"] = "exponential";
|
|
964
|
+
ClassificationExpressionSubtype["CubicBezier"] = "cubic-bezier";
|
|
965
|
+
})(exports.ClassificationExpressionSubtype || (exports.ClassificationExpressionSubtype = {}));
|
|
966
|
+
exports.ClassificationExtraAlgorithms = void 0;
|
|
967
|
+
(function (ClassificationExtraAlgorithms) {
|
|
968
|
+
ClassificationExtraAlgorithms["Interpolate"] = "interpolate";
|
|
969
|
+
})(exports.ClassificationExtraAlgorithms || (exports.ClassificationExtraAlgorithms = {}));
|
|
970
|
+
|
|
971
|
+
exports.ThemeName = void 0;
|
|
972
|
+
(function (ThemeName) {
|
|
973
|
+
ThemeName["Light"] = "light";
|
|
974
|
+
ThemeName["Dark"] = "dark";
|
|
975
|
+
})(exports.ThemeName || (exports.ThemeName = {}));
|
|
976
|
+
|
|
977
|
+
const getValuesFromExression = (expression, modifier) => {
|
|
978
|
+
if (!Array.isArray(expression)) {
|
|
979
|
+
return [expression];
|
|
980
|
+
}
|
|
981
|
+
const expressionType = expression[0];
|
|
982
|
+
let id = 0;
|
|
983
|
+
switch (expressionType) {
|
|
984
|
+
case exports.ClassificationExpressionType.Match:
|
|
985
|
+
return expression.slice(3).reduce((acc, curr, currIndex) => {
|
|
986
|
+
return currIndex % 2 === 0 || currIndex === expression.slice(3).length - 1
|
|
987
|
+
? [...acc, modifier ? modifier(curr, id++) : curr]
|
|
988
|
+
: acc;
|
|
989
|
+
}, []);
|
|
990
|
+
case exports.ClassificationExpressionType.Step:
|
|
991
|
+
return expression.slice(2).reduce((acc, curr, currIndex) => {
|
|
992
|
+
return currIndex % 2 === 0 ? [...acc, modifier ? modifier(curr, id++) : curr] : acc;
|
|
993
|
+
}, []);
|
|
994
|
+
case exports.ClassificationExpressionType.Interpolate:
|
|
995
|
+
return expression.slice(3).reduce((acc, curr, currIndex) => {
|
|
996
|
+
return currIndex % 2 !== 0 ? [...acc, modifier ? modifier(curr, id++) : curr] : acc;
|
|
997
|
+
}, []);
|
|
998
|
+
default:
|
|
999
|
+
return expression.slice(2).reduce((acc, curr, currIndex) => {
|
|
1000
|
+
return currIndex % 2 === 0 || currIndex === expression.slice(2).length - 1
|
|
1001
|
+
? [...acc, modifier ? modifier(curr, id++) : curr]
|
|
1002
|
+
: acc;
|
|
1003
|
+
}, []);
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
const composeClassification = (expressionType, itemPaint) => {
|
|
1008
|
+
const getAtttibuteName = () => {
|
|
1009
|
+
switch (expressionType) {
|
|
1010
|
+
case exports.ClassificationExpressionType.Case:
|
|
1011
|
+
return itemPaint?.[1]?.[1]?.[1]?.[1];
|
|
1012
|
+
case exports.ClassificationExpressionType.Match:
|
|
1013
|
+
case exports.ClassificationExpressionType.Step:
|
|
1014
|
+
return itemPaint?.[1]?.[1];
|
|
1015
|
+
case exports.ClassificationExpressionType.Interpolate:
|
|
1016
|
+
return itemPaint?.[2]?.[1];
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
const getClassifyType = () => {
|
|
1020
|
+
switch (expressionType) {
|
|
1021
|
+
case exports.ClassificationExpressionType.Case:
|
|
1022
|
+
return typeof itemPaint?.[1]?.[1]?.[2] === "number"
|
|
1023
|
+
? api.ClassifyAttributeType.Decimal
|
|
1024
|
+
: api.ClassifyAttributeType.Text;
|
|
1025
|
+
case exports.ClassificationExpressionType.Match:
|
|
1026
|
+
return typeof itemPaint?.[2] === "number" ? api.ClassifyAttributeType.Decimal : api.ClassifyAttributeType.Text;
|
|
1027
|
+
case exports.ClassificationExpressionType.Step:
|
|
1028
|
+
return typeof itemPaint?.[3] === "number" ? api.ClassifyAttributeType.Decimal : api.ClassifyAttributeType.Text;
|
|
1029
|
+
case exports.ClassificationExpressionType.Interpolate:
|
|
1030
|
+
return api.ClassifyAttributeType.Decimal;
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
const getAlgorithm = () => {
|
|
1034
|
+
switch (expressionType) {
|
|
1035
|
+
case exports.ClassificationExpressionType.Case:
|
|
1036
|
+
return api.ClassificationType.None;
|
|
1037
|
+
case exports.ClassificationExpressionType.Match:
|
|
1038
|
+
return api.ClassificationType.Unique;
|
|
1039
|
+
case exports.ClassificationExpressionType.Step:
|
|
1040
|
+
return api.ClassificationType.None;
|
|
1041
|
+
case exports.ClassificationExpressionType.Interpolate:
|
|
1042
|
+
return exports.ClassificationExtraAlgorithms.Interpolate;
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
const getClassifyDataResult = () => {
|
|
1046
|
+
switch (expressionType) {
|
|
1047
|
+
case exports.ClassificationExpressionType.Case:
|
|
1048
|
+
return itemPaint?.slice?.(1)?.reduce?.((acc, curr, currIndex) => {
|
|
1049
|
+
if (currIndex === 0) {
|
|
1050
|
+
return [...acc, { value: curr?.[1]?.[2] }, { value: curr?.[2]?.[2] }];
|
|
1051
|
+
}
|
|
1052
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice?.(1)?.length - 1
|
|
1053
|
+
? [...acc, { value: curr?.[2]?.[2] }]
|
|
1054
|
+
: acc;
|
|
1055
|
+
}, []);
|
|
1056
|
+
case exports.ClassificationExpressionType.Match:
|
|
1057
|
+
return itemPaint?.slice?.(2)?.reduce?.((acc, curr, currIndex) => {
|
|
1058
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice(2)?.length - 1 ? [...acc, { value: curr }] : acc;
|
|
1059
|
+
}, []);
|
|
1060
|
+
case exports.ClassificationExpressionType.Step:
|
|
1061
|
+
return itemPaint?.slice?.(2)?.reduce?.((acc, curr, currIndex) => {
|
|
1062
|
+
return currIndex % 2 === 0 ? [...acc, { value: curr }] : acc;
|
|
1063
|
+
}, []);
|
|
1064
|
+
case exports.ClassificationExpressionType.Interpolate:
|
|
1065
|
+
return itemPaint?.slice?.(3)?.reduce?.((acc, curr, currIndex) => {
|
|
1066
|
+
return currIndex % 2 === 0 ? [...acc, { value: curr }] : acc;
|
|
1067
|
+
}, []);
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
const getClassifyDataType = () => {
|
|
1071
|
+
switch (expressionType) {
|
|
1072
|
+
case exports.ClassificationExpressionType.Case:
|
|
1073
|
+
return typeof itemPaint?.[1]?.[1]?.[2] === "number" ? "Decimal" : "String";
|
|
1074
|
+
case exports.ClassificationExpressionType.Match:
|
|
1075
|
+
return typeof itemPaint?.[2] === "number" ? "Decimal" : "String";
|
|
1076
|
+
case exports.ClassificationExpressionType.Step:
|
|
1077
|
+
return typeof itemPaint?.[3] === "number" ? "Decimal" : "String";
|
|
1078
|
+
case exports.ClassificationExpressionType.Interpolate:
|
|
1079
|
+
return "Decimal";
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
const getClassifyRanges = () => {
|
|
1083
|
+
switch (expressionType) {
|
|
1084
|
+
case exports.ClassificationExpressionType.Case:
|
|
1085
|
+
return itemPaint?.slice?.(1)?.reduce?.((acc, curr, currIndex) => {
|
|
1086
|
+
if (currIndex === 0) {
|
|
1087
|
+
return [
|
|
1088
|
+
...acc,
|
|
1089
|
+
{
|
|
1090
|
+
from: curr?.find?.(item => Array.isArray(item) && [">=", ">"].includes(item[0]))?.[2] ?? null,
|
|
1091
|
+
to: curr?.find?.(item => Array.isArray(item) && ["<=", "<"].includes(item[0]))?.[2] ?? null,
|
|
1092
|
+
},
|
|
1093
|
+
];
|
|
1094
|
+
}
|
|
1095
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice?.(1)?.length - 1
|
|
1096
|
+
? [
|
|
1097
|
+
...acc,
|
|
1098
|
+
{
|
|
1099
|
+
from: curr?.find?.(item => Array.isArray(item) && [">=", ">"].includes(item[0]))?.[2] ?? null,
|
|
1100
|
+
to: curr?.find?.(item => Array.isArray(item) && ["<=", "<"].includes(item[0]))?.[2] ?? null,
|
|
1101
|
+
},
|
|
1102
|
+
]
|
|
1103
|
+
: acc;
|
|
1104
|
+
}, []);
|
|
1105
|
+
case exports.ClassificationExpressionType.Step: {
|
|
1106
|
+
const slicedExpression = itemPaint?.slice?.(3);
|
|
1107
|
+
return slicedExpression?.reduce?.((acc, curr, currIndex) => {
|
|
1108
|
+
if (currIndex === 0) {
|
|
1109
|
+
return [
|
|
1110
|
+
...acc,
|
|
1111
|
+
{
|
|
1112
|
+
from: null,
|
|
1113
|
+
to: curr ?? null,
|
|
1114
|
+
},
|
|
1115
|
+
];
|
|
1116
|
+
}
|
|
1117
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice?.(1)?.length - 1
|
|
1118
|
+
? [
|
|
1119
|
+
...acc,
|
|
1120
|
+
{
|
|
1121
|
+
from: slicedExpression[currIndex - 2] ?? null,
|
|
1122
|
+
to: curr ?? null,
|
|
1123
|
+
},
|
|
1124
|
+
]
|
|
1125
|
+
: acc;
|
|
1126
|
+
}, []);
|
|
1127
|
+
}
|
|
1128
|
+
default:
|
|
1129
|
+
return [];
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
return {
|
|
1133
|
+
expressionType,
|
|
1134
|
+
algorithm: getAlgorithm(),
|
|
1135
|
+
attributeName: getAtttibuteName(),
|
|
1136
|
+
classifyData: {
|
|
1137
|
+
classifyResult: getClassifyDataResult(),
|
|
1138
|
+
type: getClassifyDataType(),
|
|
1139
|
+
},
|
|
1140
|
+
classifyRanges: getClassifyRanges(),
|
|
1141
|
+
classifyType: getClassifyType(),
|
|
1142
|
+
};
|
|
1143
|
+
};
|
|
1144
|
+
const getClassificationFromExpression = (style, itemId, classifierType, specPropKey, styleItem, stopIndex) => {
|
|
1145
|
+
const clientStyleValidator = new ClientStyleValidator();
|
|
1146
|
+
if (!style || (!itemId && !styleItem)) {
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
const currentItem = styleItem ?? style.items?.find(item => item.id === itemId);
|
|
1150
|
+
const rawCurrentItem = currentItem?.[specPropKey]?.[classifierType];
|
|
1151
|
+
const currentItemPaint = stopIndex !== undefined && clientStyleValidator.isZoomInterpolate(rawCurrentItem)
|
|
1152
|
+
? rawCurrentItem.slice(3).filter((_, i) => i % 2 !== 0)?.[stopIndex]
|
|
1153
|
+
: currentItem?.[specPropKey]?.[classifierType];
|
|
1154
|
+
const expressionType = Array.isArray(currentItemPaint)
|
|
1155
|
+
? currentItemPaint?.[0]
|
|
1156
|
+
: undefined;
|
|
1157
|
+
let presets = {};
|
|
1158
|
+
if (expressionType === exports.ClassificationExpressionType.Interpolate) {
|
|
1159
|
+
const expressionSubtype = currentItemPaint?.[1]?.[0];
|
|
1160
|
+
const slicedExpression = currentItemPaint?.slice(3);
|
|
1161
|
+
presets = {
|
|
1162
|
+
...presets,
|
|
1163
|
+
interpolate: {
|
|
1164
|
+
expressionSubtype,
|
|
1165
|
+
expressionOptions: {
|
|
1166
|
+
[exports.ClassificationExtraAlgorithms.Interpolate]: {
|
|
1167
|
+
[exports.ClassificationExpressionSubtype.Exponential]: expressionSubtype === exports.ClassificationExpressionSubtype.Exponential
|
|
1168
|
+
? {
|
|
1169
|
+
base: currentItemPaint?.[1]?.[1],
|
|
1170
|
+
}
|
|
1171
|
+
: undefined,
|
|
1172
|
+
[exports.ClassificationExpressionSubtype.CubicBezier]: expressionSubtype === exports.ClassificationExpressionSubtype.CubicBezier
|
|
1173
|
+
? {
|
|
1174
|
+
x1: currentItemPaint?.[1]?.[1],
|
|
1175
|
+
y1: currentItemPaint?.[1]?.[2],
|
|
1176
|
+
x2: currentItemPaint?.[1]?.[3],
|
|
1177
|
+
y2: currentItemPaint?.[1]?.[4],
|
|
1178
|
+
}
|
|
1179
|
+
: undefined,
|
|
1180
|
+
},
|
|
1181
|
+
},
|
|
1182
|
+
stops: Array.from({ length: slicedExpression.length / 2 }, (_, index) => ({
|
|
1183
|
+
input: slicedExpression[index * 2],
|
|
1184
|
+
output: slicedExpression[index * 2 + 1],
|
|
1185
|
+
})),
|
|
1186
|
+
},
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
else {
|
|
1190
|
+
if (classifierType.endsWith("-color")) {
|
|
1191
|
+
const colors = getValuesFromExression(currentItemPaint)?.slice?.(0, -1);
|
|
1192
|
+
const defaultColor = getValuesFromExression(currentItemPaint)?.slice?.(-1)?.[0];
|
|
1193
|
+
presets = {
|
|
1194
|
+
colors,
|
|
1195
|
+
defaultColor,
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
else {
|
|
1199
|
+
const values = getValuesFromExression(currentItemPaint)?.slice?.(0, -1);
|
|
1200
|
+
const defaultValue = getValuesFromExression(currentItemPaint)?.slice?.(-1)?.[0];
|
|
1201
|
+
presets = {
|
|
1202
|
+
values,
|
|
1203
|
+
defaultValue,
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return {
|
|
1208
|
+
...composeClassification(expressionType, currentItemPaint),
|
|
1209
|
+
presets,
|
|
1210
|
+
style,
|
|
1211
|
+
};
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
const getPaintItemType = (classifierType) => {
|
|
1215
|
+
switch (classifierType) {
|
|
1216
|
+
case exports.StylingClassifierTypes.FillColor:
|
|
1217
|
+
return "fill";
|
|
1218
|
+
case exports.StylingClassifierTypes.CircleColor:
|
|
1219
|
+
case exports.StylingClassifierTypes.CircleStrokeColor:
|
|
1220
|
+
case exports.StylingClassifierTypes.CircleRadius:
|
|
1221
|
+
case exports.StylingClassifierTypes.CircleStrokeWidth:
|
|
1222
|
+
case exports.StylingClassifierTypes.CircleBlur:
|
|
1223
|
+
return "circle";
|
|
1224
|
+
case exports.StylingClassifierTypes.LineColor:
|
|
1225
|
+
case exports.StylingClassifierTypes.LineWidth:
|
|
1226
|
+
case exports.StylingClassifierTypes.LineBlur:
|
|
1227
|
+
return "line";
|
|
1228
|
+
default:
|
|
1229
|
+
return classifierType;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
const getClassificationForTypeArray = (clientStyle, classifierTypes = [], specPropKey) => {
|
|
1233
|
+
return classifierTypes.reduce((acc, curr) => {
|
|
1234
|
+
const styleItem = clientStyle?.items?.find(item => item.type === getPaintItemType(curr));
|
|
1235
|
+
return {
|
|
1236
|
+
...acc,
|
|
1237
|
+
[curr]: getClassificationFromExpression(clientStyle, styleItem?.id, curr, specPropKey, styleItem),
|
|
1238
|
+
};
|
|
1239
|
+
}, {});
|
|
1240
|
+
};
|
|
1241
|
+
const getClassificationList = (layer, clientStyle) => {
|
|
1242
|
+
if (!layer || !clientStyle) {
|
|
1243
|
+
return {};
|
|
1244
|
+
}
|
|
1245
|
+
const layerConfiguration = layer?.configuration;
|
|
1246
|
+
switch (layerConfiguration?.geometryType) {
|
|
1247
|
+
case api.OgcGeometryType.Polygon:
|
|
1248
|
+
case api.OgcGeometryType.MultiPolygon:
|
|
1249
|
+
return getClassificationForTypeArray(clientStyle, [exports.StylingClassifierTypes.FillColor], "paint");
|
|
1250
|
+
case api.OgcGeometryType.Point:
|
|
1251
|
+
case api.OgcGeometryType.MultiPoint:
|
|
1252
|
+
return getClassificationForTypeArray(clientStyle, [
|
|
1253
|
+
exports.StylingClassifierTypes.CircleColor,
|
|
1254
|
+
exports.StylingClassifierTypes.CircleRadius,
|
|
1255
|
+
exports.StylingClassifierTypes.CircleStrokeColor,
|
|
1256
|
+
exports.StylingClassifierTypes.CircleStrokeWidth,
|
|
1257
|
+
], "paint");
|
|
1258
|
+
case api.OgcGeometryType.LineString:
|
|
1259
|
+
case api.OgcGeometryType.MultiLineString:
|
|
1260
|
+
return getClassificationForTypeArray(clientStyle, [exports.StylingClassifierTypes.LineColor, exports.StylingClassifierTypes.LineWidth], "paint");
|
|
1261
|
+
default:
|
|
1262
|
+
return {};
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
const getInterpolateStops = (expression, previousStops) => {
|
|
1267
|
+
const clientStyleValidator = new ClientStyleValidator();
|
|
1268
|
+
if (!clientStyleValidator.isZoomInterpolate(expression)) {
|
|
1269
|
+
return [];
|
|
1270
|
+
}
|
|
1271
|
+
const slicedValue = Array.isArray(expression) ? expression.slice(3) : undefined;
|
|
1272
|
+
return Array.isArray(expression)
|
|
1273
|
+
? lodash.orderBy(slicedValue?.reduce((acc, curr, currIndex) => {
|
|
1274
|
+
if (currIndex % 2 === 0) {
|
|
1275
|
+
const updatedOutput = slicedValue?.[currIndex + 1];
|
|
1276
|
+
const previousIdenticalStop = previousStops?.find(previousStop => lodash.isEqual(previousStop.input, curr) && lodash.isEqual(previousStop.output, updatedOutput));
|
|
1277
|
+
return [
|
|
1278
|
+
...acc,
|
|
1279
|
+
{ id: previousIdenticalStop ? previousIdenticalStop.id : uuid.v4(), input: curr, output: updatedOutput },
|
|
1280
|
+
];
|
|
1281
|
+
}
|
|
1282
|
+
return acc;
|
|
1283
|
+
}, []), "input", "asc")
|
|
1284
|
+
: [];
|
|
1285
|
+
};
|
|
1286
|
+
|
|
839
1287
|
const getLayerClientStyle = (layer) => {
|
|
840
1288
|
const clientStyle = layer?.configuration?.clientStyle;
|
|
841
1289
|
return {
|
|
@@ -869,6 +1317,34 @@ const getStyleAttributes = (style) => {
|
|
|
869
1317
|
}, []);
|
|
870
1318
|
};
|
|
871
1319
|
|
|
1320
|
+
const ICON_CLASSIFIERS = [exports.StylingClassifierTypes.IconImage];
|
|
1321
|
+
const resyncStyleIcons = (clientStyle) => {
|
|
1322
|
+
if (!clientStyle) {
|
|
1323
|
+
return {};
|
|
1324
|
+
}
|
|
1325
|
+
const usedIcons = ICON_CLASSIFIERS.reduce((acc, curr) => {
|
|
1326
|
+
return [
|
|
1327
|
+
...acc,
|
|
1328
|
+
...clientStyle.items.reduce((itemsAcc, itemsCurr) => {
|
|
1329
|
+
const currentClassifier = itemsCurr.layout?.[curr] || itemsCurr.paint?.[curr];
|
|
1330
|
+
if (Array.isArray(currentClassifier)) {
|
|
1331
|
+
return [...itemsAcc, ...getValuesFromExression(currentClassifier)];
|
|
1332
|
+
}
|
|
1333
|
+
if (typeof currentClassifier === "string") {
|
|
1334
|
+
return [...itemsAcc, currentClassifier];
|
|
1335
|
+
}
|
|
1336
|
+
return itemsAcc;
|
|
1337
|
+
}, []),
|
|
1338
|
+
];
|
|
1339
|
+
}, []);
|
|
1340
|
+
return {
|
|
1341
|
+
...clientStyle,
|
|
1342
|
+
icons: Array.isArray(clientStyle.icons)
|
|
1343
|
+
? clientStyle.icons.filter(icon => usedIcons.includes(icon.name))
|
|
1344
|
+
: undefined,
|
|
1345
|
+
};
|
|
1346
|
+
};
|
|
1347
|
+
|
|
872
1348
|
const DEFAULT_COLOR = "#00ffff";
|
|
873
1349
|
const DEFAULT_BLUR = 0;
|
|
874
1350
|
const DEFAULT_OPACITY = 0.5;
|
|
@@ -1807,6 +2283,8 @@ const colorToHex = (color) => {
|
|
|
1807
2283
|
return hex.slice(HEX_RRGGBB_LENGTH).toLowerCase() === OPAQUE_ALPHA ? hex.slice(0, HEX_RRGGBB_LENGTH) : hex;
|
|
1808
2284
|
};
|
|
1809
2285
|
|
|
2286
|
+
const createEqualIntervals = (length, min, max) => Array.from({ length }, (_, index) => min + index * ((max - min) / (length - 1)));
|
|
2287
|
+
|
|
1810
2288
|
const NO_CONTENT_VALUE = "—";
|
|
1811
2289
|
exports.DateFormat = void 0;
|
|
1812
2290
|
(function (DateFormat) {
|
|
@@ -2513,17 +2991,6 @@ class SchemaResolver {
|
|
|
2513
2991
|
}
|
|
2514
2992
|
}
|
|
2515
2993
|
|
|
2516
|
-
exports.EditGeometryType = void 0;
|
|
2517
|
-
(function (EditGeometryType) {
|
|
2518
|
-
EditGeometryType["Raster"] = "raster";
|
|
2519
|
-
})(exports.EditGeometryType || (exports.EditGeometryType = {}));
|
|
2520
|
-
|
|
2521
|
-
exports.ThemeName = void 0;
|
|
2522
|
-
(function (ThemeName) {
|
|
2523
|
-
ThemeName["Light"] = "light";
|
|
2524
|
-
ThemeName["Dark"] = "dark";
|
|
2525
|
-
})(exports.ThemeName || (exports.ThemeName = {}));
|
|
2526
|
-
|
|
2527
2994
|
exports.ARRAY_ITEM_OBJECT_OPTIONS = ARRAY_ITEM_OBJECT_OPTIONS;
|
|
2528
2995
|
exports.COMPACT_FRACTION_DIGITS = COMPACT_FRACTION_DIGITS;
|
|
2529
2996
|
exports.ClientStyleValidator = ClientStyleValidator;
|
|
@@ -2571,9 +3038,13 @@ exports.TIME_ZONE_FORMAT = TIME_ZONE_FORMAT;
|
|
|
2571
3038
|
exports.adjustColor = adjustColor;
|
|
2572
3039
|
exports.buildDefaultForSchema = buildDefaultForSchema;
|
|
2573
3040
|
exports.colorToHex = colorToHex;
|
|
3041
|
+
exports.combineInterpolateStops = combineInterpolateStops;
|
|
3042
|
+
exports.createEqualIntervals = createEqualIntervals;
|
|
2574
3043
|
exports.dateOptions = dateOptions;
|
|
2575
3044
|
exports.debounce = debounce;
|
|
2576
3045
|
exports.decimalOpacityToHex = decimalOpacityToHex;
|
|
3046
|
+
exports.decodeConcat = decodeConcat;
|
|
3047
|
+
exports.encodeConcat = encodeConcat;
|
|
2577
3048
|
exports.enrichStyleItemsWithIds = enrichStyleItemsWithIds;
|
|
2578
3049
|
exports.enrichStyleModelsWithIds = enrichStyleModelsWithIds;
|
|
2579
3050
|
exports.findAttributeInExpression = findAttributeInExpression;
|
|
@@ -2585,13 +3056,17 @@ exports.formatNumber = formatNumber;
|
|
|
2585
3056
|
exports.formatPolygonMeasure = formatPolygonMeasure;
|
|
2586
3057
|
exports.geometryToEwkt = geometryToEwkt;
|
|
2587
3058
|
exports.getActualExtrusionHeight = getActualExtrusionHeight;
|
|
3059
|
+
exports.getClassificationFromExpression = getClassificationFromExpression;
|
|
3060
|
+
exports.getClassificationList = getClassificationList;
|
|
2588
3061
|
exports.getClientStyleItemId = getClientStyleItemId;
|
|
2589
3062
|
exports.getDate = getDate;
|
|
2590
3063
|
exports.getGradientColors = getGradientColors;
|
|
3064
|
+
exports.getInterpolateStops = getInterpolateStops;
|
|
2591
3065
|
exports.getLayerClientStyle = getLayerClientStyle;
|
|
2592
3066
|
exports.getMapView = getMapView;
|
|
2593
3067
|
exports.getPrimaryType = getPrimaryType;
|
|
2594
3068
|
exports.getStyleAttributes = getStyleAttributes;
|
|
3069
|
+
exports.getValuesFromExression = getValuesFromExression;
|
|
2595
3070
|
exports.hexToRgba = hexToRgba;
|
|
2596
3071
|
exports.isLayerService = isLayerService;
|
|
2597
3072
|
exports.isNumeric = isNumeric;
|
|
@@ -2604,6 +3079,7 @@ exports.parseIconNames = parseIconNames;
|
|
|
2604
3079
|
exports.parseIconNamesFromClientStyle = parseIconNamesFromClientStyle;
|
|
2605
3080
|
exports.parseMapStyle = parseMapStyle;
|
|
2606
3081
|
exports.pointOptions = pointOptions;
|
|
3082
|
+
exports.resyncStyleIcons = resyncStyleIcons;
|
|
2607
3083
|
exports.rgbToHex = rgbToHex;
|
|
2608
3084
|
exports.roundTotalSum = roundTotalSum;
|
|
2609
3085
|
exports.stretchPalette = stretchPalette;
|