@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/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Everpoint
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Everpoint
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# @evergis/common
|
|
1
|
+
# @evergis/common
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './concat';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ClientStyle, Classification, EditableItemProp, StylingClassifierTypes } from '../types';
|
|
2
|
+
export declare const getClassificationFromExpression: (style: ClientStyle, itemId: string, classifierType: StylingClassifierTypes, specPropKey: EditableItemProp, styleItem?: ClientStyle["items"][number], stopIndex?: number) => Classification;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { QueryLayerServiceInfoDc } from '@evergis/api';
|
|
2
|
+
import { ClientStyle, Classification, StylingClassifierTypes } from '../types';
|
|
3
|
+
export declare const getClassificationList: (layer?: QueryLayerServiceInfoDc, clientStyle?: ClientStyle) => Record<StylingClassifierTypes, Classification>;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
export * from './ClientStyleValidator';
|
|
2
|
+
export * from './expressions';
|
|
3
|
+
export * from './combineInterpolateStops';
|
|
2
4
|
export * from './enrichStyleItemsWithIds';
|
|
3
5
|
export * from './getClientStyleItemId';
|
|
4
6
|
export * from './enrichStyleModelsWithIds';
|
|
5
7
|
export * from './findAttributeInExpression';
|
|
6
8
|
export * from './getActualExtrusionHeight';
|
|
9
|
+
export * from './getClassificationFromExpression';
|
|
10
|
+
export * from './getClassificationList';
|
|
11
|
+
export * from './getInterpolateStops';
|
|
7
12
|
export * from './getLayerClientStyle';
|
|
8
13
|
export * from './getStyleAttributes';
|
|
14
|
+
export * from './getValuesFromExression';
|
|
15
|
+
export * from './resyncStyleIcons';
|
package/dist/common.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { expression } from '@mapbox/mapbox-gl-style-spec';
|
|
2
|
-
import { isNil, isEmpty, isEqual, isObject as isObject$1 } from 'lodash';
|
|
2
|
+
import { isNil, isEmpty, isEqual, isObject as isObject$1, orderBy } from 'lodash';
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
|
+
import { ClassifyAttributeType, ClassificationType, OgcGeometryType, AttributeType } from '@evergis/api';
|
|
4
5
|
import { toMercator, bboxPolygon } from '@turf/turf';
|
|
5
6
|
import { parseJSON, parseISO, isValid, toDate, format } from 'date-fns';
|
|
6
7
|
import { ru, enUS } from 'date-fns/locale';
|
|
7
|
-
import { AttributeType } from '@evergis/api';
|
|
8
8
|
import { stringify } from 'wkt';
|
|
9
9
|
|
|
10
10
|
/* ---------------------------------------------------------------------------------------------------------------- *
|
|
@@ -775,6 +775,51 @@ class ClientStyleValidator {
|
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
777
|
|
|
778
|
+
const ENCODE_REGEXP = /\{[a-zA-Z]+[a-zA-Z0-9_]+\}/g;
|
|
779
|
+
const encodeConcat = (value) => {
|
|
780
|
+
if (!value) {
|
|
781
|
+
return "";
|
|
782
|
+
}
|
|
783
|
+
const matches = value.match(ENCODE_REGEXP);
|
|
784
|
+
if (matches === null || matches.length === 0) {
|
|
785
|
+
return value;
|
|
786
|
+
}
|
|
787
|
+
const splits = value.split(ENCODE_REGEXP);
|
|
788
|
+
return [
|
|
789
|
+
"concat",
|
|
790
|
+
...splits.reduce((acc, curr, currentIndex) => {
|
|
791
|
+
if (currentIndex < splits.length - 1) {
|
|
792
|
+
return [...acc, curr, ["get", matches[currentIndex].slice(1, -1)]];
|
|
793
|
+
}
|
|
794
|
+
return [...acc, curr];
|
|
795
|
+
}, []),
|
|
796
|
+
];
|
|
797
|
+
};
|
|
798
|
+
const decodeConcat = (value) => {
|
|
799
|
+
if (!value) {
|
|
800
|
+
return "";
|
|
801
|
+
}
|
|
802
|
+
if (!Array.isArray(value)) {
|
|
803
|
+
return value;
|
|
804
|
+
}
|
|
805
|
+
if (value[0] !== "concat") {
|
|
806
|
+
return "";
|
|
807
|
+
}
|
|
808
|
+
return value.slice(1).reduce((acc, curr) => {
|
|
809
|
+
if (typeof curr === "string") {
|
|
810
|
+
return [...acc, curr];
|
|
811
|
+
}
|
|
812
|
+
if (Array.isArray(curr) && curr.length === 2 && curr[0] === "get") {
|
|
813
|
+
return [...acc, `{${curr[1]}}`];
|
|
814
|
+
}
|
|
815
|
+
return acc;
|
|
816
|
+
}, []).join("");
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
const combineInterpolateStops = (stops) => {
|
|
820
|
+
return stops.reduce((acc, curr) => [...acc, curr.input, curr.output], []);
|
|
821
|
+
};
|
|
822
|
+
|
|
778
823
|
const enrichStyleItemsWithIds = (style) => {
|
|
779
824
|
return {
|
|
780
825
|
...style,
|
|
@@ -834,6 +879,409 @@ const getActualExtrusionHeight = (paint) => {
|
|
|
834
879
|
: paint?.["fill-extrusion-height"];
|
|
835
880
|
};
|
|
836
881
|
|
|
882
|
+
var EditGeometryType;
|
|
883
|
+
(function (EditGeometryType) {
|
|
884
|
+
EditGeometryType["Raster"] = "raster";
|
|
885
|
+
})(EditGeometryType || (EditGeometryType = {}));
|
|
886
|
+
|
|
887
|
+
var StylingClassifierTypes;
|
|
888
|
+
(function (StylingClassifierTypes) {
|
|
889
|
+
// circle
|
|
890
|
+
StylingClassifierTypes["CircleColor"] = "circle-color";
|
|
891
|
+
StylingClassifierTypes["CircleOpacity"] = "circle-opacity";
|
|
892
|
+
StylingClassifierTypes["CircleStrokeColor"] = "circle-stroke-color";
|
|
893
|
+
StylingClassifierTypes["CircleStrokeOpacity"] = "circle-stroke-opacity";
|
|
894
|
+
StylingClassifierTypes["CircleRadius"] = "circle-radius";
|
|
895
|
+
StylingClassifierTypes["CircleStrokeWidth"] = "circle-stroke-width";
|
|
896
|
+
StylingClassifierTypes["CircleBlur"] = "circle-blur";
|
|
897
|
+
StylingClassifierTypes["CircleTranslate"] = "circle-translate";
|
|
898
|
+
// fill
|
|
899
|
+
StylingClassifierTypes["FillColor"] = "fill-color";
|
|
900
|
+
StylingClassifierTypes["FillOpacity"] = "fill-opacity";
|
|
901
|
+
// fill-extrusion
|
|
902
|
+
StylingClassifierTypes["FillExtrusionColor"] = "fill-extrusion-color";
|
|
903
|
+
StylingClassifierTypes["FillExtrusionOpacity"] = "fill-extrusion-opacity";
|
|
904
|
+
StylingClassifierTypes["FillExtrusionBase"] = "fill-extrusion-base";
|
|
905
|
+
StylingClassifierTypes["FillExtrusionHeight"] = "fill-extrusion-height";
|
|
906
|
+
// line
|
|
907
|
+
StylingClassifierTypes["LineColor"] = "line-color";
|
|
908
|
+
StylingClassifierTypes["LineOpacity"] = "line-opacity";
|
|
909
|
+
StylingClassifierTypes["LineWidth"] = "line-width";
|
|
910
|
+
StylingClassifierTypes["LineBlur"] = "line-blur";
|
|
911
|
+
StylingClassifierTypes["LineDasharray"] = "line-dasharray";
|
|
912
|
+
StylingClassifierTypes["LineCap"] = "line-cap";
|
|
913
|
+
StylingClassifierTypes["LineJoin"] = "line-join";
|
|
914
|
+
StylingClassifierTypes["LineTranslate"] = "line-translate";
|
|
915
|
+
// icon
|
|
916
|
+
StylingClassifierTypes["IconImage"] = "icon-image";
|
|
917
|
+
StylingClassifierTypes["IconSize"] = "icon-size";
|
|
918
|
+
StylingClassifierTypes["IconColor"] = "icon-color";
|
|
919
|
+
StylingClassifierTypes["IconOpacity"] = "icon-opacity";
|
|
920
|
+
StylingClassifierTypes["IconTranslate"] = "icon-translate";
|
|
921
|
+
StylingClassifierTypes["IconHaloColor"] = "icon-halo-color";
|
|
922
|
+
StylingClassifierTypes["IconHaloWidth"] = "icon-halo-width";
|
|
923
|
+
StylingClassifierTypes["IconHaloBlur"] = "icon-halo-blur";
|
|
924
|
+
StylingClassifierTypes["IconOverlap"] = "icon-overlap";
|
|
925
|
+
StylingClassifierTypes["IconAnchor"] = "icon-anchor";
|
|
926
|
+
StylingClassifierTypes["IconRotate"] = "icon-rotate";
|
|
927
|
+
StylingClassifierTypes["IconPadding"] = "icon-padding";
|
|
928
|
+
// text
|
|
929
|
+
StylingClassifierTypes["TextField"] = "text-field";
|
|
930
|
+
StylingClassifierTypes["TextColor"] = "text-color";
|
|
931
|
+
StylingClassifierTypes["TextOpacity"] = "text-opacity";
|
|
932
|
+
StylingClassifierTypes["TextFont"] = "text-font";
|
|
933
|
+
StylingClassifierTypes["TextSize"] = "text-size";
|
|
934
|
+
StylingClassifierTypes["TextTransform"] = "text-transform";
|
|
935
|
+
StylingClassifierTypes["TextAnchor"] = "text-anchor";
|
|
936
|
+
StylingClassifierTypes["TextJustify"] = "text-justify";
|
|
937
|
+
StylingClassifierTypes["TextTranslate"] = "text-translate";
|
|
938
|
+
StylingClassifierTypes["TextHaloColor"] = "text-halo-color";
|
|
939
|
+
StylingClassifierTypes["TextHaloWidth"] = "text-halo-width";
|
|
940
|
+
StylingClassifierTypes["TextHaloBlur"] = "text-halo-blur";
|
|
941
|
+
// symbol
|
|
942
|
+
StylingClassifierTypes["SymbolPlacement"] = "symbol-placement";
|
|
943
|
+
StylingClassifierTypes["SymbolSpacing"] = "symbol-spacing";
|
|
944
|
+
// heatmap
|
|
945
|
+
StylingClassifierTypes["HeatmapColor"] = "heatmap-color";
|
|
946
|
+
StylingClassifierTypes["HeatmapOpacity"] = "heatmap-opacity";
|
|
947
|
+
StylingClassifierTypes["HeatmapRadius"] = "heatmap-radius";
|
|
948
|
+
StylingClassifierTypes["HeatmapIntensity"] = "heatmap-intensity";
|
|
949
|
+
StylingClassifierTypes["HeatmapWeight"] = "heatmap-weight";
|
|
950
|
+
})(StylingClassifierTypes || (StylingClassifierTypes = {}));
|
|
951
|
+
var ClassificationExpressionType;
|
|
952
|
+
(function (ClassificationExpressionType) {
|
|
953
|
+
ClassificationExpressionType["Match"] = "match";
|
|
954
|
+
ClassificationExpressionType["Case"] = "case";
|
|
955
|
+
ClassificationExpressionType["Step"] = "step";
|
|
956
|
+
ClassificationExpressionType["Interpolate"] = "interpolate";
|
|
957
|
+
})(ClassificationExpressionType || (ClassificationExpressionType = {}));
|
|
958
|
+
var ClassificationExpressionSubtype;
|
|
959
|
+
(function (ClassificationExpressionSubtype) {
|
|
960
|
+
ClassificationExpressionSubtype["Linear"] = "linear";
|
|
961
|
+
ClassificationExpressionSubtype["Exponential"] = "exponential";
|
|
962
|
+
ClassificationExpressionSubtype["CubicBezier"] = "cubic-bezier";
|
|
963
|
+
})(ClassificationExpressionSubtype || (ClassificationExpressionSubtype = {}));
|
|
964
|
+
var ClassificationExtraAlgorithms;
|
|
965
|
+
(function (ClassificationExtraAlgorithms) {
|
|
966
|
+
ClassificationExtraAlgorithms["Interpolate"] = "interpolate";
|
|
967
|
+
})(ClassificationExtraAlgorithms || (ClassificationExtraAlgorithms = {}));
|
|
968
|
+
|
|
969
|
+
var ThemeName;
|
|
970
|
+
(function (ThemeName) {
|
|
971
|
+
ThemeName["Light"] = "light";
|
|
972
|
+
ThemeName["Dark"] = "dark";
|
|
973
|
+
})(ThemeName || (ThemeName = {}));
|
|
974
|
+
|
|
975
|
+
const getValuesFromExression = (expression, modifier) => {
|
|
976
|
+
if (!Array.isArray(expression)) {
|
|
977
|
+
return [expression];
|
|
978
|
+
}
|
|
979
|
+
const expressionType = expression[0];
|
|
980
|
+
let id = 0;
|
|
981
|
+
switch (expressionType) {
|
|
982
|
+
case ClassificationExpressionType.Match:
|
|
983
|
+
return expression.slice(3).reduce((acc, curr, currIndex) => {
|
|
984
|
+
return currIndex % 2 === 0 || currIndex === expression.slice(3).length - 1
|
|
985
|
+
? [...acc, modifier ? modifier(curr, id++) : curr]
|
|
986
|
+
: acc;
|
|
987
|
+
}, []);
|
|
988
|
+
case ClassificationExpressionType.Step:
|
|
989
|
+
return expression.slice(2).reduce((acc, curr, currIndex) => {
|
|
990
|
+
return currIndex % 2 === 0 ? [...acc, modifier ? modifier(curr, id++) : curr] : acc;
|
|
991
|
+
}, []);
|
|
992
|
+
case ClassificationExpressionType.Interpolate:
|
|
993
|
+
return expression.slice(3).reduce((acc, curr, currIndex) => {
|
|
994
|
+
return currIndex % 2 !== 0 ? [...acc, modifier ? modifier(curr, id++) : curr] : acc;
|
|
995
|
+
}, []);
|
|
996
|
+
default:
|
|
997
|
+
return expression.slice(2).reduce((acc, curr, currIndex) => {
|
|
998
|
+
return currIndex % 2 === 0 || currIndex === expression.slice(2).length - 1
|
|
999
|
+
? [...acc, modifier ? modifier(curr, id++) : curr]
|
|
1000
|
+
: acc;
|
|
1001
|
+
}, []);
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
|
|
1005
|
+
const composeClassification = (expressionType, itemPaint) => {
|
|
1006
|
+
const getAtttibuteName = () => {
|
|
1007
|
+
switch (expressionType) {
|
|
1008
|
+
case ClassificationExpressionType.Case:
|
|
1009
|
+
return itemPaint?.[1]?.[1]?.[1]?.[1];
|
|
1010
|
+
case ClassificationExpressionType.Match:
|
|
1011
|
+
case ClassificationExpressionType.Step:
|
|
1012
|
+
return itemPaint?.[1]?.[1];
|
|
1013
|
+
case ClassificationExpressionType.Interpolate:
|
|
1014
|
+
return itemPaint?.[2]?.[1];
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
const getClassifyType = () => {
|
|
1018
|
+
switch (expressionType) {
|
|
1019
|
+
case ClassificationExpressionType.Case:
|
|
1020
|
+
return typeof itemPaint?.[1]?.[1]?.[2] === "number"
|
|
1021
|
+
? ClassifyAttributeType.Decimal
|
|
1022
|
+
: ClassifyAttributeType.Text;
|
|
1023
|
+
case ClassificationExpressionType.Match:
|
|
1024
|
+
return typeof itemPaint?.[2] === "number" ? ClassifyAttributeType.Decimal : ClassifyAttributeType.Text;
|
|
1025
|
+
case ClassificationExpressionType.Step:
|
|
1026
|
+
return typeof itemPaint?.[3] === "number" ? ClassifyAttributeType.Decimal : ClassifyAttributeType.Text;
|
|
1027
|
+
case ClassificationExpressionType.Interpolate:
|
|
1028
|
+
return ClassifyAttributeType.Decimal;
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
const getAlgorithm = () => {
|
|
1032
|
+
switch (expressionType) {
|
|
1033
|
+
case ClassificationExpressionType.Case:
|
|
1034
|
+
return ClassificationType.None;
|
|
1035
|
+
case ClassificationExpressionType.Match:
|
|
1036
|
+
return ClassificationType.Unique;
|
|
1037
|
+
case ClassificationExpressionType.Step:
|
|
1038
|
+
return ClassificationType.None;
|
|
1039
|
+
case ClassificationExpressionType.Interpolate:
|
|
1040
|
+
return ClassificationExtraAlgorithms.Interpolate;
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
const getClassifyDataResult = () => {
|
|
1044
|
+
switch (expressionType) {
|
|
1045
|
+
case ClassificationExpressionType.Case:
|
|
1046
|
+
return itemPaint?.slice?.(1)?.reduce?.((acc, curr, currIndex) => {
|
|
1047
|
+
if (currIndex === 0) {
|
|
1048
|
+
return [...acc, { value: curr?.[1]?.[2] }, { value: curr?.[2]?.[2] }];
|
|
1049
|
+
}
|
|
1050
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice?.(1)?.length - 1
|
|
1051
|
+
? [...acc, { value: curr?.[2]?.[2] }]
|
|
1052
|
+
: acc;
|
|
1053
|
+
}, []);
|
|
1054
|
+
case ClassificationExpressionType.Match:
|
|
1055
|
+
return itemPaint?.slice?.(2)?.reduce?.((acc, curr, currIndex) => {
|
|
1056
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice(2)?.length - 1 ? [...acc, { value: curr }] : acc;
|
|
1057
|
+
}, []);
|
|
1058
|
+
case ClassificationExpressionType.Step:
|
|
1059
|
+
return itemPaint?.slice?.(2)?.reduce?.((acc, curr, currIndex) => {
|
|
1060
|
+
return currIndex % 2 === 0 ? [...acc, { value: curr }] : acc;
|
|
1061
|
+
}, []);
|
|
1062
|
+
case ClassificationExpressionType.Interpolate:
|
|
1063
|
+
return itemPaint?.slice?.(3)?.reduce?.((acc, curr, currIndex) => {
|
|
1064
|
+
return currIndex % 2 === 0 ? [...acc, { value: curr }] : acc;
|
|
1065
|
+
}, []);
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
const getClassifyDataType = () => {
|
|
1069
|
+
switch (expressionType) {
|
|
1070
|
+
case ClassificationExpressionType.Case:
|
|
1071
|
+
return typeof itemPaint?.[1]?.[1]?.[2] === "number" ? "Decimal" : "String";
|
|
1072
|
+
case ClassificationExpressionType.Match:
|
|
1073
|
+
return typeof itemPaint?.[2] === "number" ? "Decimal" : "String";
|
|
1074
|
+
case ClassificationExpressionType.Step:
|
|
1075
|
+
return typeof itemPaint?.[3] === "number" ? "Decimal" : "String";
|
|
1076
|
+
case ClassificationExpressionType.Interpolate:
|
|
1077
|
+
return "Decimal";
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
const getClassifyRanges = () => {
|
|
1081
|
+
switch (expressionType) {
|
|
1082
|
+
case ClassificationExpressionType.Case:
|
|
1083
|
+
return itemPaint?.slice?.(1)?.reduce?.((acc, curr, currIndex) => {
|
|
1084
|
+
if (currIndex === 0) {
|
|
1085
|
+
return [
|
|
1086
|
+
...acc,
|
|
1087
|
+
{
|
|
1088
|
+
from: curr?.find?.(item => Array.isArray(item) && [">=", ">"].includes(item[0]))?.[2] ?? null,
|
|
1089
|
+
to: curr?.find?.(item => Array.isArray(item) && ["<=", "<"].includes(item[0]))?.[2] ?? null,
|
|
1090
|
+
},
|
|
1091
|
+
];
|
|
1092
|
+
}
|
|
1093
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice?.(1)?.length - 1
|
|
1094
|
+
? [
|
|
1095
|
+
...acc,
|
|
1096
|
+
{
|
|
1097
|
+
from: curr?.find?.(item => Array.isArray(item) && [">=", ">"].includes(item[0]))?.[2] ?? null,
|
|
1098
|
+
to: curr?.find?.(item => Array.isArray(item) && ["<=", "<"].includes(item[0]))?.[2] ?? null,
|
|
1099
|
+
},
|
|
1100
|
+
]
|
|
1101
|
+
: acc;
|
|
1102
|
+
}, []);
|
|
1103
|
+
case ClassificationExpressionType.Step: {
|
|
1104
|
+
const slicedExpression = itemPaint?.slice?.(3);
|
|
1105
|
+
return slicedExpression?.reduce?.((acc, curr, currIndex) => {
|
|
1106
|
+
if (currIndex === 0) {
|
|
1107
|
+
return [
|
|
1108
|
+
...acc,
|
|
1109
|
+
{
|
|
1110
|
+
from: null,
|
|
1111
|
+
to: curr ?? null,
|
|
1112
|
+
},
|
|
1113
|
+
];
|
|
1114
|
+
}
|
|
1115
|
+
return currIndex % 2 === 0 && currIndex !== itemPaint?.slice?.(1)?.length - 1
|
|
1116
|
+
? [
|
|
1117
|
+
...acc,
|
|
1118
|
+
{
|
|
1119
|
+
from: slicedExpression[currIndex - 2] ?? null,
|
|
1120
|
+
to: curr ?? null,
|
|
1121
|
+
},
|
|
1122
|
+
]
|
|
1123
|
+
: acc;
|
|
1124
|
+
}, []);
|
|
1125
|
+
}
|
|
1126
|
+
default:
|
|
1127
|
+
return [];
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
return {
|
|
1131
|
+
expressionType,
|
|
1132
|
+
algorithm: getAlgorithm(),
|
|
1133
|
+
attributeName: getAtttibuteName(),
|
|
1134
|
+
classifyData: {
|
|
1135
|
+
classifyResult: getClassifyDataResult(),
|
|
1136
|
+
type: getClassifyDataType(),
|
|
1137
|
+
},
|
|
1138
|
+
classifyRanges: getClassifyRanges(),
|
|
1139
|
+
classifyType: getClassifyType(),
|
|
1140
|
+
};
|
|
1141
|
+
};
|
|
1142
|
+
const getClassificationFromExpression = (style, itemId, classifierType, specPropKey, styleItem, stopIndex) => {
|
|
1143
|
+
const clientStyleValidator = new ClientStyleValidator();
|
|
1144
|
+
if (!style || (!itemId && !styleItem)) {
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
const currentItem = styleItem ?? style.items?.find(item => item.id === itemId);
|
|
1148
|
+
const rawCurrentItem = currentItem?.[specPropKey]?.[classifierType];
|
|
1149
|
+
const currentItemPaint = stopIndex !== undefined && clientStyleValidator.isZoomInterpolate(rawCurrentItem)
|
|
1150
|
+
? rawCurrentItem.slice(3).filter((_, i) => i % 2 !== 0)?.[stopIndex]
|
|
1151
|
+
: currentItem?.[specPropKey]?.[classifierType];
|
|
1152
|
+
const expressionType = Array.isArray(currentItemPaint)
|
|
1153
|
+
? currentItemPaint?.[0]
|
|
1154
|
+
: undefined;
|
|
1155
|
+
let presets = {};
|
|
1156
|
+
if (expressionType === ClassificationExpressionType.Interpolate) {
|
|
1157
|
+
const expressionSubtype = currentItemPaint?.[1]?.[0];
|
|
1158
|
+
const slicedExpression = currentItemPaint?.slice(3);
|
|
1159
|
+
presets = {
|
|
1160
|
+
...presets,
|
|
1161
|
+
interpolate: {
|
|
1162
|
+
expressionSubtype,
|
|
1163
|
+
expressionOptions: {
|
|
1164
|
+
[ClassificationExtraAlgorithms.Interpolate]: {
|
|
1165
|
+
[ClassificationExpressionSubtype.Exponential]: expressionSubtype === ClassificationExpressionSubtype.Exponential
|
|
1166
|
+
? {
|
|
1167
|
+
base: currentItemPaint?.[1]?.[1],
|
|
1168
|
+
}
|
|
1169
|
+
: undefined,
|
|
1170
|
+
[ClassificationExpressionSubtype.CubicBezier]: expressionSubtype === ClassificationExpressionSubtype.CubicBezier
|
|
1171
|
+
? {
|
|
1172
|
+
x1: currentItemPaint?.[1]?.[1],
|
|
1173
|
+
y1: currentItemPaint?.[1]?.[2],
|
|
1174
|
+
x2: currentItemPaint?.[1]?.[3],
|
|
1175
|
+
y2: currentItemPaint?.[1]?.[4],
|
|
1176
|
+
}
|
|
1177
|
+
: undefined,
|
|
1178
|
+
},
|
|
1179
|
+
},
|
|
1180
|
+
stops: Array.from({ length: slicedExpression.length / 2 }, (_, index) => ({
|
|
1181
|
+
input: slicedExpression[index * 2],
|
|
1182
|
+
output: slicedExpression[index * 2 + 1],
|
|
1183
|
+
})),
|
|
1184
|
+
},
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
if (classifierType.endsWith("-color")) {
|
|
1189
|
+
const colors = getValuesFromExression(currentItemPaint)?.slice?.(0, -1);
|
|
1190
|
+
const defaultColor = getValuesFromExression(currentItemPaint)?.slice?.(-1)?.[0];
|
|
1191
|
+
presets = {
|
|
1192
|
+
colors,
|
|
1193
|
+
defaultColor,
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
const values = getValuesFromExression(currentItemPaint)?.slice?.(0, -1);
|
|
1198
|
+
const defaultValue = getValuesFromExression(currentItemPaint)?.slice?.(-1)?.[0];
|
|
1199
|
+
presets = {
|
|
1200
|
+
values,
|
|
1201
|
+
defaultValue,
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return {
|
|
1206
|
+
...composeClassification(expressionType, currentItemPaint),
|
|
1207
|
+
presets,
|
|
1208
|
+
style,
|
|
1209
|
+
};
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
const getPaintItemType = (classifierType) => {
|
|
1213
|
+
switch (classifierType) {
|
|
1214
|
+
case StylingClassifierTypes.FillColor:
|
|
1215
|
+
return "fill";
|
|
1216
|
+
case StylingClassifierTypes.CircleColor:
|
|
1217
|
+
case StylingClassifierTypes.CircleStrokeColor:
|
|
1218
|
+
case StylingClassifierTypes.CircleRadius:
|
|
1219
|
+
case StylingClassifierTypes.CircleStrokeWidth:
|
|
1220
|
+
case StylingClassifierTypes.CircleBlur:
|
|
1221
|
+
return "circle";
|
|
1222
|
+
case StylingClassifierTypes.LineColor:
|
|
1223
|
+
case StylingClassifierTypes.LineWidth:
|
|
1224
|
+
case StylingClassifierTypes.LineBlur:
|
|
1225
|
+
return "line";
|
|
1226
|
+
default:
|
|
1227
|
+
return classifierType;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
const getClassificationForTypeArray = (clientStyle, classifierTypes = [], specPropKey) => {
|
|
1231
|
+
return classifierTypes.reduce((acc, curr) => {
|
|
1232
|
+
const styleItem = clientStyle?.items?.find(item => item.type === getPaintItemType(curr));
|
|
1233
|
+
return {
|
|
1234
|
+
...acc,
|
|
1235
|
+
[curr]: getClassificationFromExpression(clientStyle, styleItem?.id, curr, specPropKey, styleItem),
|
|
1236
|
+
};
|
|
1237
|
+
}, {});
|
|
1238
|
+
};
|
|
1239
|
+
const getClassificationList = (layer, clientStyle) => {
|
|
1240
|
+
if (!layer || !clientStyle) {
|
|
1241
|
+
return {};
|
|
1242
|
+
}
|
|
1243
|
+
const layerConfiguration = layer?.configuration;
|
|
1244
|
+
switch (layerConfiguration?.geometryType) {
|
|
1245
|
+
case OgcGeometryType.Polygon:
|
|
1246
|
+
case OgcGeometryType.MultiPolygon:
|
|
1247
|
+
return getClassificationForTypeArray(clientStyle, [StylingClassifierTypes.FillColor], "paint");
|
|
1248
|
+
case OgcGeometryType.Point:
|
|
1249
|
+
case OgcGeometryType.MultiPoint:
|
|
1250
|
+
return getClassificationForTypeArray(clientStyle, [
|
|
1251
|
+
StylingClassifierTypes.CircleColor,
|
|
1252
|
+
StylingClassifierTypes.CircleRadius,
|
|
1253
|
+
StylingClassifierTypes.CircleStrokeColor,
|
|
1254
|
+
StylingClassifierTypes.CircleStrokeWidth,
|
|
1255
|
+
], "paint");
|
|
1256
|
+
case OgcGeometryType.LineString:
|
|
1257
|
+
case OgcGeometryType.MultiLineString:
|
|
1258
|
+
return getClassificationForTypeArray(clientStyle, [StylingClassifierTypes.LineColor, StylingClassifierTypes.LineWidth], "paint");
|
|
1259
|
+
default:
|
|
1260
|
+
return {};
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
const getInterpolateStops = (expression, previousStops) => {
|
|
1265
|
+
const clientStyleValidator = new ClientStyleValidator();
|
|
1266
|
+
if (!clientStyleValidator.isZoomInterpolate(expression)) {
|
|
1267
|
+
return [];
|
|
1268
|
+
}
|
|
1269
|
+
const slicedValue = Array.isArray(expression) ? expression.slice(3) : undefined;
|
|
1270
|
+
return Array.isArray(expression)
|
|
1271
|
+
? orderBy(slicedValue?.reduce((acc, curr, currIndex) => {
|
|
1272
|
+
if (currIndex % 2 === 0) {
|
|
1273
|
+
const updatedOutput = slicedValue?.[currIndex + 1];
|
|
1274
|
+
const previousIdenticalStop = previousStops?.find(previousStop => isEqual(previousStop.input, curr) && isEqual(previousStop.output, updatedOutput));
|
|
1275
|
+
return [
|
|
1276
|
+
...acc,
|
|
1277
|
+
{ id: previousIdenticalStop ? previousIdenticalStop.id : v4(), input: curr, output: updatedOutput },
|
|
1278
|
+
];
|
|
1279
|
+
}
|
|
1280
|
+
return acc;
|
|
1281
|
+
}, []), "input", "asc")
|
|
1282
|
+
: [];
|
|
1283
|
+
};
|
|
1284
|
+
|
|
837
1285
|
const getLayerClientStyle = (layer) => {
|
|
838
1286
|
const clientStyle = layer?.configuration?.clientStyle;
|
|
839
1287
|
return {
|
|
@@ -867,6 +1315,34 @@ const getStyleAttributes = (style) => {
|
|
|
867
1315
|
}, []);
|
|
868
1316
|
};
|
|
869
1317
|
|
|
1318
|
+
const ICON_CLASSIFIERS = [StylingClassifierTypes.IconImage];
|
|
1319
|
+
const resyncStyleIcons = (clientStyle) => {
|
|
1320
|
+
if (!clientStyle) {
|
|
1321
|
+
return {};
|
|
1322
|
+
}
|
|
1323
|
+
const usedIcons = ICON_CLASSIFIERS.reduce((acc, curr) => {
|
|
1324
|
+
return [
|
|
1325
|
+
...acc,
|
|
1326
|
+
...clientStyle.items.reduce((itemsAcc, itemsCurr) => {
|
|
1327
|
+
const currentClassifier = itemsCurr.layout?.[curr] || itemsCurr.paint?.[curr];
|
|
1328
|
+
if (Array.isArray(currentClassifier)) {
|
|
1329
|
+
return [...itemsAcc, ...getValuesFromExression(currentClassifier)];
|
|
1330
|
+
}
|
|
1331
|
+
if (typeof currentClassifier === "string") {
|
|
1332
|
+
return [...itemsAcc, currentClassifier];
|
|
1333
|
+
}
|
|
1334
|
+
return itemsAcc;
|
|
1335
|
+
}, []),
|
|
1336
|
+
];
|
|
1337
|
+
}, []);
|
|
1338
|
+
return {
|
|
1339
|
+
...clientStyle,
|
|
1340
|
+
icons: Array.isArray(clientStyle.icons)
|
|
1341
|
+
? clientStyle.icons.filter(icon => usedIcons.includes(icon.name))
|
|
1342
|
+
: undefined,
|
|
1343
|
+
};
|
|
1344
|
+
};
|
|
1345
|
+
|
|
870
1346
|
const DEFAULT_COLOR = "#00ffff";
|
|
871
1347
|
const DEFAULT_BLUR = 0;
|
|
872
1348
|
const DEFAULT_OPACITY = 0.5;
|
|
@@ -1805,6 +2281,8 @@ const colorToHex = (color) => {
|
|
|
1805
2281
|
return hex.slice(HEX_RRGGBB_LENGTH).toLowerCase() === OPAQUE_ALPHA ? hex.slice(0, HEX_RRGGBB_LENGTH) : hex;
|
|
1806
2282
|
};
|
|
1807
2283
|
|
|
2284
|
+
const createEqualIntervals = (length, min, max) => Array.from({ length }, (_, index) => min + index * ((max - min) / (length - 1)));
|
|
2285
|
+
|
|
1808
2286
|
const NO_CONTENT_VALUE = "—";
|
|
1809
2287
|
var DateFormat;
|
|
1810
2288
|
(function (DateFormat) {
|
|
@@ -2511,16 +2989,5 @@ class SchemaResolver {
|
|
|
2511
2989
|
}
|
|
2512
2990
|
}
|
|
2513
2991
|
|
|
2514
|
-
|
|
2515
|
-
(function (EditGeometryType) {
|
|
2516
|
-
EditGeometryType["Raster"] = "raster";
|
|
2517
|
-
})(EditGeometryType || (EditGeometryType = {}));
|
|
2518
|
-
|
|
2519
|
-
var ThemeName;
|
|
2520
|
-
(function (ThemeName) {
|
|
2521
|
-
ThemeName["Light"] = "light";
|
|
2522
|
-
ThemeName["Dark"] = "dark";
|
|
2523
|
-
})(ThemeName || (ThemeName = {}));
|
|
2524
|
-
|
|
2525
|
-
export { ARRAY_ITEM_OBJECT_OPTIONS, COMPACT_FRACTION_DIGITS, ClientStyleValidator, DEFAULT_BLUR, DEFAULT_CIRCLE_RADIUS, DEFAULT_CIRCLE_STROKE_WIDTH, DEFAULT_CIRCLE_STYLE, DEFAULT_COLOR, DEFAULT_FILL_EXTRUSION_BASE, DEFAULT_FILL_EXTRUSION_HEIGHT, DEFAULT_FILL_EXTRUSION_STYLE, DEFAULT_FILL_EXTRUSION_VERTICAL_GRADIENT, DEFAULT_FILL_STYLE, DEFAULT_HEATMAP_COLOR, DEFAULT_HEATMAP_INTENSITY, DEFAULT_HEATMAP_RADIUS, DEFAULT_HEATMAP_STYLE, DEFAULT_HEATMAP_WEIGHT, DEFAULT_ICON_ANCHOR, DEFAULT_ICON_OVERLAP, DEFAULT_ICON_PADDING, DEFAULT_ICON_ROTATE, DEFAULT_ICON_SIZE, DEFAULT_LINE_CAP, DEFAULT_LINE_JOIN, DEFAULT_LINE_STYLE, DEFAULT_LINE_WIDTH, DEFAULT_OPACITY, DEFAULT_SYMBOL_COLOR, DEFAULT_SYMBOL_HALO_COLOR, DEFAULT_SYMBOL_PLACEMENT, DEFAULT_SYMBOL_SPACING, DEFAULT_SYMBOL_STYLE, DEFAULT_TEXT_ANCHOR, DEFAULT_TEXT_JUSTIFY, DEFAULT_TEXT_SIZE, DEFAULT_TEXT_TRANSFORM, DEFAULT_TRANSLATE, DateFormat, EditGeometryType, FORM_DEFAULT_OPTIONS, MERCATOR_MAX_LATITUDE, MERCATOR_MAX_LONGITUDE, NO_CONTENT_VALUE, ScalingFactor, SchemaResolver, TIME_ZONE_FORMAT, ThemeName, adjustColor, buildDefaultForSchema, colorToHex, dateOptions, debounce, decimalOpacityToHex, enrichStyleItemsWithIds, enrichStyleModelsWithIds, findAttributeInExpression, formatArea, formatAttributeValue, formatDate$1 as formatDate, formatLength, formatNumber, formatPolygonMeasure, geometryToEwkt, getActualExtrusionHeight, getClientStyleItemId, getDate, getGradientColors, getLayerClientStyle, getMapView, getPrimaryType, getStyleAttributes, hexToRgba, isLayerService, isNumeric, isObject, mergeHiddenFieldDefaults, metersPerPixel, numberOptions, orderPropertyKeys, parseIconNames, parseIconNamesFromClientStyle, parseMapStyle, pointOptions, rgbToHex, roundTotalSum, stretchPalette, timeOptions, transparentizeColor };
|
|
2992
|
+
export { ARRAY_ITEM_OBJECT_OPTIONS, COMPACT_FRACTION_DIGITS, ClassificationExpressionSubtype, ClassificationExpressionType, ClassificationExtraAlgorithms, ClientStyleValidator, DEFAULT_BLUR, DEFAULT_CIRCLE_RADIUS, DEFAULT_CIRCLE_STROKE_WIDTH, DEFAULT_CIRCLE_STYLE, DEFAULT_COLOR, DEFAULT_FILL_EXTRUSION_BASE, DEFAULT_FILL_EXTRUSION_HEIGHT, DEFAULT_FILL_EXTRUSION_STYLE, DEFAULT_FILL_EXTRUSION_VERTICAL_GRADIENT, DEFAULT_FILL_STYLE, DEFAULT_HEATMAP_COLOR, DEFAULT_HEATMAP_INTENSITY, DEFAULT_HEATMAP_RADIUS, DEFAULT_HEATMAP_STYLE, DEFAULT_HEATMAP_WEIGHT, DEFAULT_ICON_ANCHOR, DEFAULT_ICON_OVERLAP, DEFAULT_ICON_PADDING, DEFAULT_ICON_ROTATE, DEFAULT_ICON_SIZE, DEFAULT_LINE_CAP, DEFAULT_LINE_JOIN, DEFAULT_LINE_STYLE, DEFAULT_LINE_WIDTH, DEFAULT_OPACITY, DEFAULT_SYMBOL_COLOR, DEFAULT_SYMBOL_HALO_COLOR, DEFAULT_SYMBOL_PLACEMENT, DEFAULT_SYMBOL_SPACING, DEFAULT_SYMBOL_STYLE, DEFAULT_TEXT_ANCHOR, DEFAULT_TEXT_JUSTIFY, DEFAULT_TEXT_SIZE, DEFAULT_TEXT_TRANSFORM, DEFAULT_TRANSLATE, DateFormat, EditGeometryType, FORM_DEFAULT_OPTIONS, MERCATOR_MAX_LATITUDE, MERCATOR_MAX_LONGITUDE, NO_CONTENT_VALUE, ScalingFactor, SchemaResolver, StylingClassifierTypes, TIME_ZONE_FORMAT, ThemeName, adjustColor, buildDefaultForSchema, colorToHex, combineInterpolateStops, createEqualIntervals, dateOptions, debounce, decimalOpacityToHex, decodeConcat, encodeConcat, enrichStyleItemsWithIds, enrichStyleModelsWithIds, findAttributeInExpression, formatArea, formatAttributeValue, formatDate$1 as formatDate, formatLength, formatNumber, formatPolygonMeasure, geometryToEwkt, getActualExtrusionHeight, getClassificationFromExpression, getClassificationList, getClientStyleItemId, getDate, getGradientColors, getInterpolateStops, getLayerClientStyle, getMapView, getPrimaryType, getStyleAttributes, getValuesFromExression, hexToRgba, isLayerService, isNumeric, isObject, mergeHiddenFieldDefaults, metersPerPixel, numberOptions, orderPropertyKeys, parseIconNames, parseIconNamesFromClientStyle, parseMapStyle, pointOptions, resyncStyleIcons, rgbToHex, roundTotalSum, stretchPalette, timeOptions, transparentizeColor };
|
|
2526
2993
|
//# sourceMappingURL=common.esm.js.map
|