1 |
|
2 |
|
3 |
|
4 | import styleSpec from '../../style-spec/reference/latest';
|
5 |
|
6 | import {
|
7 | Properties,
|
8 | DataConstantProperty,
|
9 | DataDrivenProperty,
|
10 | CrossFadedDataDrivenProperty,
|
11 | CrossFadedProperty,
|
12 | ColorRampProperty,
|
13 | PossiblyEvaluatedPropertyValue,
|
14 | CrossFaded
|
15 | } from '../properties';
|
16 |
|
17 | import type Color from '../../style-spec/util/color';
|
18 |
|
19 | import type Formatted from '../../style-spec/expression/types/formatted';
|
20 |
|
21 | import type ResolvedImage from '../../style-spec/expression/types/resolved_image';
|
22 | import {StylePropertySpecification} from '../../style-spec/style-spec';
|
23 |
|
24 | import {
|
25 | ColorType
|
26 | } from '../../style-spec/expression/types';
|
27 |
|
28 | export type SymbolLayoutProps = {
|
29 | "symbol-placement": DataConstantProperty<"point" | "line" | "line-center">,
|
30 | "symbol-spacing": DataConstantProperty<number>,
|
31 | "symbol-avoid-edges": DataConstantProperty<boolean>,
|
32 | "symbol-sort-key": DataDrivenProperty<number>,
|
33 | "symbol-z-order": DataConstantProperty<"auto" | "viewport-y" | "source">,
|
34 | "icon-allow-overlap": DataConstantProperty<boolean>,
|
35 | "icon-overlap": DataConstantProperty<"never" | "always" | "cooperative">,
|
36 | "icon-ignore-placement": DataConstantProperty<boolean>,
|
37 | "icon-optional": DataConstantProperty<boolean>,
|
38 | "icon-rotation-alignment": DataConstantProperty<"map" | "viewport" | "auto">,
|
39 | "icon-size": DataDrivenProperty<number>,
|
40 | "icon-text-fit": DataConstantProperty<"none" | "width" | "height" | "both">,
|
41 | "icon-text-fit-padding": DataConstantProperty<[number, number, number, number]>,
|
42 | "icon-image": DataDrivenProperty<ResolvedImage>,
|
43 | "icon-rotate": DataDrivenProperty<number>,
|
44 | "icon-padding": DataConstantProperty<number>,
|
45 | "icon-keep-upright": DataConstantProperty<boolean>,
|
46 | "icon-offset": DataDrivenProperty<[number, number]>,
|
47 | "icon-anchor": DataDrivenProperty<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">,
|
48 | "icon-pitch-alignment": DataConstantProperty<"map" | "viewport" | "auto">,
|
49 | "text-pitch-alignment": DataConstantProperty<"map" | "viewport" | "auto">,
|
50 | "text-rotation-alignment": DataConstantProperty<"map" | "viewport" | "viewport-glyph" | "auto">,
|
51 | "text-field": DataDrivenProperty<Formatted>,
|
52 | "text-font": DataDrivenProperty<Array<string>>,
|
53 | "text-size": DataDrivenProperty<number>,
|
54 | "text-max-width": DataDrivenProperty<number>,
|
55 | "text-line-height": DataConstantProperty<number>,
|
56 | "text-letter-spacing": DataDrivenProperty<number>,
|
57 | "text-justify": DataDrivenProperty<"auto" | "left" | "center" | "right">,
|
58 | "text-radial-offset": DataDrivenProperty<number>,
|
59 | "text-variable-anchor": DataConstantProperty<Array<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">>,
|
60 | "text-anchor": DataDrivenProperty<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">,
|
61 | "text-max-angle": DataConstantProperty<number>,
|
62 | "text-writing-mode": DataConstantProperty<Array<"horizontal" | "vertical">>,
|
63 | "text-rotate": DataDrivenProperty<number>,
|
64 | "text-padding": DataConstantProperty<number>,
|
65 | "text-keep-upright": DataConstantProperty<boolean>,
|
66 | "text-transform": DataDrivenProperty<"none" | "uppercase" | "lowercase">,
|
67 | "text-offset": DataDrivenProperty<[number, number]>,
|
68 | "text-allow-overlap": DataConstantProperty<boolean>,
|
69 | "text-overlap": DataConstantProperty<"never" | "always" | "cooperative">,
|
70 | "text-ignore-placement": DataConstantProperty<boolean>,
|
71 | "text-optional": DataConstantProperty<boolean>,
|
72 | };
|
73 |
|
74 | export type SymbolLayoutPropsPossiblyEvaluated = {
|
75 | "symbol-placement": "point" | "line" | "line-center",
|
76 | "symbol-spacing": number,
|
77 | "symbol-avoid-edges": boolean,
|
78 | "symbol-sort-key": PossiblyEvaluatedPropertyValue<number>,
|
79 | "symbol-z-order": "auto" | "viewport-y" | "source",
|
80 | "icon-allow-overlap": boolean,
|
81 | "icon-overlap": "never" | "always" | "cooperative",
|
82 | "icon-ignore-placement": boolean,
|
83 | "icon-optional": boolean,
|
84 | "icon-rotation-alignment": "map" | "viewport" | "auto",
|
85 | "icon-size": PossiblyEvaluatedPropertyValue<number>,
|
86 | "icon-text-fit": "none" | "width" | "height" | "both",
|
87 | "icon-text-fit-padding": [number, number, number, number],
|
88 | "icon-image": PossiblyEvaluatedPropertyValue<ResolvedImage>,
|
89 | "icon-rotate": PossiblyEvaluatedPropertyValue<number>,
|
90 | "icon-padding": number,
|
91 | "icon-keep-upright": boolean,
|
92 | "icon-offset": PossiblyEvaluatedPropertyValue<[number, number]>,
|
93 | "icon-anchor": PossiblyEvaluatedPropertyValue<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">,
|
94 | "icon-pitch-alignment": "map" | "viewport" | "auto",
|
95 | "text-pitch-alignment": "map" | "viewport" | "auto",
|
96 | "text-rotation-alignment": "map" | "viewport" | "viewport-glyph" | "auto",
|
97 | "text-field": PossiblyEvaluatedPropertyValue<Formatted>,
|
98 | "text-font": PossiblyEvaluatedPropertyValue<Array<string>>,
|
99 | "text-size": PossiblyEvaluatedPropertyValue<number>,
|
100 | "text-max-width": PossiblyEvaluatedPropertyValue<number>,
|
101 | "text-line-height": number,
|
102 | "text-letter-spacing": PossiblyEvaluatedPropertyValue<number>,
|
103 | "text-justify": PossiblyEvaluatedPropertyValue<"auto" | "left" | "center" | "right">,
|
104 | "text-radial-offset": PossiblyEvaluatedPropertyValue<number>,
|
105 | "text-variable-anchor": Array<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">,
|
106 | "text-anchor": PossiblyEvaluatedPropertyValue<"center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right">,
|
107 | "text-max-angle": number,
|
108 | "text-writing-mode": Array<"horizontal" | "vertical">,
|
109 | "text-rotate": PossiblyEvaluatedPropertyValue<number>,
|
110 | "text-padding": number,
|
111 | "text-keep-upright": boolean,
|
112 | "text-transform": PossiblyEvaluatedPropertyValue<"none" | "uppercase" | "lowercase">,
|
113 | "text-offset": PossiblyEvaluatedPropertyValue<[number, number]>,
|
114 | "text-allow-overlap": boolean,
|
115 | "text-overlap": "never" | "always" | "cooperative",
|
116 | "text-ignore-placement": boolean,
|
117 | "text-optional": boolean,
|
118 | };
|
119 |
|
120 | const layout: Properties<SymbolLayoutProps> = new Properties({
|
121 | "symbol-placement": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-placement"] as any as StylePropertySpecification),
|
122 | "symbol-spacing": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-spacing"] as any as StylePropertySpecification),
|
123 | "symbol-avoid-edges": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-avoid-edges"] as any as StylePropertySpecification),
|
124 | "symbol-sort-key": new DataDrivenProperty(styleSpec["layout_symbol"]["symbol-sort-key"] as any as StylePropertySpecification),
|
125 | "symbol-z-order": new DataConstantProperty(styleSpec["layout_symbol"]["symbol-z-order"] as any as StylePropertySpecification),
|
126 | "icon-allow-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["icon-allow-overlap"] as any as StylePropertySpecification),
|
127 | "icon-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["icon-overlap"] as any as StylePropertySpecification),
|
128 | "icon-ignore-placement": new DataConstantProperty(styleSpec["layout_symbol"]["icon-ignore-placement"] as any as StylePropertySpecification),
|
129 | "icon-optional": new DataConstantProperty(styleSpec["layout_symbol"]["icon-optional"] as any as StylePropertySpecification),
|
130 | "icon-rotation-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["icon-rotation-alignment"] as any as StylePropertySpecification),
|
131 | "icon-size": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-size"] as any as StylePropertySpecification),
|
132 | "icon-text-fit": new DataConstantProperty(styleSpec["layout_symbol"]["icon-text-fit"] as any as StylePropertySpecification),
|
133 | "icon-text-fit-padding": new DataConstantProperty(styleSpec["layout_symbol"]["icon-text-fit-padding"] as any as StylePropertySpecification),
|
134 | "icon-image": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-image"] as any as StylePropertySpecification),
|
135 | "icon-rotate": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-rotate"] as any as StylePropertySpecification),
|
136 | "icon-padding": new DataConstantProperty(styleSpec["layout_symbol"]["icon-padding"] as any as StylePropertySpecification),
|
137 | "icon-keep-upright": new DataConstantProperty(styleSpec["layout_symbol"]["icon-keep-upright"] as any as StylePropertySpecification),
|
138 | "icon-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-offset"] as any as StylePropertySpecification),
|
139 | "icon-anchor": new DataDrivenProperty(styleSpec["layout_symbol"]["icon-anchor"] as any as StylePropertySpecification),
|
140 | "icon-pitch-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["icon-pitch-alignment"] as any as StylePropertySpecification),
|
141 | "text-pitch-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["text-pitch-alignment"] as any as StylePropertySpecification),
|
142 | "text-rotation-alignment": new DataConstantProperty(styleSpec["layout_symbol"]["text-rotation-alignment"] as any as StylePropertySpecification),
|
143 | "text-field": new DataDrivenProperty(styleSpec["layout_symbol"]["text-field"] as any as StylePropertySpecification),
|
144 | "text-font": new DataDrivenProperty(styleSpec["layout_symbol"]["text-font"] as any as StylePropertySpecification),
|
145 | "text-size": new DataDrivenProperty(styleSpec["layout_symbol"]["text-size"] as any as StylePropertySpecification),
|
146 | "text-max-width": new DataDrivenProperty(styleSpec["layout_symbol"]["text-max-width"] as any as StylePropertySpecification),
|
147 | "text-line-height": new DataConstantProperty(styleSpec["layout_symbol"]["text-line-height"] as any as StylePropertySpecification),
|
148 | "text-letter-spacing": new DataDrivenProperty(styleSpec["layout_symbol"]["text-letter-spacing"] as any as StylePropertySpecification),
|
149 | "text-justify": new DataDrivenProperty(styleSpec["layout_symbol"]["text-justify"] as any as StylePropertySpecification),
|
150 | "text-radial-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["text-radial-offset"] as any as StylePropertySpecification),
|
151 | "text-variable-anchor": new DataConstantProperty(styleSpec["layout_symbol"]["text-variable-anchor"] as any as StylePropertySpecification),
|
152 | "text-anchor": new DataDrivenProperty(styleSpec["layout_symbol"]["text-anchor"] as any as StylePropertySpecification),
|
153 | "text-max-angle": new DataConstantProperty(styleSpec["layout_symbol"]["text-max-angle"] as any as StylePropertySpecification),
|
154 | "text-writing-mode": new DataConstantProperty(styleSpec["layout_symbol"]["text-writing-mode"] as any as StylePropertySpecification),
|
155 | "text-rotate": new DataDrivenProperty(styleSpec["layout_symbol"]["text-rotate"] as any as StylePropertySpecification),
|
156 | "text-padding": new DataConstantProperty(styleSpec["layout_symbol"]["text-padding"] as any as StylePropertySpecification),
|
157 | "text-keep-upright": new DataConstantProperty(styleSpec["layout_symbol"]["text-keep-upright"] as any as StylePropertySpecification),
|
158 | "text-transform": new DataDrivenProperty(styleSpec["layout_symbol"]["text-transform"] as any as StylePropertySpecification),
|
159 | "text-offset": new DataDrivenProperty(styleSpec["layout_symbol"]["text-offset"] as any as StylePropertySpecification),
|
160 | "text-allow-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["text-allow-overlap"] as any as StylePropertySpecification),
|
161 | "text-overlap": new DataConstantProperty(styleSpec["layout_symbol"]["text-overlap"] as any as StylePropertySpecification),
|
162 | "text-ignore-placement": new DataConstantProperty(styleSpec["layout_symbol"]["text-ignore-placement"] as any as StylePropertySpecification),
|
163 | "text-optional": new DataConstantProperty(styleSpec["layout_symbol"]["text-optional"] as any as StylePropertySpecification),
|
164 | });
|
165 |
|
166 | export type SymbolPaintProps = {
|
167 | "icon-opacity": DataDrivenProperty<number>,
|
168 | "icon-color": DataDrivenProperty<Color>,
|
169 | "icon-halo-color": DataDrivenProperty<Color>,
|
170 | "icon-halo-width": DataDrivenProperty<number>,
|
171 | "icon-halo-blur": DataDrivenProperty<number>,
|
172 | "icon-translate": DataConstantProperty<[number, number]>,
|
173 | "icon-translate-anchor": DataConstantProperty<"map" | "viewport">,
|
174 | "text-opacity": DataDrivenProperty<number>,
|
175 | "text-color": DataDrivenProperty<Color>,
|
176 | "text-halo-color": DataDrivenProperty<Color>,
|
177 | "text-halo-width": DataDrivenProperty<number>,
|
178 | "text-halo-blur": DataDrivenProperty<number>,
|
179 | "text-translate": DataConstantProperty<[number, number]>,
|
180 | "text-translate-anchor": DataConstantProperty<"map" | "viewport">,
|
181 | };
|
182 |
|
183 | export type SymbolPaintPropsPossiblyEvaluated = {
|
184 | "icon-opacity": PossiblyEvaluatedPropertyValue<number>,
|
185 | "icon-color": PossiblyEvaluatedPropertyValue<Color>,
|
186 | "icon-halo-color": PossiblyEvaluatedPropertyValue<Color>,
|
187 | "icon-halo-width": PossiblyEvaluatedPropertyValue<number>,
|
188 | "icon-halo-blur": PossiblyEvaluatedPropertyValue<number>,
|
189 | "icon-translate": [number, number],
|
190 | "icon-translate-anchor": "map" | "viewport",
|
191 | "text-opacity": PossiblyEvaluatedPropertyValue<number>,
|
192 | "text-color": PossiblyEvaluatedPropertyValue<Color>,
|
193 | "text-halo-color": PossiblyEvaluatedPropertyValue<Color>,
|
194 | "text-halo-width": PossiblyEvaluatedPropertyValue<number>,
|
195 | "text-halo-blur": PossiblyEvaluatedPropertyValue<number>,
|
196 | "text-translate": [number, number],
|
197 | "text-translate-anchor": "map" | "viewport",
|
198 | };
|
199 |
|
200 | const paint: Properties<SymbolPaintProps> = new Properties({
|
201 | "icon-opacity": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-opacity"] as any as StylePropertySpecification),
|
202 | "icon-color": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-color"] as any as StylePropertySpecification),
|
203 | "icon-halo-color": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-halo-color"] as any as StylePropertySpecification),
|
204 | "icon-halo-width": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-halo-width"] as any as StylePropertySpecification),
|
205 | "icon-halo-blur": new DataDrivenProperty(styleSpec["paint_symbol"]["icon-halo-blur"] as any as StylePropertySpecification),
|
206 | "icon-translate": new DataConstantProperty(styleSpec["paint_symbol"]["icon-translate"] as any as StylePropertySpecification),
|
207 | "icon-translate-anchor": new DataConstantProperty(styleSpec["paint_symbol"]["icon-translate-anchor"] as any as StylePropertySpecification),
|
208 | "text-opacity": new DataDrivenProperty(styleSpec["paint_symbol"]["text-opacity"] as any as StylePropertySpecification),
|
209 | "text-color": new DataDrivenProperty(styleSpec["paint_symbol"]["text-color"] as any as StylePropertySpecification, { runtimeType: ColorType, getOverride: (o) => o.textColor, hasOverride: (o) => !!o.textColor }),
|
210 | "text-halo-color": new DataDrivenProperty(styleSpec["paint_symbol"]["text-halo-color"] as any as StylePropertySpecification),
|
211 | "text-halo-width": new DataDrivenProperty(styleSpec["paint_symbol"]["text-halo-width"] as any as StylePropertySpecification),
|
212 | "text-halo-blur": new DataDrivenProperty(styleSpec["paint_symbol"]["text-halo-blur"] as any as StylePropertySpecification),
|
213 | "text-translate": new DataConstantProperty(styleSpec["paint_symbol"]["text-translate"] as any as StylePropertySpecification),
|
214 | "text-translate-anchor": new DataConstantProperty(styleSpec["paint_symbol"]["text-translate-anchor"] as any as StylePropertySpecification),
|
215 | });
|
216 |
|
217 | export default ({ paint, layout } as {
|
218 | paint: Properties<SymbolPaintProps>,
|
219 | layout: Properties<SymbolLayoutProps>
|
220 | }); |
\ | No newline at end of file |