Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumbobeaty committed Sep 30, 2024
1 parent 8156831 commit 00fc035
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const PresetLayerStyle: FC<PresetLayerStyleProps> = ({
);

useEffect(() => {
if (layerStyleAdded) {
const addedStyle = layerStyles?.find(
if (layerStyleAdded && layerStyles) {
const addedStyle = layerStyles.find(
(style) => style.name === layerStyleAdded
);
onLayerStyleSelect(addedStyle?.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const defaultStyle = {
export const professionalStyle = {
marker: {
heightReference: "clamp",
hideIndicator: "false",
hideIndicator: false,
pointColor: "#E9373D",
pointOutlineColor: "white",
pointOutlineWidth: 1,
Expand All @@ -39,14 +39,14 @@ export const professionalStyle = {
expression: "color('#E9373D',0.6)"
},
heightReference: "clamp",
hideIndicator: "false",
hideIndicator: false,
selectedFeatureColor: {
expression: "color('#F1AF02',0.6)"
}
},
polyline: {
clampToGround: true,
hideIndicator: "false",
hideIndicator: false,
selectedFeatureColor: "#F1AF02",
strokeColor: "#E9373D",
strokeWidth: 2
Expand Down Expand Up @@ -83,7 +83,7 @@ export const pointWithLabelStyle = {
export const polylineStyle = {
polyline: {
clampToGround: true,
hideIndicator: "false",
hideIndicator: false,
selectedFeatureColor: "#F1AF02",
strokeColor: "#E9373D",
strokeWidth: 2
Expand All @@ -94,7 +94,7 @@ export const polygonStyle = {
polygon: {
fillColor: "#E9373D",
heightReference: "clamp",
hideIndicator: "false",
hideIndicator: false,
selectedFeatureColor: "#F1AF02"
}
};
Expand All @@ -106,7 +106,7 @@ export const extrudedPolygonStyle = {
},
fillColor: "#E9373D",
heightReference: "clamp",
hideIndicator: "false",
hideIndicator: false,
selectedFeatureColor: "#F1AF02"
}
};
Expand Down Expand Up @@ -182,13 +182,19 @@ export const colorBuildingsByHeight = {
}
};

export const getLayerStyleName = (baseName: string, layerStyles?: LayerStyle[]) => {
export const getLayerStyleName = (
baseName: string,
layerStyles?: LayerStyle[]
) => {
if (!layerStyles) return `${baseName}.01`;
const nextNumber =
layerStyles.reduce((max, style) => {
const match = style.name?.match(new RegExp(`^${baseName}\\.(\\d+)$`));
const escapedBaseName = baseName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const match = style.name?.match(
new RegExp(`^${escapedBaseName}\\.(\\d+)$`)
);
return match ? Math.max(max, parseInt(match[1], 10)) : max;
}, 0) + 1;

return `${baseName}.${nextNumber.toString().padStart(2, "0")}`;
};
};

0 comments on commit 00fc035

Please sign in to comment.