import { LabelProperty, ShapeProperty, StyleFeatureConfig, } from "../types/config.js"; import { ApiEntity, IdKeyType } from "../types/main.js"; import { LabelsOptions } from "../types/request.js"; export function getStyleFeatureString(args: StyleFeatureConfig) { const { [IdKeyType.Feature]: featureId, [ApiEntity.Style]: style = {} } = args; const { [ShapeProperty.Fill]: fill = "", [ShapeProperty.Stroke]: stroke = "", [ShapeProperty.StrokeWidth]: strokeWidth = "", [ShapeProperty.PointRadius]: pointRadius = "", [LabelProperty.LabelText]: labelText = "", [LabelProperty.LabelPriority]: labelPriority = "", [LabelProperty.LabelFont]: labelFont = "", [LabelProperty.LabelFontStyle]: labelFontStyle = "", [LabelProperty.LabelColor]: labelColor = "", [LabelProperty.LabelSize]: labelSize = "", [LabelProperty.LabelWeight]: labelWeight = "", [LabelProperty.LabelStroke]: labelStroke = "", [LabelProperty.LabelStrokeWidth]: labelStrokeWidth = "", } = style; return [ featureId, fill, stroke, strokeWidth, pointRadius, labelText, labelPriority, labelFont, labelFontStyle, labelColor, labelSize, labelWeight, labelStroke, labelStrokeWidth, ].join(";"); } export function getStyleFeatureConfig(text: string) { const [ featureId, fill, stroke, strokeWidth, pointRadius, labelText, labelPriority, labelFont, labelFontStyle, labelColor, labelSize, labelWeight, labelStroke, labelStrokeWidth, ] = text.split(";"); return { [IdKeyType.Feature]: featureId, style: { [ShapeProperty.Fill]: fill, [ShapeProperty.Stroke]: stroke, [ShapeProperty.StrokeWidth]: strokeWidth, [ShapeProperty.PointRadius]: pointRadius, [LabelProperty.LabelText]: labelText, [LabelProperty.LabelPriority]: labelPriority, [LabelProperty.LabelFont]: labelFont, [LabelProperty.LabelFontStyle]: labelFontStyle, [LabelProperty.LabelColor]: labelColor, [LabelProperty.LabelSize]: labelSize, [LabelProperty.LabelWeight]: labelWeight, [LabelProperty.LabelStroke]: labelStroke, [LabelProperty.LabelStrokeWidth]: labelStrokeWidth, }, }; } export function getLabelsString(args: LabelsOptions): string { const { margin, minSize, maxSize, minArea, maxArea } = args; return [margin, minSize, maxSize, minArea, maxArea].join(";"); } export function getLabelsConfig(text: string) { const [margin, minSize, maxSize, minArea, maxArea] = text.split(";"); return { margin, minSize, maxSize, minArea, maxArea }; }