@vaadin/bundles 25.0.0-alpha3 → 25.0.0-alpha5

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 (192) hide show
  1. package/node_modules_ol_ImageCanvas_js.js +76 -83
  2. package/node_modules_ol_ImageCanvas_js.js.map +1 -1
  3. package/node_modules_ol_TileRange_js.js +128 -110
  4. package/node_modules_ol_TileRange_js.js.map +1 -1
  5. package/node_modules_ol_Tile_js.js +279 -0
  6. package/node_modules_ol_Tile_js.js.map +1 -0
  7. package/node_modules_ol_VectorRenderTile_js.js +428 -143
  8. package/node_modules_ol_VectorRenderTile_js.js.map +1 -1
  9. package/node_modules_ol_VectorTile_js.js +405 -119
  10. package/node_modules_ol_VectorTile_js.js.map +1 -1
  11. package/node_modules_ol_control_MousePosition_js.js +327 -0
  12. package/node_modules_ol_control_MousePosition_js.js.map +1 -0
  13. package/node_modules_ol_control_ZoomToExtent_js.js +118 -0
  14. package/node_modules_ol_control_ZoomToExtent_js.js.map +1 -0
  15. package/node_modules_ol_events_SnapEvent_js.js +79 -0
  16. package/node_modules_ol_events_SnapEvent_js.js.map +1 -0
  17. package/node_modules_ol_featureloader_js.js +205 -0
  18. package/node_modules_ol_featureloader_js.js.map +1 -0
  19. package/node_modules_ol_geom_Circle_js.js +300 -0
  20. package/node_modules_ol_geom_Circle_js.js.map +1 -0
  21. package/node_modules_ol_geom_GeometryCollection_js.js +369 -0
  22. package/node_modules_ol_geom_GeometryCollection_js.js.map +1 -0
  23. package/node_modules_ol_geom_MultiPoint_js.js +228 -0
  24. package/node_modules_ol_geom_MultiPoint_js.js.map +1 -0
  25. package/node_modules_ol_geom_flat_center_js.js +47 -0
  26. package/node_modules_ol_geom_flat_center_js.js.map +1 -0
  27. package/node_modules_ol_geom_flat_geodesic_js.js +123 -88
  28. package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -1
  29. package/node_modules_ol_geom_flat_interpolate_js.js +230 -0
  30. package/node_modules_ol_geom_flat_interpolate_js.js.map +1 -0
  31. package/node_modules_ol_geom_flat_length_js-_375a0.js +58 -0
  32. package/node_modules_ol_geom_flat_length_js-_375a0.js.map +1 -0
  33. package/node_modules_ol_geom_flat_length_js-_375a1.js +58 -0
  34. package/node_modules_ol_geom_flat_length_js-_375a1.js.map +1 -0
  35. package/node_modules_ol_geom_flat_length_js-_375a2.js +58 -0
  36. package/node_modules_ol_geom_flat_length_js-_375a2.js.map +1 -0
  37. package/node_modules_ol_geom_flat_length_js-_375a3.js +58 -0
  38. package/node_modules_ol_geom_flat_length_js-_375a3.js.map +1 -0
  39. package/node_modules_ol_geom_flat_length_js-_375a4.js +58 -0
  40. package/node_modules_ol_geom_flat_length_js-_375a4.js.map +1 -0
  41. package/node_modules_ol_geom_flat_linechunk_js.js +76 -0
  42. package/node_modules_ol_geom_flat_linechunk_js.js.map +1 -0
  43. package/node_modules_ol_geom_flat_straightchunk_js.js +68 -0
  44. package/node_modules_ol_geom_flat_straightchunk_js.js.map +1 -0
  45. package/node_modules_ol_geom_flat_textpath_js.js +178 -0
  46. package/node_modules_ol_geom_flat_textpath_js.js.map +1 -0
  47. package/node_modules_ol_interaction_DblClickDragZoom_js.js +285 -0
  48. package/node_modules_ol_interaction_DblClickDragZoom_js.js.map +1 -0
  49. package/node_modules_ol_interaction_DragAndDrop_js.js +351 -0
  50. package/node_modules_ol_interaction_DragAndDrop_js.js.map +1 -0
  51. package/node_modules_ol_interaction_DragRotateAndZoom_js.js +159 -0
  52. package/node_modules_ol_interaction_DragRotateAndZoom_js.js.map +1 -0
  53. package/node_modules_ol_layer_Vector_js-_49290.js +110 -0
  54. package/node_modules_ol_layer_Vector_js-_49290.js.map +1 -0
  55. package/node_modules_ol_layer_Vector_js-_49291.js +110 -0
  56. package/node_modules_ol_layer_Vector_js-_49291.js.map +1 -0
  57. package/node_modules_ol_layer_Vector_js-_49292.js +110 -0
  58. package/node_modules_ol_layer_Vector_js-_49292.js.map +1 -0
  59. package/node_modules_ol_layer_Vector_js-_49293.js +110 -0
  60. package/node_modules_ol_layer_Vector_js-_49293.js.map +1 -0
  61. package/node_modules_ol_loadingstrategy_js.js +95 -0
  62. package/node_modules_ol_loadingstrategy_js.js.map +1 -0
  63. package/node_modules_ol_render_VectorContext_js-_3ad60.js +144 -0
  64. package/node_modules_ol_render_VectorContext_js-_3ad60.js.map +1 -0
  65. package/node_modules_ol_render_VectorContext_js-_3ad61.js +144 -0
  66. package/node_modules_ol_render_VectorContext_js-_3ad61.js.map +1 -0
  67. package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js +372 -0
  68. package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js.map +1 -0
  69. package/node_modules_ol_render_canvas_ImageBuilder_js.js +318 -0
  70. package/node_modules_ol_render_canvas_ImageBuilder_js.js.map +1 -0
  71. package/node_modules_ol_render_canvas_Instruction_js.js +66 -0
  72. package/node_modules_ol_render_canvas_Instruction_js.js.map +1 -0
  73. package/node_modules_ol_render_canvas_LineStringBuilder_js.js +187 -0
  74. package/node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -0
  75. package/node_modules_ol_render_canvas_PolygonBuilder_js.js +276 -0
  76. package/node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
  77. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js +156 -0
  78. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js.map +1 -0
  79. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js +156 -0
  80. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js.map +1 -0
  81. package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js +301 -0
  82. package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js.map +1 -0
  83. package/node_modules_ol_renderer_Layer_js.js +219 -0
  84. package/node_modules_ol_renderer_Layer_js.js.map +1 -0
  85. package/node_modules_ol_source_Source_js.js +256 -0
  86. package/node_modules_ol_source_Source_js.js.map +1 -0
  87. package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js +318 -0
  88. package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js.map +1 -0
  89. package/node_modules_ol_source_VectorEventType_js.js +80 -0
  90. package/node_modules_ol_source_VectorEventType_js.js.map +1 -0
  91. package/node_modules_ol_structs_RBush_js.js +242 -0
  92. package/node_modules_ol_structs_RBush_js.js.map +1 -0
  93. package/node_modules_ol_style_js.js +2 -1
  94. package/node_modules_ol_style_js.js.map +1 -1
  95. package/node_modules_rbush_rbush_min_js.js +16 -0
  96. package/node_modules_rbush_rbush_min_js.js.map +1 -0
  97. package/package.json +142 -146
  98. package/vaadin-bundle.json +2447 -2352
  99. package/vaadin.js +52246 -63791
  100. package/vaadin.js.map +1 -1
  101. package/vendors-node_modules_dompurify_dist_purify_es_mjs.js +1364 -0
  102. package/vendors-node_modules_dompurify_dist_purify_es_mjs.js.map +1 -0
  103. package/vendors-node_modules_dompurify_dist_purify_js.js +26 -21
  104. package/vendors-node_modules_dompurify_dist_purify_js.js.map +1 -1
  105. package/vendors-node_modules_marked_lib_marked_esm_js.js +2205 -0
  106. package/vendors-node_modules_marked_lib_marked_esm_js.js.map +1 -0
  107. package/vendors-node_modules_marked_lib_marked_umd_js.js +2164 -2556
  108. package/vendors-node_modules_marked_lib_marked_umd_js.js.map +1 -1
  109. package/vendors-node_modules_ol_Feature_js.js +360 -0
  110. package/vendors-node_modules_ol_Feature_js.js.map +1 -0
  111. package/vendors-node_modules_ol_Geolocation_js.js +352 -293
  112. package/vendors-node_modules_ol_Geolocation_js.js.map +1 -1
  113. package/vendors-node_modules_ol_ImageTile_js.js +494 -0
  114. package/vendors-node_modules_ol_ImageTile_js.js.map +1 -0
  115. package/vendors-node_modules_ol_Overlay_js.js +606 -0
  116. package/vendors-node_modules_ol_Overlay_js.js.map +1 -0
  117. package/vendors-node_modules_ol_control_FullScreen_js.js +417 -0
  118. package/vendors-node_modules_ol_control_FullScreen_js.js.map +1 -0
  119. package/vendors-node_modules_ol_control_OverviewMap_js.js +711 -0
  120. package/vendors-node_modules_ol_control_OverviewMap_js.js.map +1 -0
  121. package/vendors-node_modules_ol_control_ScaleLine_js.js +509 -0
  122. package/vendors-node_modules_ol_control_ScaleLine_js.js.map +1 -0
  123. package/vendors-node_modules_ol_control_ZoomSlider_js.js +418 -0
  124. package/vendors-node_modules_ol_control_ZoomSlider_js.js.map +1 -0
  125. package/vendors-node_modules_ol_control_js.js +490 -0
  126. package/vendors-node_modules_ol_control_js.js.map +1 -0
  127. package/vendors-node_modules_ol_geom_LineString_js.js +574 -0
  128. package/vendors-node_modules_ol_geom_LineString_js.js.map +1 -0
  129. package/vendors-node_modules_ol_geom_MultiLineString_js.js +405 -0
  130. package/vendors-node_modules_ol_geom_MultiLineString_js.js.map +1 -0
  131. package/vendors-node_modules_ol_geom_MultiPolygon_js.js +773 -0
  132. package/vendors-node_modules_ol_geom_MultiPolygon_js.js.map +1 -0
  133. package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js +769 -0
  134. package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js.map +1 -0
  135. package/vendors-node_modules_ol_index_js.js +526 -675
  136. package/vendors-node_modules_ol_index_js.js.map +1 -1
  137. package/vendors-node_modules_ol_interaction_Draw_js.js +2777 -0
  138. package/vendors-node_modules_ol_interaction_Draw_js.js.map +1 -0
  139. package/vendors-node_modules_ol_interaction_Extent_js.js +586 -0
  140. package/vendors-node_modules_ol_interaction_Extent_js.js.map +1 -0
  141. package/vendors-node_modules_ol_interaction_Link_js.js +489 -0
  142. package/vendors-node_modules_ol_interaction_Link_js.js.map +1 -0
  143. package/vendors-node_modules_ol_interaction_Modify_js.js +1841 -0
  144. package/vendors-node_modules_ol_interaction_Modify_js.js.map +1 -0
  145. package/vendors-node_modules_ol_interaction_Select_js.js +623 -0
  146. package/vendors-node_modules_ol_interaction_Select_js.js.map +1 -0
  147. package/vendors-node_modules_ol_interaction_Snap_js.js +982 -0
  148. package/vendors-node_modules_ol_interaction_Snap_js.js.map +1 -0
  149. package/vendors-node_modules_ol_interaction_Translate_js.js +466 -0
  150. package/vendors-node_modules_ol_interaction_Translate_js.js.map +1 -0
  151. package/vendors-node_modules_ol_interaction_js.js +872 -0
  152. package/vendors-node_modules_ol_interaction_js.js.map +1 -0
  153. package/vendors-node_modules_ol_layer_Graticule_js.js +1374 -989
  154. package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -1
  155. package/vendors-node_modules_ol_render_Feature_js.js +546 -0
  156. package/vendors-node_modules_ol_render_Feature_js.js.map +1 -0
  157. package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js +897 -0
  158. package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -0
  159. package/vendors-node_modules_ol_render_canvas_Builder_js.js +907 -0
  160. package/vendors-node_modules_ol_render_canvas_Builder_js.js.map +1 -0
  161. package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js +539 -0
  162. package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -0
  163. package/vendors-node_modules_ol_render_canvas_Executor_js.js +1715 -0
  164. package/vendors-node_modules_ol_render_canvas_Executor_js.js.map +1 -0
  165. package/vendors-node_modules_ol_render_canvas_Immediate_js.js +1208 -0
  166. package/vendors-node_modules_ol_render_canvas_Immediate_js.js.map +1 -0
  167. package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js +825 -0
  168. package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -0
  169. package/vendors-node_modules_ol_renderer_canvas_Layer_js.js +654 -0
  170. package/vendors-node_modules_ol_renderer_canvas_Layer_js.js.map +1 -0
  171. package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js +1044 -0
  172. package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -0
  173. package/vendors-node_modules_ol_renderer_vector_js.js +460 -0
  174. package/vendors-node_modules_ol_renderer_vector_js.js.map +1 -0
  175. package/vendors-node_modules_ol_source_Vector_js.js +2091 -0
  176. package/vendors-node_modules_ol_source_Vector_js.js.map +1 -0
  177. package/node_modules_ol_ImageTile_js.js +0 -177
  178. package/node_modules_ol_ImageTile_js.js.map +0 -1
  179. package/node_modules_ol_render_js.js +0 -131
  180. package/node_modules_ol_render_js.js.map +0 -1
  181. package/node_modules_ol_structs_LRUCache_js.js +0 -275
  182. package/node_modules_ol_structs_LRUCache_js.js.map +0 -1
  183. package/node_modules_ol_tilecoord_js.js +0 -115
  184. package/node_modules_ol_tilecoord_js.js.map +0 -1
  185. package/vendors-node_modules_ol_TileCache_js.js +0 -461
  186. package/vendors-node_modules_ol_TileCache_js.js.map +0 -1
  187. package/vendors-node_modules_ol_Tile_js.js +0 -330
  188. package/vendors-node_modules_ol_Tile_js.js.map +0 -1
  189. package/vendors-node_modules_ol_style_Text_js.js +0 -509
  190. package/vendors-node_modules_ol_style_Text_js.js.map +0 -1
  191. package/vendors-node_modules_rbush_index_js.js +0 -531
  192. package/vendors-node_modules_rbush_index_js.js.map +0 -1
@@ -12,13 +12,14 @@ __webpack_require__.r(__webpack_exports__);
12
12
  /* harmony export */ "meridian": () => (/* binding */ meridian),
13
13
  /* harmony export */ "parallel": () => (/* binding */ parallel)
14
14
  /* harmony export */ });
15
- /* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../proj.js */ "./node_modules/ol/proj.js");
16
15
  /* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../math.js */ "./node_modules/ol/math.js");
16
+ /* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../proj.js */ "./node_modules/ol/proj.js");
17
17
  /**
18
18
  * @module ol/geom/flat/geodesic
19
19
  */
20
20
 
21
21
 
22
+
22
23
  /**
23
24
  * @param {function(number): import("../../coordinate.js").Coordinate} interpolate Interpolate function.
24
25
  * @param {import("../../proj.js").TransformFunction} transform Transform from longitude/latitude to
@@ -27,62 +28,72 @@ __webpack_require__.r(__webpack_exports__);
27
28
  * @return {Array<number>} Flat coordinates.
28
29
  */
29
30
  function line(interpolate, transform, squaredTolerance) {
30
- // FIXME reduce garbage generation
31
- // FIXME optimize stack operations
32
- /** @type {Array<number>} */
33
- var flatCoordinates = [];
34
- var geoA = interpolate(0);
35
- var geoB = interpolate(1);
36
- var a = transform(geoA);
37
- var b = transform(geoB);
38
- /** @type {Array<import("../../coordinate.js").Coordinate>} */
39
- var geoStack = [geoB, geoA];
40
- /** @type {Array<import("../../coordinate.js").Coordinate>} */
41
- var stack = [b, a];
42
- /** @type {Array<number>} */
43
- var fractionStack = [1, 0];
44
- /** @type {!Object<string, boolean>} */
45
- var fractions = {};
46
- var maxIterations = 1e5;
47
- var geoM, m, fracA, fracB, fracM, key;
48
- while (--maxIterations > 0 && fractionStack.length > 0) {
49
- // Pop the a coordinate off the stack
50
- fracA = fractionStack.pop();
51
- geoA = geoStack.pop();
52
- a = stack.pop();
53
- // Add the a coordinate if it has not been added yet
54
- key = fracA.toString();
55
- if (!(key in fractions)) {
56
- flatCoordinates.push(a[0], a[1]);
57
- fractions[key] = true;
58
- }
59
- // Pop the b coordinate off the stack
60
- fracB = fractionStack.pop();
61
- geoB = geoStack.pop();
62
- b = stack.pop();
63
- // Find the m point between the a and b coordinates
64
- fracM = (fracA + fracB) / 2;
65
- geoM = interpolate(fracM);
66
- m = transform(geoM);
67
- if ((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.squaredSegmentDistance)(m[0], m[1], a[0], a[1], b[0], b[1]) <
68
- squaredTolerance) {
69
- // If the m point is sufficiently close to the straight line, then we
70
- // discard it. Just use the b coordinate and move on to the next line
71
- // segment.
72
- flatCoordinates.push(b[0], b[1]);
73
- key = fracB.toString();
74
- fractions[key] = true;
75
- }
76
- else {
77
- // Otherwise, we need to subdivide the current line segment. Split it
78
- // into two and push the two line segments onto the stack.
79
- fractionStack.push(fracB, fracM, fracM, fracA);
80
- stack.push(b, m, m, a);
81
- geoStack.push(geoB, geoM, geoM, geoA);
82
- }
31
+ // FIXME reduce garbage generation
32
+ // FIXME optimize stack operations
33
+
34
+ /** @type {Array<number>} */
35
+ const flatCoordinates = [];
36
+
37
+ let geoA = interpolate(0);
38
+ let geoB = interpolate(1);
39
+
40
+ let a = transform(geoA);
41
+ let b = transform(geoB);
42
+
43
+ /** @type {Array<import("../../coordinate.js").Coordinate>} */
44
+ const geoStack = [geoB, geoA];
45
+ /** @type {Array<import("../../coordinate.js").Coordinate>} */
46
+ const stack = [b, a];
47
+ /** @type {Array<number>} */
48
+ const fractionStack = [1, 0];
49
+
50
+ /** @type {!Object<string, boolean>} */
51
+ const fractions = {};
52
+
53
+ let maxIterations = 1e5;
54
+ let geoM, m, fracA, fracB, fracM, key;
55
+
56
+ while (--maxIterations > 0 && fractionStack.length > 0) {
57
+ // Pop the a coordinate off the stack
58
+ fracA = fractionStack.pop();
59
+ geoA = geoStack.pop();
60
+ a = stack.pop();
61
+ // Add the a coordinate if it has not been added yet
62
+ key = fracA.toString();
63
+ if (!(key in fractions)) {
64
+ flatCoordinates.push(a[0], a[1]);
65
+ fractions[key] = true;
66
+ }
67
+ // Pop the b coordinate off the stack
68
+ fracB = fractionStack.pop();
69
+ geoB = geoStack.pop();
70
+ b = stack.pop();
71
+ // Find the m point between the a and b coordinates
72
+ fracM = (fracA + fracB) / 2;
73
+ geoM = interpolate(fracM);
74
+ m = transform(geoM);
75
+ if (
76
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.squaredSegmentDistance)(m[0], m[1], a[0], a[1], b[0], b[1]) <
77
+ squaredTolerance
78
+ ) {
79
+ // If the m point is sufficiently close to the straight line, then we
80
+ // discard it. Just use the b coordinate and move on to the next line
81
+ // segment.
82
+ flatCoordinates.push(b[0], b[1]);
83
+ key = fracB.toString();
84
+ fractions[key] = true;
85
+ } else {
86
+ // Otherwise, we need to subdivide the current line segment. Split it
87
+ // into two and push the two line segments onto the stack.
88
+ fractionStack.push(fracB, fracM, fracM, fracA);
89
+ stack.push(b, m, m, a);
90
+ geoStack.push(geoB, geoM, geoM, geoA);
83
91
  }
84
- return flatCoordinates;
92
+ }
93
+
94
+ return flatCoordinates;
85
95
  }
96
+
86
97
  /**
87
98
  * Generate a great-circle arcs between two lat/lon points.
88
99
  * @param {number} lon1 Longitude 1 in degrees.
@@ -93,36 +104,53 @@ function line(interpolate, transform, squaredTolerance) {
93
104
  * @param {number} squaredTolerance Squared tolerance.
94
105
  * @return {Array<number>} Flat coordinates.
95
106
  */
96
- function greatCircleArc(lon1, lat1, lon2, lat2, projection, squaredTolerance) {
97
- var geoProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
98
- var cosLat1 = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat1));
99
- var sinLat1 = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat1));
100
- var cosLat2 = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat2));
101
- var sinLat2 = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat2));
102
- var cosDeltaLon = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon2 - lon1));
103
- var sinDeltaLon = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon2 - lon1));
104
- var d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
105
- return line(
107
+ function greatCircleArc(
108
+ lon1,
109
+ lat1,
110
+ lon2,
111
+ lat2,
112
+ projection,
113
+ squaredTolerance,
114
+ ) {
115
+ const geoProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
116
+
117
+ const cosLat1 = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat1));
118
+ const sinLat1 = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat1));
119
+ const cosLat2 = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat2));
120
+ const sinLat2 = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat2));
121
+ const cosDeltaLon = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon2 - lon1));
122
+ const sinDeltaLon = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon2 - lon1));
123
+ const d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
124
+
125
+ return line(
106
126
  /**
107
127
  * @param {number} frac Fraction.
108
128
  * @return {import("../../coordinate.js").Coordinate} Coordinate.
109
129
  */
110
130
  function (frac) {
111
- if (1 <= d) {
112
- return [lon2, lat2];
113
- }
114
- var D = frac * Math.acos(d);
115
- var cosD = Math.cos(D);
116
- var sinD = Math.sin(D);
117
- var y = sinDeltaLon * cosLat2;
118
- var x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon;
119
- var theta = Math.atan2(y, x);
120
- var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
121
- var lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon1) +
122
- Math.atan2(Math.sin(theta) * sinD * cosLat1, cosD - sinLat1 * Math.sin(lat));
123
- return [(0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toDegrees)(lon), (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toDegrees)(lat)];
124
- }, (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(geoProjection, projection), squaredTolerance);
131
+ if (1 <= d) {
132
+ return [lon2, lat2];
133
+ }
134
+ const D = frac * Math.acos(d);
135
+ const cosD = Math.cos(D);
136
+ const sinD = Math.sin(D);
137
+ const y = sinDeltaLon * cosLat2;
138
+ const x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon;
139
+ const theta = Math.atan2(y, x);
140
+ const lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
141
+ const lon =
142
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon1) +
143
+ Math.atan2(
144
+ Math.sin(theta) * sinD * cosLat1,
145
+ cosD - sinLat1 * Math.sin(lat),
146
+ );
147
+ return [(0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toDegrees)(lon), (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toDegrees)(lat)];
148
+ },
149
+ (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(geoProjection, projection),
150
+ squaredTolerance,
151
+ );
125
152
  }
153
+
126
154
  /**
127
155
  * Generate a meridian (line at constant longitude).
128
156
  * @param {number} lon Longitude.
@@ -133,16 +161,20 @@ function greatCircleArc(lon1, lat1, lon2, lat2, projection, squaredTolerance) {
133
161
  * @return {Array<number>} Flat coordinates.
134
162
  */
135
163
  function meridian(lon, lat1, lat2, projection, squaredTolerance) {
136
- var epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
137
- return line(
164
+ const epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
165
+ return line(
138
166
  /**
139
167
  * @param {number} frac Fraction.
140
168
  * @return {import("../../coordinate.js").Coordinate} Coordinate.
141
169
  */
142
170
  function (frac) {
143
- return [lon, lat1 + (lat2 - lat1) * frac];
144
- }, (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection), squaredTolerance);
171
+ return [lon, lat1 + (lat2 - lat1) * frac];
172
+ },
173
+ (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection),
174
+ squaredTolerance,
175
+ );
145
176
  }
177
+
146
178
  /**
147
179
  * Generate a parallel (line at constant latitude).
148
180
  * @param {number} lat Latitude.
@@ -153,17 +185,20 @@ function meridian(lon, lat1, lat2, projection, squaredTolerance) {
153
185
  * @return {Array<number>} Flat coordinates.
154
186
  */
155
187
  function parallel(lat, lon1, lon2, projection, squaredTolerance) {
156
- var epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
157
- return line(
188
+ const epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
189
+ return line(
158
190
  /**
159
191
  * @param {number} frac Fraction.
160
192
  * @return {import("../../coordinate.js").Coordinate} Coordinate.
161
193
  */
162
194
  function (frac) {
163
- return [lon1 + (lon2 - lon1) * frac, lat];
164
- }, (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection), squaredTolerance);
195
+ return [lon1 + (lon2 - lon1) * frac, lat];
196
+ },
197
+ (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection),
198
+ squaredTolerance,
199
+ );
165
200
  }
166
- //# sourceMappingURL=geodesic.js.map
201
+
167
202
 
168
203
  /***/ }),
169
204
 
@@ -178,39 +213,22 @@ __webpack_require__.r(__webpack_exports__);
178
213
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
179
214
  /* harmony export */ });
180
215
  /* harmony import */ var _Collection_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collection.js */ "./node_modules/ol/Collection.js");
181
- /* harmony import */ var _render_EventType_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../render/EventType.js */ "./node_modules/ol/render/EventType.js");
182
216
  /* harmony import */ var _Feature_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Feature.js */ "./node_modules/ol/Feature.js");
183
- /* harmony import */ var _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../style/Fill.js */ "./node_modules/ol/style/Fill.js");
184
- /* harmony import */ var _geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../geom/GeometryLayout.js */ "./node_modules/ol/geom/GeometryLayout.js");
217
+ /* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/ol/coordinate.js");
218
+ /* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
185
219
  /* harmony import */ var _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../geom/LineString.js */ "./node_modules/ol/geom/LineString.js");
186
220
  /* harmony import */ var _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../geom/Point.js */ "./node_modules/ol/geom/Point.js");
187
- /* harmony import */ var _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/Stroke.js */ "./node_modules/ol/style/Stroke.js");
188
- /* harmony import */ var _style_Style_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../style/Style.js */ "./node_modules/ol/style/Style.js");
189
- /* harmony import */ var _style_Text_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../style/Text.js */ "./node_modules/ol/style/Text.js");
190
- /* harmony import */ var _Vector_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Vector.js */ "./node_modules/ol/layer/Vector.js");
191
- /* harmony import */ var _source_Vector_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../source/Vector.js */ "./node_modules/ol/source/Vector.js");
192
- /* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
193
- /* harmony import */ var _obj_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../obj.js */ "./node_modules/ol/obj.js");
221
+ /* harmony import */ var _geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../geom/flat/geodesic.js */ "./node_modules/ol/geom/flat/geodesic.js");
194
222
  /* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../math.js */ "./node_modules/ol/math.js");
195
- /* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/ol/coordinate.js");
196
223
  /* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proj.js */ "./node_modules/ol/proj.js");
224
+ /* harmony import */ var _render_EventType_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../render/EventType.js */ "./node_modules/ol/render/EventType.js");
197
225
  /* harmony import */ var _render_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../render.js */ "./node_modules/ol/render.js");
198
- /* harmony import */ var _geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../geom/flat/geodesic.js */ "./node_modules/ol/geom/flat/geodesic.js");
199
- var __extends = (undefined && undefined.__extends) || (function () {
200
- var extendStatics = function (d, b) {
201
- extendStatics = Object.setPrototypeOf ||
202
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
203
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
204
- return extendStatics(d, b);
205
- };
206
- return function (d, b) {
207
- if (typeof b !== "function" && b !== null)
208
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
209
- extendStatics(d, b);
210
- function __() { this.constructor = d; }
211
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
212
- };
213
- })();
226
+ /* harmony import */ var _source_Vector_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../source/Vector.js */ "./node_modules/ol/source/Vector.js");
227
+ /* harmony import */ var _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../style/Fill.js */ "./node_modules/ol/style/Fill.js");
228
+ /* harmony import */ var _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/Stroke.js */ "./node_modules/ol/style/Stroke.js");
229
+ /* harmony import */ var _style_Style_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../style/Style.js */ "./node_modules/ol/style/Style.js");
230
+ /* harmony import */ var _style_Text_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../style/Text.js */ "./node_modules/ol/style/Text.js");
231
+ /* harmony import */ var _Vector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Vector.js */ "./node_modules/ol/layer/Vector.js");
214
232
  /**
215
233
  * @module ol/layer/Graticule
216
234
  */
@@ -232,27 +250,48 @@ var __extends = (undefined && undefined.__extends) || (function () {
232
250
 
233
251
 
234
252
 
235
-
236
253
  /**
237
254
  * @type {Stroke}
238
255
  * @private
239
256
  * @const
240
257
  */
241
- var DEFAULT_STROKE_STYLE = new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
242
- color: 'rgba(0,0,0,0.2)',
258
+ const DEFAULT_STROKE_STYLE = new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
259
+ color: 'rgba(0,0,0,0.2)',
243
260
  });
261
+
244
262
  /**
245
263
  * @type {Array<number>}
246
264
  * @private
247
265
  */
248
- var INTERVALS = [
249
- 90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001,
266
+ const INTERVALS = [
267
+ 90,
268
+ 45,
269
+ 30,
270
+ 20,
271
+ 10,
272
+ 5,
273
+ 2,
274
+ 1,
275
+ 30 / 60,
276
+ 20 / 60,
277
+ 10 / 60,
278
+ 5 / 60,
279
+ 2 / 60,
280
+ 1 / 60,
281
+ 30 / 3600,
282
+ 20 / 3600,
283
+ 10 / 3600,
284
+ 5 / 3600,
285
+ 2 / 3600,
286
+ 1 / 3600,
250
287
  ];
288
+
251
289
  /**
252
290
  * @typedef {Object} GraticuleLabelDataType
253
291
  * @property {Point} geom Geometry.
254
292
  * @property {string} text Text.
255
293
  */
294
+
256
295
  /**
257
296
  * @typedef {Object} Options
258
297
  * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
@@ -339,7 +378,7 @@ var INTERVALS = [
339
378
  * Note that the default's `textAlign` configuration will not work well for
340
379
  * `latLabelPosition` configurations that position labels close to the left of
341
380
  * the viewport.
342
- * @property {Array<number>} [intervals=[90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001]]
381
+ * @property {Array<number>} [intervals=[90, 45, 30, 20, 10, 5, 2, 1, 30/60, 20/60, 10/60, 5/60, 2/60, 1/60, 30/3600, 20/3600, 10/3600, 5/3600, 2/3600, 1/3600]]
343
382
  * Intervals (in degrees) for the graticule. Example to limit graticules to 30 and 10 degrees intervals:
344
383
  * ```js
345
384
  * [30, 10]
@@ -347,884 +386,1200 @@ var INTERVALS = [
347
386
  * @property {boolean} [wrapX=true] Whether to repeat the graticule horizontally.
348
387
  * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
349
388
  */
389
+
350
390
  /**
351
391
  * @classdesc
352
392
  * Layer that renders a grid for a coordinate system (currently only EPSG:4326 is supported).
353
393
  * Note that the view projection must define both extent and worldExtent.
354
394
  *
355
- * @fires import("../render/Event.js").RenderEvent
356
- * @extends {VectorLayer<import("../source/Vector.js").default>}
395
+ * @fires import("../render/Event.js").RenderEvent#prerender
396
+ * @fires import("../render/Event.js").RenderEvent#postrender
397
+ * @extends {VectorLayer<VectorSource<Feature>>}
357
398
  * @api
358
399
  */
359
- var Graticule = /** @class */ (function (_super) {
360
- __extends(Graticule, _super);
400
+ class Graticule extends _Vector_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
401
+ /**
402
+ * @param {Options} [options] Options.
403
+ */
404
+ constructor(options) {
405
+ options = options ? options : {};
406
+
407
+ const baseOptions = Object.assign(
408
+ {
409
+ updateWhileAnimating: true,
410
+ updateWhileInteracting: true,
411
+ renderBuffer: 0,
412
+ },
413
+ options,
414
+ );
415
+
416
+ delete baseOptions.maxLines;
417
+ delete baseOptions.strokeStyle;
418
+ delete baseOptions.targetSize;
419
+ delete baseOptions.showLabels;
420
+ delete baseOptions.lonLabelFormatter;
421
+ delete baseOptions.latLabelFormatter;
422
+ delete baseOptions.lonLabelPosition;
423
+ delete baseOptions.latLabelPosition;
424
+ delete baseOptions.lonLabelStyle;
425
+ delete baseOptions.latLabelStyle;
426
+ delete baseOptions.intervals;
427
+ super(baseOptions);
428
+
361
429
  /**
362
- * @param {Options} [opt_options] Options.
430
+ * @type {import("../proj/Projection.js").default}
431
+ * @private
363
432
  */
364
- function Graticule(opt_options) {
365
- var _this = this;
366
- var options = opt_options ? opt_options : {};
367
- var baseOptions = (0,_obj_js__WEBPACK_IMPORTED_MODULE_2__.assign)({
368
- updateWhileAnimating: true,
369
- updateWhileInteracting: true,
370
- renderBuffer: 0,
371
- }, options);
372
- delete baseOptions.maxLines;
373
- delete baseOptions.strokeStyle;
374
- delete baseOptions.targetSize;
375
- delete baseOptions.showLabels;
376
- delete baseOptions.lonLabelFormatter;
377
- delete baseOptions.latLabelFormatter;
378
- delete baseOptions.lonLabelPosition;
379
- delete baseOptions.latLabelPosition;
380
- delete baseOptions.lonLabelStyle;
381
- delete baseOptions.latLabelStyle;
382
- delete baseOptions.intervals;
383
- _this = _super.call(this, baseOptions) || this;
384
- /**
385
- * @type {import("../proj/Projection.js").default}
386
- */
387
- _this.projection_ = null;
388
- /**
389
- * @type {number}
390
- * @private
391
- */
392
- _this.maxLat_ = Infinity;
393
- /**
394
- * @type {number}
395
- * @private
396
- */
397
- _this.maxLon_ = Infinity;
398
- /**
399
- * @type {number}
400
- * @private
401
- */
402
- _this.minLat_ = -Infinity;
403
- /**
404
- * @type {number}
405
- * @private
406
- */
407
- _this.minLon_ = -Infinity;
408
- /**
409
- * @type {number}
410
- * @private
411
- */
412
- _this.maxX_ = Infinity;
413
- /**
414
- * @type {number}
415
- * @private
416
- */
417
- _this.maxY_ = Infinity;
418
- /**
419
- * @type {number}
420
- * @private
421
- */
422
- _this.minX_ = -Infinity;
423
- /**
424
- * @type {number}
425
- * @private
426
- */
427
- _this.minY_ = -Infinity;
428
- /**
429
- * @type {number}
430
- * @private
431
- */
432
- _this.targetSize_ =
433
- options.targetSize !== undefined ? options.targetSize : 100;
434
- /**
435
- * @type {number}
436
- * @private
437
- */
438
- _this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
439
- /**
440
- * @type {Array<LineString>}
441
- * @private
442
- */
443
- _this.meridians_ = [];
444
- /**
445
- * @type {Array<LineString>}
446
- * @private
447
- */
448
- _this.parallels_ = [];
449
- /**
450
- * @type {Stroke}
451
- * @private
452
- */
453
- _this.strokeStyle_ =
454
- options.strokeStyle !== undefined
455
- ? options.strokeStyle
456
- : DEFAULT_STROKE_STYLE;
457
- /**
458
- * @type {import("../proj.js").TransformFunction|undefined}
459
- * @private
460
- */
461
- _this.fromLonLatTransform_ = undefined;
462
- /**
463
- * @type {import("../proj.js").TransformFunction|undefined}
464
- * @private
465
- */
466
- _this.toLonLatTransform_ = undefined;
467
- /**
468
- * @type {import("../coordinate.js").Coordinate}
469
- * @private
470
- */
471
- _this.projectionCenterLonLat_ = null;
472
- /**
473
- * @type {import("../coordinate.js").Coordinate}
474
- * @private
475
- */
476
- _this.bottomLeft_ = null;
477
- /**
478
- * @type {import("../coordinate.js").Coordinate}
479
- * @private
480
- */
481
- _this.bottomRight_ = null;
482
- /**
483
- * @type {import("../coordinate.js").Coordinate}
484
- * @private
485
- */
486
- _this.topLeft_ = null;
487
- /**
488
- * @type {import("../coordinate.js").Coordinate}
489
- * @private
490
- */
491
- _this.topRight_ = null;
492
- /**
493
- * @type {Array<GraticuleLabelDataType>}
494
- * @private
495
- */
496
- _this.meridiansLabels_ = null;
497
- /**
498
- * @type {Array<GraticuleLabelDataType>}
499
- * @private
500
- */
501
- _this.parallelsLabels_ = null;
502
- if (options.showLabels) {
503
- /**
504
- * @type {null|function(number):string}
505
- * @private
506
- */
507
- _this.lonLabelFormatter_ =
508
- options.lonLabelFormatter == undefined
509
- ? _coordinate_js__WEBPACK_IMPORTED_MODULE_3__.degreesToStringHDMS.bind(_this, 'EW')
510
- : options.lonLabelFormatter;
511
- /**
512
- * @type {function(number):string}
513
- * @private
514
- */
515
- _this.latLabelFormatter_ =
516
- options.latLabelFormatter == undefined
517
- ? _coordinate_js__WEBPACK_IMPORTED_MODULE_3__.degreesToStringHDMS.bind(_this, 'NS')
518
- : options.latLabelFormatter;
519
- /**
520
- * Longitude label position in fractions (0..1) of view extent. 0 means
521
- * bottom, 1 means top.
522
- * @type {number}
523
- * @private
524
- */
525
- _this.lonLabelPosition_ =
526
- options.lonLabelPosition == undefined ? 0 : options.lonLabelPosition;
527
- /**
528
- * Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
529
- * means right.
530
- * @type {number}
531
- * @private
532
- */
533
- _this.latLabelPosition_ =
534
- options.latLabelPosition == undefined ? 1 : options.latLabelPosition;
535
- /**
536
- * @type {Style}
537
- * @private
538
- */
539
- _this.lonLabelStyleBase_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
540
- text: options.lonLabelStyle !== undefined
541
- ? options.lonLabelStyle.clone()
542
- : new _style_Text_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
543
- font: '12px Calibri,sans-serif',
544
- textBaseline: 'bottom',
545
- fill: new _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
546
- color: 'rgba(0,0,0,1)',
547
- }),
548
- stroke: new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
549
- color: 'rgba(255,255,255,1)',
550
- width: 3,
551
- }),
552
- }),
553
- });
554
- /**
555
- * @private
556
- * @param {import("../Feature").default} feature Feature
557
- * @return {Style} style
558
- */
559
- _this.lonLabelStyle_ = function (feature) {
560
- var label = feature.get('graticule_label');
561
- this.lonLabelStyleBase_.getText().setText(label);
562
- return this.lonLabelStyleBase_;
563
- }.bind(_this);
564
- /**
565
- * @type {Style}
566
- * @private
567
- */
568
- _this.latLabelStyleBase_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
569
- text: options.latLabelStyle !== undefined
570
- ? options.latLabelStyle.clone()
571
- : new _style_Text_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
572
- font: '12px Calibri,sans-serif',
573
- textAlign: 'right',
574
- fill: new _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
575
- color: 'rgba(0,0,0,1)',
576
- }),
577
- stroke: new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
578
- color: 'rgba(255,255,255,1)',
579
- width: 3,
580
- }),
581
- }),
582
- });
583
- /**
584
- * @private
585
- * @param {import("../Feature").default} feature Feature
586
- * @return {Style} style
587
- */
588
- _this.latLabelStyle_ = function (feature) {
589
- var label = feature.get('graticule_label');
590
- this.latLabelStyleBase_.getText().setText(label);
591
- return this.latLabelStyleBase_;
592
- }.bind(_this);
593
- _this.meridiansLabels_ = [];
594
- _this.parallelsLabels_ = [];
595
- _this.addEventListener(_render_EventType_js__WEBPACK_IMPORTED_MODULE_7__["default"].POSTRENDER, _this.drawLabels_.bind(_this));
596
- }
597
- /**
598
- * @type {Array<number>}
599
- * @private
600
- */
601
- _this.intervals_ =
602
- options.intervals !== undefined ? options.intervals : INTERVALS;
603
- // use a source with a custom loader for lines & text
604
- _this.setSource(new _source_Vector_js__WEBPACK_IMPORTED_MODULE_8__["default"]({
605
- loader: _this.loaderFunction.bind(_this),
606
- strategy: _this.strategyFunction.bind(_this),
607
- features: new _Collection_js__WEBPACK_IMPORTED_MODULE_9__["default"](),
608
- overlaps: false,
609
- useSpatialIndex: false,
610
- wrapX: options.wrapX,
611
- }));
612
- /**
613
- * feature pool to use when updating graticule
614
- * @type {Array<Feature>}
615
- * @private
616
- */
617
- _this.featurePool_ = [];
618
- /**
619
- * @type {Style}
620
- * @private
621
- */
622
- _this.lineStyle_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
623
- stroke: _this.strokeStyle_,
624
- });
625
- /**
626
- * @type {?import("../extent.js").Extent}
627
- * @private
628
- */
629
- _this.loadedExtent_ = null;
630
- /**
631
- * @type {?import("../extent.js").Extent}
632
- * @private
633
- */
634
- _this.renderedExtent_ = null;
635
- /**
636
- * @type {?number}
637
- * @private
638
- */
639
- _this.renderedResolution_ = null;
640
- _this.setRenderOrder(null);
641
- return _this;
642
- }
433
+ this.projection_ = null;
434
+
643
435
  /**
644
- * Strategy function for loading features based on the view's extent and
645
- * resolution.
646
- * @param {import("../extent.js").Extent} extent Extent.
647
- * @param {number} resolution Resolution.
648
- * @return {Array<import("../extent.js").Extent>} Extents.
436
+ * @type {number}
437
+ * @private
649
438
  */
650
- Graticule.prototype.strategyFunction = function (extent, resolution) {
651
- // extents may be passed in different worlds, to avoid endless loop we use only one
652
- var realWorldExtent = extent.slice();
653
- if (this.projection_ && this.getSource().getWrapX()) {
654
- (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.wrapX)(realWorldExtent, this.projection_);
655
- }
656
- if (this.loadedExtent_) {
657
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.approximatelyEquals)(this.loadedExtent_, realWorldExtent, resolution)) {
658
- // make sure result is exactly equal to previous extent
659
- realWorldExtent = this.loadedExtent_.slice();
660
- }
661
- else {
662
- // we should not keep track of loaded extents
663
- this.getSource().removeLoadedExtent(this.loadedExtent_);
664
- }
665
- }
666
- return [realWorldExtent];
667
- };
439
+ this.maxLat_ = Infinity;
440
+
668
441
  /**
669
- * Update geometries in the source based on current view
670
- * @param {import("../extent").Extent} extent Extent
671
- * @param {number} resolution Resolution
672
- * @param {import("../proj/Projection.js").default} projection Projection
442
+ * @type {number}
443
+ * @private
673
444
  */
674
- Graticule.prototype.loaderFunction = function (extent, resolution, projection) {
675
- this.loadedExtent_ = extent;
676
- var source = this.getSource();
677
- // only consider the intersection between our own extent & the requested one
678
- var layerExtent = this.getExtent() || [
679
- -Infinity,
680
- -Infinity,
681
- Infinity,
682
- Infinity,
683
- ];
684
- var renderExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getIntersection)(layerExtent, extent);
685
- if (this.renderedExtent_ &&
686
- (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.equals)(this.renderedExtent_, renderExtent) &&
687
- this.renderedResolution_ === resolution) {
688
- return;
689
- }
690
- this.renderedExtent_ = renderExtent;
691
- this.renderedResolution_ = resolution;
692
- // bail out if nothing to render
693
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.isEmpty)(renderExtent)) {
694
- return;
695
- }
696
- // update projection info
697
- var center = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(renderExtent);
698
- var squaredTolerance = (resolution * resolution) / 4;
699
- var updateProjectionInfo = !this.projection_ || !(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.equivalent)(this.projection_, projection);
700
- if (updateProjectionInfo) {
701
- this.updateProjectionInfo_(projection);
702
- }
703
- this.createGraticule_(renderExtent, center, resolution, squaredTolerance);
704
- // first make sure we have enough features in the pool
705
- var featureCount = this.meridians_.length + this.parallels_.length;
706
- if (this.meridiansLabels_) {
707
- featureCount += this.meridians_.length;
708
- }
709
- if (this.parallelsLabels_) {
710
- featureCount += this.parallels_.length;
711
- }
712
- var feature;
713
- while (featureCount > this.featurePool_.length) {
714
- feature = new _Feature_js__WEBPACK_IMPORTED_MODULE_11__["default"]();
715
- this.featurePool_.push(feature);
716
- }
717
- var featuresColl = source.getFeaturesCollection();
718
- featuresColl.clear();
719
- var poolIndex = 0;
720
- // add features for the lines & labels
721
- var i, l;
722
- for (i = 0, l = this.meridians_.length; i < l; ++i) {
723
- feature = this.featurePool_[poolIndex++];
724
- feature.setGeometry(this.meridians_[i]);
725
- feature.setStyle(this.lineStyle_);
726
- featuresColl.push(feature);
727
- }
728
- for (i = 0, l = this.parallels_.length; i < l; ++i) {
729
- feature = this.featurePool_[poolIndex++];
730
- feature.setGeometry(this.parallels_[i]);
731
- feature.setStyle(this.lineStyle_);
732
- featuresColl.push(feature);
733
- }
734
- };
445
+ this.maxLon_ = Infinity;
446
+
735
447
  /**
736
- * @param {number} lon Longitude.
737
- * @param {number} minLat Minimal latitude.
738
- * @param {number} maxLat Maximal latitude.
739
- * @param {number} squaredTolerance Squared tolerance.
740
- * @param {import("../extent.js").Extent} extent Extent.
741
- * @param {number} index Index.
742
- * @return {number} Index.
448
+ * @type {number}
743
449
  * @private
744
450
  */
745
- Graticule.prototype.addMeridian_ = function (lon, minLat, maxLat, squaredTolerance, extent, index) {
746
- var lineString = this.getMeridian_(lon, minLat, maxLat, squaredTolerance, index);
747
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.intersects)(lineString.getExtent(), extent)) {
748
- if (this.meridiansLabels_) {
749
- var text = this.lonLabelFormatter_(lon);
750
- if (index in this.meridiansLabels_) {
751
- this.meridiansLabels_[index].text = text;
752
- }
753
- else {
754
- this.meridiansLabels_[index] = {
755
- geom: new _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__["default"]([]),
756
- text: text,
757
- };
758
- }
759
- }
760
- this.meridians_[index++] = lineString;
761
- }
762
- return index;
763
- };
451
+ this.minLat_ = -Infinity;
452
+
764
453
  /**
765
- * @param {number} lat Latitude.
766
- * @param {number} minLon Minimal longitude.
767
- * @param {number} maxLon Maximal longitude.
768
- * @param {number} squaredTolerance Squared tolerance.
769
- * @param {import("../extent.js").Extent} extent Extent.
770
- * @param {number} index Index.
771
- * @return {number} Index.
454
+ * @type {number}
772
455
  * @private
773
456
  */
774
- Graticule.prototype.addParallel_ = function (lat, minLon, maxLon, squaredTolerance, extent, index) {
775
- var lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance, index);
776
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.intersects)(lineString.getExtent(), extent)) {
777
- if (this.parallelsLabels_) {
778
- var text = this.latLabelFormatter_(lat);
779
- if (index in this.parallelsLabels_) {
780
- this.parallelsLabels_[index].text = text;
781
- }
782
- else {
783
- this.parallelsLabels_[index] = {
784
- geom: new _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__["default"]([]),
785
- text: text,
786
- };
787
- }
788
- }
789
- this.parallels_[index++] = lineString;
790
- }
791
- return index;
792
- };
457
+ this.minLon_ = -Infinity;
458
+
793
459
  /**
794
- * @param {import("../render/Event.js").default} event Render event.
460
+ * @type {number}
795
461
  * @private
796
462
  */
797
- Graticule.prototype.drawLabels_ = function (event) {
798
- var rotation = event.frameState.viewState.rotation;
799
- var resolution = event.frameState.viewState.resolution;
800
- var size = event.frameState.size;
801
- var extent = event.frameState.extent;
802
- var rotationCenter = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(extent);
803
- var rotationExtent = extent;
804
- if (rotation) {
805
- var unrotatedWidth = size[0] * resolution;
806
- var unrotatedHeight = size[1] * resolution;
807
- rotationExtent = [
808
- rotationCenter[0] - unrotatedWidth / 2,
809
- rotationCenter[1] - unrotatedHeight / 2,
810
- rotationCenter[0] + unrotatedWidth / 2,
811
- rotationCenter[1] + unrotatedHeight / 2,
812
- ];
813
- }
814
- var startWorld = 0;
815
- var endWorld = 0;
816
- var labelsAtStart = this.latLabelPosition_ < 0.5;
817
- var projectionExtent = this.projection_.getExtent();
818
- var worldWidth = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(projectionExtent);
819
- if (this.getSource().getWrapX() &&
820
- this.projection_.canWrapX() &&
821
- !(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsExtent)(projectionExtent, extent)) {
822
- startWorld = Math.floor((extent[0] - projectionExtent[0]) / worldWidth);
823
- endWorld = Math.ceil((extent[2] - projectionExtent[2]) / worldWidth);
824
- var inverted = Math.abs(rotation) > Math.PI / 2;
825
- labelsAtStart = labelsAtStart !== inverted;
826
- }
827
- var vectorContext = (0,_render_js__WEBPACK_IMPORTED_MODULE_13__.getVectorContext)(event);
828
- for (var world = startWorld; world <= endWorld; ++world) {
829
- var poolIndex = this.meridians_.length + this.parallels_.length;
830
- var feature = void 0, index = void 0, l = void 0, textPoint = void 0;
831
- if (this.meridiansLabels_) {
832
- for (index = 0, l = this.meridiansLabels_.length; index < l; ++index) {
833
- var lineString = this.meridians_[index];
834
- if (!rotation && world === 0) {
835
- textPoint = this.getMeridianPoint_(lineString, extent, index);
836
- }
837
- else {
838
- var clone = lineString.clone();
839
- clone.translate(world * worldWidth, 0);
840
- clone.rotate(-rotation, rotationCenter);
841
- textPoint = this.getMeridianPoint_(clone, rotationExtent, index);
842
- textPoint.rotate(rotation, rotationCenter);
843
- }
844
- feature = this.featurePool_[poolIndex++];
845
- feature.setGeometry(textPoint);
846
- feature.set('graticule_label', this.meridiansLabels_[index].text);
847
- vectorContext.drawFeature(feature, this.lonLabelStyle_(feature));
848
- }
849
- }
850
- if (this.parallelsLabels_) {
851
- if ((world === startWorld && labelsAtStart) ||
852
- (world === endWorld && !labelsAtStart)) {
853
- for (index = 0, l = this.parallels_.length; index < l; ++index) {
854
- var lineString = this.parallels_[index];
855
- if (!rotation && world === 0) {
856
- textPoint = this.getParallelPoint_(lineString, extent, index);
857
- }
858
- else {
859
- var clone = lineString.clone();
860
- clone.translate(world * worldWidth, 0);
861
- clone.rotate(-rotation, rotationCenter);
862
- textPoint = this.getParallelPoint_(clone, rotationExtent, index);
863
- textPoint.rotate(rotation, rotationCenter);
864
- }
865
- feature = this.featurePool_[poolIndex++];
866
- feature.setGeometry(textPoint);
867
- feature.set('graticule_label', this.parallelsLabels_[index].text);
868
- vectorContext.drawFeature(feature, this.latLabelStyle_(feature));
869
- }
870
- }
871
- }
872
- }
873
- };
463
+ this.maxX_ = Infinity;
464
+
874
465
  /**
875
- * @param {import("../extent.js").Extent} extent Extent.
876
- * @param {import("../coordinate.js").Coordinate} center Center.
877
- * @param {number} resolution Resolution.
878
- * @param {number} squaredTolerance Squared tolerance.
466
+ * @type {number}
879
467
  * @private
880
468
  */
881
- Graticule.prototype.createGraticule_ = function (extent, center, resolution, squaredTolerance) {
882
- var interval = this.getInterval_(resolution);
883
- if (interval == -1) {
884
- this.meridians_.length = 0;
885
- this.parallels_.length = 0;
886
- if (this.meridiansLabels_) {
887
- this.meridiansLabels_.length = 0;
888
- }
889
- if (this.parallelsLabels_) {
890
- this.parallelsLabels_.length = 0;
891
- }
892
- return;
893
- }
894
- var wrapX = false;
895
- var projectionExtent = this.projection_.getExtent();
896
- var worldWidth = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(projectionExtent);
897
- if (this.getSource().getWrapX() &&
898
- this.projection_.canWrapX() &&
899
- !(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsExtent)(projectionExtent, extent)) {
900
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(extent) >= worldWidth) {
901
- extent[0] = projectionExtent[0];
902
- extent[2] = projectionExtent[2];
903
- }
904
- else {
905
- wrapX = true;
906
- }
907
- }
908
- // Constrain the center to fit into the extent available to the graticule
909
- var validCenterP = [
910
- (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(center[0], this.minX_, this.maxX_),
911
- (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(center[1], this.minY_, this.maxY_),
912
- ];
913
- // Transform the center to lon lat
914
- // Some projections may have a void area at the poles
915
- // so replace any NaN latitudes with the min or max value closest to a pole
916
- var centerLonLat = this.toLonLatTransform_(validCenterP);
917
- if (isNaN(centerLonLat[1])) {
918
- centerLonLat[1] =
919
- Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
920
- ? this.maxLat_
921
- : this.minLat_;
922
- }
923
- var centerLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLonLat[0], this.minLon_, this.maxLon_);
924
- var centerLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLonLat[1], this.minLat_, this.maxLat_);
925
- var maxLines = this.maxLines_;
926
- var cnt, idx, lat, lon;
927
- // Limit the extent to fit into the extent available to the graticule
928
- var validExtentP = extent;
929
- if (!wrapX) {
930
- validExtentP = [
931
- (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[0], this.minX_, this.maxX_),
932
- (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[1], this.minY_, this.maxY_),
933
- (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[2], this.minX_, this.maxX_),
934
- (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[3], this.minY_, this.maxY_),
935
- ];
936
- }
937
- // Transform the extent to get the lon lat ranges for the edges of the extent
938
- var validExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.applyTransform)(validExtentP, this.toLonLatTransform_, undefined, 8);
939
- var maxLat = validExtent[3];
940
- var maxLon = validExtent[2];
941
- var minLat = validExtent[1];
942
- var minLon = validExtent[0];
943
- if (!wrapX) {
944
- // Check if extremities of the world extent lie inside the extent
945
- // (for example the pole in a polar projection)
946
- // and extend the extent as appropriate
947
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.bottomLeft_)) {
948
- minLon = this.minLon_;
949
- minLat = this.minLat_;
950
- }
951
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.bottomRight_)) {
952
- maxLon = this.maxLon_;
953
- minLat = this.minLat_;
954
- }
955
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.topLeft_)) {
956
- minLon = this.minLon_;
957
- maxLat = this.maxLat_;
958
- }
959
- if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.topRight_)) {
960
- maxLon = this.maxLon_;
961
- maxLat = this.maxLat_;
962
- }
963
- // The transformed center may also extend the lon lat ranges used for rendering
964
- maxLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(maxLat, centerLat, this.maxLat_);
965
- maxLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(maxLon, centerLon, this.maxLon_);
966
- minLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(minLat, this.minLat_, centerLat);
967
- minLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(minLon, this.minLon_, centerLon);
968
- }
969
- // Create meridians
970
- centerLon = Math.floor(centerLon / interval) * interval;
971
- lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLon, this.minLon_, this.maxLon_);
972
- idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0);
973
- cnt = 0;
974
- if (wrapX) {
975
- while ((lon -= interval) >= minLon && cnt++ < maxLines) {
976
- idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
977
- }
978
- }
979
- else {
980
- while (lon != this.minLon_ && cnt++ < maxLines) {
981
- lon = Math.max(lon - interval, this.minLon_);
982
- idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
983
- }
984
- }
985
- lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLon, this.minLon_, this.maxLon_);
986
- cnt = 0;
987
- if (wrapX) {
988
- while ((lon += interval) <= maxLon && cnt++ < maxLines) {
989
- idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
990
- }
991
- }
992
- else {
993
- while (lon != this.maxLon_ && cnt++ < maxLines) {
994
- lon = Math.min(lon + interval, this.maxLon_);
995
- idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
996
- }
997
- }
998
- this.meridians_.length = idx;
999
- if (this.meridiansLabels_) {
1000
- this.meridiansLabels_.length = idx;
1001
- }
1002
- // Create parallels
1003
- centerLat = Math.floor(centerLat / interval) * interval;
1004
- lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, this.minLat_, this.maxLat_);
1005
- idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0);
1006
- cnt = 0;
1007
- while (lat != this.minLat_ && cnt++ < maxLines) {
1008
- lat = Math.max(lat - interval, this.minLat_);
1009
- idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
1010
- }
1011
- lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, this.minLat_, this.maxLat_);
1012
- cnt = 0;
1013
- while (lat != this.maxLat_ && cnt++ < maxLines) {
1014
- lat = Math.min(lat + interval, this.maxLat_);
1015
- idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
1016
- }
1017
- this.parallels_.length = idx;
1018
- if (this.parallelsLabels_) {
1019
- this.parallelsLabels_.length = idx;
1020
- }
1021
- };
469
+ this.maxY_ = Infinity;
470
+
1022
471
  /**
1023
- * @param {number} resolution Resolution.
1024
- * @return {number} The interval in degrees.
472
+ * @type {number}
1025
473
  * @private
1026
474
  */
1027
- Graticule.prototype.getInterval_ = function (resolution) {
1028
- var centerLon = this.projectionCenterLonLat_[0];
1029
- var centerLat = this.projectionCenterLonLat_[1];
1030
- var interval = -1;
1031
- var target = Math.pow(this.targetSize_ * resolution, 2);
1032
- /** @type {Array<number>} **/
1033
- var p1 = [];
1034
- /** @type {Array<number>} **/
1035
- var p2 = [];
1036
- for (var i = 0, ii = this.intervals_.length; i < ii; ++i) {
1037
- var delta = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(this.intervals_[i] / 2, 0, 90);
1038
- // Don't attempt to transform latitudes beyond the poles!
1039
- var clampedLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, -90 + delta, 90 - delta);
1040
- p1[0] = centerLon - delta;
1041
- p1[1] = clampedLat - delta;
1042
- p2[0] = centerLon + delta;
1043
- p2[1] = clampedLat + delta;
1044
- this.fromLonLatTransform_(p1, p1);
1045
- this.fromLonLatTransform_(p2, p2);
1046
- var dist = Math.pow(p2[0] - p1[0], 2) + Math.pow(p2[1] - p1[1], 2);
1047
- if (dist <= target) {
1048
- break;
1049
- }
1050
- interval = this.intervals_[i];
1051
- }
1052
- return interval;
1053
- };
475
+ this.minX_ = -Infinity;
476
+
1054
477
  /**
1055
- * @param {number} lon Longitude.
1056
- * @param {number} minLat Minimal latitude.
1057
- * @param {number} maxLat Maximal latitude.
1058
- * @param {number} squaredTolerance Squared tolerance.
1059
- * @return {LineString} The meridian line string.
1060
- * @param {number} index Index.
478
+ * @type {number}
1061
479
  * @private
1062
480
  */
1063
- Graticule.prototype.getMeridian_ = function (lon, minLat, maxLat, squaredTolerance, index) {
1064
- var flatCoordinates = (0,_geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__.meridian)(lon, minLat, maxLat, this.projection_, squaredTolerance);
1065
- var lineString = this.meridians_[index];
1066
- if (!lineString) {
1067
- lineString = new _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__["default"](flatCoordinates, _geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY);
1068
- this.meridians_[index] = lineString;
1069
- }
1070
- else {
1071
- lineString.setFlatCoordinates(_geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY, flatCoordinates);
1072
- lineString.changed();
1073
- }
1074
- return lineString;
1075
- };
481
+ this.minY_ = -Infinity;
482
+
1076
483
  /**
1077
- * @param {LineString} lineString Meridian
1078
- * @param {import("../extent.js").Extent} extent Extent.
1079
- * @param {number} index Index.
1080
- * @return {Point} Meridian point.
484
+ * @type {number}
1081
485
  * @private
1082
486
  */
1083
- Graticule.prototype.getMeridianPoint_ = function (lineString, extent, index) {
1084
- var flatCoordinates = lineString.getFlatCoordinates();
1085
- var bottom = 1;
1086
- var top = flatCoordinates.length - 1;
1087
- if (flatCoordinates[bottom] > flatCoordinates[top]) {
1088
- bottom = top;
1089
- top = 1;
1090
- }
1091
- var clampedBottom = Math.max(extent[1], flatCoordinates[bottom]);
1092
- var clampedTop = Math.min(extent[3], flatCoordinates[top]);
1093
- var lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_, clampedBottom, clampedTop);
1094
- var coordinate0 = flatCoordinates[bottom - 1] +
1095
- ((flatCoordinates[top - 1] - flatCoordinates[bottom - 1]) *
1096
- (lat - flatCoordinates[bottom])) /
1097
- (flatCoordinates[top] - flatCoordinates[bottom]);
1098
- var coordinate = [coordinate0, lat];
1099
- var point = this.meridiansLabels_[index].geom;
1100
- point.setCoordinates(coordinate);
1101
- return point;
1102
- };
487
+ this.targetSize_ =
488
+ options.targetSize !== undefined ? options.targetSize : 100;
489
+
1103
490
  /**
1104
- * Get the list of meridians. Meridians are lines of equal longitude.
1105
- * @return {Array<LineString>} The meridians.
1106
- * @api
491
+ * @type {number}
492
+ * @private
1107
493
  */
1108
- Graticule.prototype.getMeridians = function () {
1109
- return this.meridians_;
1110
- };
494
+ this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
495
+
1111
496
  /**
1112
- * @param {number} lat Latitude.
1113
- * @param {number} minLon Minimal longitude.
1114
- * @param {number} maxLon Maximal longitude.
1115
- * @param {number} squaredTolerance Squared tolerance.
1116
- * @return {LineString} The parallel line string.
1117
- * @param {number} index Index.
497
+ * @type {Array<LineString>}
1118
498
  * @private
1119
499
  */
1120
- Graticule.prototype.getParallel_ = function (lat, minLon, maxLon, squaredTolerance, index) {
1121
- var flatCoordinates = (0,_geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__.parallel)(lat, minLon, maxLon, this.projection_, squaredTolerance);
1122
- var lineString = this.parallels_[index];
1123
- if (!lineString) {
1124
- lineString = new _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__["default"](flatCoordinates, _geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY);
1125
- }
1126
- else {
1127
- lineString.setFlatCoordinates(_geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY, flatCoordinates);
1128
- lineString.changed();
1129
- }
1130
- return lineString;
1131
- };
500
+ this.meridians_ = [];
501
+
1132
502
  /**
1133
- * @param {LineString} lineString Parallels.
1134
- * @param {import("../extent.js").Extent} extent Extent.
1135
- * @param {number} index Index.
1136
- * @return {Point} Parallel point.
503
+ * @type {Array<LineString>}
1137
504
  * @private
1138
505
  */
1139
- Graticule.prototype.getParallelPoint_ = function (lineString, extent, index) {
1140
- var flatCoordinates = lineString.getFlatCoordinates();
1141
- var left = 0;
1142
- var right = flatCoordinates.length - 2;
1143
- if (flatCoordinates[left] > flatCoordinates[right]) {
1144
- left = right;
1145
- right = 0;
1146
- }
1147
- var clampedLeft = Math.max(extent[0], flatCoordinates[left]);
1148
- var clampedRight = Math.min(extent[2], flatCoordinates[right]);
1149
- var lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_, clampedLeft, clampedRight);
1150
- var coordinate1 = flatCoordinates[left + 1] +
1151
- ((flatCoordinates[right + 1] - flatCoordinates[left + 1]) *
1152
- (lon - flatCoordinates[left])) /
1153
- (flatCoordinates[right] - flatCoordinates[left]);
1154
- var coordinate = [lon, coordinate1];
1155
- var point = this.parallelsLabels_[index].geom;
1156
- point.setCoordinates(coordinate);
1157
- return point;
1158
- };
506
+ this.parallels_ = [];
507
+
508
+ /**
509
+ * @type {Stroke}
510
+ * @private
511
+ */
512
+ this.strokeStyle_ =
513
+ options.strokeStyle !== undefined
514
+ ? options.strokeStyle
515
+ : DEFAULT_STROKE_STYLE;
516
+
517
+ /**
518
+ * @type {import("../proj.js").TransformFunction|undefined}
519
+ * @private
520
+ */
521
+ this.fromLonLatTransform_ = undefined;
522
+
523
+ /**
524
+ * @type {import("../proj.js").TransformFunction|undefined}
525
+ * @private
526
+ */
527
+ this.toLonLatTransform_ = undefined;
528
+
529
+ /**
530
+ * @type {import("../coordinate.js").Coordinate}
531
+ * @private
532
+ */
533
+ this.projectionCenterLonLat_ = null;
534
+
535
+ /**
536
+ * @type {import("../coordinate.js").Coordinate}
537
+ * @private
538
+ */
539
+ this.bottomLeft_ = null;
540
+
541
+ /**
542
+ * @type {import("../coordinate.js").Coordinate}
543
+ * @private
544
+ */
545
+ this.bottomRight_ = null;
546
+
547
+ /**
548
+ * @type {import("../coordinate.js").Coordinate}
549
+ * @private
550
+ */
551
+ this.topLeft_ = null;
552
+
553
+ /**
554
+ * @type {import("../coordinate.js").Coordinate}
555
+ * @private
556
+ */
557
+ this.topRight_ = null;
558
+
559
+ /**
560
+ * @type {Array<GraticuleLabelDataType>}
561
+ * @private
562
+ */
563
+ this.meridiansLabels_ = null;
564
+
565
+ /**
566
+ * @type {Array<GraticuleLabelDataType>}
567
+ * @private
568
+ */
569
+ this.parallelsLabels_ = null;
570
+
571
+ if (options.showLabels) {
572
+ /**
573
+ * @type {null|function(number):string}
574
+ * @private
575
+ */
576
+ this.lonLabelFormatter_ =
577
+ options.lonLabelFormatter == undefined
578
+ ? _coordinate_js__WEBPACK_IMPORTED_MODULE_3__.degreesToStringHDMS.bind(this, 'EW')
579
+ : options.lonLabelFormatter;
580
+
581
+ /**
582
+ * @type {function(number):string}
583
+ * @private
584
+ */
585
+ this.latLabelFormatter_ =
586
+ options.latLabelFormatter == undefined
587
+ ? _coordinate_js__WEBPACK_IMPORTED_MODULE_3__.degreesToStringHDMS.bind(this, 'NS')
588
+ : options.latLabelFormatter;
589
+
590
+ /**
591
+ * Longitude label position in fractions (0..1) of view extent. 0 means
592
+ * bottom, 1 means top.
593
+ * @type {number}
594
+ * @private
595
+ */
596
+ this.lonLabelPosition_ =
597
+ options.lonLabelPosition == undefined ? 0 : options.lonLabelPosition;
598
+
599
+ /**
600
+ * Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
601
+ * means right.
602
+ * @type {number}
603
+ * @private
604
+ */
605
+ this.latLabelPosition_ =
606
+ options.latLabelPosition == undefined ? 1 : options.latLabelPosition;
607
+
608
+ /**
609
+ * @type {Style}
610
+ * @private
611
+ */
612
+ this.lonLabelStyleBase_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
613
+ text:
614
+ options.lonLabelStyle !== undefined
615
+ ? options.lonLabelStyle.clone()
616
+ : new _style_Text_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
617
+ font: '12px Calibri,sans-serif',
618
+ textBaseline: 'bottom',
619
+ fill: new _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
620
+ color: 'rgba(0,0,0,1)',
621
+ }),
622
+ stroke: new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
623
+ color: 'rgba(255,255,255,1)',
624
+ width: 3,
625
+ }),
626
+ }),
627
+ });
628
+
629
+ /**
630
+ * @private
631
+ * @param {import("../Feature").default} feature Feature
632
+ * @return {Style} style
633
+ */
634
+ this.lonLabelStyle_ = (feature) => {
635
+ const label = feature.get('graticule_label');
636
+ this.lonLabelStyleBase_.getText().setText(label);
637
+ return this.lonLabelStyleBase_;
638
+ };
639
+
640
+ /**
641
+ * @type {Style}
642
+ * @private
643
+ */
644
+ this.latLabelStyleBase_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
645
+ text:
646
+ options.latLabelStyle !== undefined
647
+ ? options.latLabelStyle.clone()
648
+ : new _style_Text_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
649
+ font: '12px Calibri,sans-serif',
650
+ textAlign: 'right',
651
+ fill: new _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
652
+ color: 'rgba(0,0,0,1)',
653
+ }),
654
+ stroke: new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
655
+ color: 'rgba(255,255,255,1)',
656
+ width: 3,
657
+ }),
658
+ }),
659
+ });
660
+
661
+ /**
662
+ * @private
663
+ * @param {import("../Feature").default} feature Feature
664
+ * @return {Style} style
665
+ */
666
+ this.latLabelStyle_ = (feature) => {
667
+ const label = feature.get('graticule_label');
668
+ this.latLabelStyleBase_.getText().setText(label);
669
+ return this.latLabelStyleBase_;
670
+ };
671
+
672
+ this.meridiansLabels_ = [];
673
+ this.parallelsLabels_ = [];
674
+
675
+ this.addEventListener(_render_EventType_js__WEBPACK_IMPORTED_MODULE_7__["default"].POSTRENDER, this.drawLabels_.bind(this));
676
+ }
677
+
678
+ /**
679
+ * @type {Array<number>}
680
+ * @private
681
+ */
682
+ this.intervals_ =
683
+ options.intervals !== undefined ? options.intervals : INTERVALS;
684
+
685
+ // use a source with a custom loader for lines & text
686
+ this.setSource(
687
+ new _source_Vector_js__WEBPACK_IMPORTED_MODULE_8__["default"]({
688
+ loader: this.loaderFunction.bind(this),
689
+ strategy: this.strategyFunction.bind(this),
690
+ features: new _Collection_js__WEBPACK_IMPORTED_MODULE_9__["default"](),
691
+ overlaps: false,
692
+ useSpatialIndex: false,
693
+ wrapX: options.wrapX,
694
+ }),
695
+ );
696
+
697
+ /**
698
+ * feature pool to use when updating graticule
699
+ * @type {Array<Feature>}
700
+ * @private
701
+ */
702
+ this.featurePool_ = [];
703
+
1159
704
  /**
1160
- * Get the list of parallels. Parallels are lines of equal latitude.
1161
- * @return {Array<LineString>} The parallels.
1162
- * @api
705
+ * @type {Style}
706
+ * @private
707
+ */
708
+ this.lineStyle_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
709
+ stroke: this.strokeStyle_,
710
+ });
711
+
712
+ /**
713
+ * @type {?import("../extent.js").Extent}
714
+ * @private
715
+ */
716
+ this.loadedExtent_ = null;
717
+
718
+ /**
719
+ * @type {?import("../extent.js").Extent}
720
+ * @private
1163
721
  */
1164
- Graticule.prototype.getParallels = function () {
1165
- return this.parallels_;
1166
- };
722
+ this.renderedExtent_ = null;
723
+
1167
724
  /**
1168
- * @param {import("../proj/Projection.js").default} projection Projection.
725
+ * @type {?number}
1169
726
  * @private
1170
727
  */
1171
- Graticule.prototype.updateProjectionInfo_ = function (projection) {
1172
- var epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
1173
- var worldExtent = projection.getWorldExtent();
1174
- this.maxLat_ = worldExtent[3];
1175
- this.maxLon_ = worldExtent[2];
1176
- this.minLat_ = worldExtent[1];
1177
- this.minLon_ = worldExtent[0];
1178
- // If the world extent crosses the dateline define a custom transform to
1179
- // return longitudes which wrap the dateline
1180
- var toLonLatTransform = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(projection, epsg4326Projection);
1181
- if (this.minLon_ < this.maxLon_) {
1182
- this.toLonLatTransform_ = toLonLatTransform;
728
+ this.renderedResolution_ = null;
729
+
730
+ this.setRenderOrder(null);
731
+ }
732
+
733
+ /**
734
+ * Strategy function for loading features based on the view's extent and
735
+ * resolution.
736
+ * @param {import("../extent.js").Extent} extent Extent.
737
+ * @param {number} resolution Resolution.
738
+ * @return {Array<import("../extent.js").Extent>} Extents.
739
+ */
740
+ strategyFunction(extent, resolution) {
741
+ // extents may be passed in different worlds, to avoid endless loop we use only one
742
+ let realWorldExtent = extent.slice();
743
+ if (this.projection_ && this.getSource().getWrapX()) {
744
+ (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.wrapX)(realWorldExtent, this.projection_);
745
+ }
746
+ if (this.loadedExtent_) {
747
+ if (
748
+ (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.approximatelyEquals)(this.loadedExtent_, realWorldExtent, resolution)
749
+ ) {
750
+ // make sure result is exactly equal to previous extent
751
+ realWorldExtent = this.loadedExtent_.slice();
752
+ } else {
753
+ // we should not keep track of loaded extents
754
+ this.getSource().removeLoadedExtent(this.loadedExtent_);
755
+ }
756
+ }
757
+ return [realWorldExtent];
758
+ }
759
+
760
+ /**
761
+ * Update geometries in the source based on current view
762
+ * @param {import("../extent").Extent} extent Extent
763
+ * @param {number} resolution Resolution
764
+ * @param {import("../proj/Projection.js").default} projection Projection
765
+ */
766
+ loaderFunction(extent, resolution, projection) {
767
+ this.loadedExtent_ = extent;
768
+ const source = this.getSource();
769
+
770
+ // only consider the intersection between our own extent & the requested one
771
+ const layerExtent = this.getExtent() || [
772
+ -Infinity,
773
+ -Infinity,
774
+ Infinity,
775
+ Infinity,
776
+ ];
777
+ const renderExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getIntersection)(layerExtent, extent);
778
+
779
+ if (
780
+ this.renderedExtent_ &&
781
+ (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.equals)(this.renderedExtent_, renderExtent) &&
782
+ this.renderedResolution_ === resolution
783
+ ) {
784
+ return;
785
+ }
786
+ this.renderedExtent_ = renderExtent;
787
+ this.renderedResolution_ = resolution;
788
+
789
+ // bail out if nothing to render
790
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.isEmpty)(renderExtent)) {
791
+ return;
792
+ }
793
+
794
+ // update projection info
795
+ const center = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(renderExtent);
796
+ const squaredTolerance = (resolution * resolution) / 4;
797
+
798
+ const updateProjectionInfo =
799
+ !this.projection_ || !(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.equivalent)(this.projection_, projection);
800
+
801
+ if (updateProjectionInfo) {
802
+ this.updateProjectionInfo_(projection);
803
+ }
804
+
805
+ this.createGraticule_(renderExtent, center, resolution, squaredTolerance);
806
+
807
+ // first make sure we have enough features in the pool
808
+ let featureCount = this.meridians_.length + this.parallels_.length;
809
+ if (this.meridiansLabels_) {
810
+ featureCount += this.meridians_.length;
811
+ }
812
+ if (this.parallelsLabels_) {
813
+ featureCount += this.parallels_.length;
814
+ }
815
+
816
+ let feature;
817
+ while (featureCount > this.featurePool_.length) {
818
+ feature = new _Feature_js__WEBPACK_IMPORTED_MODULE_11__["default"]();
819
+ this.featurePool_.push(feature);
820
+ }
821
+
822
+ const featuresColl = source.getFeaturesCollection();
823
+ featuresColl.clear();
824
+ let poolIndex = 0;
825
+
826
+ // add features for the lines & labels
827
+ let i, l;
828
+ for (i = 0, l = this.meridians_.length; i < l; ++i) {
829
+ feature = this.featurePool_[poolIndex++];
830
+ feature.setGeometry(this.meridians_[i]);
831
+ feature.setStyle(this.lineStyle_);
832
+ featuresColl.push(feature);
833
+ }
834
+ for (i = 0, l = this.parallels_.length; i < l; ++i) {
835
+ feature = this.featurePool_[poolIndex++];
836
+ feature.setGeometry(this.parallels_[i]);
837
+ feature.setStyle(this.lineStyle_);
838
+ featuresColl.push(feature);
839
+ }
840
+ }
841
+
842
+ /**
843
+ * @param {number} lon Longitude.
844
+ * @param {number} minLat Minimal latitude.
845
+ * @param {number} maxLat Maximal latitude.
846
+ * @param {number} squaredTolerance Squared tolerance.
847
+ * @param {import("../extent.js").Extent} extent Extent.
848
+ * @param {number} index Index.
849
+ * @return {number} Index.
850
+ * @private
851
+ */
852
+ addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, index) {
853
+ const lineString = this.getMeridian_(
854
+ lon,
855
+ minLat,
856
+ maxLat,
857
+ squaredTolerance,
858
+ index,
859
+ );
860
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.intersects)(lineString.getExtent(), extent)) {
861
+ if (this.meridiansLabels_) {
862
+ const text = this.lonLabelFormatter_(lon);
863
+ if (index in this.meridiansLabels_) {
864
+ this.meridiansLabels_[index].text = text;
865
+ } else {
866
+ this.meridiansLabels_[index] = {
867
+ geom: new _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__["default"]([]),
868
+ text: text,
869
+ };
1183
870
  }
1184
- else {
1185
- var split_1 = this.minLon_ + this.maxLon_ / 2;
1186
- this.maxLon_ += 360;
1187
- this.toLonLatTransform_ = function (coordinates, opt_output, opt_dimension) {
1188
- var dimension = opt_dimension || 2;
1189
- var lonLatCoordinates = toLonLatTransform(coordinates, opt_output, dimension);
1190
- for (var i = 0, l = lonLatCoordinates.length; i < l; i += dimension) {
1191
- if (lonLatCoordinates[i] < split_1) {
1192
- lonLatCoordinates[i] += 360;
1193
- }
1194
- }
1195
- return lonLatCoordinates;
1196
- };
871
+ }
872
+ this.meridians_[index++] = lineString;
873
+ }
874
+ return index;
875
+ }
876
+
877
+ /**
878
+ * @param {number} lat Latitude.
879
+ * @param {number} minLon Minimal longitude.
880
+ * @param {number} maxLon Maximal longitude.
881
+ * @param {number} squaredTolerance Squared tolerance.
882
+ * @param {import("../extent.js").Extent} extent Extent.
883
+ * @param {number} index Index.
884
+ * @return {number} Index.
885
+ * @private
886
+ */
887
+ addParallel_(lat, minLon, maxLon, squaredTolerance, extent, index) {
888
+ const lineString = this.getParallel_(
889
+ lat,
890
+ minLon,
891
+ maxLon,
892
+ squaredTolerance,
893
+ index,
894
+ );
895
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.intersects)(lineString.getExtent(), extent)) {
896
+ if (this.parallelsLabels_) {
897
+ const text = this.latLabelFormatter_(lat);
898
+ if (index in this.parallelsLabels_) {
899
+ this.parallelsLabels_[index].text = text;
900
+ } else {
901
+ this.parallelsLabels_[index] = {
902
+ geom: new _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__["default"]([]),
903
+ text: text,
904
+ };
1197
905
  }
1198
- // Transform the extent to get the limits of the view projection extent
1199
- // which should be available to the graticule
1200
- this.fromLonLatTransform_ = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection);
1201
- var worldExtentP = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.applyTransform)([this.minLon_, this.minLat_, this.maxLon_, this.maxLat_], this.fromLonLatTransform_, undefined, 8);
1202
- this.minX_ = worldExtentP[0];
1203
- this.maxX_ = worldExtentP[2];
1204
- this.minY_ = worldExtentP[1];
1205
- this.maxY_ = worldExtentP[3];
1206
- // Determine the view projection coordinates of the extremities of the world extent
1207
- // as these may lie inside a view extent (for example the pole in a polar projection)
1208
- this.bottomLeft_ = this.fromLonLatTransform_([this.minLon_, this.minLat_]);
1209
- this.bottomRight_ = this.fromLonLatTransform_([this.maxLon_, this.minLat_]);
1210
- this.topLeft_ = this.fromLonLatTransform_([this.minLon_, this.maxLat_]);
1211
- this.topRight_ = this.fromLonLatTransform_([this.maxLon_, this.maxLat_]);
1212
- // Transform the projection center to lon lat
1213
- // Some projections may have a void area at the poles
1214
- // so replace any NaN latitudes with the min or max value closest to a pole
1215
- this.projectionCenterLonLat_ = this.toLonLatTransform_((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(projection.getExtent()));
1216
- if (isNaN(this.projectionCenterLonLat_[1])) {
1217
- this.projectionCenterLonLat_[1] =
1218
- Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
1219
- ? this.maxLat_
1220
- : this.minLat_;
906
+ }
907
+ this.parallels_[index++] = lineString;
908
+ }
909
+ return index;
910
+ }
911
+
912
+ /**
913
+ * @param {import("../render/Event.js").default} event Render event.
914
+ * @private
915
+ */
916
+ drawLabels_(event) {
917
+ const rotation = event.frameState.viewState.rotation;
918
+ const resolution = event.frameState.viewState.resolution;
919
+ const size = event.frameState.size;
920
+ const extent = event.frameState.extent;
921
+ const rotationCenter = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(extent);
922
+ let rotationExtent = extent;
923
+ if (rotation) {
924
+ const unrotatedWidth = size[0] * resolution;
925
+ const unrotatedHeight = size[1] * resolution;
926
+ rotationExtent = [
927
+ rotationCenter[0] - unrotatedWidth / 2,
928
+ rotationCenter[1] - unrotatedHeight / 2,
929
+ rotationCenter[0] + unrotatedWidth / 2,
930
+ rotationCenter[1] + unrotatedHeight / 2,
931
+ ];
932
+ }
933
+
934
+ let startWorld = 0;
935
+ let endWorld = 0;
936
+ let labelsAtStart = this.latLabelPosition_ < 0.5;
937
+ const projectionExtent = this.projection_.getExtent();
938
+ const worldWidth = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(projectionExtent);
939
+ if (
940
+ this.getSource().getWrapX() &&
941
+ this.projection_.canWrapX() &&
942
+ !(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsExtent)(projectionExtent, extent)
943
+ ) {
944
+ startWorld = Math.floor((extent[0] - projectionExtent[0]) / worldWidth);
945
+ endWorld = Math.ceil((extent[2] - projectionExtent[2]) / worldWidth);
946
+ const inverted = Math.abs(rotation) > Math.PI / 2;
947
+ labelsAtStart = labelsAtStart !== inverted;
948
+ }
949
+ const vectorContext = (0,_render_js__WEBPACK_IMPORTED_MODULE_13__.getVectorContext)(event);
950
+
951
+ for (let world = startWorld; world <= endWorld; ++world) {
952
+ let poolIndex = this.meridians_.length + this.parallels_.length;
953
+ let feature, index, l, textPoint;
954
+
955
+ if (this.meridiansLabels_) {
956
+ for (index = 0, l = this.meridiansLabels_.length; index < l; ++index) {
957
+ const lineString = this.meridians_[index];
958
+ if (!rotation && world === 0) {
959
+ textPoint = this.getMeridianPoint_(lineString, extent, index);
960
+ } else {
961
+ const clone = lineString.clone();
962
+ clone.translate(world * worldWidth, 0);
963
+ clone.rotate(-rotation, rotationCenter);
964
+ textPoint = this.getMeridianPoint_(clone, rotationExtent, index);
965
+ textPoint.rotate(rotation, rotationCenter);
966
+ }
967
+ feature = this.featurePool_[poolIndex++];
968
+ feature.setGeometry(textPoint);
969
+ feature.set('graticule_label', this.meridiansLabels_[index].text);
970
+ vectorContext.drawFeature(feature, this.lonLabelStyle_(feature));
971
+ }
972
+ }
973
+ if (this.parallelsLabels_) {
974
+ if (
975
+ (world === startWorld && labelsAtStart) ||
976
+ (world === endWorld && !labelsAtStart)
977
+ ) {
978
+ for (index = 0, l = this.parallels_.length; index < l; ++index) {
979
+ const lineString = this.parallels_[index];
980
+ if (!rotation && world === 0) {
981
+ textPoint = this.getParallelPoint_(lineString, extent, index);
982
+ } else {
983
+ const clone = lineString.clone();
984
+ clone.translate(world * worldWidth, 0);
985
+ clone.rotate(-rotation, rotationCenter);
986
+ textPoint = this.getParallelPoint_(clone, rotationExtent, index);
987
+ textPoint.rotate(rotation, rotationCenter);
988
+ }
989
+ feature = this.featurePool_[poolIndex++];
990
+ feature.setGeometry(textPoint);
991
+ feature.set('graticule_label', this.parallelsLabels_[index].text);
992
+ vectorContext.drawFeature(feature, this.latLabelStyle_(feature));
993
+ }
1221
994
  }
1222
- this.projection_ = projection;
1223
- };
1224
- return Graticule;
1225
- }(_Vector_js__WEBPACK_IMPORTED_MODULE_18__["default"]));
995
+ }
996
+ }
997
+ }
998
+
999
+ /**
1000
+ * @param {import("../extent.js").Extent} extent Extent.
1001
+ * @param {import("../coordinate.js").Coordinate} center Center.
1002
+ * @param {number} resolution Resolution.
1003
+ * @param {number} squaredTolerance Squared tolerance.
1004
+ * @private
1005
+ */
1006
+ createGraticule_(extent, center, resolution, squaredTolerance) {
1007
+ const interval = this.getInterval_(resolution);
1008
+ if (interval == -1) {
1009
+ this.meridians_.length = 0;
1010
+ this.parallels_.length = 0;
1011
+ if (this.meridiansLabels_) {
1012
+ this.meridiansLabels_.length = 0;
1013
+ }
1014
+ if (this.parallelsLabels_) {
1015
+ this.parallelsLabels_.length = 0;
1016
+ }
1017
+ return;
1018
+ }
1019
+
1020
+ let wrapX = false;
1021
+ const projectionExtent = this.projection_.getExtent();
1022
+ const worldWidth = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(projectionExtent);
1023
+ if (
1024
+ this.getSource().getWrapX() &&
1025
+ this.projection_.canWrapX() &&
1026
+ !(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsExtent)(projectionExtent, extent)
1027
+ ) {
1028
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(extent) >= worldWidth) {
1029
+ extent[0] = projectionExtent[0];
1030
+ extent[2] = projectionExtent[2];
1031
+ } else {
1032
+ wrapX = true;
1033
+ }
1034
+ }
1035
+
1036
+ // Constrain the center to fit into the extent available to the graticule
1037
+
1038
+ const validCenterP = [
1039
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(center[0], this.minX_, this.maxX_),
1040
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(center[1], this.minY_, this.maxY_),
1041
+ ];
1042
+
1043
+ // Transform the center to lon lat
1044
+ // Some projections may have a void area at the poles
1045
+ // so replace any NaN latitudes with the min or max value closest to a pole
1046
+
1047
+ const centerLonLat = this.toLonLatTransform_(validCenterP);
1048
+ if (isNaN(centerLonLat[1])) {
1049
+ centerLonLat[1] =
1050
+ Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
1051
+ ? this.maxLat_
1052
+ : this.minLat_;
1053
+ }
1054
+ let centerLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLonLat[0], this.minLon_, this.maxLon_);
1055
+ let centerLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLonLat[1], this.minLat_, this.maxLat_);
1056
+ const maxLines = this.maxLines_;
1057
+ let cnt, idx, lat, lon;
1058
+
1059
+ // Limit the extent to fit into the extent available to the graticule
1060
+
1061
+ let validExtentP = extent;
1062
+ if (!wrapX) {
1063
+ validExtentP = [
1064
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[0], this.minX_, this.maxX_),
1065
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[1], this.minY_, this.maxY_),
1066
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[2], this.minX_, this.maxX_),
1067
+ (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[3], this.minY_, this.maxY_),
1068
+ ];
1069
+ }
1070
+
1071
+ // Transform the extent to get the lon lat ranges for the edges of the extent
1072
+
1073
+ const validExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.applyTransform)(
1074
+ validExtentP,
1075
+ this.toLonLatTransform_,
1076
+ undefined,
1077
+ 8,
1078
+ );
1079
+
1080
+ let maxLat = validExtent[3];
1081
+ let maxLon = validExtent[2];
1082
+ let minLat = validExtent[1];
1083
+ let minLon = validExtent[0];
1084
+
1085
+ if (!wrapX) {
1086
+ // Check if extremities of the world extent lie inside the extent
1087
+ // (for example the pole in a polar projection)
1088
+ // and extend the extent as appropriate
1089
+
1090
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.bottomLeft_)) {
1091
+ minLon = this.minLon_;
1092
+ minLat = this.minLat_;
1093
+ }
1094
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.bottomRight_)) {
1095
+ maxLon = this.maxLon_;
1096
+ minLat = this.minLat_;
1097
+ }
1098
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.topLeft_)) {
1099
+ minLon = this.minLon_;
1100
+ maxLat = this.maxLat_;
1101
+ }
1102
+ if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.topRight_)) {
1103
+ maxLon = this.maxLon_;
1104
+ maxLat = this.maxLat_;
1105
+ }
1106
+
1107
+ // The transformed center may also extend the lon lat ranges used for rendering
1108
+
1109
+ maxLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(maxLat, centerLat, this.maxLat_);
1110
+ maxLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(maxLon, centerLon, this.maxLon_);
1111
+ minLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(minLat, this.minLat_, centerLat);
1112
+ minLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(minLon, this.minLon_, centerLon);
1113
+ }
1114
+
1115
+ // Create meridians
1116
+
1117
+ centerLon = Math.floor(centerLon / interval) * interval;
1118
+ lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLon, this.minLon_, this.maxLon_);
1119
+
1120
+ idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0);
1121
+
1122
+ cnt = 0;
1123
+ if (wrapX) {
1124
+ while ((lon -= interval) >= minLon && cnt++ < maxLines) {
1125
+ idx = this.addMeridian_(
1126
+ lon,
1127
+ minLat,
1128
+ maxLat,
1129
+ squaredTolerance,
1130
+ extent,
1131
+ idx,
1132
+ );
1133
+ }
1134
+ } else {
1135
+ while (lon != this.minLon_ && cnt++ < maxLines) {
1136
+ lon = Math.max(lon - interval, this.minLon_);
1137
+ idx = this.addMeridian_(
1138
+ lon,
1139
+ minLat,
1140
+ maxLat,
1141
+ squaredTolerance,
1142
+ extent,
1143
+ idx,
1144
+ );
1145
+ }
1146
+ }
1147
+
1148
+ lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLon, this.minLon_, this.maxLon_);
1149
+
1150
+ cnt = 0;
1151
+ if (wrapX) {
1152
+ while ((lon += interval) <= maxLon && cnt++ < maxLines) {
1153
+ idx = this.addMeridian_(
1154
+ lon,
1155
+ minLat,
1156
+ maxLat,
1157
+ squaredTolerance,
1158
+ extent,
1159
+ idx,
1160
+ );
1161
+ }
1162
+ } else {
1163
+ while (lon != this.maxLon_ && cnt++ < maxLines) {
1164
+ lon = Math.min(lon + interval, this.maxLon_);
1165
+ idx = this.addMeridian_(
1166
+ lon,
1167
+ minLat,
1168
+ maxLat,
1169
+ squaredTolerance,
1170
+ extent,
1171
+ idx,
1172
+ );
1173
+ }
1174
+ }
1175
+
1176
+ this.meridians_.length = idx;
1177
+ if (this.meridiansLabels_) {
1178
+ this.meridiansLabels_.length = idx;
1179
+ }
1180
+
1181
+ // Create parallels
1182
+
1183
+ centerLat = Math.floor(centerLat / interval) * interval;
1184
+ lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, this.minLat_, this.maxLat_);
1185
+
1186
+ idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0);
1187
+
1188
+ cnt = 0;
1189
+ while (lat != this.minLat_ && cnt++ < maxLines) {
1190
+ lat = Math.max(lat - interval, this.minLat_);
1191
+ idx = this.addParallel_(
1192
+ lat,
1193
+ minLon,
1194
+ maxLon,
1195
+ squaredTolerance,
1196
+ extent,
1197
+ idx,
1198
+ );
1199
+ }
1200
+
1201
+ lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, this.minLat_, this.maxLat_);
1202
+
1203
+ cnt = 0;
1204
+ while (lat != this.maxLat_ && cnt++ < maxLines) {
1205
+ lat = Math.min(lat + interval, this.maxLat_);
1206
+ idx = this.addParallel_(
1207
+ lat,
1208
+ minLon,
1209
+ maxLon,
1210
+ squaredTolerance,
1211
+ extent,
1212
+ idx,
1213
+ );
1214
+ }
1215
+
1216
+ this.parallels_.length = idx;
1217
+ if (this.parallelsLabels_) {
1218
+ this.parallelsLabels_.length = idx;
1219
+ }
1220
+ }
1221
+
1222
+ /**
1223
+ * @param {number} resolution Resolution.
1224
+ * @return {number} The interval in degrees.
1225
+ * @private
1226
+ */
1227
+ getInterval_(resolution) {
1228
+ const centerLon = this.projectionCenterLonLat_[0];
1229
+ const centerLat = this.projectionCenterLonLat_[1];
1230
+ let interval = -1;
1231
+ const target = Math.pow(this.targetSize_ * resolution, 2);
1232
+ /** @type {Array<number>} **/
1233
+ const p1 = [];
1234
+ /** @type {Array<number>} **/
1235
+ const p2 = [];
1236
+ for (let i = 0, ii = this.intervals_.length; i < ii; ++i) {
1237
+ const delta = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(this.intervals_[i] / 2, 0, 90);
1238
+ // Don't attempt to transform latitudes beyond the poles!
1239
+ const clampedLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, -90 + delta, 90 - delta);
1240
+ p1[0] = centerLon - delta;
1241
+ p1[1] = clampedLat - delta;
1242
+ p2[0] = centerLon + delta;
1243
+ p2[1] = clampedLat + delta;
1244
+ this.fromLonLatTransform_(p1, p1);
1245
+ this.fromLonLatTransform_(p2, p2);
1246
+ const dist = Math.pow(p2[0] - p1[0], 2) + Math.pow(p2[1] - p1[1], 2);
1247
+ if (dist <= target) {
1248
+ break;
1249
+ }
1250
+ interval = this.intervals_[i];
1251
+ }
1252
+ return interval;
1253
+ }
1254
+
1255
+ /**
1256
+ * @param {number} lon Longitude.
1257
+ * @param {number} minLat Minimal latitude.
1258
+ * @param {number} maxLat Maximal latitude.
1259
+ * @param {number} squaredTolerance Squared tolerance.
1260
+ * @return {LineString} The meridian line string.
1261
+ * @param {number} index Index.
1262
+ * @private
1263
+ */
1264
+ getMeridian_(lon, minLat, maxLat, squaredTolerance, index) {
1265
+ const flatCoordinates = (0,_geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__.meridian)(
1266
+ lon,
1267
+ minLat,
1268
+ maxLat,
1269
+ this.projection_,
1270
+ squaredTolerance,
1271
+ );
1272
+ let lineString = this.meridians_[index];
1273
+ if (!lineString) {
1274
+ lineString = new _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__["default"](flatCoordinates, 'XY');
1275
+ this.meridians_[index] = lineString;
1276
+ } else {
1277
+ lineString.setFlatCoordinates('XY', flatCoordinates);
1278
+ lineString.changed();
1279
+ }
1280
+ return lineString;
1281
+ }
1282
+
1283
+ /**
1284
+ * @param {LineString} lineString Meridian
1285
+ * @param {import("../extent.js").Extent} extent Extent.
1286
+ * @param {number} index Index.
1287
+ * @return {Point} Meridian point.
1288
+ * @private
1289
+ */
1290
+ getMeridianPoint_(lineString, extent, index) {
1291
+ const flatCoordinates = lineString.getFlatCoordinates();
1292
+ let bottom = 1;
1293
+ let top = flatCoordinates.length - 1;
1294
+ if (flatCoordinates[bottom] > flatCoordinates[top]) {
1295
+ bottom = top;
1296
+ top = 1;
1297
+ }
1298
+ const clampedBottom = Math.max(extent[1], flatCoordinates[bottom]);
1299
+ const clampedTop = Math.min(extent[3], flatCoordinates[top]);
1300
+ const lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(
1301
+ extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_,
1302
+ clampedBottom,
1303
+ clampedTop,
1304
+ );
1305
+ const coordinate0 =
1306
+ flatCoordinates[bottom - 1] +
1307
+ ((flatCoordinates[top - 1] - flatCoordinates[bottom - 1]) *
1308
+ (lat - flatCoordinates[bottom])) /
1309
+ (flatCoordinates[top] - flatCoordinates[bottom]);
1310
+ const coordinate = [coordinate0, lat];
1311
+ const point = this.meridiansLabels_[index].geom;
1312
+ point.setCoordinates(coordinate);
1313
+ return point;
1314
+ }
1315
+
1316
+ /**
1317
+ * Get the list of meridians. Meridians are lines of equal longitude.
1318
+ * @return {Array<LineString>} The meridians.
1319
+ * @api
1320
+ */
1321
+ getMeridians() {
1322
+ return this.meridians_;
1323
+ }
1324
+
1325
+ /**
1326
+ * @param {number} lat Latitude.
1327
+ * @param {number} minLon Minimal longitude.
1328
+ * @param {number} maxLon Maximal longitude.
1329
+ * @param {number} squaredTolerance Squared tolerance.
1330
+ * @return {LineString} The parallel line string.
1331
+ * @param {number} index Index.
1332
+ * @private
1333
+ */
1334
+ getParallel_(lat, minLon, maxLon, squaredTolerance, index) {
1335
+ const flatCoordinates = (0,_geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__.parallel)(
1336
+ lat,
1337
+ minLon,
1338
+ maxLon,
1339
+ this.projection_,
1340
+ squaredTolerance,
1341
+ );
1342
+ let lineString = this.parallels_[index];
1343
+ if (!lineString) {
1344
+ lineString = new _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__["default"](flatCoordinates, 'XY');
1345
+ } else {
1346
+ lineString.setFlatCoordinates('XY', flatCoordinates);
1347
+ lineString.changed();
1348
+ }
1349
+ return lineString;
1350
+ }
1351
+
1352
+ /**
1353
+ * @param {LineString} lineString Parallels.
1354
+ * @param {import("../extent.js").Extent} extent Extent.
1355
+ * @param {number} index Index.
1356
+ * @return {Point} Parallel point.
1357
+ * @private
1358
+ */
1359
+ getParallelPoint_(lineString, extent, index) {
1360
+ const flatCoordinates = lineString.getFlatCoordinates();
1361
+ let left = 0;
1362
+ let right = flatCoordinates.length - 2;
1363
+ if (flatCoordinates[left] > flatCoordinates[right]) {
1364
+ left = right;
1365
+ right = 0;
1366
+ }
1367
+ const clampedLeft = Math.max(extent[0], flatCoordinates[left]);
1368
+ const clampedRight = Math.min(extent[2], flatCoordinates[right]);
1369
+ const lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(
1370
+ extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_,
1371
+ clampedLeft,
1372
+ clampedRight,
1373
+ );
1374
+ const coordinate1 =
1375
+ flatCoordinates[left + 1] +
1376
+ ((flatCoordinates[right + 1] - flatCoordinates[left + 1]) *
1377
+ (lon - flatCoordinates[left])) /
1378
+ (flatCoordinates[right] - flatCoordinates[left]);
1379
+ const coordinate = [lon, coordinate1];
1380
+ const point = this.parallelsLabels_[index].geom;
1381
+ point.setCoordinates(coordinate);
1382
+ return point;
1383
+ }
1384
+
1385
+ /**
1386
+ * Get the list of parallels. Parallels are lines of equal latitude.
1387
+ * @return {Array<LineString>} The parallels.
1388
+ * @api
1389
+ */
1390
+ getParallels() {
1391
+ return this.parallels_;
1392
+ }
1393
+
1394
+ /**
1395
+ * @param {import("../proj/Projection.js").default} projection Projection.
1396
+ * @private
1397
+ */
1398
+ updateProjectionInfo_(projection) {
1399
+ const epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
1400
+
1401
+ const worldExtent = projection.getWorldExtent();
1402
+
1403
+ this.maxLat_ = worldExtent[3];
1404
+ this.maxLon_ = worldExtent[2];
1405
+ this.minLat_ = worldExtent[1];
1406
+ this.minLon_ = worldExtent[0];
1407
+
1408
+ // If the world extent crosses the dateline define a custom transform to
1409
+ // return longitudes which wrap the dateline
1410
+
1411
+ const toLonLatTransform = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(projection, epsg4326Projection);
1412
+ if (this.minLon_ < this.maxLon_) {
1413
+ this.toLonLatTransform_ = toLonLatTransform;
1414
+ } else {
1415
+ const split = this.minLon_ + this.maxLon_ / 2;
1416
+ this.maxLon_ += 360;
1417
+ this.toLonLatTransform_ = function (coordinates, output, dimension) {
1418
+ dimension = dimension || 2;
1419
+ const lonLatCoordinates = toLonLatTransform(
1420
+ coordinates,
1421
+ output,
1422
+ dimension,
1423
+ );
1424
+ for (let i = 0, l = lonLatCoordinates.length; i < l; i += dimension) {
1425
+ if (lonLatCoordinates[i] < split) {
1426
+ lonLatCoordinates[i] += 360;
1427
+ }
1428
+ }
1429
+ return lonLatCoordinates;
1430
+ };
1431
+ }
1432
+
1433
+ // Transform the extent to get the limits of the view projection extent
1434
+ // which should be available to the graticule
1435
+
1436
+ this.fromLonLatTransform_ = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection);
1437
+ const worldExtentP = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.applyTransform)(
1438
+ [this.minLon_, this.minLat_, this.maxLon_, this.maxLat_],
1439
+ this.fromLonLatTransform_,
1440
+ undefined,
1441
+ 8,
1442
+ );
1443
+
1444
+ this.minX_ = worldExtentP[0];
1445
+ this.maxX_ = worldExtentP[2];
1446
+ this.minY_ = worldExtentP[1];
1447
+ this.maxY_ = worldExtentP[3];
1448
+
1449
+ // Determine the view projection coordinates of the extremities of the world extent
1450
+ // as these may lie inside a view extent (for example the pole in a polar projection)
1451
+
1452
+ this.bottomLeft_ = this.fromLonLatTransform_([this.minLon_, this.minLat_]);
1453
+ this.bottomRight_ = this.fromLonLatTransform_([this.maxLon_, this.minLat_]);
1454
+ this.topLeft_ = this.fromLonLatTransform_([this.minLon_, this.maxLat_]);
1455
+ this.topRight_ = this.fromLonLatTransform_([this.maxLon_, this.maxLat_]);
1456
+
1457
+ // Transform the projection center to lon lat
1458
+ // Some projections may have a void area at the poles
1459
+ // so replace any NaN latitudes with the min or max value closest to a pole
1460
+
1461
+ this.projectionCenterLonLat_ = this.toLonLatTransform_(
1462
+ (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(projection.getExtent()),
1463
+ );
1464
+ if (isNaN(this.projectionCenterLonLat_[1])) {
1465
+ this.projectionCenterLonLat_[1] =
1466
+ Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
1467
+ ? this.maxLat_
1468
+ : this.minLat_;
1469
+ }
1470
+
1471
+ this.projection_ = projection;
1472
+ }
1473
+ }
1474
+
1226
1475
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Graticule);
1227
- //# sourceMappingURL=Graticule.js.map
1476
+
1477
+
1478
+ /***/ }),
1479
+
1480
+ /***/ "./node_modules/ol/layer/Vector.js":
1481
+ /*!*****************************************!*\
1482
+ !*** ./node_modules/ol/layer/Vector.js ***!
1483
+ \*****************************************/
1484
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1485
+
1486
+ __webpack_require__.r(__webpack_exports__);
1487
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1488
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1489
+ /* harmony export */ });
1490
+ /* harmony import */ var _renderer_canvas_VectorLayer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../renderer/canvas/VectorLayer.js */ "./node_modules/ol/renderer/canvas/VectorLayer.js");
1491
+ /* harmony import */ var _BaseVector_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BaseVector.js */ "./node_modules/ol/layer/BaseVector.js");
1492
+ /**
1493
+ * @module ol/layer/Vector
1494
+ */
1495
+
1496
+
1497
+
1498
+ /**
1499
+ * @template {import("../source/Vector.js").default<FeatureType>} [VectorSourceType=import("../source/Vector.js").default<*>]
1500
+ * @template {import('../Feature.js').FeatureLike} [FeatureType=import("./BaseVector.js").ExtractedFeatureType<VectorSourceType>]
1501
+ * @typedef {Object} Options
1502
+ * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
1503
+ * @property {number} [opacity=1] Opacity (0, 1).
1504
+ * @property {boolean} [visible=true] Visibility.
1505
+ * @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
1506
+ * rendered outside of this extent.
1507
+ * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
1508
+ * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
1509
+ * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
1510
+ * method was used.
1511
+ * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
1512
+ * visible.
1513
+ * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
1514
+ * be visible.
1515
+ * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
1516
+ * visible.
1517
+ * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
1518
+ * be visible.
1519
+ * @property {import("../render.js").OrderFunction} [renderOrder] Render order. Function to be used when sorting
1520
+ * features before rendering. By default features are drawn in the order that they are created. Use
1521
+ * `null` to avoid the sort, but get an undefined draw order.
1522
+ * @property {number} [renderBuffer=100] The buffer in pixels around the viewport extent used by the
1523
+ * renderer when getting features from the vector source for the rendering or hit-detection.
1524
+ * Recommended value: the size of the largest symbol, line width or label.
1525
+ * @property {VectorSourceType} [source] Source.
1526
+ * @property {import("../Map.js").default} [map] Sets the layer as overlay on a map. The map will not manage
1527
+ * this layer in its layers collection, and the layer will be rendered on top. This is useful for
1528
+ * temporary layers. The standard way to add a layer to a map and have it managed by the map is to
1529
+ * use [map.addLayer()]{@link import("../Map.js").default#addLayer}.
1530
+ * @property {boolean|string|number} [declutter=false] Declutter images and text. Any truthy value will enable
1531
+ * decluttering. Within a layer, a feature rendered before another has higher priority. All layers with the
1532
+ * same `declutter` value will be decluttered together. The priority is determined by the drawing order of the
1533
+ * layers with the same `declutter` value. Higher in the layer stack means higher priority. To declutter distinct
1534
+ * layers or groups of layers separately, use different truthy values for `declutter`.
1535
+ * @property {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [style] Layer style. When set to `null`, only
1536
+ * features that have their own style will be rendered. See {@link module:ol/style/Style~Style} for the default style
1537
+ * which will be used if this is not set.
1538
+ * @property {import("./Base.js").BackgroundColor} [background] Background color for the layer. If not specified, no background
1539
+ * will be rendered.
1540
+ * @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will
1541
+ * be recreated during animations. This means that no vectors will be shown clipped, but the
1542
+ * setting will have a performance impact for large amounts of vector data. When set to `false`,
1543
+ * batches will be recreated when no animation is active.
1544
+ * @property {boolean} [updateWhileInteracting=false] When set to `true`, feature batches will
1545
+ * be recreated during interactions. See also `updateWhileAnimating`.
1546
+ * @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
1547
+ */
1548
+
1549
+ /**
1550
+ * @classdesc
1551
+ * Vector data is rendered client-side, as vectors. This layer type provides most accurate rendering
1552
+ * even during animations. Points and labels stay upright on rotated views. For very large
1553
+ * amounts of vector data, performance may suffer during pan and zoom animations. In this case,
1554
+ * try {@link module:ol/layer/VectorImage~VectorImageLayer}.
1555
+ *
1556
+ * Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
1557
+ * property on the layer object; for example, setting `title: 'My Title'` in the
1558
+ * options means that `title` is observable, and has get/set accessors.
1559
+ *
1560
+ * @template {import("../source/Vector.js").default<FeatureType>} [VectorSourceType=import("../source/Vector.js").default<*>]
1561
+ * @template {import('../Feature.js').FeatureLike} [FeatureType=import("./BaseVector.js").ExtractedFeatureType<VectorSourceType>]
1562
+ * @extends {BaseVectorLayer<FeatureType, VectorSourceType, CanvasVectorLayerRenderer>}
1563
+ * @api
1564
+ */
1565
+ class VectorLayer extends _BaseVector_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
1566
+ /**
1567
+ * @param {Options<VectorSourceType, FeatureType>} [options] Options.
1568
+ */
1569
+ constructor(options) {
1570
+ super(options);
1571
+ }
1572
+
1573
+ /**
1574
+ * @override
1575
+ */
1576
+ createRenderer() {
1577
+ return new _renderer_canvas_VectorLayer_js__WEBPACK_IMPORTED_MODULE_1__["default"](this);
1578
+ }
1579
+ }
1580
+
1581
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (VectorLayer);
1582
+
1228
1583
 
1229
1584
  /***/ }),
1230
1585
 
@@ -1240,11 +1595,11 @@ __webpack_require__.r(__webpack_exports__);
1240
1595
  /* harmony export */ "getVectorContext": () => (/* binding */ getVectorContext),
1241
1596
  /* harmony export */ "toContext": () => (/* binding */ toContext)
1242
1597
  /* harmony export */ });
1243
- /* harmony import */ var _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./render/canvas/Immediate.js */ "./node_modules/ol/render/canvas/Immediate.js");
1244
1598
  /* harmony import */ var _has_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./has.js */ "./node_modules/ol/has.js");
1245
- /* harmony import */ var _transform_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./transform.js */ "./node_modules/ol/transform.js");
1246
- /* harmony import */ var _renderer_vector_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./renderer/vector.js */ "./node_modules/ol/renderer/vector.js");
1247
1599
  /* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./proj.js */ "./node_modules/ol/proj.js");
1600
+ /* harmony import */ var _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./render/canvas/Immediate.js */ "./node_modules/ol/render/canvas/Immediate.js");
1601
+ /* harmony import */ var _renderer_vector_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./renderer/vector.js */ "./node_modules/ol/renderer/vector.js");
1602
+ /* harmony import */ var _transform_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./transform.js */ "./node_modules/ol/transform.js");
1248
1603
  /**
1249
1604
  * @module ol/render
1250
1605
  */
@@ -1253,6 +1608,7 @@ __webpack_require__.r(__webpack_exports__);
1253
1608
 
1254
1609
 
1255
1610
 
1611
+
1256
1612
  /**
1257
1613
  * @typedef {Object} State
1258
1614
  * @property {CanvasRenderingContext2D} context Canvas context that the layer is being rendered to.
@@ -1263,6 +1619,7 @@ __webpack_require__.r(__webpack_exports__);
1263
1619
  * This is not the view's resolution that is being rendered.
1264
1620
  * @property {number} rotation Rotation of the rendered layer in radians.
1265
1621
  */
1622
+
1266
1623
  /**
1267
1624
  * A function to be used when sorting features before rendering.
1268
1625
  * It takes two instances of {@link module:ol/Feature~Feature} or
@@ -1270,6 +1627,7 @@ __webpack_require__.r(__webpack_exports__);
1270
1627
  *
1271
1628
  * @typedef {function(import("./Feature.js").FeatureLike, import("./Feature.js").FeatureLike):number} OrderFunction
1272
1629
  */
1630
+
1273
1631
  /**
1274
1632
  * @typedef {Object} ToContextOptions
1275
1633
  * @property {import("./size.js").Size} [size] Desired size of the canvas in css
@@ -1279,6 +1637,7 @@ __webpack_require__.r(__webpack_exports__);
1279
1637
  * @property {number} [pixelRatio=window.devicePixelRatio] Pixel ratio (canvas
1280
1638
  * pixel to css pixel ratio) for the canvas.
1281
1639
  */
1640
+
1282
1641
  /**
1283
1642
  * Binds a Canvas Immediate API to a canvas context, to allow drawing geometries
1284
1643
  * to the context's canvas.
@@ -1286,38 +1645,42 @@ __webpack_require__.r(__webpack_exports__);
1286
1645
  * The units for geometry coordinates are css pixels relative to the top left
1287
1646
  * corner of the canvas element.
1288
1647
  * ```js
1289
- * import {toContext} from 'ol/render';
1290
- * import Fill from 'ol/style/Fill';
1291
- * import Polygon from 'ol/geom/Polygon';
1648
+ * import {toContext} from 'ol/render.js';
1649
+ * import Fill from 'ol/style/Fill.js';
1650
+ * import Polygon from 'ol/geom/Polygon.js';
1292
1651
  *
1293
- * var canvas = document.createElement('canvas');
1294
- * var render = toContext(canvas.getContext('2d'),
1295
- * { size: [100, 100] });
1652
+ * const canvas = document.createElement('canvas');
1653
+ * const render = toContext(
1654
+ * canvas.getContext('2d'),
1655
+ * {size: [100, 100]}
1656
+ * );
1296
1657
  * render.setFillStrokeStyle(new Fill({ color: blue }));
1297
1658
  * render.drawPolygon(
1298
- * new Polygon([[[0, 0], [100, 100], [100, 0], [0, 0]]]));
1659
+ * new Polygon([[[0, 0], [100, 100], [100, 0], [0, 0]]])
1660
+ * );
1299
1661
  * ```
1300
1662
  *
1301
1663
  * @param {CanvasRenderingContext2D} context Canvas context.
1302
- * @param {ToContextOptions} [opt_options] Options.
1664
+ * @param {ToContextOptions} [options] Options.
1303
1665
  * @return {CanvasImmediateRenderer} Canvas Immediate.
1304
1666
  * @api
1305
1667
  */
1306
- function toContext(context, opt_options) {
1307
- var canvas = context.canvas;
1308
- var options = opt_options ? opt_options : {};
1309
- var pixelRatio = options.pixelRatio || _has_js__WEBPACK_IMPORTED_MODULE_1__.DEVICE_PIXEL_RATIO;
1310
- var size = options.size;
1311
- if (size) {
1312
- canvas.width = size[0] * pixelRatio;
1313
- canvas.height = size[1] * pixelRatio;
1314
- canvas.style.width = size[0] + 'px';
1315
- canvas.style.height = size[1] + 'px';
1316
- }
1317
- var extent = [0, 0, canvas.width, canvas.height];
1318
- var transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.scale)((0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.create)(), pixelRatio, pixelRatio);
1319
- return new _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__["default"](context, pixelRatio, extent, transform, 0);
1668
+ function toContext(context, options) {
1669
+ const canvas = context.canvas;
1670
+ options = options ? options : {};
1671
+ const pixelRatio = options.pixelRatio || _has_js__WEBPACK_IMPORTED_MODULE_1__.DEVICE_PIXEL_RATIO;
1672
+ const size = options.size;
1673
+ if (size) {
1674
+ canvas.width = size[0] * pixelRatio;
1675
+ canvas.height = size[1] * pixelRatio;
1676
+ canvas.style.width = size[0] + 'px';
1677
+ canvas.style.height = size[1] + 'px';
1678
+ }
1679
+ const extent = [0, 0, canvas.width, canvas.height];
1680
+ const transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.scale)((0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.create)(), pixelRatio, pixelRatio);
1681
+ return new _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__["default"](context, pixelRatio, extent, transform, 0);
1320
1682
  }
1683
+
1321
1684
  /**
1322
1685
  * Gets a vector context for drawing to the event's canvas.
1323
1686
  * @param {import("./render/Event.js").default} event Render event.
@@ -1325,21 +1688,43 @@ function toContext(context, opt_options) {
1325
1688
  * @api
1326
1689
  */
1327
1690
  function getVectorContext(event) {
1328
- if (!(event.context instanceof CanvasRenderingContext2D)) {
1329
- throw new Error('Only works for render events from Canvas 2D layers');
1330
- }
1331
- // canvas may be at a different pixel ratio than frameState.pixelRatio
1332
- var canvasPixelRatio = event.inversePixelTransform[0];
1333
- var frameState = event.frameState;
1334
- var transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.multiply)(event.inversePixelTransform.slice(), frameState.coordinateToPixelTransform);
1335
- var squaredTolerance = (0,_renderer_vector_js__WEBPACK_IMPORTED_MODULE_4__.getSquaredTolerance)(frameState.viewState.resolution, canvasPixelRatio);
1336
- var userTransform;
1337
- var userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
1338
- if (userProjection) {
1339
- userTransform = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransformFromProjections)(userProjection, frameState.viewState.projection);
1340
- }
1341
- return new _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__["default"](event.context, canvasPixelRatio, frameState.extent, transform, frameState.viewState.rotation, squaredTolerance, userTransform);
1691
+ if (!(event.context instanceof CanvasRenderingContext2D)) {
1692
+ throw new Error('Only works for render events from Canvas 2D layers');
1693
+ }
1694
+
1695
+ // canvas may be at a different pixel ratio than frameState.pixelRatio
1696
+ const a = event.inversePixelTransform[0];
1697
+ const b = event.inversePixelTransform[1];
1698
+ const canvasPixelRatio = Math.sqrt(a * a + b * b);
1699
+ const frameState = event.frameState;
1700
+ const transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.multiply)(
1701
+ event.inversePixelTransform.slice(),
1702
+ frameState.coordinateToPixelTransform,
1703
+ );
1704
+ const squaredTolerance = (0,_renderer_vector_js__WEBPACK_IMPORTED_MODULE_4__.getSquaredTolerance)(
1705
+ frameState.viewState.resolution,
1706
+ canvasPixelRatio,
1707
+ );
1708
+ let userTransform;
1709
+ const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
1710
+ if (userProjection) {
1711
+ userTransform = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransformFromProjections)(
1712
+ userProjection,
1713
+ frameState.viewState.projection,
1714
+ );
1715
+ }
1716
+
1717
+ return new _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__["default"](
1718
+ event.context,
1719
+ canvasPixelRatio,
1720
+ frameState.extent,
1721
+ transform,
1722
+ frameState.viewState.rotation,
1723
+ squaredTolerance,
1724
+ userTransform,
1725
+ );
1342
1726
  }
1727
+
1343
1728
  /**
1344
1729
  * Gets the pixel of the event's canvas context from the map viewport's CSS pixel.
1345
1730
  * @param {import("./render/Event.js").default} event Render event.
@@ -1349,9 +1734,9 @@ function getVectorContext(event) {
1349
1734
  * @api
1350
1735
  */
1351
1736
  function getRenderPixel(event, pixel) {
1352
- return (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(event.inversePixelTransform, pixel.slice(0));
1737
+ return (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(event.inversePixelTransform, pixel.slice(0));
1353
1738
  }
1354
- //# sourceMappingURL=render.js.map
1739
+
1355
1740
 
1356
1741
  /***/ })
1357
1742