@mapsight/lib-ol 4.0.0

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 (237) hide show
  1. package/README.md +20 -0
  2. package/dist/coordinate/add.d.ts +3 -0
  3. package/dist/coordinate/add.d.ts.map +1 -0
  4. package/dist/coordinate/add.js +8 -0
  5. package/dist/coordinate/add.js.map +1 -0
  6. package/dist/coordinate/addPixelPadding.d.ts +10 -0
  7. package/dist/coordinate/addPixelPadding.d.ts.map +1 -0
  8. package/dist/coordinate/addPixelPadding.js +13 -0
  9. package/dist/coordinate/addPixelPadding.js.map +1 -0
  10. package/dist/coordinate/fromPixel.d.ts +3 -0
  11. package/dist/coordinate/fromPixel.d.ts.map +1 -0
  12. package/dist/coordinate/fromPixel.js +8 -0
  13. package/dist/coordinate/fromPixel.js.map +1 -0
  14. package/dist/coordinate/scale.d.ts +3 -0
  15. package/dist/coordinate/scale.d.ts.map +1 -0
  16. package/dist/coordinate/scale.js +5 -0
  17. package/dist/coordinate/scale.js.map +1 -0
  18. package/dist/coordinate/toPixel.d.ts +3 -0
  19. package/dist/coordinate/toPixel.d.ts.map +1 -0
  20. package/dist/coordinate/toPixel.js +8 -0
  21. package/dist/coordinate/toPixel.js.map +1 -0
  22. package/dist/coordinates/equals.d.ts +3 -0
  23. package/dist/coordinates/equals.d.ts.map +1 -0
  24. package/dist/coordinates/equals.js +5 -0
  25. package/dist/coordinates/equals.js.map +1 -0
  26. package/dist/coordinates/middleCoordinate.d.ts +3 -0
  27. package/dist/coordinates/middleCoordinate.d.ts.map +1 -0
  28. package/dist/coordinates/middleCoordinate.js +5 -0
  29. package/dist/coordinates/middleCoordinate.js.map +1 -0
  30. package/dist/events/condition/clickOnFeature.d.ts +9 -0
  31. package/dist/events/condition/clickOnFeature.d.ts.map +1 -0
  32. package/dist/events/condition/clickOnFeature.js +10 -0
  33. package/dist/events/condition/clickOnFeature.js.map +1 -0
  34. package/dist/extent/getCentroid.d.ts +6 -0
  35. package/dist/extent/getCentroid.d.ts.map +1 -0
  36. package/dist/extent/getCentroid.js +9 -0
  37. package/dist/extent/getCentroid.js.map +1 -0
  38. package/dist/extent/isFiniteExtent.d.ts +3 -0
  39. package/dist/extent/isFiniteExtent.d.ts.map +1 -0
  40. package/dist/extent/isFiniteExtent.js +4 -0
  41. package/dist/extent/isFiniteExtent.js.map +1 -0
  42. package/dist/extents/combineExtents.d.ts +3 -0
  43. package/dist/extents/combineExtents.d.ts.map +1 -0
  44. package/dist/extents/combineExtents.js +9 -0
  45. package/dist/extents/combineExtents.js.map +1 -0
  46. package/dist/feature/animator.d.ts +9 -0
  47. package/dist/feature/animator.d.ts.map +1 -0
  48. package/dist/feature/animator.js +33 -0
  49. package/dist/feature/animator.js.map +1 -0
  50. package/dist/feature/cluster.d.ts +8 -0
  51. package/dist/feature/cluster.d.ts.map +1 -0
  52. package/dist/feature/cluster.js +50 -0
  53. package/dist/feature/cluster.js.map +1 -0
  54. package/dist/feature/detectFeatureHits.d.ts +11 -0
  55. package/dist/feature/detectFeatureHits.d.ts.map +1 -0
  56. package/dist/feature/detectFeatureHits.js +34 -0
  57. package/dist/feature/detectFeatureHits.js.map +1 -0
  58. package/dist/feature/ensureId.d.ts +3 -0
  59. package/dist/feature/ensureId.d.ts.map +1 -0
  60. package/dist/feature/ensureId.js +7 -0
  61. package/dist/feature/ensureId.js.map +1 -0
  62. package/dist/feature/getCentroid.d.ts +3 -0
  63. package/dist/feature/getCentroid.d.ts.map +1 -0
  64. package/dist/feature/getCentroid.js +13 -0
  65. package/dist/feature/getCentroid.js.map +1 -0
  66. package/dist/feature/getExtent.d.ts +3 -0
  67. package/dist/feature/getExtent.d.ts.map +1 -0
  68. package/dist/feature/getExtent.js +8 -0
  69. package/dist/feature/getExtent.js.map +1 -0
  70. package/dist/feature/getLayer.d.ts +4 -0
  71. package/dist/feature/getLayer.d.ts.map +1 -0
  72. package/dist/feature/getLayer.js +23 -0
  73. package/dist/feature/getLayer.js.map +1 -0
  74. package/dist/feature/getUid.d.ts +3 -0
  75. package/dist/feature/getUid.d.ts.map +1 -0
  76. package/dist/feature/getUid.js +5 -0
  77. package/dist/feature/getUid.js.map +1 -0
  78. package/dist/features/getCentroidForFeatures.d.ts +3 -0
  79. package/dist/features/getCentroidForFeatures.d.ts.map +1 -0
  80. package/dist/features/getCentroidForFeatures.js +7 -0
  81. package/dist/features/getCentroidForFeatures.js.map +1 -0
  82. package/dist/features/getExtentForFeatures.d.ts +3 -0
  83. package/dist/features/getExtentForFeatures.d.ts.map +1 -0
  84. package/dist/features/getExtentForFeatures.js +7 -0
  85. package/dist/features/getExtentForFeatures.js.map +1 -0
  86. package/dist/geometry/deriveGeometriesFromBase.d.ts +8 -0
  87. package/dist/geometry/deriveGeometriesFromBase.d.ts.map +1 -0
  88. package/dist/geometry/deriveGeometriesFromBase.js +69 -0
  89. package/dist/geometry/deriveGeometriesFromBase.js.map +1 -0
  90. package/dist/geometry/getDominantGeometryType.d.ts +4 -0
  91. package/dist/geometry/getDominantGeometryType.d.ts.map +1 -0
  92. package/dist/geometry/getDominantGeometryType.js +30 -0
  93. package/dist/geometry/getDominantGeometryType.js.map +1 -0
  94. package/dist/geometry/getLineStringSegmentVerticesWithRotation.d.ts +4 -0
  95. package/dist/geometry/getLineStringSegmentVerticesWithRotation.d.ts.map +1 -0
  96. package/dist/geometry/getLineStringSegmentVerticesWithRotation.js +28 -0
  97. package/dist/geometry/getLineStringSegmentVerticesWithRotation.js.map +1 -0
  98. package/dist/geometry/getPolygonRingSegmentVerticesWithRotation.d.ts +4 -0
  99. package/dist/geometry/getPolygonRingSegmentVerticesWithRotation.d.ts.map +1 -0
  100. package/dist/geometry/getPolygonRingSegmentVerticesWithRotation.js +49 -0
  101. package/dist/geometry/getPolygonRingSegmentVerticesWithRotation.js.map +1 -0
  102. package/dist/index.d.ts +52 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +2 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/map/animateDuringTransition.d.ts +4 -0
  107. package/dist/map/animateDuringTransition.d.ts.map +1 -0
  108. package/dist/map/animateDuringTransition.js +41 -0
  109. package/dist/map/animateDuringTransition.js.map +1 -0
  110. package/dist/map/canvasSizeFixer.d.ts +10 -0
  111. package/dist/map/canvasSizeFixer.d.ts.map +1 -0
  112. package/dist/map/canvasSizeFixer.js +35 -0
  113. package/dist/map/canvasSizeFixer.js.map +1 -0
  114. package/dist/map/containsExtentWithPadding.d.ts +5 -0
  115. package/dist/map/containsExtentWithPadding.d.ts.map +1 -0
  116. package/dist/map/containsExtentWithPadding.js +9 -0
  117. package/dist/map/containsExtentWithPadding.js.map +1 -0
  118. package/dist/map/fitToExtent.d.ts +10 -0
  119. package/dist/map/fitToExtent.d.ts.map +1 -0
  120. package/dist/map/fitToExtent.js +26 -0
  121. package/dist/map/fitToExtent.js.map +1 -0
  122. package/dist/map/fitToFeature.d.ts +17 -0
  123. package/dist/map/fitToFeature.d.ts.map +1 -0
  124. package/dist/map/fitToFeature.js +16 -0
  125. package/dist/map/fitToFeature.js.map +1 -0
  126. package/dist/map/fitToFeatures.d.ts +17 -0
  127. package/dist/map/fitToFeatures.d.ts.map +1 -0
  128. package/dist/map/fitToFeatures.js +11 -0
  129. package/dist/map/fitToFeatures.js.map +1 -0
  130. package/dist/map/getPaddedViewExtent.d.ts +5 -0
  131. package/dist/map/getPaddedViewExtent.d.ts.map +1 -0
  132. package/dist/map/getPaddedViewExtent.js +28 -0
  133. package/dist/map/getPaddedViewExtent.js.map +1 -0
  134. package/dist/map/getVisibleLayersFromFramestate.d.ts +5 -0
  135. package/dist/map/getVisibleLayersFromFramestate.d.ts.map +1 -0
  136. package/dist/map/getVisibleLayersFromFramestate.js +8 -0
  137. package/dist/map/getVisibleLayersFromFramestate.js.map +1 -0
  138. package/dist/map/updateSizeDuringTransition.d.ts +3 -0
  139. package/dist/map/updateSizeDuringTransition.d.ts.map +1 -0
  140. package/dist/map/updateSizeDuringTransition.js +7 -0
  141. package/dist/map/updateSizeDuringTransition.js.map +1 -0
  142. package/dist/map/updateSizeOnTransitionEnd.d.ts +3 -0
  143. package/dist/map/updateSizeOnTransitionEnd.d.ts.map +1 -0
  144. package/dist/map/updateSizeOnTransitionEnd.js +19 -0
  145. package/dist/map/updateSizeOnTransitionEnd.js.map +1 -0
  146. package/dist/points/findClosestPoint.d.ts +11 -0
  147. package/dist/points/findClosestPoint.d.ts.map +1 -0
  148. package/dist/points/findClosestPoint.js +32 -0
  149. package/dist/points/findClosestPoint.js.map +1 -0
  150. package/dist/points/spreadPointClusterInRadius.d.ts +14 -0
  151. package/dist/points/spreadPointClusterInRadius.d.ts.map +1 -0
  152. package/dist/points/spreadPointClusterInRadius.js +53 -0
  153. package/dist/points/spreadPointClusterInRadius.js.map +1 -0
  154. package/dist/style/bindStyleToGeometry.d.ts +4 -0
  155. package/dist/style/bindStyleToGeometry.d.ts.map +1 -0
  156. package/dist/style/bindStyleToGeometry.js +6 -0
  157. package/dist/style/bindStyleToGeometry.js.map +1 -0
  158. package/dist/style/createCachedStyleFunction.d.ts +45 -0
  159. package/dist/style/createCachedStyleFunction.d.ts.map +1 -0
  160. package/dist/style/createCachedStyleFunction.js +175 -0
  161. package/dist/style/createCachedStyleFunction.js.map +1 -0
  162. package/dist/style/declarationToGeometry.d.ts +3 -0
  163. package/dist/style/declarationToGeometry.d.ts.map +1 -0
  164. package/dist/style/declarationToGeometry.js +4 -0
  165. package/dist/style/declarationToGeometry.js.map +1 -0
  166. package/dist/style/declarationToStyle.d.ts +6 -0
  167. package/dist/style/declarationToStyle.d.ts.map +1 -0
  168. package/dist/style/declarationToStyle.js +167 -0
  169. package/dist/style/declarationToStyle.js.map +1 -0
  170. package/dist/style/styleFunction.d.ts +21 -0
  171. package/dist/style/styleFunction.d.ts.map +1 -0
  172. package/dist/style/styleFunction.js +13 -0
  173. package/dist/style/styleFunction.js.map +1 -0
  174. package/dist/tileGrid/getTileUrlsForExtent.d.ts +4 -0
  175. package/dist/tileGrid/getTileUrlsForExtent.d.ts.map +1 -0
  176. package/dist/tileGrid/getTileUrlsForExtent.js +23 -0
  177. package/dist/tileGrid/getTileUrlsForExtent.js.map +1 -0
  178. package/dist/view/centerOnFeature.d.ts +10 -0
  179. package/dist/view/centerOnFeature.d.ts.map +1 -0
  180. package/dist/view/centerOnFeature.js +12 -0
  181. package/dist/view/centerOnFeature.js.map +1 -0
  182. package/dist/view/centerOnFeatures.d.ts +8 -0
  183. package/dist/view/centerOnFeatures.d.ts.map +1 -0
  184. package/dist/view/centerOnFeatures.js +19 -0
  185. package/dist/view/centerOnFeatures.js.map +1 -0
  186. package/dist/view/getMinZoomFittingContentInView.d.ts +15 -0
  187. package/dist/view/getMinZoomFittingContentInView.d.ts.map +1 -0
  188. package/dist/view/getMinZoomFittingContentInView.js +29 -0
  189. package/dist/view/getMinZoomFittingContentInView.js.map +1 -0
  190. package/package.json +36 -0
  191. package/src/js/coordinate/add.ts +13 -0
  192. package/src/js/coordinate/addPixelPadding.ts +21 -0
  193. package/src/js/coordinate/fromPixel.ts +10 -0
  194. package/src/js/coordinate/scale.ts +7 -0
  195. package/src/js/coordinate/toPixel.ts +13 -0
  196. package/src/js/coordinates/equals.ts +6 -0
  197. package/src/js/coordinates/middleCoordinate.ts +7 -0
  198. package/src/js/events/condition/clickOnFeature.ts +13 -0
  199. package/src/js/extent/getCentroid.ts +14 -0
  200. package/src/js/extent/isFiniteExtent.ts +7 -0
  201. package/src/js/extents/combineExtents.ts +11 -0
  202. package/src/js/feature/animator.ts +91 -0
  203. package/src/js/feature/cluster.ts +86 -0
  204. package/src/js/feature/detectFeatureHits.ts +57 -0
  205. package/src/js/feature/ensureId.ts +9 -0
  206. package/src/js/feature/getCentroid.ts +18 -0
  207. package/src/js/feature/getExtent.ts +10 -0
  208. package/src/js/feature/getLayer.ts +39 -0
  209. package/src/js/feature/getUid.ts +6 -0
  210. package/src/js/features/getCentroidForFeatures.ts +10 -0
  211. package/src/js/features/getExtentForFeatures.ts +10 -0
  212. package/src/js/geometry/deriveGeometriesFromBase.ts +122 -0
  213. package/src/js/geometry/getDominantGeometryType.ts +40 -0
  214. package/src/js/geometry/getLineStringSegmentVerticesWithRotation.ts +48 -0
  215. package/src/js/geometry/getPolygonRingSegmentVerticesWithRotation.ts +90 -0
  216. package/src/js/index.ts +62 -0
  217. package/src/js/map/animateDuringTransition.ts +58 -0
  218. package/src/js/map/canvasSizeFixer.ts +46 -0
  219. package/src/js/map/containsExtentWithPadding.ts +17 -0
  220. package/src/js/map/fitToExtent.ts +45 -0
  221. package/src/js/map/fitToFeature.ts +29 -0
  222. package/src/js/map/fitToFeatures.ts +21 -0
  223. package/src/js/map/getPaddedViewExtent.ts +42 -0
  224. package/src/js/map/getVisibleLayersFromFramestate.ts +14 -0
  225. package/src/js/map/updateSizeDuringTransition.ts +9 -0
  226. package/src/js/map/updateSizeOnTransitionEnd.ts +28 -0
  227. package/src/js/points/findClosestPoint.ts +51 -0
  228. package/src/js/points/spreadPointClusterInRadius.ts +84 -0
  229. package/src/js/style/bindStyleToGeometry.ts +11 -0
  230. package/src/js/style/createCachedStyleFunction.ts +344 -0
  231. package/src/js/style/declarationToGeometry.ts +7 -0
  232. package/src/js/style/declarationToStyle.ts +277 -0
  233. package/src/js/style/styleFunction.ts +42 -0
  234. package/src/js/tileGrid/getTileUrlsForExtent.ts +41 -0
  235. package/src/js/view/centerOnFeature.ts +23 -0
  236. package/src/js/view/centerOnFeatures.ts +30 -0
  237. package/src/js/view/getMinZoomFittingContentInView.ts +50 -0
@@ -0,0 +1,167 @@
1
+ import LRUCache from "ol/structs/LRUCache";
2
+ const IMAGE_TYPES = ["image", "icon", "circle"];
3
+ const NONE_ABLE_PROPS = ["fill", "stroke"];
4
+ const unitFromAnchorValue = (a) => a && typeof a === "string" && a.indexOf("px") > -1 ? "pixels" : "fraction";
5
+ const boolishValue = (a) => a === true || a === 1 || a === "1" || a === "true";
6
+ const numberValue = (a) => a ? parseFloat(String(a)) : 0;
7
+ const intValue = (a) => a ? parseInt(String(a), 10) : 0;
8
+ const numberArrayValue = (a) => {
9
+ let arr = [];
10
+ if (a) {
11
+ if (Array.isArray(a)) {
12
+ arr = a;
13
+ }
14
+ if (typeof a === "string") {
15
+ arr = a.split(",");
16
+ }
17
+ }
18
+ return arr.map((b) => parseFloat(String(b).trim()));
19
+ };
20
+ const HASH_STRING_DELIMITER = "|";
21
+ export const DEFAULT_CACHE_SIZE = 100;
22
+ let defaultCache = null;
23
+ function getDefaultCache() {
24
+ if (defaultCache === null) {
25
+ defaultCache = new LRUCache(DEFAULT_CACHE_SIZE);
26
+ }
27
+ return defaultCache;
28
+ }
29
+ function _declarationToStyle(constructorsMap, declaration, type, cache, root = true) {
30
+ const style = {};
31
+ if (root) {
32
+ const rootDeclaration = declaration;
33
+ if (rootDeclaration.display?.value === "none") {
34
+ return null;
35
+ }
36
+ // image is the base for icon, circle and regular shape. image only has image-type: *; any other options
37
+ // will be in either of the above. e.g. icon-src: ...;
38
+ if (rootDeclaration.image) {
39
+ const imageType = rootDeclaration.image.type.value;
40
+ if (imageType) {
41
+ if (rootDeclaration[imageType]) {
42
+ // FIXME: converting `Style` to `Image`
43
+ style.image = declarationToStyle(constructorsMap, rootDeclaration[imageType], imageType, undefined, cache, false);
44
+ }
45
+ }
46
+ else {
47
+ console.error("Image type unknown", imageType, rootDeclaration);
48
+ }
49
+ }
50
+ }
51
+ Object.keys(declaration).forEach((key) => {
52
+ if (IMAGE_TYPES.indexOf(key) > -1) {
53
+ return;
54
+ }
55
+ const values = declaration;
56
+ const declarationValue = values[key];
57
+ if (typeof declarationValue !== "object") {
58
+ return;
59
+ }
60
+ const declarationValueValue = "value" in declarationValue ? declarationValue.value : undefined;
61
+ if (declarationValueValue === undefined) {
62
+ if (key in constructorsMap) {
63
+ try {
64
+ style[key] = declarationToStyle(constructorsMap, declarationValue, key, undefined, cache, false);
65
+ }
66
+ catch (e) {
67
+ console.error("Style error", e);
68
+ }
69
+ }
70
+ return;
71
+ }
72
+ if (declarationValueValue === "unset" ||
73
+ (declarationValueValue === "none" &&
74
+ NONE_ABLE_PROPS.indexOf(key) > -1)) {
75
+ delete style[key];
76
+ return;
77
+ }
78
+ switch (key) {
79
+ // booleans
80
+ case "snapToPixel":
81
+ style.snapToPixel = boolishValue(declarationValueValue);
82
+ break;
83
+ case "rotateWithView":
84
+ style.rotateWithView = boolishValue(declarationValueValue);
85
+ break;
86
+ // allow space separated double value (x and y)
87
+ //case 'size':
88
+ // style.size = declarationValueValue ? declarationValueValue.split(' ').map(part => parseFloat(part)) : style.size;
89
+ // break;
90
+ case "sizeX":
91
+ style.size = style.size || [0, 0];
92
+ style.size[0] = numberValue(declarationValueValue);
93
+ break;
94
+ case "sizeY":
95
+ style.size = style.size || [0, 0];
96
+ style.size[1] = numberValue(declarationValueValue);
97
+ break;
98
+ // allow space separated double value (x and y)
99
+ //case 'imgSize':
100
+ // style.imgSize = declarationValueValue ? declarationValueValue.split(' ').map(part => parseFloat(part)) : style.imgSize;
101
+ // break;
102
+ case "imgSizeX":
103
+ style.imgSize = style.imgSize || [0, 0];
104
+ style.imgSize[0] = numberValue(declarationValueValue);
105
+ break;
106
+ case "imgSizeY":
107
+ style.imgSize = style.imgSize || [0, 0];
108
+ style.imgSize[1] = numberValue(declarationValueValue);
109
+ break;
110
+ case "anchorX":
111
+ style.anchor = style.anchor || [0, 0];
112
+ style.anchor[0] = numberValue(declarationValueValue);
113
+ style.anchorXUnits = unitFromAnchorValue(declarationValueValue);
114
+ break;
115
+ case "anchorY":
116
+ style.anchor = style.anchor || [0, 0];
117
+ style.anchor[1] = numberValue(declarationValueValue);
118
+ style.anchorYUnits = unitFromAnchorValue(declarationValueValue);
119
+ break;
120
+ // can be directly (offsetX in ol.style.Text or offset array in ol.style.Icon)
121
+ case "offsetX":
122
+ style.offset = style.offset || [0, 0];
123
+ style.offsetX = style.offset[0] = numberValue(declarationValueValue);
124
+ break;
125
+ // can be directly (offsetY in ol.style.Text or offset array in ol.style.Icon)
126
+ case "offsetY":
127
+ style.offset = style.offset || [0, 0];
128
+ style.offsetY = style.offset[1] = numberValue(declarationValueValue);
129
+ break;
130
+ case "colorRed":
131
+ style.color = style.color || [0, 0, 0, 1];
132
+ style.color[0] = intValue(declarationValueValue);
133
+ break;
134
+ case "colorGreen":
135
+ style.color = style.color || [0, 0, 0, 1];
136
+ style.color[1] = intValue(declarationValueValue);
137
+ break;
138
+ case "colorBlue":
139
+ style.color = style.color || [0, 0, 0, 1];
140
+ style.color[2] = intValue(declarationValueValue);
141
+ break;
142
+ case "colorAlpha":
143
+ style.color = style.color || [0, 0, 0, 1];
144
+ style.color[3] = numberValue(declarationValueValue);
145
+ break;
146
+ case "lineDash":
147
+ style.lineDash = numberArrayValue(declarationValueValue);
148
+ break;
149
+ default:
150
+ style[key] = declarationValueValue;
151
+ }
152
+ });
153
+ const StyleCtor = constructorsMap[type];
154
+ return StyleCtor ? new StyleCtor(style) : null;
155
+ }
156
+ export default function declarationToStyle(constructorsMap, declaration, type, hash, cache = getDefaultCache(), root = true) {
157
+ if (!constructorsMap[type]) {
158
+ console.error("Style unknown", type, declaration);
159
+ return null;
160
+ }
161
+ const cacheHash = type + HASH_STRING_DELIMITER + (hash || JSON.stringify(declaration));
162
+ if (!cache.containsKey(cacheHash)) {
163
+ cache.set(cacheHash, _declarationToStyle(constructorsMap, declaration, type, cache, root));
164
+ }
165
+ return cache.get(cacheHash);
166
+ }
167
+ //# sourceMappingURL=declarationToStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarationToStyle.js","sourceRoot":"","sources":["../../src/js/style/declarationToStyle.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAc3C,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAChD,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE3C,MAAM,mBAAmB,GAAG,CAAC,CAAiB,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C;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { FeatureLike } from "ol/Feature";
2
+ import type Style from "ol/style/Style";
3
+ import type { StyleFunctionOptions } from "./createCachedStyleFunction";
4
+ export declare const STYLE_ENV_FIELD_NAME = "style";
5
+ type StatePrimitive = string | number | boolean | null | undefined;
6
+ type StateObject = {
7
+ [key: string]: StateValue;
8
+ };
9
+ type StateArray = StateValue[];
10
+ type StateValue = StatePrimitive | StateObject | StateArray;
11
+ export type MapsightStyleFunctionEnv = {
12
+ [k: string]: StateValue;
13
+ [STYLE_ENV_FIELD_NAME]?: string;
14
+ };
15
+ export type MapsightStyleFunctionProps = {
16
+ [k: string]: StateValue;
17
+ };
18
+ export type MapsightStyleFunction = (env: MapsightStyleFunctionEnv, feature: FeatureLike) => Array<Style> | Style | undefined;
19
+ export declare const createPropsFilter: (allowedProps?: StyleFunctionOptions["allowedProps"]) => (props: MapsightStyleFunctionProps) => MapsightStyleFunctionProps;
20
+ export {};
21
+ //# sourceMappingURL=styleFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleFunction.d.ts","sourceRoot":"","sources":["../../src/js/style/styleFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAExC,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAEtE,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAI5C,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AACnE,KAAK,WAAW,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAC,CAAC;AAC/C,KAAK,UAAU,GAAG,UAAU,EAAE,CAAC;AAC/B,KAAK,UAAU,GAAG,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC;AAE5D,MAAM,MAAM,wBAAwB,GAAG;IACtC,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACxB,CAAC,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG;IACxC,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CACnC,GAAG,EAAE,wBAAwB,EAC7B,OAAO,EAAE,WAAW,KAChB,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,SAAS,CAAC;AAEtC,eAAO,MAAM,iBAAiB,GAC7B,eAAc,oBAAoB,CAAC,cAAc,CAAM,aAG5C,0BAA0B,+BAUlC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const STYLE_ENV_FIELD_NAME = "style";
2
+ export const createPropsFilter = (allowedProps = []) => allowedProps === false
3
+ ? (props) => props
4
+ : function filterProps(props) {
5
+ const filteredProps = {};
6
+ allowedProps
7
+ .filter((key) => props[key])
8
+ .forEach((key) => {
9
+ filteredProps[key] = props[key];
10
+ });
11
+ return filteredProps;
12
+ };
13
+ //# sourceMappingURL=styleFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleFunction.js","sourceRoot":"","sources":["../../src/js/style/styleFunction.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAsB5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAChC,eAAqD,EAAE,EACtD,EAAE,CACH,YAAY,KAAK,KAAK;IACrB,CAAC,CAAC,CAAC,KAAiC,EAAE,EAAE,CAAC,KAAK;IAC9C,CAAC,CAAC,SAAS,WAAW,CAAC,KAAiC;QACtD,MAAM,aAAa,GAA+B,EAAE,CAAC;QACrD,YAAY;aACV,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAC3B,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAChB,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEJ,OAAO,aAAa,CAAC;IACtB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Extent } from "ol/extent";
2
+ import type TileGrid from "ol/tilegrid/TileGrid";
3
+ export default function getTileUrlsForExtent(tileGrid: TileGrid, extent: Extent): string[];
4
+ //# sourceMappingURL=getTileUrlsForExtent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTileUrlsForExtent.d.ts","sourceRoot":"","sources":["../../src/js/tileGrid/getTileUrlsForExtent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAOjD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,YA8Bd"}
@@ -0,0 +1,23 @@
1
+ import { assertNonNullable, ensureNonNullable, } from "@mapsight/lib-js/nonNullable";
2
+ export default function getTileUrlsForExtent(tileGrid, extent) {
3
+ assertNonNullable(extent[0]);
4
+ assertNonNullable(extent[1]);
5
+ assertNonNullable(extent[2]);
6
+ assertNonNullable(extent[3]);
7
+ const tileUrls = [];
8
+ for (let z = 17; z <= 21; z++) {
9
+ const leftBottom = tileGrid.getTileCoordForCoordAndZ([extent[0], extent[1]], z);
10
+ const left = ensureNonNullable(leftBottom[1]);
11
+ const bottom = -ensureNonNullable(leftBottom[2]);
12
+ const rightTop = tileGrid.getTileCoordForCoordAndZ([extent[2], extent[3]], z);
13
+ const right = ensureNonNullable(rightTop[1]);
14
+ const top = -ensureNonNullable(rightTop[2]);
15
+ for (let x = left; x <= right; x += 1) {
16
+ for (let y = top; y <= bottom; y += 1) {
17
+ tileUrls.push(`${z}/${x}/${y}.png`);
18
+ }
19
+ }
20
+ }
21
+ return tileUrls;
22
+ }
23
+ //# sourceMappingURL=getTileUrlsForExtent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTileUrlsForExtent.js","sourceRoot":"","sources":["../../src/js/tileGrid/getTileUrlsForExtent.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC3C,QAAkB,EAClB,MAAc;IAEd,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,wBAAwB,CACnD,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EACtB,CAAC,CACD,CAAC;QACF,MAAM,IAAI,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,wBAAwB,CACjD,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EACtB,CAAC,CACD,CAAC;QACF,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5C,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrC,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type Feature from "ol/Feature";
2
+ import type View from "ol/View";
3
+ export type CenterOnFeatureOptions = {
4
+ duration?: number;
5
+ };
6
+ export declare const DEFAULT_OPTIONS: {
7
+ duration: number;
8
+ };
9
+ export default function centerOnFeature(view: View, feature: Feature, options?: CenterOnFeatureOptions): void;
10
+ //# sourceMappingURL=centerOnFeature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centerOnFeature.d.ts","sourceRoot":"","sources":["../../src/js/view/centerOnFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAGhC,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,eAAe;;CAE3B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,sBAAwC,QAOjD"}
@@ -0,0 +1,12 @@
1
+ import * as olExtent from "ol/extent";
2
+ export const DEFAULT_OPTIONS = {
3
+ duration: 300, // TODO: MAGIC NUMBER!
4
+ };
5
+ export default function centerOnFeature(view, feature, options = DEFAULT_OPTIONS) {
6
+ const featureExtent = feature.getGeometry()?.getExtent();
7
+ if (featureExtent) {
8
+ const center = olExtent.getCenter(featureExtent);
9
+ view.animate({ center: center, ...options });
10
+ }
11
+ }
12
+ //# sourceMappingURL=centerOnFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centerOnFeature.js","sourceRoot":"","sources":["../../src/js/view/centerOnFeature.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAMtC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,QAAQ,EAAE,GAAG,EAAE,sBAAsB;CACrC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACtC,IAAU,EACV,OAAgB,EAChB,UAAkC,eAAe;IAEjD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC;IACzD,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAC,CAAC,CAAC;IAC5C,CAAC;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type Feature from "ol/Feature";
2
+ import type View from "ol/View";
3
+ import type { CenterOnFeatureOptions } from "./centerOnFeature";
4
+ export declare const DEFAULT_OPTIONS: {
5
+ duration: number;
6
+ };
7
+ export default function centerOnFeatures(view: View, features: Array<Feature>, options?: CenterOnFeatureOptions): void;
8
+ //# sourceMappingURL=centerOnFeatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centerOnFeatures.d.ts","sourceRoot":"","sources":["../../src/js/view/centerOnFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAGhC,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AAG9D,eAAO,MAAM,eAAe;;CAAsC,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACvC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,EACxB,OAAO,GAAE,sBAAwC,QAiBjD"}
@@ -0,0 +1,19 @@
1
+ import * as olExtent from "ol/extent";
2
+ import { DEFAULT_OPTIONS as SINGLE_FEATURE_DEFAULT_OPTIONS } from "./centerOnFeature";
3
+ export const DEFAULT_OPTIONS = { ...SINGLE_FEATURE_DEFAULT_OPTIONS };
4
+ export default function centerOnFeatures(view, features, options = DEFAULT_OPTIONS) {
5
+ if (!features || !features.length) {
6
+ return;
7
+ }
8
+ // combine extents
9
+ const featuresExtent = olExtent.createEmpty();
10
+ features.forEach((feature) => {
11
+ const extent = feature.getGeometry()?.getExtent();
12
+ if (extent) {
13
+ olExtent.extend(featuresExtent, extent);
14
+ }
15
+ });
16
+ const center = olExtent.getCenter(featuresExtent);
17
+ view.animate({ center: center, ...options });
18
+ }
19
+ //# sourceMappingURL=centerOnFeatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centerOnFeatures.js","sourceRoot":"","sources":["../../src/js/view/centerOnFeatures.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAC,eAAe,IAAI,8BAA8B,EAAC,MAAM,mBAAmB,CAAC;AAEpF,MAAM,CAAC,MAAM,eAAe,GAAG,EAAC,GAAG,8BAA8B,EAAC,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACvC,IAAU,EACV,QAAwB,EACxB,UAAkC,eAAe;IAEjD,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO;IACR,CAAC;IAED,kBAAkB;IAClB,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC9C,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC;QAClD,IAAI,MAAM,EAAE,CAAC;YACZ,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,IAAI,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAC,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param contentExtentWidth contentExtentWidth
3
+ * @param contentExtentHeight contentExtentHeight
4
+ * @param viewWidth viewWidth
5
+ * @param viewHeight viewHeight
6
+ * @param options options
7
+ * @returns zoom
8
+ */
9
+ export default function getMinZoomFittingContentInView(contentExtentWidth: number, contentExtentHeight: number, viewWidth: number, viewHeight: number, { zoomFactor, projectionCode, tileSize, minZoom, }?: {
10
+ zoomFactor?: number | undefined;
11
+ projectionCode?: string | undefined;
12
+ tileSize?: number | undefined;
13
+ minZoom?: number | undefined;
14
+ }): number;
15
+ //# sourceMappingURL=getMinZoomFittingContentInView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMinZoomFittingContentInView.d.ts","sourceRoot":"","sources":["../../src/js/view/getMinZoomFittingContentInView.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACrD,kBAAkB,EAAE,MAAM,EAC1B,mBAAmB,EAAE,MAAM,EAC3B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,EACC,UAAc,EACd,cAA4B,EAC5B,QAAc,EACd,OAAW,GACX;;;;;CAAK,UAwBN"}
@@ -0,0 +1,29 @@
1
+ import { getHeight, getWidth } from "ol/extent";
2
+ import { get as projGet } from "ol/proj";
3
+ function getBaseLog(x, base) {
4
+ return Math.log(x) / Math.log(base);
5
+ }
6
+ /**
7
+ * @param contentExtentWidth contentExtentWidth
8
+ * @param contentExtentHeight contentExtentHeight
9
+ * @param viewWidth viewWidth
10
+ * @param viewHeight viewHeight
11
+ * @param options options
12
+ * @returns zoom
13
+ */
14
+ export default function getMinZoomFittingContentInView(contentExtentWidth, contentExtentHeight, viewWidth, viewHeight, { zoomFactor = 2, projectionCode = "EPSG:3857", tileSize = 256, minZoom = 0, } = {}) {
15
+ const maxResolutionX = contentExtentWidth / viewWidth;
16
+ const maxResolutionY = contentExtentHeight / viewHeight;
17
+ const maxResolution = Math.max(maxResolutionX, maxResolutionY);
18
+ const projection = projGet(projectionCode);
19
+ if (!projection) {
20
+ throw Error("projection missing");
21
+ }
22
+ const projectionExtent = projection.getExtent();
23
+ const projectionExtentSizeMax = Math.max(getWidth(projectionExtent), getHeight(projectionExtent));
24
+ return getBaseLog(projectionExtentSizeMax /
25
+ tileSize /
26
+ Math.pow(zoomFactor, minZoom) /
27
+ maxResolution, zoomFactor);
28
+ }
29
+ //# sourceMappingURL=getMinZoomFittingContentInView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMinZoomFittingContentInView.js","sourceRoot":"","sources":["../../src/js/view/getMinZoomFittingContentInView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAC,GAAG,IAAI,OAAO,EAAC,MAAM,SAAS,CAAC;AAEvC,SAAS,UAAU,CAAC,CAAS,EAAE,IAAY;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACrD,kBAA0B,EAC1B,mBAA2B,EAC3B,SAAiB,EACjB,UAAkB,EAClB,EACC,UAAU,GAAG,CAAC,EACd,cAAc,GAAG,WAAW,EAC5B,QAAQ,GAAG,GAAG,EACd,OAAO,GAAG,CAAC,GACX,GAAG,EAAE;IAEN,MAAM,cAAc,GAAG,kBAAkB,GAAG,SAAS,CAAC;IACtD,MAAM,cAAc,GAAG,mBAAmB,GAAG,UAAU,CAAC;IACxD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAE/D,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAChD,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,CACvC,QAAQ,CAAC,gBAAgB,CAAC,EAC1B,SAAS,CAAC,gBAAgB,CAAC,CAC3B,CAAC;IAEF,OAAO,UAAU,CAChB,uBAAuB;QACtB,QAAQ;QACR,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;QAC7B,aAAa,EACd,UAAU,CACV,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@mapsight/lib-ol",
3
+ "description": "Mapsight OpenLayers Library",
4
+ "version": "4.0.0",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "@types/lodash": "^4.17.24",
8
+ "lodash": "^4.18.1",
9
+ "ol": "^10.9.0",
10
+ "@mapsight/lib-js": "^3.0.0"
11
+ },
12
+ "devDependencies": {
13
+ "tsc-alias": "^1.8.17"
14
+ },
15
+ "exports": {
16
+ "./*": {
17
+ "types": "./dist/*.d.ts",
18
+ "default": "./dist/*.js"
19
+ }
20
+ },
21
+ "license": "UNLICENSED",
22
+ "main": "index.js",
23
+ "peerDependencies": {
24
+ "ol": "^10.9.0"
25
+ },
26
+ "scripts": {
27
+ "build": "tsc && tsc-alias",
28
+ "clean": "rimraf dist/*",
29
+ "clean-build": "run-s clean build",
30
+ "typecheck": "tsc --noEmit",
31
+ "watch": "run-s build watch:build",
32
+ "watch:build": "run-p watch:build:modules watch:build:paths",
33
+ "watch:build:modules": "tsc --watch",
34
+ "watch:build:paths": "tsc-alias --watch"
35
+ }
36
+ }
@@ -0,0 +1,13 @@
1
+ import type {Coordinate} from "ol/coordinate";
2
+
3
+ import {ensureNonNullable} from "@mapsight/lib-js/nonNullable";
4
+
5
+ export default function add(
6
+ [aX, aY]: Coordinate,
7
+ [bX, bY]: Coordinate,
8
+ ): [number, number] {
9
+ return [
10
+ ensureNonNullable(aX) + ensureNonNullable(bX),
11
+ ensureNonNullable(aY) + ensureNonNullable(bY),
12
+ ];
13
+ }
@@ -0,0 +1,21 @@
1
+ import type {Coordinate} from "ol/coordinate";
2
+
3
+ import type {Padding} from "../index";
4
+ import add from "./add";
5
+ import fromPixel from "./fromPixel";
6
+
7
+ /**
8
+ * @param resolution Resolution
9
+ * @param coordinate Coordinate
10
+ * @param padding Padding (in pixels) to be cleared inside the view. Values in the array are top, right, bottom and left padding. Default is [0, 0, 0, 0]. Required.
11
+ * @returns coordinate with added pixel padding
12
+ */
13
+ export default function addPixelPadding(
14
+ resolution: number,
15
+ coordinate: Coordinate,
16
+ [top, right, bottom, left]: Padding = [0, 0, 0, 0],
17
+ ): Coordinate {
18
+ const pixelDelta = [(right - left) / 2, (bottom - top) / 2];
19
+
20
+ return add(coordinate, fromPixel(pixelDelta, resolution));
21
+ }
@@ -0,0 +1,10 @@
1
+ import type {Pixel} from "ol/pixel";
2
+
3
+ import {ensureNonNullable} from "@mapsight/lib-js/nonNullable";
4
+
5
+ export default function fromPixel([x, y]: Pixel, resolution: number) {
6
+ return [
7
+ ensureNonNullable(x) * resolution,
8
+ ensureNonNullable(y) * -1 * resolution,
9
+ ];
10
+ }
@@ -0,0 +1,7 @@
1
+ import type {Coordinate} from "ol/coordinate";
2
+
3
+ import {ensureNonNullable} from "@mapsight/lib-js/nonNullable";
4
+
5
+ export default function scale([x, y]: Coordinate, s: number): [number, number] {
6
+ return [ensureNonNullable(x) * s, ensureNonNullable(y) * s];
7
+ }
@@ -0,0 +1,13 @@
1
+ import type {Coordinate} from "ol/coordinate";
2
+
3
+ import {ensureNonNullable} from "@mapsight/lib-js/nonNullable";
4
+
5
+ export default function toPixel(
6
+ [x, y]: Coordinate,
7
+ resolution: number,
8
+ ): [number, number] {
9
+ return [
10
+ ensureNonNullable(x) / resolution,
11
+ (ensureNonNullable(y) * -1) / resolution,
12
+ ];
13
+ }
@@ -0,0 +1,6 @@
1
+ import type {Coordinate} from "ol/coordinate";
2
+
3
+ export default function equals(a: Coordinate, b: Coordinate) {
4
+ // FIXME: check index 2, 3, ...
5
+ return a[0] === b[0] && a[1] === b[1];
6
+ }
@@ -0,0 +1,7 @@
1
+ import type {Coordinate} from "ol/coordinate";
2
+
3
+ import add from "../coordinate/add";
4
+
5
+ export default function middleCoordinate(coordinates: Array<Coordinate>) {
6
+ return coordinates.reduce(add, [0, 0]).map((a) => a / coordinates.length);
7
+ }
@@ -0,0 +1,13 @@
1
+ import type {MapBrowserEvent} from "ol";
2
+
3
+ /**
4
+ * based on http://stackoverflow.com/questions/29396614/openlayers3-clicking-outside-feature-deselects-all-features
5
+ *
6
+ * @param e event
7
+ * @returns return
8
+ */
9
+ export default function clickOnFeature(e: MapBrowserEvent<PointerEvent>) {
10
+ return (
11
+ e.type === "click" && !!e.map.forEachFeatureAtPixel(e.pixel, () => true)
12
+ );
13
+ }
@@ -0,0 +1,14 @@
1
+ import type {Extent} from "ol/extent";
2
+
3
+ import {assertNonNullable} from "@mapsight/lib-js/nonNullable";
4
+
5
+ export default function getCentroid([top, right, bottom, left]: Extent): [
6
+ number,
7
+ number,
8
+ ] {
9
+ assertNonNullable(top);
10
+ assertNonNullable(bottom);
11
+ assertNonNullable(right);
12
+ assertNonNullable(left);
13
+ return [top + (bottom - top) / 2, right + (left - right) / 2];
14
+ }
@@ -0,0 +1,7 @@
1
+ import type {Extent} from "ol/extent";
2
+
3
+ export default function isFiniteExtent(extent: Extent) {
4
+ return !extent.some(
5
+ (coordinate) => coordinate === Infinity || coordinate === -Infinity,
6
+ );
7
+ }
@@ -0,0 +1,11 @@
1
+ import type {Extent} from "ol/extent";
2
+ import {createEmpty, extend} from "ol/extent";
3
+
4
+ export default function combineExtents(extents: Array<Extent>) {
5
+ const combinedExtent = createEmpty();
6
+ extents
7
+ .filter((extent) => !!extent)
8
+ .forEach((extent) => extend(combinedExtent, extent));
9
+
10
+ return combinedExtent;
11
+ }