ol 7.5.1 → 8.0.0-dev.1692053484481

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.
Files changed (135) hide show
  1. package/DataTile.d.ts +2 -2
  2. package/DataTile.d.ts.map +1 -1
  3. package/DataTile.js +3 -2
  4. package/Image.d.ts +139 -40
  5. package/Image.d.ts.map +1 -1
  6. package/Image.js +194 -96
  7. package/ImageCanvas.d.ts +2 -2
  8. package/ImageCanvas.d.ts.map +1 -1
  9. package/ImageCanvas.js +2 -2
  10. package/Object.d.ts +7 -0
  11. package/Object.d.ts.map +1 -1
  12. package/Object.js +8 -0
  13. package/dist/ol.js +2 -2
  14. package/dist/ol.js.map +1 -1
  15. package/expr/cpu.d.ts +71 -0
  16. package/expr/cpu.d.ts.map +1 -0
  17. package/expr/cpu.js +312 -0
  18. package/expr/expression.d.ts +97 -0
  19. package/expr/expression.d.ts.map +1 -0
  20. package/expr/expression.js +373 -0
  21. package/has.d.ts +5 -0
  22. package/has.d.ts.map +1 -1
  23. package/has.js +6 -0
  24. package/index.d.ts +1 -2
  25. package/index.js +1 -1
  26. package/layer/Base.d.ts +12 -8
  27. package/layer/Base.d.ts.map +1 -1
  28. package/layer/Base.js +12 -8
  29. package/layer/BaseVector.d.ts.map +1 -1
  30. package/layer/BaseVector.js +67 -33
  31. package/layer/Heatmap.d.ts.map +1 -1
  32. package/layer/Heatmap.js +16 -55
  33. package/layer/Layer.d.ts +2 -2
  34. package/layer/Layer.d.ts.map +1 -1
  35. package/layer/Layer.js +1 -1
  36. package/layer/WebGLPoints.d.ts +7 -12
  37. package/layer/WebGLPoints.d.ts.map +1 -1
  38. package/layer/WebGLPoints.js +7 -12
  39. package/package.json +1 -1
  40. package/render/Feature.d.ts +8 -0
  41. package/render/Feature.d.ts.map +1 -1
  42. package/render/Feature.js +9 -0
  43. package/render/canvas/Immediate.d.ts.map +1 -1
  44. package/render/canvas/Immediate.js +5 -3
  45. package/render/canvas/TextBuilder.js +2 -2
  46. package/render/canvas/style.d.ts +69 -0
  47. package/render/canvas/style.d.ts.map +1 -0
  48. package/render/canvas/style.js +1192 -0
  49. package/render/canvas.js +1 -1
  50. package/render/webgl/VectorStyleRenderer.d.ts.map +1 -1
  51. package/render/webgl/VectorStyleRenderer.js +4 -0
  52. package/renderer/Layer.d.ts +2 -2
  53. package/renderer/Layer.d.ts.map +1 -1
  54. package/renderer/Layer.js +1 -1
  55. package/renderer/canvas/ImageLayer.d.ts +4 -4
  56. package/renderer/canvas/ImageLayer.d.ts.map +1 -1
  57. package/renderer/canvas/ImageLayer.js +17 -12
  58. package/renderer/canvas/Layer.d.ts +2 -2
  59. package/renderer/canvas/Layer.d.ts.map +1 -1
  60. package/renderer/canvas/Layer.js +1 -1
  61. package/renderer/canvas/VectorImageLayer.d.ts.map +1 -1
  62. package/renderer/canvas/VectorImageLayer.js +3 -2
  63. package/renderer/webgl/VectorLayer.d.ts +1 -2
  64. package/renderer/webgl/VectorLayer.d.ts.map +1 -1
  65. package/reproj/Image.d.ts +5 -5
  66. package/reproj/Image.d.ts.map +1 -1
  67. package/reproj/Image.js +6 -6
  68. package/reproj.d.ts +2 -2
  69. package/reproj.d.ts.map +1 -1
  70. package/reproj.js +1 -1
  71. package/resolution.d.ts +13 -0
  72. package/resolution.d.ts.map +1 -0
  73. package/resolution.js +18 -0
  74. package/source/Image.d.ts +44 -7
  75. package/source/Image.d.ts.map +1 -1
  76. package/source/Image.js +97 -8
  77. package/source/ImageArcGISRest.d.ts +0 -23
  78. package/source/ImageArcGISRest.d.ts.map +1 -1
  79. package/source/ImageArcGISRest.js +18 -120
  80. package/source/ImageMapGuide.d.ts +0 -24
  81. package/source/ImageMapGuide.d.ts.map +1 -1
  82. package/source/ImageMapGuide.js +21 -113
  83. package/source/ImageStatic.d.ts +2 -27
  84. package/source/ImageStatic.d.ts.map +1 -1
  85. package/source/ImageStatic.js +20 -70
  86. package/source/ImageWMS.d.ts +2 -46
  87. package/source/ImageWMS.d.ts.map +1 -1
  88. package/source/ImageWMS.js +43 -201
  89. package/source/{Stamen.d.ts → StadiaMaps.d.ts} +17 -7
  90. package/source/StadiaMaps.d.ts.map +1 -0
  91. package/source/{Stamen.js → StadiaMaps.js} +85 -38
  92. package/source/TileArcGISRest.d.ts.map +1 -1
  93. package/source/TileArcGISRest.js +11 -22
  94. package/source/TileWMS.d.ts +0 -1
  95. package/source/TileWMS.d.ts.map +1 -1
  96. package/source/TileWMS.js +43 -106
  97. package/source/arcgisRest.d.ts +88 -0
  98. package/source/arcgisRest.d.ts.map +1 -0
  99. package/source/arcgisRest.js +131 -0
  100. package/source/common.d.ts +5 -0
  101. package/source/common.d.ts.map +1 -1
  102. package/source/common.js +6 -0
  103. package/source/mapguide.d.ts +52 -0
  104. package/source/mapguide.d.ts.map +1 -0
  105. package/source/mapguide.js +116 -0
  106. package/source/static.d.ts +45 -0
  107. package/source/static.d.ts.map +1 -0
  108. package/source/static.js +44 -0
  109. package/source/wms.d.ts +109 -1
  110. package/source/wms.d.ts.map +1 -1
  111. package/source/wms.js +170 -0
  112. package/source.d.ts +5 -1
  113. package/source.d.ts.map +1 -1
  114. package/source.js +5 -1
  115. package/style/flat.d.ts +332 -173
  116. package/style/flat.d.ts.map +1 -1
  117. package/style/flat.js +176 -248
  118. package/style/literal.d.ts +27 -72
  119. package/style/literal.d.ts.map +1 -1
  120. package/style/literal.js +14 -35
  121. package/util.d.ts.map +1 -1
  122. package/util.js +1 -1
  123. package/webgl/Helper.d.ts +7 -2
  124. package/webgl/Helper.d.ts.map +1 -1
  125. package/webgl/Helper.js +16 -27
  126. package/webgl/ShaderBuilder.d.ts +4 -14
  127. package/webgl/ShaderBuilder.d.ts.map +1 -1
  128. package/webgl/ShaderBuilder.js +72 -72
  129. package/webgl/styleparser.d.ts +3 -9
  130. package/webgl/styleparser.d.ts.map +1 -1
  131. package/webgl/styleparser.js +503 -88
  132. package/ImageBase.d.ts +0 -65
  133. package/ImageBase.d.ts.map +0 -1
  134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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA4GrC,WAAW,GAAC,UAAU,GAAC,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA2BvC,WAAW,GAAC,UAAU,GAAC,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAwBvC,WAAW,GAAC,UAAU,GAAC,MAAM,GAAC,SAAS;;;;;;;;;;;;;kBAQvC,MAAM;;;;oBACN,MAAM;;;;oBACN,MAAM;;;;qBACN,MAAM;;;;yBACN,MAAM;;;;2BACN,MAAM;;;;2BACN,MAAM;;;;;;;;;;WAuBN,SAAS,GAAC,MAAM,SAAS,CAAC"}
package/style/flat.js CHANGED
@@ -2,13 +2,83 @@
2
2
  * @module ol/style/flat
3
3
  */
4
4
 
5
- import Circle from '../style/Circle.js';
6
- import Fill from './Fill.js';
7
- import Icon from './Icon.js';
8
- import RegularShape from './RegularShape.js';
9
- import Stroke from './Stroke.js';
10
- import Style from './Style.js';
11
- import Text from './Text.js';
5
+ /**
6
+ * @api
7
+ * @fileoverview Vector layers can be styled with an object literal containing properties for
8
+ * stroke, fill, image, and text styles. The types below can be composed into a single object.
9
+ * For example, a style with both stroke and fill properties could look like this:
10
+ *
11
+ * const style = {
12
+ * 'stroke-color': 'yellow',
13
+ * 'stroke-width': 1.5,
14
+ * 'fill-color': 'orange',
15
+ * };
16
+ *
17
+ * See details about the available properties depending on what type of symbolizer should be applied:
18
+ * * {@link module:ol/style/flat~FlatStroke Stroke} - properties for applying a stroke to lines and polygons
19
+ * * {@link module:ol/style/flat~FlatFill Fill} - properties for filling polygons
20
+ * * {@link module:ol/style/flat~FlatText Text} - properties for labeling points, lines, and polygons
21
+ * * {@link module:ol/style/flat~FlatIcon Icon} - properties for rendering points with an icon
22
+ * * {@link module:ol/style/flat~FlatCircle Circle} - properties for rendering points with a circle
23
+ * * {@link module:ol/style/flat~FlatShape Shape} - properties for rendering points with a regular shape
24
+ *
25
+ * To conditionally apply styles based on a filter, a list of {@link module:ol/style/flat~Rule rules} can be used.
26
+ * For example, to style points with a big orange circle if the population is greater than 1 million and
27
+ * a smaller blue circle otherwise:
28
+ *
29
+ * const rules = [
30
+ * {
31
+ * filter: ['>', 'population', 1_000_000],
32
+ * style: {
33
+ * 'circle-radius': 10,
34
+ * 'circle-color': 'red',
35
+ * }
36
+ * },
37
+ * {
38
+ * else: true,
39
+ * style: {
40
+ * 'circle-radius': 5,
41
+ * 'circle-color': 'blue',
42
+ * },
43
+ * ];
44
+ */
45
+
46
+ /**
47
+ * A literal boolean (e.g. `true`) or an expression that evaluates to a boolean (e.g. `['>', ['get', 'population'], 1_000_000]`).
48
+ *
49
+ * @typedef {boolean|Array} BooleanExpression
50
+ */
51
+
52
+ /**
53
+ * A literal string (e.g. `'hello'`) or an expression that evaluates to a string (e.g. `['get', 'greeting']`).
54
+ *
55
+ * @typedef {string|Array} StringExpression
56
+ */
57
+
58
+ /**
59
+ * A literal number (e.g. `42`) or an expression that evaluates to a number (e.g. `['+', 40, 2]`).
60
+ *
61
+ * @typedef {number|Array} NumberExpression
62
+ */
63
+
64
+ /**
65
+ * A CSS named color (e.g. `'blue'`), an array of 3 RGB values (e.g. `[0, 255, 0]`), an array of 4 RGBA values
66
+ * (e.g. `[0, 255, 0, 0.5]`), or an expression that evaluates to one of these color types (e.g. `['get', 'color']`).
67
+ *
68
+ * @typedef {import("../color.js").Color|string|Array} ColorExpression
69
+ */
70
+
71
+ /**
72
+ * An array of numbers (e.g. `[1, 2, 3]`) or an expression that evaluates to the same (e.g. `['get', 'values']`).
73
+ *
74
+ * @typedef {Array<number>|Array} NumberArrayExpression
75
+ */
76
+
77
+ /**
78
+ * An array of two numbers (e.g. `[10, 20]`) or an expression that evaluates to the same (e.g. `['get', 'size']`).
79
+ *
80
+ * @typedef {number|Array<number>|Array} SizeExpression
81
+ */
12
82
 
13
83
  /**
14
84
  * For static styling, the [layer.setStyle()]{@link module:ol/layer/Vector~VectorLayer#setStyle} method
@@ -21,14 +91,14 @@ import Text from './Text.js';
21
91
  /**
22
92
  * A flat style literal or an array of the same.
23
93
  *
24
- * @typedef {FlatStyle|Array<FlatStyle>} FlatStyleLike
94
+ * @typedef {FlatStyle|Array<FlatStyle>|Array<Rule>} FlatStyleLike
25
95
  */
26
96
 
27
97
  /**
28
98
  * Fill style properties applied to polygon features.
29
99
  *
30
100
  * @typedef {Object} FlatFill
31
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [fill-color] The fill color.
101
+ * @property {ColorExpression} [fill-color] The fill color.
32
102
  */
33
103
 
34
104
  /**
@@ -36,65 +106,62 @@ import Text from './Text.js';
36
106
  * `stroke-color` or `stroke-width` must be provided.
37
107
  *
38
108
  * @typedef {Object} FlatStroke
39
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [stroke-color] The stroke color.
40
- * @property {number} [stroke-width] Stroke pixel width.
41
- * @property {CanvasLineCap} [stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
42
- * @property {CanvasLineJoin} [stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
43
- * @property {Array<number>} [stroke-line-dash] Line dash pattern.
44
- * @property {number} [stroke-line-dash-offset=0] Line dash offset.
45
- * @property {number} [stroke-miter-limit=10] Miter limit.
109
+ * @property {ColorExpression} [stroke-color] The stroke color.
110
+ * @property {NumberExpression} [stroke-width] Stroke pixel width.
111
+ * @property {StringExpression} [stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
112
+ * @property {StringExpression} [stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
113
+ * @property {NumberArrayExpression} [stroke-line-dash] Line dash pattern.
114
+ * @property {NumberExpression} [stroke-line-dash-offset=0] Line dash offset.
115
+ * @property {NumberExpression} [stroke-miter-limit=10] Miter limit.
116
+ * @property {NumberExpression} [z-index] The zIndex of the style.
46
117
  */
47
118
 
48
119
  /**
49
120
  * Label style properties applied to all features. At a minimum, a `text-value` must be provided.
50
121
  *
51
122
  * @typedef {Object} FlatText
52
- * @property {string|Array<string>} [text-value] Text content or rich text content. For plain text provide a string, which can
53
- * contain line breaks (`\n`). For rich text provide an array of text/font tuples. A tuple consists of the text to
54
- * render and the font to use (or `''` to use the text style's font). A line break has to be a separate tuple (i.e. `'\n', ''`).
55
- * **Example:** `['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']` will yield "**foo** *bar* baz".
56
- * **Note:** Rich text is not supported for `'text-placement': 'line'` or the immediate rendering API.
57
- * @property {string} [text-font] Font style as CSS `font` value, see:
58
- * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is `'10px sans-serif'`
59
- * @property {number} [text-max-angle=Math.PI/4] When `text-placement` is set to `'line'`, allow a maximum angle between adjacent characters.
123
+ * @property {StringExpression} [text-value] Text content (with `\n` for line breaks).
124
+ * @property {StringExpression} [text-font='10px sans-serif'] Font style as [CSS `font`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font) value.
125
+ * @property {NumberExpression} [text-max-angle=Math.PI/4] When `text-placement` is set to `'line'`, allow a maximum angle between adjacent characters.
60
126
  * The expected value is in radians, and the default is 45° (`Math.PI / 4`).
61
- * @property {number} [text-offset-x=0] Horizontal text offset in pixels. A positive will shift the text right.
62
- * @property {number} [text-offset-y=0] Vertical text offset in pixels. A positive will shift the text down.
63
- * @property {boolean} [text-overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
127
+ * @property {NumberExpression} [text-offset-x=0] Horizontal text offset in pixels. A positive will shift the text right.
128
+ * @property {NumberExpression} [text-offset-y=0] Vertical text offset in pixels. A positive will shift the text down.
129
+ * @property {BooleanExpression} [text-overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
64
130
  * the width of the polygon at the label position or the length of the path that it follows.
65
- * @property {import("./Text.js").TextPlacement} [text-placement='point'] Text placement.
66
- * @property {number} [text-repeat] Repeat interval in pixels. When set, the text will be repeated at this interval. Only available when
131
+ * @property {StringExpression} [text-placement='point'] Text placement.
132
+ * @property {NumberExpression} [text-repeat] Repeat interval in pixels. When set, the text will be repeated at this interval. Only available when
67
133
  * `text-placement` is set to `'line'`. Overrides `text-align`.
68
- * @property {number|import("../size.js").Size} [text-scale] Scale.
69
- * @property {boolean} [text-rotate-with-view=false] Whether to rotate the text with the view.
70
- * @property {number} [text-rotation=0] Rotation in radians (positive rotation clockwise).
71
- * @property {CanvasTextAlign} [text-align] Text alignment. Possible values: `'left'`, `'right'`, `'center'`, `'end'` or `'start'`.
134
+ * @property {SizeExpression} [text-scale] Scale.
135
+ * @property {BooleanExpression} [text-rotate-with-view=false] Whether to rotate the text with the view.
136
+ * @property {NumberExpression} [text-rotation=0] Rotation in radians (positive rotation clockwise).
137
+ * @property {StringExpression} [text-align] Text alignment. Possible values: `'left'`, `'right'`, `'center'`, `'end'` or `'start'`.
72
138
  * Default is `'center'` for `'text-placement': 'point'`. For `'text-placement': 'line'`, the default is to let the renderer choose a
73
139
  * placement where `text-max-angle` is not exceeded.
74
- * @property {import('./Text.js').TextJustify} [text-justify] Text justification within the text box.
140
+ * @property {StringExpression} [text-justify] Text justification within the text box.
75
141
  * If not set, text is justified towards the `textAlign` anchor.
76
142
  * Otherwise, use options `'left'`, `'center'`, or `'right'` to justify the text within the text box.
77
143
  * **Note:** `text-justify` is ignored for immediate rendering and also for `'text-placement': 'line'`.
78
- * @property {CanvasTextBaseline} [text-baseline='middle'] Text base line. Possible values: `'bottom'`, `'top'`, `'middle'`, `'alphabetic'`,
144
+ * @property {StringExpression} [text-baseline='middle'] Text base line. Possible values: `'bottom'`, `'top'`, `'middle'`, `'alphabetic'`,
79
145
  * `'hanging'`, `'ideographic'`.
80
- * @property {Array<number>} [text-padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of
146
+ * @property {NumberArrayExpression} [text-padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of
81
147
  * values in the array is `[top, right, bottom, left]`.
82
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-fill-color] The fill color. Specify `'none'` to avoid hit detection on the fill.
83
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-background-fill-color] The fill color.
84
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-stroke-color] The stroke color.
85
- * @property {CanvasLineCap} [text-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
86
- * @property {CanvasLineJoin} [text-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
87
- * @property {Array<number>} [text-stroke-line-dash] Line dash pattern.
88
- * @property {number} [text-stroke-line-dash-offset=0] Line dash offset.
89
- * @property {number} [text-stroke-miter-limit=10] Miter limit.
90
- * @property {number} [text-stroke-width] Stroke pixel width.
91
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-background-stroke-color] The stroke color.
92
- * @property {CanvasLineCap} [text-background-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
93
- * @property {CanvasLineJoin} [text-background-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
94
- * @property {Array<number>} [text-background-stroke-line-dash] Line dash pattern.
95
- * @property {number} [text-background-stroke-line-dash-offset=0] Line dash offset.
96
- * @property {number} [text-background-stroke-miter-limit=10] Miter limit.
97
- * @property {number} [text-background-stroke-width] Stroke pixel width.
148
+ * @property {ColorExpression} [text-fill-color] The fill color. Specify `'none'` to avoid hit detection on the fill.
149
+ * @property {ColorExpression} [text-background-fill-color] The fill color.
150
+ * @property {ColorExpression} [text-stroke-color] The stroke color.
151
+ * @property {StringExpression} [text-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
152
+ * @property {StringExpression} [text-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
153
+ * @property {NumberArrayExpression} [text-stroke-line-dash] Line dash pattern.
154
+ * @property {NumberExpression} [text-stroke-line-dash-offset=0] Line dash offset.
155
+ * @property {NumberExpression} [text-stroke-miter-limit=10] Miter limit.
156
+ * @property {NumberExpression} [text-stroke-width] Stroke pixel width.
157
+ * @property {ColorExpression} [text-background-stroke-color] The stroke color.
158
+ * @property {StringExpression} [text-background-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
159
+ * @property {StringExpression} [text-background-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
160
+ * @property {NumberArrayExpression} [text-background-stroke-line-dash] Line dash pattern.
161
+ * @property {NumberExpression} [text-background-stroke-line-dash-offset=0] Line dash offset.
162
+ * @property {NumberExpression} [text-background-stroke-miter-limit=10] Miter limit.
163
+ * @property {NumberExpression} [text-background-stroke-width] Stroke pixel width.
164
+ * @property {NumberExpression} [z-index] The zIndex of the style.
98
165
  */
99
166
 
100
167
  /**
@@ -103,12 +170,7 @@ import Text from './Text.js';
103
170
  *
104
171
  * @typedef {Object} FlatIcon
105
172
  * @property {string} [icon-src] Image source URI.
106
- * @property {HTMLImageElement|HTMLCanvasElement} [icon-img] Image object for the icon. If the `icon-src` option is not provided then the
107
- * provided image must already be loaded. And in that case, it is required
108
- * to provide the size of the image, with the `icon-img-size` option.
109
- * @property {import("../size.js").Size} [icon-img-size] Image size in pixels. Only required if `icon-img` is set and `icon-src` is not.
110
- * The provided size needs to match the actual size of the image.
111
- * @property {Array<number>} [icon-anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
173
+ * @property {NumberArrayExpression} [icon-anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
112
174
  * @property {import("./Icon.js").IconOrigin} [icon-anchor-origin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,
113
175
  * `top-left` or `top-right`.
114
176
  * @property {import("./Icon.js").IconAnchorUnits} [icon-anchor-x-units='fraction'] Units in which the anchor x value is
@@ -124,20 +186,21 @@ import Text from './Text.js';
124
186
  * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
125
187
  * @property {Array<number>} [icon-offset=[0, 0]] Offset, which, together with the size and the offset origin, define the
126
188
  * sub-rectangle to use from the original icon image.
127
- * @property {Array<number>} [icon-displacement=[0,0]] Displacement of the icon.
189
+ * @property {NumberArrayExpression} [icon-displacement=[0,0]] Displacement of the icon.
128
190
  * @property {import("./Icon.js").IconOrigin} [icon-offset-origin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,
129
191
  * `top-left` or `top-right`.
130
- * @property {number} [icon-opacity=1] Opacity of the icon.
131
- * @property {number|import("../size.js").Size} [icon-scale=1] Scale.
192
+ * @property {NumberExpression} [icon-opacity=1] Opacity of the icon.
193
+ * @property {SizeExpression} [icon-scale=1] Scale.
132
194
  * @property {number} [icon-width] Width of the icon. If not specified, the actual image width will be used. Cannot be combined
133
195
  * with `scale`.
134
196
  * @property {number} [icon-height] Height of the icon. If not specified, the actual image height will be used. Cannot be combined
135
197
  * with `scale`.
136
- * @property {number} [icon-rotation=0] Rotation in radians (positive rotation clockwise).
137
- * @property {boolean} [icon-rotate-with-view=false] Whether to rotate the icon with the view.
198
+ * @property {NumberExpression} [icon-rotation=0] Rotation in radians (positive rotation clockwise).
199
+ * @property {BooleanExpression} [icon-rotate-with-view=false] Whether to rotate the icon with the view.
138
200
  * @property {import("../size.js").Size} [icon-size] Icon size in pixel. Can be used together with `icon-offset` to define the
139
201
  * sub-rectangle to use from the origin (sprite) icon image.
140
202
  * @property {"declutter"|"obstacle"|"none"|undefined} [icon-declutter-mode] Declutter mode
203
+ * @property {NumberExpression} [z-index] The zIndex of the style.
141
204
  */
142
205
 
143
206
  /**
@@ -146,24 +209,25 @@ import Text from './Text.js';
146
209
  * @typedef {Object} FlatShape
147
210
  * @property {number} [shape-points] Number of points for stars and regular polygons. In case of a polygon, the number of points
148
211
  * is the number of sides.
149
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [shape-fill-color] The fill color.
150
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [shape-stroke-color] The stroke color.
151
- * @property {number} [shape-stroke-width] Stroke pixel width.
152
- * @property {CanvasLineCap} [shape-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
153
- * @property {CanvasLineJoin} [shape-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
154
- * @property {Array<number>} [shape-stroke-line-dash] Line dash pattern.
155
- * @property {number} [shape-stroke-line-dash-offset=0] Line dash offset.
156
- * @property {number} [shape-stroke-miter-limit=10] Miter limit.
212
+ * @property {ColorExpression} [shape-fill-color] The fill color.
213
+ * @property {ColorExpression} [shape-stroke-color] The stroke color.
214
+ * @property {NumberExpression} [shape-stroke-width] Stroke pixel width.
215
+ * @property {StringExpression} [shape-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
216
+ * @property {StringExpression} [shape-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
217
+ * @property {NumberArrayExpression} [shape-stroke-line-dash] Line dash pattern.
218
+ * @property {NumberExpression} [shape-stroke-line-dash-offset=0] Line dash offset.
219
+ * @property {NumberExpression} [shape-stroke-miter-limit=10] Miter limit.
157
220
  * @property {number} [shape-radius] Radius of a regular polygon.
158
221
  * @property {number} [shape-radius1] First radius of a star. Ignored if radius is set.
159
222
  * @property {number} [shape-radius2] Second radius of a star.
160
223
  * @property {number} [shape-angle=0] Shape's angle in radians. A value of 0 will have one of the shape's point facing up.
161
- * @property {Array<number>} [shape-displacement=[0,0]] Displacement of the shape
162
- * @property {number} [shape-rotation=0] Rotation in radians (positive rotation clockwise).
163
- * @property {boolean} [shape-rotate-with-view=false] Whether to rotate the shape with the view.
164
- * @property {number|import("../size.js").Size} [shape-scale=1] Scale. Unless two dimensional scaling is required a better
224
+ * @property {NumberArrayExpression} [shape-displacement=[0,0]] Displacement of the shape
225
+ * @property {NumberExpression} [shape-rotation=0] Rotation in radians (positive rotation clockwise).
226
+ * @property {BooleanExpression} [shape-rotate-with-view=false] Whether to rotate the shape with the view.
227
+ * @property {SizeExpression} [shape-scale=1] Scale. Unless two dimensional scaling is required a better
165
228
  * result may be obtained with appropriate settings for `shape-radius`, `shape-radius1` and `shape-radius2`.
166
229
  * @property {"declutter"|"obstacle"|"none"|undefined} [shape-declutter-mode] Declutter mode.
230
+ * @property {NumberExpression} [z-index] The zIndex of the style.
167
231
  */
168
232
 
169
233
  /**
@@ -171,189 +235,40 @@ import Text from './Text.js';
171
235
  *
172
236
  * @typedef {Object} FlatCircle
173
237
  * @property {number} [circle-radius] Circle radius.
174
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [circle-fill-color] The fill color.
175
- * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [circle-stroke-color] The stroke color.
176
- * @property {number} [circle-stroke-width] Stroke pixel width.
177
- * @property {CanvasLineCap} [circle-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
178
- * @property {CanvasLineJoin} [circle-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
179
- * @property {Array<number>} [circle-stroke-line-dash] Line dash pattern.
180
- * @property {number} [circle-stroke-line-dash-offset=0] Line dash offset.
181
- * @property {number} [circle-stroke-miter-limit=10] Miter limit.
182
- * @property {Array<number>} [circle-displacement=[0,0]] displacement
183
- * @property {number|import("../size.js").Size} [circle-scale=1] Scale. A two dimensional scale will produce an ellipse.
238
+ * @property {ColorExpression} [circle-fill-color] The fill color.
239
+ * @property {ColorExpression} [circle-stroke-color] The stroke color.
240
+ * @property {NumberExpression} [circle-stroke-width] Stroke pixel width.
241
+ * @property {StringExpression} [circle-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
242
+ * @property {StringExpression} [circle-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
243
+ * @property {NumberArrayExpression} [circle-stroke-line-dash] Line dash pattern.
244
+ * @property {NumberExpression} [circle-stroke-line-dash-offset=0] Line dash offset.
245
+ * @property {NumberExpression} [circle-stroke-miter-limit=10] Miter limit.
246
+ * @property {NumberArrayExpression} [circle-displacement=[0,0]] displacement
247
+ * @property {SizeExpression} [circle-scale=1] Scale. A two dimensional scale will produce an ellipse.
184
248
  * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `circle-radius`.
185
- * @property {number} [circle-rotation=0] Rotation in radians
249
+ * @property {NumberExpression} [circle-rotation=0] Rotation in radians
186
250
  * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).
187
- * @property {boolean} [circle-rotate-with-view=false] Whether to rotate the shape with the view
251
+ * @property {BooleanExpression} [circle-rotate-with-view=false] Whether to rotate the shape with the view
188
252
  * (meaningful only when used in conjunction with a two dimensional scale).
189
253
  * @property {"declutter"|"obstacle"|"none"|undefined} [circle-declutter-mode] Declutter mode
254
+ * @property {NumberExpression} [z-index] The zIndex of the style.
190
255
  */
191
256
 
192
257
  /**
193
- * @param {FlatStyle} flatStyle A flat style literal.
194
- * @return {import("./Style.js").default} A style instance.
195
- */
196
- export function toStyle(flatStyle) {
197
- const style = new Style({
198
- fill: getFill(flatStyle, ''),
199
- stroke: getStroke(flatStyle, ''),
200
- text: getText(flatStyle),
201
- image: getImage(flatStyle),
202
- });
203
-
204
- return style;
205
- }
206
-
207
- /**
208
- * @param {FlatStyle} flatStyle The flat style.
209
- * @param {string} prefix The property prefix.
210
- * @return {Fill|null|undefined} The fill (if any).
211
- */
212
- function getFill(flatStyle, prefix) {
213
- const color = flatStyle[prefix + 'fill-color'];
214
- if (!color) {
215
- return;
216
- }
217
- if (color === 'none') {
218
- return null;
219
- }
220
-
221
- return new Fill({color: color});
222
- }
223
-
224
- /**
225
- * @param {FlatStyle} flatStyle The flat style.
226
- * @param {string} prefix The property prefix.
227
- * @return {Stroke|undefined} The stroke (if any).
228
- */
229
- function getStroke(flatStyle, prefix) {
230
- const width = flatStyle[prefix + 'stroke-width'];
231
- const color = flatStyle[prefix + 'stroke-color'];
232
- if (!width && !color) {
233
- return;
234
- }
235
-
236
- return new Stroke({
237
- width: width,
238
- color: color,
239
- lineCap: flatStyle[prefix + 'stroke-line-cap'],
240
- lineJoin: flatStyle[prefix + 'stroke-line-join'],
241
- lineDash: flatStyle[prefix + 'stroke-line-dash'],
242
- lineDashOffset: flatStyle[prefix + 'stroke-line-dash-offset'],
243
- miterLimit: flatStyle[prefix + 'stroke-miter-limit'],
244
- });
245
- }
246
-
247
- /**
248
- * @param {FlatStyle} flatStyle The flat style.
249
- * @return {Text|undefined} The text (if any).
250
- */
251
- function getText(flatStyle) {
252
- const value = flatStyle['text-value'];
253
- if (!value) {
254
- return;
255
- }
256
-
257
- const text = new Text({
258
- text: value,
259
- font: flatStyle['text-font'],
260
- maxAngle: flatStyle['text-max-angle'],
261
- offsetX: flatStyle['text-offset-x'],
262
- offsetY: flatStyle['text-offset-y'],
263
- overflow: flatStyle['text-overflow'],
264
- placement: flatStyle['text-placement'],
265
- repeat: flatStyle['text-repeat'],
266
- scale: flatStyle['text-scale'],
267
- rotateWithView: flatStyle['text-rotate-with-view'],
268
- rotation: flatStyle['text-rotation'],
269
- textAlign: flatStyle['text-align'],
270
- justify: flatStyle['text-justify'],
271
- textBaseline: flatStyle['text-baseline'],
272
- padding: flatStyle['text-padding'],
273
- fill: getFill(flatStyle, 'text-'),
274
- backgroundFill: getFill(flatStyle, 'text-background-'),
275
- stroke: getStroke(flatStyle, 'text-'),
276
- backgroundStroke: getStroke(flatStyle, 'text-background-'),
277
- });
278
-
279
- return text;
280
- }
281
-
282
- /**
283
- * @param {FlatStyle} flatStyle The flat style.
284
- * @return {import("./Image.js").default|undefined} The image (if any).
258
+ * These default style properties are applied when no other style is given.
259
+ *
260
+ * @typedef {Object} DefaultStyle
261
+ * @property {string} fill-color `'rgba(255,255,255,0.4)'`
262
+ * @property {string} stroke-color `'#3399CC'`
263
+ * @property {number} stroke-width `1.25`
264
+ * @property {number} circle-radius `5`
265
+ * @property {string} circle-fill-color `'rgba(255,255,255,0.4)'`
266
+ * @property {number} circle-stroke-width `1.25`
267
+ * @property {string} circle-stroke-color `'#3399CC'`
285
268
  */
286
- function getImage(flatStyle) {
287
- const iconSrc = flatStyle['icon-src'];
288
- const iconImg = flatStyle['icon-img'];
289
- if (iconSrc || iconImg) {
290
- const icon = new Icon({
291
- src: iconSrc,
292
- img: iconImg,
293
- imgSize: flatStyle['icon-img-size'],
294
- anchor: flatStyle['icon-anchor'],
295
- anchorOrigin: flatStyle['icon-anchor-origin'],
296
- anchorXUnits: flatStyle['icon-anchor-x-units'],
297
- anchorYUnits: flatStyle['icon-anchor-y-units'],
298
- color: flatStyle['icon-color'],
299
- crossOrigin: flatStyle['icon-cross-origin'],
300
- offset: flatStyle['icon-offset'],
301
- displacement: flatStyle['icon-displacement'],
302
- opacity: flatStyle['icon-opacity'],
303
- scale: flatStyle['icon-scale'],
304
- width: flatStyle['icon-width'],
305
- height: flatStyle['icon-height'],
306
- rotation: flatStyle['icon-rotation'],
307
- rotateWithView: flatStyle['icon-rotate-with-view'],
308
- size: flatStyle['icon-size'],
309
- declutterMode: flatStyle['icon-declutter-mode'],
310
- });
311
- return icon;
312
- }
313
-
314
- const shapePoints = flatStyle['shape-points'];
315
- if (shapePoints) {
316
- const prefix = 'shape-';
317
- const shape = new RegularShape({
318
- points: shapePoints,
319
- fill: getFill(flatStyle, prefix),
320
- stroke: getStroke(flatStyle, prefix),
321
- radius: flatStyle['shape-radius'],
322
- radius1: flatStyle['shape-radius1'],
323
- radius2: flatStyle['shape-radius2'],
324
- angle: flatStyle['shape-angle'],
325
- displacement: flatStyle['shape-displacement'],
326
- rotation: flatStyle['shape-rotation'],
327
- rotateWithView: flatStyle['shape-rotate-with-view'],
328
- scale: flatStyle['shape-scale'],
329
- declutterMode: flatStyle['shape-declutter-mode'],
330
- });
331
-
332
- return shape;
333
- }
334
-
335
- const circleRadius = flatStyle['circle-radius'];
336
- if (circleRadius) {
337
- const prefix = 'circle-';
338
- const circle = new Circle({
339
- radius: circleRadius,
340
- fill: getFill(flatStyle, prefix),
341
- stroke: getStroke(flatStyle, prefix),
342
- displacement: flatStyle['circle-displacement'],
343
- scale: flatStyle['circle-scale'],
344
- rotation: flatStyle['circle-rotation'],
345
- rotateWithView: flatStyle['circle-rotate-with-view'],
346
- declutterMode: flatStyle['circle-declutter-mode'],
347
- });
348
-
349
- return circle;
350
- }
351
-
352
- return;
353
- }
354
269
 
355
270
  /**
356
- * @return {import('./flat.js').FlatStyle} The default flat style.
271
+ * @return {DefaultStyle} The default flat style.
357
272
  */
358
273
  export function createDefaultStyle() {
359
274
  return {
@@ -366,3 +281,16 @@ export function createDefaultStyle() {
366
281
  'circle-stroke-color': '#3399CC',
367
282
  };
368
283
  }
284
+
285
+ /**
286
+ * A rule is used to conditionally apply a style. If the rule's filter evaluates to true,
287
+ * the style will be applied.
288
+ *
289
+ * @typedef {Object} Rule
290
+ * @property {FlatStyle|Array<FlatStyle>} style The style to be applied if the filter matches.
291
+ * @property {import("../expr/expression.js").EncodedExpression} [filter] The filter used
292
+ * to determine if a style applies. If no filter is included, the rule always applies
293
+ * (unless it is an else rule).
294
+ * @property {boolean} [else] If true, the rule applies only if no other previous rule applies.
295
+ * If the else rule also has a filter, the rule will not apply if the filter does not match.
296
+ */