maplair 4.0.0-alpha.1

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 (262) hide show
  1. package/CHANGELOG.md +2804 -0
  2. package/LICENSE +27 -0
  3. package/README.md +40 -0
  4. package/dist/esm/Maplair.js +71 -0
  5. package/dist/esm/Maplair.js.map +1 -0
  6. package/dist/esm/_virtual/_rolldown/runtime.js +13 -0
  7. package/dist/esm/control/AttributionControl.js +79 -0
  8. package/dist/esm/control/AttributionControl.js.map +1 -0
  9. package/dist/esm/control/Control.js +81 -0
  10. package/dist/esm/control/Control.js.map +1 -0
  11. package/dist/esm/control/LayersControl.js +220 -0
  12. package/dist/esm/control/LayersControl.js.map +1 -0
  13. package/dist/esm/control/ScaleControl.js +72 -0
  14. package/dist/esm/control/ScaleControl.js.map +1 -0
  15. package/dist/esm/control/ZoomControl.js +86 -0
  16. package/dist/esm/control/ZoomControl.js.map +1 -0
  17. package/dist/esm/core/Browser.js +31 -0
  18. package/dist/esm/core/Browser.js.map +1 -0
  19. package/dist/esm/core/Class.js +52 -0
  20. package/dist/esm/core/Class.js.map +1 -0
  21. package/dist/esm/core/Events.js +149 -0
  22. package/dist/esm/core/Events.js.map +1 -0
  23. package/dist/esm/core/Handler.js +32 -0
  24. package/dist/esm/core/Handler.js.map +1 -0
  25. package/dist/esm/core/I18n.js +36 -0
  26. package/dist/esm/core/I18n.js.map +1 -0
  27. package/dist/esm/core/Util.js +71 -0
  28. package/dist/esm/core/Util.js.map +1 -0
  29. package/dist/esm/dom/DomEvent.DoubleTap.js +74 -0
  30. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -0
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +46 -0
  32. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -0
  33. package/dist/esm/dom/DomEvent.js +135 -0
  34. package/dist/esm/dom/DomEvent.js.map +1 -0
  35. package/dist/esm/dom/DomUtil.js +107 -0
  36. package/dist/esm/dom/DomUtil.js.map +1 -0
  37. package/dist/esm/dom/Draggable.js +107 -0
  38. package/dist/esm/dom/Draggable.js.map +1 -0
  39. package/dist/esm/dom/PosAnimation.js +56 -0
  40. package/dist/esm/dom/PosAnimation.js.map +1 -0
  41. package/dist/esm/geo/LatLng.js +65 -0
  42. package/dist/esm/geo/LatLng.js.map +1 -0
  43. package/dist/esm/geo/LatLngBounds.js +114 -0
  44. package/dist/esm/geo/LatLngBounds.js.map +1 -0
  45. package/dist/esm/geo/crs/CRS.js +51 -0
  46. package/dist/esm/geo/crs/CRS.js.map +1 -0
  47. package/dist/esm/geo/crs/EPSG3395.js +16 -0
  48. package/dist/esm/geo/crs/EPSG3395.js.map +1 -0
  49. package/dist/esm/geo/crs/EPSG3857.js +19 -0
  50. package/dist/esm/geo/crs/EPSG3857.js.map +1 -0
  51. package/dist/esm/geo/crs/EPSG4326.js +13 -0
  52. package/dist/esm/geo/crs/EPSG4326.js.map +1 -0
  53. package/dist/esm/geo/crs/EarthCRS.js +14 -0
  54. package/dist/esm/geo/crs/EarthCRS.js.map +1 -0
  55. package/dist/esm/geo/crs/SimpleCRS.js +23 -0
  56. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -0
  57. package/dist/esm/geo/projection/Projection.LonLat.js +19 -0
  58. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -0
  59. package/dist/esm/geo/projection/Projection.Mercator.js +33 -0
  60. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -0
  61. package/dist/esm/geo/projection/Projection.SphericalMercator.js +27 -0
  62. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -0
  63. package/dist/esm/geo/projection/index.js +14 -0
  64. package/dist/esm/geo/projection/index.js.map +1 -0
  65. package/dist/esm/geometry/Bounds.js +91 -0
  66. package/dist/esm/geometry/Bounds.js.map +1 -0
  67. package/dist/esm/geometry/LineUtil.js +169 -0
  68. package/dist/esm/geometry/LineUtil.js.map +1 -0
  69. package/dist/esm/geometry/Point.js +119 -0
  70. package/dist/esm/geometry/Point.js.map +1 -0
  71. package/dist/esm/geometry/PolyUtil.js +89 -0
  72. package/dist/esm/geometry/PolyUtil.js.map +1 -0
  73. package/dist/esm/geometry/Transformation.js +34 -0
  74. package/dist/esm/geometry/Transformation.js.map +1 -0
  75. package/dist/esm/layer/BlanketOverlay.js +87 -0
  76. package/dist/esm/layer/BlanketOverlay.js.map +1 -0
  77. package/dist/esm/layer/DivOverlay.js +192 -0
  78. package/dist/esm/layer/DivOverlay.js.map +1 -0
  79. package/dist/esm/layer/FeatureGroup.js +40 -0
  80. package/dist/esm/layer/FeatureGroup.js.map +1 -0
  81. package/dist/esm/layer/GeoJSON.js +192 -0
  82. package/dist/esm/layer/GeoJSON.js.map +1 -0
  83. package/dist/esm/layer/ImageOverlay.js +140 -0
  84. package/dist/esm/layer/ImageOverlay.js.map +1 -0
  85. package/dist/esm/layer/Layer.js +119 -0
  86. package/dist/esm/layer/Layer.js.map +1 -0
  87. package/dist/esm/layer/LayerGroup.js +58 -0
  88. package/dist/esm/layer/LayerGroup.js.map +1 -0
  89. package/dist/esm/layer/Popup.js +224 -0
  90. package/dist/esm/layer/Popup.js.map +1 -0
  91. package/dist/esm/layer/SVGOverlay.js +21 -0
  92. package/dist/esm/layer/SVGOverlay.js.map +1 -0
  93. package/dist/esm/layer/Tooltip.js +228 -0
  94. package/dist/esm/layer/Tooltip.js.map +1 -0
  95. package/dist/esm/layer/VideoOverlay.js +54 -0
  96. package/dist/esm/layer/VideoOverlay.js.map +1 -0
  97. package/dist/esm/layer/marker/DefaultIcon.js +50 -0
  98. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -0
  99. package/dist/esm/layer/marker/DivIcon.js +37 -0
  100. package/dist/esm/layer/marker/DivIcon.js.map +1 -0
  101. package/dist/esm/layer/marker/Icon.js +65 -0
  102. package/dist/esm/layer/marker/Icon.js.map +1 -0
  103. package/dist/esm/layer/marker/Marker.Drag.js +77 -0
  104. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -0
  105. package/dist/esm/layer/marker/Marker.js +235 -0
  106. package/dist/esm/layer/marker/Marker.js.map +1 -0
  107. package/dist/esm/layer/tile/GridLayer.js +447 -0
  108. package/dist/esm/layer/tile/GridLayer.js.map +1 -0
  109. package/dist/esm/layer/tile/TileLayer.js +139 -0
  110. package/dist/esm/layer/tile/TileLayer.js.map +1 -0
  111. package/dist/esm/layer/tile/WMSTileLayer.js +68 -0
  112. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -0
  113. package/dist/esm/layer/vector/Canvas.js +292 -0
  114. package/dist/esm/layer/vector/Canvas.js.map +1 -0
  115. package/dist/esm/layer/vector/Circle.js +35 -0
  116. package/dist/esm/layer/vector/Circle.js.map +1 -0
  117. package/dist/esm/layer/vector/CircleMarker.js +69 -0
  118. package/dist/esm/layer/vector/CircleMarker.js.map +1 -0
  119. package/dist/esm/layer/vector/Path.js +68 -0
  120. package/dist/esm/layer/vector/Path.js.map +1 -0
  121. package/dist/esm/layer/vector/Polygon.js +70 -0
  122. package/dist/esm/layer/vector/Polygon.js.map +1 -0
  123. package/dist/esm/layer/vector/Polyline.js +152 -0
  124. package/dist/esm/layer/vector/Polyline.js.map +1 -0
  125. package/dist/esm/layer/vector/Rectangle.js +25 -0
  126. package/dist/esm/layer/vector/Rectangle.js.map +1 -0
  127. package/dist/esm/layer/vector/Renderer.getRenderer.js +31 -0
  128. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -0
  129. package/dist/esm/layer/vector/Renderer.js +39 -0
  130. package/dist/esm/layer/vector/Renderer.js.map +1 -0
  131. package/dist/esm/layer/vector/SVG.js +115 -0
  132. package/dist/esm/layer/vector/SVG.js.map +1 -0
  133. package/dist/esm/map/Map.js +844 -0
  134. package/dist/esm/map/Map.js.map +1 -0
  135. package/dist/esm/map/handler/BoxZoomHandler.js +105 -0
  136. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -0
  137. package/dist/esm/map/handler/DoubleClickZoomHandler.js +27 -0
  138. package/dist/esm/map/handler/DoubleClickZoomHandler.js.map +1 -0
  139. package/dist/esm/map/handler/DragHandler.js +133 -0
  140. package/dist/esm/map/handler/DragHandler.js.map +1 -0
  141. package/dist/esm/map/handler/KeyboardHandler.js +117 -0
  142. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -0
  143. package/dist/esm/map/handler/PinchZoomHandler.js +96 -0
  144. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -0
  145. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +50 -0
  146. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -0
  147. package/dist/esm/map/handler/TapHoldHandler.js +77 -0
  148. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -0
  149. package/dist/esm/package.js +6 -0
  150. package/dist/esm/package.js.map +1 -0
  151. package/dist/images/layers.svg +1 -0
  152. package/dist/images/logo.svg +1 -0
  153. package/dist/images/marker-icon.svg +1 -0
  154. package/dist/images/marker-shadow.svg +1 -0
  155. package/dist/maplair-global-src.js +6810 -0
  156. package/dist/maplair-global-src.js.map +1 -0
  157. package/dist/maplair-global.js +12 -0
  158. package/dist/maplair-global.js.map +1 -0
  159. package/dist/maplair-src.js +6704 -0
  160. package/dist/maplair-src.js.map +1 -0
  161. package/dist/maplair.css +730 -0
  162. package/dist/maplair.js +7 -0
  163. package/dist/maplair.js.map +1 -0
  164. package/i18n/cs.json +12 -0
  165. package/i18n/de.json +12 -0
  166. package/i18n/en.json +12 -0
  167. package/i18n/es.json +12 -0
  168. package/i18n/fr.json +12 -0
  169. package/i18n/hu.json +12 -0
  170. package/i18n/it.json +12 -0
  171. package/i18n/rm.json +12 -0
  172. package/i18n/sk.json +12 -0
  173. package/i18n/sl.json +12 -0
  174. package/package.json +87 -0
  175. package/src/Maplair.js +24 -0
  176. package/src/control/AttributionControl.js +147 -0
  177. package/src/control/Control.js +174 -0
  178. package/src/control/LayersControl.js +444 -0
  179. package/src/control/ScaleControl.js +141 -0
  180. package/src/control/ZoomControl.js +147 -0
  181. package/src/control/index.js +5 -0
  182. package/src/core/Browser.js +75 -0
  183. package/src/core/Class.js +97 -0
  184. package/src/core/Events.js +334 -0
  185. package/src/core/Handler.js +59 -0
  186. package/src/core/I18n.js +76 -0
  187. package/src/core/Util.js +122 -0
  188. package/src/core/index.js +8 -0
  189. package/src/dom/DomEvent.DoubleTap.js +120 -0
  190. package/src/dom/DomEvent.PointerEvents.js +75 -0
  191. package/src/dom/DomEvent.js +282 -0
  192. package/src/dom/DomUtil.js +175 -0
  193. package/src/dom/Draggable.js +204 -0
  194. package/src/dom/PosAnimation.js +115 -0
  195. package/src/dom/index.js +9 -0
  196. package/src/geo/LatLng.js +163 -0
  197. package/src/geo/LatLngBounds.js +260 -0
  198. package/src/geo/crs/CRS.js +143 -0
  199. package/src/geo/crs/EPSG3395.js +19 -0
  200. package/src/geo/crs/EPSG3857.js +26 -0
  201. package/src/geo/crs/EPSG4326.js +21 -0
  202. package/src/geo/crs/EarthCRS.js +32 -0
  203. package/src/geo/crs/SimpleCRS.js +35 -0
  204. package/src/geo/crs/index.js +6 -0
  205. package/src/geo/index.js +7 -0
  206. package/src/geo/projection/Projection.LonLat.js +30 -0
  207. package/src/geo/projection/Projection.Mercator.js +53 -0
  208. package/src/geo/projection/Projection.SphericalMercator.js +46 -0
  209. package/src/geo/projection/index.js +26 -0
  210. package/src/geometry/Bounds.js +222 -0
  211. package/src/geometry/LineUtil.js +299 -0
  212. package/src/geometry/Point.js +239 -0
  213. package/src/geometry/PolyUtil.js +129 -0
  214. package/src/geometry/Transformation.js +67 -0
  215. package/src/geometry/index.js +8 -0
  216. package/src/images/layers.svg +1 -0
  217. package/src/images/logo.svg +1 -0
  218. package/src/images/marker-icon.svg +1 -0
  219. package/src/images/marker-shadow.svg +1 -0
  220. package/src/layer/BlanketOverlay.js +171 -0
  221. package/src/layer/DivOverlay.js +353 -0
  222. package/src/layer/FeatureGroup.js +93 -0
  223. package/src/layer/GeoJSON.js +432 -0
  224. package/src/layer/ImageOverlay.js +279 -0
  225. package/src/layer/Layer.js +273 -0
  226. package/src/layer/LayerGroup.js +129 -0
  227. package/src/layer/Popup.js +528 -0
  228. package/src/layer/SVGOverlay.js +47 -0
  229. package/src/layer/Tooltip.js +469 -0
  230. package/src/layer/VideoOverlay.js +111 -0
  231. package/src/layer/index.js +18 -0
  232. package/src/layer/marker/DefaultIcon.js +79 -0
  233. package/src/layer/marker/DivIcon.js +76 -0
  234. package/src/layer/marker/Icon.js +164 -0
  235. package/src/layer/marker/Marker.Drag.js +161 -0
  236. package/src/layer/marker/Marker.js +465 -0
  237. package/src/layer/marker/index.js +5 -0
  238. package/src/layer/tile/GridLayer.js +901 -0
  239. package/src/layer/tile/TileLayer.js +299 -0
  240. package/src/layer/tile/WMSTileLayer.js +133 -0
  241. package/src/layer/tile/index.js +3 -0
  242. package/src/layer/vector/Canvas.js +479 -0
  243. package/src/layer/vector/Circle.js +87 -0
  244. package/src/layer/vector/CircleMarker.js +110 -0
  245. package/src/layer/vector/Path.js +145 -0
  246. package/src/layer/vector/Polygon.js +160 -0
  247. package/src/layer/vector/Polyline.js +296 -0
  248. package/src/layer/vector/Rectangle.js +52 -0
  249. package/src/layer/vector/Renderer.getRenderer.js +48 -0
  250. package/src/layer/vector/Renderer.js +75 -0
  251. package/src/layer/vector/SVG.js +216 -0
  252. package/src/layer/vector/index.js +10 -0
  253. package/src/map/Map.js +1830 -0
  254. package/src/map/handler/BoxZoomHandler.js +156 -0
  255. package/src/map/handler/DoubleClickZoomHandler.js +62 -0
  256. package/src/map/handler/DragHandler.js +240 -0
  257. package/src/map/handler/KeyboardHandler.js +188 -0
  258. package/src/map/handler/PinchZoomHandler.js +157 -0
  259. package/src/map/handler/ScrollWheelZoomHandler.js +98 -0
  260. package/src/map/handler/TapHoldHandler.js +111 -0
  261. package/src/map/index.js +8 -0
  262. package/src/maplair.css +730 -0
@@ -0,0 +1,65 @@
1
+ import { formatNum } from "../core/Util.js";
2
+ import { LatLngBounds } from "./LatLngBounds.js";
3
+ import { EarthCRS } from "./crs/EarthCRS.js";
4
+ //#region src/geo/LatLng.js
5
+ var LatLng = class LatLng {
6
+ constructor(lat, lng, alt) {
7
+ if (!LatLng.validate(lat, lng, alt)) throw new Error(`Invalid LatLng object: (${lat}, ${lng})`);
8
+ let _lat, _lng, _alt;
9
+ if (lat instanceof LatLng) {
10
+ _lat = lat.lat;
11
+ _lng = lat.lng;
12
+ _alt = lat.alt;
13
+ } else if (Array.isArray(lat) && typeof lat[0] !== "object") {
14
+ if (lat.length === 3) {
15
+ _lat = lat[0];
16
+ _lng = lat[1];
17
+ _alt = lat[2];
18
+ } else if (lat.length === 2) {
19
+ _lat = lat[0];
20
+ _lng = lat[1];
21
+ }
22
+ } else if (typeof lat === "object" && "lat" in lat) {
23
+ _lat = lat.lat;
24
+ _lng = "lng" in lat ? lat.lng : lat.lon;
25
+ _alt = lat.alt;
26
+ } else {
27
+ _lat = lat;
28
+ _lng = lng;
29
+ _alt = alt;
30
+ }
31
+ this.lat = +_lat;
32
+ this.lng = +_lng;
33
+ if (_alt !== void 0) this.alt = +_alt;
34
+ }
35
+ static validate(lat, lng, alt) {
36
+ if (lat instanceof LatLng || typeof lat === "object" && lat !== null && "lat" in lat) return true;
37
+ else if (lat && Array.isArray(lat) && typeof lat[0] !== "object") {
38
+ if (lat.length === 3 || lat.length === 2) return true;
39
+ return false;
40
+ } else if ((lat || lat === 0) && (lng || lng === 0)) return true;
41
+ return false;
42
+ }
43
+ equals(obj, maxMargin) {
44
+ if (!obj) return false;
45
+ obj = new LatLng(obj);
46
+ return Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)) <= (maxMargin ?? 1e-9);
47
+ }
48
+ toString(precision) {
49
+ return `LatLng(${formatNum(this.lat, precision)}, ${formatNum(this.lng, precision)})`;
50
+ }
51
+ distanceTo(other) {
52
+ return EarthCRS.distance(this, new LatLng(other));
53
+ }
54
+ wrap() {
55
+ return EarthCRS.wrapLatLng(this);
56
+ }
57
+ toBounds(sizeInMeters) {
58
+ const latAccuracy = 180 * sizeInMeters / 40075017, lngAccuracy = latAccuracy / Math.cos(Math.PI / 180 * this.lat);
59
+ return new LatLngBounds([this.lat - latAccuracy, this.lng - lngAccuracy], [this.lat + latAccuracy, this.lng + lngAccuracy]);
60
+ }
61
+ };
62
+ //#endregion
63
+ export { LatLng };
64
+
65
+ //# sourceMappingURL=LatLng.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LatLng.js","names":["Util.formatNum"],"sources":["../../../src/geo/LatLng.js"],"sourcesContent":["import * as Util from '../core/Util.js';\nimport {EarthCRS} from './crs/EarthCRS.js';\nimport {LatLngBounds} from './LatLngBounds.js';\n\n/* @class LatLng\n *\n * Represents a geographical point with a certain latitude and longitude.\n *\n * @example\n *\n * ```\n * const latlng = new LatLng(50.5, 30.5);\n * ```\n *\n * All Maplair methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:\n *\n * ```\n * map.panTo([50, 30]);\n * map.panTo({lat: 50, lng: 30});\n * map.panTo({lat: 50, lon: 30});\n * map.panTo(new LatLng(50, 30));\n * ```\n *\n * Note that `LatLng` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\n\n// @constructor LatLng(latitude: Number, longitude: Number, altitude?: Number): LatLng\n// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).\n\n// @alternative\n// @constructor LatLng(coords: LatLng)\n// Expects a LatLng object instead.\n\n// @alternative\n// @constructor LatLng(coords: Array): LatLng\n// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.\n\n// @alternative\n// @constructor LatLng(coords: Object): LatLng\n// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.\n// You can also use `lon` in place of `lng` in the object form.\nexport class LatLng {\n\tconstructor(lat, lng, alt) {\n\t\tconst valid = LatLng.validate(lat, lng, alt);\n\t\tif (!valid) {\n\t\t\tthrow new Error(`Invalid LatLng object: (${lat}, ${lng})`);\n\t\t}\n\n\t\tlet _lat, _lng, _alt;\n\t\tif (lat instanceof LatLng) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = lat.lng;\n\t\t\t_alt = lat.alt;\n\t\t} else if (Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t\t_alt = lat[2];\n\t\t\t} else if (lat.length === 2) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t}\n\t\t} else if (typeof lat === 'object' && 'lat' in lat) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = 'lng' in lat ? lat.lng : lat.lon;\n\t\t\t_alt = lat.alt;\n\t\t} else {\n\t\t\t_lat = lat;\n\t\t\t_lng = lng;\n\t\t\t_alt = alt;\n\t\t}\n\n\t\t// @property lat: Number\n\t\t// Latitude in degrees\n\t\tthis.lat = +_lat;\n\n\t\t// @property lng: Number\n\t\t// Longitude in degrees\n\t\tthis.lng = +_lng;\n\n\t\t// @property alt: Number\n\t\t// Altitude in meters (optional)\n\t\tif (_alt !== undefined) {\n\t\t\tthis.alt = +_alt;\n\t\t}\n\t}\n\n\t// @section\n\t// There are several static functions which can be called without instantiating LatLng:\n\n\t// @function validate(latitude: Number, longitude: Number, altitude?: Number): Boolean\n\t// Returns `true` if the LatLng object can be properly initialized.\n\n\t// @alternative\n\t// @function validate(coords: Array): Boolean\n\t// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]`.\n\t// Returns `true` if the LatLng object can be properly initialized.\n\n\t// @alternative\n\t// @function validate(coords: Object): Boolean\n\t// Returns `true` if the LatLng object can be properly initialized.\n\n\t// eslint-disable-next-line no-unused-vars\n\tstatic validate(lat, lng, alt) {\n\t\tif (lat instanceof LatLng || (typeof lat === 'object' && lat !== null && 'lat' in lat)) {\n\t\t\treturn true;\n\t\t} else if (lat && Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3 || lat.length === 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if ((lat || lat === 0) && (lng || lng === 0)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t// @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean\n\t// Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number.\n\tequals(obj, maxMargin) {\n\t\tif (!obj) { return false; }\n\n\t\tobj = new LatLng(obj);\n\n\t\tconst margin = Math.max(\n\t\t\tMath.abs(this.lat - obj.lat),\n\t\t\tMath.abs(this.lng - obj.lng));\n\n\t\treturn margin <= (maxMargin ?? 1.0E-9);\n\t}\n\n\t// @method toString(precision?: Number): String\n\t// Returns a string representation of the point (for debugging purposes).\n\ttoString(precision) {\n\t\treturn `LatLng(${Util.formatNum(this.lat, precision)}, ${Util.formatNum(this.lng, precision)})`;\n\t}\n\n\t// @method distanceTo(otherLatLng: LatLng): Number\n\t// Returns the distance (in meters) to the given `LatLng` calculated using the [Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula).\n\tdistanceTo(other) {\n\t\treturn EarthCRS.distance(this, new LatLng(other));\n\t}\n\n\t// @method wrap(): LatLng\n\t// Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.\n\twrap() {\n\t\treturn EarthCRS.wrapLatLng(this);\n\t}\n\n\t// @method toBounds(sizeInMeters: Number): LatLngBounds\n\t// Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.\n\ttoBounds(sizeInMeters) {\n\t\tconst latAccuracy = 180 * sizeInMeters / 40075017,\n\t\tlngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\n\n\t\treturn new LatLngBounds(\n\t\t\t[this.lat - latAccuracy, this.lng - lngAccuracy],\n\t\t\t[this.lat + latAccuracy, this.lng + lngAccuracy]);\n\t}\n\n};\n"],"mappings":";;;;AA2CA,IAAa,SAAb,MAAa,OAAO;CACnB,YAAY,KAAK,KAAK,KAAK;EAE1B,IAAI,CADU,OAAO,SAAS,KAAK,KAAK,GAC/B,GACR,MAAM,IAAI,MAAM,2BAA2B,IAAI,IAAI,IAAI,EAAE;EAG1D,IAAI,MAAM,MAAM;EAChB,IAAI,eAAe,QAAQ;GAC1B,OAAO,IAAI;GACX,OAAO,IAAI;GACX,OAAO,IAAI;EACZ,OAAO,IAAI,MAAM,QAAQ,GAAG,KAAK,OAAO,IAAI,OAAO,UAAU;GAC5D,IAAI,IAAI,WAAW,GAAG;IACrB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,OAAO,IAAI;GACZ,OAAO,IAAI,IAAI,WAAW,GAAG;IAC5B,OAAO,IAAI;IACX,OAAO,IAAI;GACZ;EACD,OAAO,IAAI,OAAO,QAAQ,YAAY,SAAS,KAAK;GACnD,OAAO,IAAI;GACX,OAAO,SAAS,MAAM,IAAI,MAAM,IAAI;GACpC,OAAO,IAAI;EACZ,OAAO;GACN,OAAO;GACP,OAAO;GACP,OAAO;EACR;EAIA,KAAK,MAAM,CAAC;EAIZ,KAAK,MAAM,CAAC;EAIZ,IAAI,SAAS,KAAA,GACZ,KAAK,MAAM,CAAC;CAEd;CAkBA,OAAO,SAAS,KAAK,KAAK,KAAK;EAC9B,IAAI,eAAe,UAAW,OAAO,QAAQ,YAAY,QAAQ,QAAQ,SAAS,KACjF,OAAO;OACD,IAAI,OAAO,MAAM,QAAQ,GAAG,KAAK,OAAO,IAAI,OAAO,UAAU;GACnE,IAAI,IAAI,WAAW,KAAK,IAAI,WAAW,GACtC,OAAO;GAER,OAAO;EACR,OAAO,KAAK,OAAO,QAAQ,OAAO,OAAO,QAAQ,IAChD,OAAO;EAER,OAAO;CACR;CAIA,OAAO,KAAK,WAAW;EACtB,IAAI,CAAC,KAAO,OAAO;EAEnB,MAAM,IAAI,OAAO,GAAG;EAMpB,OAJe,KAAK,IACnB,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,GAC3B,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAEhB,MAAM,aAAa;CAChC;CAIA,SAAS,WAAW;EACnB,OAAO,UAAUA,UAAe,KAAK,KAAK,SAAS,EAAE,IAAIA,UAAe,KAAK,KAAK,SAAS,EAAE;CAC9F;CAIA,WAAW,OAAO;EACjB,OAAO,SAAS,SAAS,MAAM,IAAI,OAAO,KAAK,CAAC;CACjD;CAIA,OAAO;EACN,OAAO,SAAS,WAAW,IAAI;CAChC;CAIA,SAAS,cAAc;EACtB,MAAM,cAAc,MAAM,eAAe,UACzC,cAAc,cAAc,KAAK,IAAK,KAAK,KAAK,MAAO,KAAK,GAAG;EAE/D,OAAO,IAAI,aACV,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,GAC/C,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,CAAC;CAClD;AAED"}
@@ -0,0 +1,114 @@
1
+ import { LatLng } from "./LatLng.js";
2
+ //#region src/geo/LatLngBounds.js
3
+ var LatLngBounds = class LatLngBounds {
4
+ constructor(corner1, corner2) {
5
+ if (!corner1) return;
6
+ if (corner1 instanceof LatLngBounds) {
7
+ if (corner1.isValid()) {
8
+ this._southWest = new LatLng(corner1._southWest);
9
+ this._northEast = new LatLng(corner1._northEast);
10
+ }
11
+ return;
12
+ }
13
+ const latlngs = corner2 ? [corner1, corner2] : corner1;
14
+ for (const latlng of latlngs) this.extend(latlng);
15
+ }
16
+ extend(obj) {
17
+ const sw = this._southWest, ne = this._northEast;
18
+ let sw2, ne2;
19
+ if (obj instanceof LatLng) {
20
+ sw2 = obj;
21
+ ne2 = obj;
22
+ } else if (obj instanceof LatLngBounds) {
23
+ sw2 = obj._southWest;
24
+ ne2 = obj._northEast;
25
+ if (!sw2 || !ne2) return this;
26
+ } else {
27
+ if (!obj) return this;
28
+ if (LatLng.validate(obj)) return this.extend(new LatLng(obj));
29
+ return this.extend(new LatLngBounds(obj));
30
+ }
31
+ if (!sw && !ne) {
32
+ this._southWest = new LatLng(sw2.lat, sw2.lng);
33
+ this._northEast = new LatLng(ne2.lat, ne2.lng);
34
+ } else {
35
+ sw.lat = Math.min(sw2.lat, sw.lat);
36
+ sw.lng = Math.min(sw2.lng, sw.lng);
37
+ ne.lat = Math.max(ne2.lat, ne.lat);
38
+ ne.lng = Math.max(ne2.lng, ne.lng);
39
+ }
40
+ return this;
41
+ }
42
+ pad(bufferRatio) {
43
+ const sw = this._southWest, ne = this._northEast, heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
44
+ return new LatLngBounds(new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
45
+ }
46
+ getCenter() {
47
+ return new LatLng((this._southWest.lat + this._northEast.lat) / 2, (this._southWest.lng + this._northEast.lng) / 2);
48
+ }
49
+ getSouthWest() {
50
+ return this._southWest;
51
+ }
52
+ getNorthEast() {
53
+ return this._northEast;
54
+ }
55
+ getNorthWest() {
56
+ return new LatLng(this.getNorth(), this.getWest());
57
+ }
58
+ getSouthEast() {
59
+ return new LatLng(this.getSouth(), this.getEast());
60
+ }
61
+ getWest() {
62
+ return this._southWest.lng;
63
+ }
64
+ getSouth() {
65
+ return this._southWest.lat;
66
+ }
67
+ getEast() {
68
+ return this._northEast.lng;
69
+ }
70
+ getNorth() {
71
+ return this._northEast.lat;
72
+ }
73
+ contains(obj) {
74
+ if (LatLng.validate(obj)) obj = new LatLng(obj);
75
+ else obj = new LatLngBounds(obj);
76
+ const sw = this._southWest, ne = this._northEast;
77
+ let sw2, ne2;
78
+ if (obj instanceof LatLngBounds) {
79
+ sw2 = obj.getSouthWest();
80
+ ne2 = obj.getNorthEast();
81
+ } else sw2 = ne2 = obj;
82
+ return sw2.lat >= sw.lat && ne2.lat <= ne.lat && sw2.lng >= sw.lng && ne2.lng <= ne.lng;
83
+ }
84
+ intersects(bounds) {
85
+ bounds = new LatLngBounds(bounds);
86
+ const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latIntersects = ne2.lat >= sw.lat && sw2.lat <= ne.lat, lngIntersects = ne2.lng >= sw.lng && sw2.lng <= ne.lng;
87
+ return latIntersects && lngIntersects;
88
+ }
89
+ overlaps(bounds) {
90
+ bounds = new LatLngBounds(bounds);
91
+ const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = ne2.lat > sw.lat && sw2.lat < ne.lat, lngOverlaps = ne2.lng > sw.lng && sw2.lng < ne.lng;
92
+ return latOverlaps && lngOverlaps;
93
+ }
94
+ toBBoxString() {
95
+ return [
96
+ this.getWest(),
97
+ this.getSouth(),
98
+ this.getEast(),
99
+ this.getNorth()
100
+ ].join(",");
101
+ }
102
+ equals(bounds, maxMargin) {
103
+ if (!bounds) return false;
104
+ bounds = new LatLngBounds(bounds);
105
+ return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin);
106
+ }
107
+ isValid() {
108
+ return !!(this._southWest && this._northEast);
109
+ }
110
+ };
111
+ //#endregion
112
+ export { LatLngBounds };
113
+
114
+ //# sourceMappingURL=LatLngBounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n\n/*\n * @class LatLngBounds\n *\n * Represents a rectangular geographical area on a map.\n *\n * @example\n *\n * ```js\n * const corner1 = new LatLng(40.712, -74.227),\n * corner2 = new LatLng(40.774, -74.125),\n * bounds = new LatLngBounds(corner1, corner2);\n * ```\n *\n * All Maplair methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\n *\n * ```js\n * map.fitBounds([\n * \t[40.712, -74.227],\n * \t[40.774, -74.125]\n * ]);\n * ```\n *\n * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\n *\n * Note that `LatLngBounds` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\n\n// TODO International date line?\n\n// @constructor LatLngBounds(corner1: LatLng, corner2: LatLng)\n// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.\n\n// @alternative\n// @constructor LatLngBounds(latlngs: LatLng[])\n// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).\n\n// @alternative\n// @constructor LatLngBounds(bounds: LatLngBounds)\n// Creates a copy of the given `LatLngBounds` object.\nexport class LatLngBounds {\n\tconstructor(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\n\t\tif (!corner1) { return; }\n\n\t\tif (corner1 instanceof LatLngBounds) {\n\t\t\tif (corner1.isValid()) {\n\t\t\t\tthis._southWest = new LatLng(corner1._southWest);\n\t\t\t\tthis._northEast = new LatLng(corner1._northEast);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst latlngs = corner2 ? [corner1, corner2] : corner1;\n\n\t\tfor (const latlng of latlngs) {\n\t\t\tthis.extend(latlng);\n\t\t}\n\t}\n\n\t// @method extend(latlng: LatLng): this\n\t// Extend the bounds to contain the given point\n\n\t// @alternative\n\t// @method extend(otherBounds: LatLngBounds): this\n\t// Extend the bounds to contain the given bounds\n\textend(obj) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLng) {\n\t\t\tsw2 = obj;\n\t\t\tne2 = obj;\n\n\t\t} else if (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj._southWest;\n\t\t\tne2 = obj._northEast;\n\n\t\t\tif (!sw2 || !ne2) { return this; }\n\n\t\t} else {\n\t\t\tif (!obj) {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tif (LatLng.validate(obj)) {\n\t\t\t\treturn this.extend(new LatLng(obj));\n\t\t\t}\n\t\t\treturn this.extend(new LatLngBounds(obj));\n\t\t}\n\n\t\tif (!sw && !ne) {\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\n\t\t} else {\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t// @method pad(bufferRatio: Number): LatLngBounds\n\t// Returns bounds created by extending or retracting the current bounds by a given ratio in each direction.\n\t// For example, a ratio of 0.5 extends the bounds by 50% in each direction.\n\t// Negative values will retract the bounds.\n\tpad(bufferRatio) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\theightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\n\t\twidthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\n\n\t\treturn new LatLngBounds(\n\t\t\tnew LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\n\t\t\tnew LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\n\t}\n\n\t// @method getCenter(): LatLng\n\t// Returns the center point of the bounds.\n\tgetCenter() {\n\t\treturn new LatLng(\n\t\t\t(this._southWest.lat + this._northEast.lat) / 2,\n\t\t\t(this._southWest.lng + this._northEast.lng) / 2);\n\t}\n\n\t// @method getSouthWest(): LatLng\n\t// Returns the south-west point of the bounds.\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t// @method getNorthEast(): LatLng\n\t// Returns the north-east point of the bounds.\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t// @method getNorthWest(): LatLng\n\t// Returns the north-west point of the bounds.\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t// @method getSouthEast(): LatLng\n\t// Returns the south-east point of the bounds.\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t// @method getWest(): Number\n\t// Returns the west longitude of the bounds\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t// @method getSouth(): Number\n\t// Returns the south latitude of the bounds\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t// @method getEast(): Number\n\t// Returns the east longitude of the bounds\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t// @method getNorth(): Number\n\t// Returns the north latitude of the bounds\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t// @method contains(otherBounds: LatLngBounds): Boolean\n\t// Returns `true` if the rectangle contains the given one.\n\n\t// @alternative\n\t// @method contains (latlng: LatLng): Boolean\n\t// Returns `true` if the rectangle contains the given point.\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = new LatLng(obj);\n\t\t} else {\n\t\t\tobj = new LatLngBounds(obj);\n\t\t}\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj.getSouthWest();\n\t\t\tne2 = obj.getNorthEast();\n\t\t} else {\n\t\t\tsw2 = ne2 = obj;\n\t\t}\n\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\n\t}\n\n\t// @method intersects(otherBounds: LatLngBounds): Boolean\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.\n\tintersects(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\n\t\tlngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\n\n\t\treturn latIntersects && lngIntersects;\n\t}\n\n\t// @method overlaps(otherBounds: LatLngBounds): Boolean\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.\n\toverlaps(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\n\t\tlngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\n\n\t\treturn latOverlaps && lngOverlaps;\n\t}\n\n\t// @method toBBoxString(): String\n\t// Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t// @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean\n\t// Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number.\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = new LatLngBounds(bounds);\n\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\n\t}\n\n\t// @method isValid(): Boolean\n\t// Returns `true` if the bounds are properly initialized.\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;AA2CA,IAAa,eAAb,MAAa,aAAa;CACzB,YAAY,SAAS,SAAS;EAC7B,IAAI,CAAC,SAAW;EAEhB,IAAI,mBAAmB,cAAc;GACpC,IAAI,QAAQ,QAAQ,GAAG;IACtB,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;IAC/C,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;GAChD;GACA;EACD;EAEA,MAAM,UAAU,UAAU,CAAC,SAAS,OAAO,IAAI;EAE/C,KAAK,MAAM,UAAU,SACpB,KAAK,OAAO,MAAM;CAEpB;CAQA,OAAO,KAAK;EACX,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK;EACV,IAAI,KAAK;EAET,IAAI,eAAe,QAAQ;GAC1B,MAAM;GACN,MAAM;EAEP,OAAO,IAAI,eAAe,cAAc;GACvC,MAAM,IAAI;GACV,MAAM,IAAI;GAEV,IAAI,CAAC,OAAO,CAAC,KAAO,OAAO;EAE5B,OAAO;GACN,IAAI,CAAC,KACJ,OAAO;GAER,IAAI,OAAO,SAAS,GAAG,GACtB,OAAO,KAAK,OAAO,IAAI,OAAO,GAAG,CAAC;GAEnC,OAAO,KAAK,OAAO,IAAI,aAAa,GAAG,CAAC;EACzC;EAEA,IAAI,CAAC,MAAM,CAAC,IAAI;GACf,KAAK,aAAa,IAAI,OAAO,IAAI,KAAK,IAAI,GAAG;GAC7C,KAAK,aAAa,IAAI,OAAO,IAAI,KAAK,IAAI,GAAG;EAC9C,OAAO;GACN,GAAG,MAAM,KAAK,IAAI,IAAI,KAAK,GAAG,GAAG;GACjC,GAAG,MAAM,KAAK,IAAI,IAAI,KAAK,GAAG,GAAG;GACjC,GAAG,MAAM,KAAK,IAAI,IAAI,KAAK,GAAG,GAAG;GACjC,GAAG,MAAM,KAAK,IAAI,IAAI,KAAK,GAAG,GAAG;EAClC;EAEA,OAAO;CACR;CAMA,IAAI,aAAa;EAChB,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK,YACV,eAAe,KAAK,IAAI,GAAG,MAAM,GAAG,GAAG,IAAI,aAC3C,cAAc,KAAK,IAAI,GAAG,MAAM,GAAG,GAAG,IAAI;EAE1C,OAAO,IAAI,aACV,IAAI,OAAO,GAAG,MAAM,cAAc,GAAG,MAAM,WAAW,GACtD,IAAI,OAAO,GAAG,MAAM,cAAc,GAAG,MAAM,WAAW,CAAC;CACzD;CAIA,YAAY;EACX,OAAO,IAAI,QACT,KAAK,WAAW,MAAM,KAAK,WAAW,OAAO,IAC7C,KAAK,WAAW,MAAM,KAAK,WAAW,OAAO,CAAC;CACjD;CAIA,eAAe;EACd,OAAO,KAAK;CACb;CAIA,eAAe;EACd,OAAO,KAAK;CACb;CAIA,eAAe;EACd,OAAO,IAAI,OAAO,KAAK,SAAS,GAAG,KAAK,QAAQ,CAAC;CAClD;CAIA,eAAe;EACd,OAAO,IAAI,OAAO,KAAK,SAAS,GAAG,KAAK,QAAQ,CAAC;CAClD;CAIA,UAAU;EACT,OAAO,KAAK,WAAW;CACxB;CAIA,WAAW;EACV,OAAO,KAAK,WAAW;CACxB;CAIA,UAAU;EACT,OAAO,KAAK,WAAW;CACxB;CAIA,WAAW;EACV,OAAO,KAAK,WAAW;CACxB;CAQA,SAAS,KAAK;EACb,IAAI,OAAO,SAAS,GAAG,GACtB,MAAM,IAAI,OAAO,GAAG;OAEpB,MAAM,IAAI,aAAa,GAAG;EAG3B,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK;EACV,IAAI,KAAK;EAET,IAAI,eAAe,cAAc;GAChC,MAAM,IAAI,aAAa;GACvB,MAAM,IAAI,aAAa;EACxB,OACC,MAAM,MAAM;EAGb,OAAQ,IAAI,OAAO,GAAG,OAAS,IAAI,OAAO,GAAG,OACrC,IAAI,OAAO,GAAG,OAAS,IAAI,OAAO,GAAG;CAC9C;CAIA,WAAW,QAAQ;EAClB,SAAS,IAAI,aAAa,MAAM;EAEhC,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK,YACV,MAAM,OAAO,aAAa,GAC1B,MAAM,OAAO,aAAa,GAE1B,gBAAiB,IAAI,OAAO,GAAG,OAAS,IAAI,OAAO,GAAG,KACtD,gBAAiB,IAAI,OAAO,GAAG,OAAS,IAAI,OAAO,GAAG;EAEtD,OAAO,iBAAiB;CACzB;CAIA,SAAS,QAAQ;EAChB,SAAS,IAAI,aAAa,MAAM;EAEhC,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK,YACV,MAAM,OAAO,aAAa,GAC1B,MAAM,OAAO,aAAa,GAE1B,cAAe,IAAI,MAAM,GAAG,OAAS,IAAI,MAAM,GAAG,KAClD,cAAe,IAAI,MAAM,GAAG,OAAS,IAAI,MAAM,GAAG;EAElD,OAAO,eAAe;CACvB;CAIA,eAAe;EACd,OAAO;GAAC,KAAK,QAAQ;GAAG,KAAK,SAAS;GAAG,KAAK,QAAQ;GAAG,KAAK,SAAS;EAAC,CAAC,CAAC,KAAK,GAAG;CACnF;CAIA,OAAO,QAAQ,WAAW;EACzB,IAAI,CAAC,QAAU,OAAO;EAEtB,SAAS,IAAI,aAAa,MAAM;EAEhC,OAAO,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS,KACvD,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS;CAC/D;CAIA,UAAU;EACT,OAAO,CAAC,EAAE,KAAK,cAAc,KAAK;CACnC;AACD"}
@@ -0,0 +1,51 @@
1
+ import { wrapNum } from "../../core/Util.js";
2
+ import { Bounds } from "../../geometry/Bounds.js";
3
+ import { LatLngBounds } from "../LatLngBounds.js";
4
+ import { LatLng } from "../LatLng.js";
5
+ //#region src/geo/crs/CRS.js
6
+ var CRS = class {
7
+ static projection = void 0;
8
+ static transformation = void 0;
9
+ static latLngToPoint(latlng, zoom) {
10
+ const projectedPoint = this.projection.project(latlng), scale = this.scale(zoom);
11
+ return this.transformation._transform(projectedPoint, scale);
12
+ }
13
+ static pointToLatLng(point, zoom) {
14
+ const scale = this.scale(zoom), untransformedPoint = this.transformation.untransform(point, scale);
15
+ return this.projection.unproject(untransformedPoint);
16
+ }
17
+ static project(latlng) {
18
+ return this.projection.project(latlng);
19
+ }
20
+ static unproject(point) {
21
+ return this.projection.unproject(point);
22
+ }
23
+ static scale(zoom) {
24
+ return 256 * 2 ** zoom;
25
+ }
26
+ static zoom(scale) {
27
+ return Math.log(scale / 256) / Math.LN2;
28
+ }
29
+ static getProjectedBounds(zoom) {
30
+ if (this.infinite) return null;
31
+ const b = this.projection.bounds, s = this.scale(zoom), min = this.transformation.transform(b.min, s), max = this.transformation.transform(b.max, s);
32
+ return new Bounds(min, max);
33
+ }
34
+ static infinite = false;
35
+ static wrapLatLng(latlng) {
36
+ latlng = new LatLng(latlng);
37
+ const lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, alt = latlng.alt;
38
+ return new LatLng(lat, lng, alt);
39
+ }
40
+ static wrapLatLngBounds(bounds) {
41
+ bounds = new LatLngBounds(bounds);
42
+ const center = bounds.getCenter(), newCenter = this.wrapLatLng(center), latShift = center.lat - newCenter.lat, lngShift = center.lng - newCenter.lng;
43
+ if (latShift === 0 && lngShift === 0) return bounds;
44
+ const sw = bounds.getSouthWest(), ne = bounds.getNorthEast(), newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift), newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);
45
+ return new LatLngBounds(newSw, newNe);
46
+ }
47
+ };
48
+ //#endregion
49
+ export { CRS };
50
+
51
+ //# sourceMappingURL=CRS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CRS.js","names":["Util.wrapNum"],"sources":["../../../../src/geo/crs/CRS.js"],"sourcesContent":["\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {LatLng} from '../LatLng.js';\nimport {LatLngBounds} from '../LatLngBounds.js';\nimport * as Util from '../../core/Util.js';\n\n/*\n * @namespace CRS\n * @crs CRS.Base\n * Object that defines coordinate reference systems for projecting\n * geographical points into pixel (screen) coordinates and back (and to\n * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See\n * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).\n *\n * Maplair defines the most usual CRSs by default. If you want to use a\n * CRS not defined by default, take a look at the\n * [Proj4Maplair](https://github.com/kartena/Proj4Leaflet) plugin.\n *\n * Note that the CRS instances do not inherit from Maplair's `Class` object,\n * and can't be instantiated. Also, new classes can't inherit from them,\n * and methods can't be added to them with the `include` function.\n */\n\nexport class CRS {\n\tstatic projection = undefined;\n\tstatic transformation = undefined;\n\n\t// @method latLngToPoint(latlng: LatLng, zoom: Number): Point\n\t// Projects geographical coordinates into pixel coordinates for a given zoom.\n\tstatic latLngToPoint(latlng, zoom) {\n\t\tconst projectedPoint = this.projection.project(latlng),\n\t\tscale = this.scale(zoom);\n\n\t\treturn this.transformation._transform(projectedPoint, scale);\n\t}\n\n\t// @method pointToLatLng(point: Point, zoom: Number): LatLng\n\t// The inverse of `latLngToPoint`. Projects pixel coordinates on a given\n\t// zoom into geographical coordinates.\n\tstatic pointToLatLng(point, zoom) {\n\t\tconst scale = this.scale(zoom),\n\t\tuntransformedPoint = this.transformation.untransform(point, scale);\n\n\t\treturn this.projection.unproject(untransformedPoint);\n\t}\n\n\t// @method project(latlng: LatLng): Point\n\t// Projects geographical coordinates into coordinates in units accepted for\n\t// this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\n\tstatic project(latlng) {\n\t\treturn this.projection.project(latlng);\n\t}\n\n\t// @method unproject(point: Point): LatLng\n\t// Given a projected coordinate returns the corresponding LatLng.\n\t// The inverse of `project`.\n\tstatic unproject(point) {\n\t\treturn this.projection.unproject(point);\n\t}\n\n\t// @method scale(zoom: Number): Number\n\t// Returns the scale used when transforming projected coordinates into\n\t// pixel coordinates for a particular zoom. For example, it returns\n\t// `256 * 2^zoom` for Mercator-based CRS.\n\tstatic scale(zoom) {\n\t\treturn 256 * 2 ** zoom;\n\t}\n\n\t// @method zoom(scale: Number): Number\n\t// Inverse of `scale()`, returns the zoom level corresponding to a scale\n\t// factor of `scale`.\n\tstatic zoom(scale) {\n\t\treturn Math.log(scale / 256) / Math.LN2;\n\t}\n\n\t// @method getProjectedBounds(zoom: Number): Bounds\n\t// Returns the projection's bounds scaled and transformed for the provided `zoom`.\n\tstatic getProjectedBounds(zoom) {\n\t\tif (this.infinite) { return null; }\n\n\t\tconst b = this.projection.bounds,\n\t\ts = this.scale(zoom),\n\t\tmin = this.transformation.transform(b.min, s),\n\t\tmax = this.transformation.transform(b.max, s);\n\n\t\treturn new Bounds(min, max);\n\t}\n\n\t// @method distance(latlng1: LatLng, latlng2: LatLng): Number\n\t// Returns the distance between two geographical coordinates.\n\n\t// @property code: String\n\t// Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)\n\t//\n\t// @property wrapLng: Number[]\n\t// An array of two numbers defining whether the longitude (horizontal) coordinate\n\t// axis wraps around a given range and how. Defaults to `[-180, 180]` in most\n\t// geographical CRSs. If `undefined`, the longitude axis does not wrap around.\n\t//\n\t// @property wrapLat: Number[]\n\t// Like `wrapLng`, but for the latitude (vertical) axis.\n\n\t// wrapLng: [min, max],\n\t// wrapLat: [min, max],\n\n\t// @property infinite: Boolean\n\t// If true, the coordinate space will be unbounded (infinite in both axes)\n\tstatic infinite = false;\n\n\t// @method wrapLatLng(latlng: LatLng): LatLng\n\t// Returns a `LatLng` where lat and lng has been wrapped according to the\n\t// CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\n\tstatic wrapLatLng(latlng) {\n\t\tlatlng = new LatLng(latlng);\n\t\tconst lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\n\t\tlat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\n\t\talt = latlng.alt;\n\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t// @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds\n\t// Returns a `LatLngBounds` with the same size as the given one, ensuring\n\t// that its center is within the CRS's bounds.\n\tstatic wrapLatLngBounds(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\t\tconst center = bounds.getCenter(),\n\t\tnewCenter = this.wrapLatLng(center),\n\t\tlatShift = center.lat - newCenter.lat,\n\t\tlngShift = center.lng - newCenter.lng;\n\n\t\tif (latShift === 0 && lngShift === 0) {\n\t\t\treturn bounds;\n\t\t}\n\n\t\tconst sw = bounds.getSouthWest(),\n\t\tne = bounds.getNorthEast(),\n\t\tnewSw = new LatLng(sw.lat - latShift, sw.lng - lngShift),\n\t\tnewNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);\n\n\t\treturn new LatLngBounds(newSw, newNe);\n\t}\n}\n"],"mappings":";;;;;AAuBA,IAAa,MAAb,MAAiB;CAChB,OAAO,aAAa,KAAA;CACpB,OAAO,iBAAiB,KAAA;CAIxB,OAAO,cAAc,QAAQ,MAAM;EAClC,MAAM,iBAAiB,KAAK,WAAW,QAAQ,MAAM,GACrD,QAAQ,KAAK,MAAM,IAAI;EAEvB,OAAO,KAAK,eAAe,WAAW,gBAAgB,KAAK;CAC5D;CAKA,OAAO,cAAc,OAAO,MAAM;EACjC,MAAM,QAAQ,KAAK,MAAM,IAAI,GAC7B,qBAAqB,KAAK,eAAe,YAAY,OAAO,KAAK;EAEjE,OAAO,KAAK,WAAW,UAAU,kBAAkB;CACpD;CAKA,OAAO,QAAQ,QAAQ;EACtB,OAAO,KAAK,WAAW,QAAQ,MAAM;CACtC;CAKA,OAAO,UAAU,OAAO;EACvB,OAAO,KAAK,WAAW,UAAU,KAAK;CACvC;CAMA,OAAO,MAAM,MAAM;EAClB,OAAO,MAAM,KAAK;CACnB;CAKA,OAAO,KAAK,OAAO;EAClB,OAAO,KAAK,IAAI,QAAQ,GAAG,IAAI,KAAK;CACrC;CAIA,OAAO,mBAAmB,MAAM;EAC/B,IAAI,KAAK,UAAY,OAAO;EAE5B,MAAM,IAAI,KAAK,WAAW,QAC1B,IAAI,KAAK,MAAM,IAAI,GACnB,MAAM,KAAK,eAAe,UAAU,EAAE,KAAK,CAAC,GAC5C,MAAM,KAAK,eAAe,UAAU,EAAE,KAAK,CAAC;EAE5C,OAAO,IAAI,OAAO,KAAK,GAAG;CAC3B;CAqBA,OAAO,WAAW;CAKlB,OAAO,WAAW,QAAQ;EACzB,SAAS,IAAI,OAAO,MAAM;EAC1B,MAAM,MAAM,KAAK,UAAUA,QAAa,OAAO,KAAK,KAAK,SAAS,IAAI,IAAI,OAAO,KACjF,MAAM,KAAK,UAAUA,QAAa,OAAO,KAAK,KAAK,SAAS,IAAI,IAAI,OAAO,KAC3E,MAAM,OAAO;EAEb,OAAO,IAAI,OAAO,KAAK,KAAK,GAAG;CAChC;CAKA,OAAO,iBAAiB,QAAQ;EAC/B,SAAS,IAAI,aAAa,MAAM;EAChC,MAAM,SAAS,OAAO,UAAU,GAChC,YAAY,KAAK,WAAW,MAAM,GAClC,WAAW,OAAO,MAAM,UAAU,KAClC,WAAW,OAAO,MAAM,UAAU;EAElC,IAAI,aAAa,KAAK,aAAa,GAClC,OAAO;EAGR,MAAM,KAAK,OAAO,aAAa,GAC/B,KAAK,OAAO,aAAa,GACzB,QAAQ,IAAI,OAAO,GAAG,MAAM,UAAU,GAAG,MAAM,QAAQ,GACvD,QAAQ,IAAI,OAAO,GAAG,MAAM,UAAU,GAAG,MAAM,QAAQ;EAEvD,OAAO,IAAI,aAAa,OAAO,KAAK;CACrC;AACD"}
@@ -0,0 +1,16 @@
1
+ import { Transformation } from "../../geometry/Transformation.js";
2
+ import { EarthCRS } from "./EarthCRS.js";
3
+ import { Mercator } from "../projection/Projection.Mercator.js";
4
+ //#region src/geo/crs/EPSG3395.js
5
+ var EPSG3395 = class extends EarthCRS {
6
+ static code = "EPSG:3395";
7
+ static projection = Mercator;
8
+ static transformation = (() => {
9
+ const scale = .5 / (Math.PI * Mercator.R);
10
+ return new Transformation(scale, .5, -scale, .5);
11
+ })();
12
+ };
13
+ //#endregion
14
+ export { EPSG3395 };
15
+
16
+ //# sourceMappingURL=EPSG3395.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EPSG3395.js","names":[],"sources":["../../../../src/geo/crs/EPSG3395.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {Mercator} from '../projection/Projection.Mercator.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n\n/*\n * @namespace CRS\n * @crs EPSG3395\n *\n * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.\n */\nexport class EPSG3395 extends EarthCRS {\n\tstatic code = 'EPSG:3395';\n\tstatic projection = Mercator;\n\n\tstatic transformation = (() => {\n\t\tconst scale = 0.5 / (Math.PI * Mercator.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n"],"mappings":";;;;AAUA,IAAa,WAAb,cAA8B,SAAS;CACtC,OAAO,OAAO;CACd,OAAO,aAAa;CAEpB,OAAO,wBAAwB;EAC9B,MAAM,QAAQ,MAAO,KAAK,KAAK,SAAS;EACxC,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ"}
@@ -0,0 +1,19 @@
1
+ import { Transformation } from "../../geometry/Transformation.js";
2
+ import { EarthCRS } from "./EarthCRS.js";
3
+ import { SphericalMercator } from "../projection/Projection.SphericalMercator.js";
4
+ //#region src/geo/crs/EPSG3857.js
5
+ var EPSG3857 = class extends EarthCRS {
6
+ static code = "EPSG:3857";
7
+ static projection = SphericalMercator;
8
+ static transformation = (() => {
9
+ const scale = .5 / (Math.PI * SphericalMercator.R);
10
+ return new Transformation(scale, .5, -scale, .5);
11
+ })();
12
+ };
13
+ var EPSG900913 = class extends EPSG3857 {
14
+ static code = "EPSG:900913";
15
+ };
16
+ //#endregion
17
+ export { EPSG3857, EPSG900913 };
18
+
19
+ //# sourceMappingURL=EPSG3857.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EPSG3857.js","names":[],"sources":["../../../../src/geo/crs/EPSG3857.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {SphericalMercator} from '../projection/Projection.SphericalMercator.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n\n/*\n * @namespace CRS\n * @crs EPSG3857\n *\n * The most common CRS for online maps, used by almost all free and commercial\n * tile providers. Uses Spherical Mercator projection. Set in by default in\n * Map's `crs` option.\n */\n\nexport class EPSG3857 extends EarthCRS {\n\tstatic code = 'EPSG:3857';\n\tstatic projection = SphericalMercator;\n\n\tstatic transformation = (() => {\n\t\tconst scale = 0.5 / (Math.PI * SphericalMercator.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n\nexport class EPSG900913 extends EPSG3857 {\n\tstatic code = 'EPSG:900913';\n}\n"],"mappings":";;;;AAaA,IAAa,WAAb,cAA8B,SAAS;CACtC,OAAO,OAAO;CACd,OAAO,aAAa;CAEpB,OAAO,wBAAwB;EAC9B,MAAM,QAAQ,MAAO,KAAK,KAAK,kBAAkB;EACjD,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ;AAEA,IAAa,aAAb,cAAgC,SAAS;CACxC,OAAO,OAAO;AACf"}
@@ -0,0 +1,13 @@
1
+ import { Transformation } from "../../geometry/Transformation.js";
2
+ import { EarthCRS } from "./EarthCRS.js";
3
+ import { LonLat } from "../projection/Projection.LonLat.js";
4
+ //#region src/geo/crs/EPSG4326.js
5
+ var EPSG4326 = class extends EarthCRS {
6
+ static code = "EPSG:4326";
7
+ static projection = LonLat;
8
+ static transformation = new Transformation(1 / 180, 1, -1 / 180, .5);
9
+ };
10
+ //#endregion
11
+ export { EPSG4326 };
12
+
13
+ //# sourceMappingURL=EPSG4326.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EPSG4326.js","names":[],"sources":["../../../../src/geo/crs/EPSG4326.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {LonLat} from '../projection/Projection.LonLat.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n\n/*\n * @namespace CRS\n * @crs EPSG4326\n *\n * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.\n *\n * Maplair complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic).\n * If you are using a `TileLayer` with this CRS, ensure that there are two 256x256 pixel tiles covering the\n * whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),\n * or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.\n */\n\nexport class EPSG4326 extends EarthCRS {\n\tstatic code = 'EPSG:4326';\n\tstatic projection = LonLat;\n\tstatic transformation = new Transformation(1 / 180, 1, -1 / 180, 0.5);\n}\n"],"mappings":";;;;AAgBA,IAAa,WAAb,cAA8B,SAAS;CACtC,OAAO,OAAO;CACd,OAAO,aAAa;CACpB,OAAO,iBAAiB,IAAI,eAAe,IAAI,KAAK,GAAG,KAAK,KAAK,EAAG;AACrE"}
@@ -0,0 +1,14 @@
1
+ import { CRS } from "./CRS.js";
2
+ //#region src/geo/crs/EarthCRS.js
3
+ var EarthCRS = class extends CRS {
4
+ static wrapLng = [-180, 180];
5
+ static R = 6371e3;
6
+ static distance(latlng1, latlng2) {
7
+ const rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon, c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
8
+ return this.R * c;
9
+ }
10
+ };
11
+ //#endregion
12
+ export { EarthCRS };
13
+
14
+ //# sourceMappingURL=EarthCRS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EarthCRS.js","names":[],"sources":["../../../../src/geo/crs/EarthCRS.js"],"sourcesContent":["import {CRS} from './CRS.js';\n\n/*\n * @namespace CRS\n * @crs EarthCRS\n *\n * Serves as the base for CRS that are global such that they cover the earth.\n * Can only be used as the base for other CRS and cannot be used directly,\n * since it does not have a `code`, `projection` or `transformation`. `distance()` returns\n * meters.\n */\n\nexport class EarthCRS extends CRS {\n\tstatic wrapLng = [-180, 180];\n\n\t// Mean Earth Radius, as recommended for use by\n\t// the International Union of Geodesy and Geophysics,\n\t// see https://rosettacode.org/wiki/Haversine_formula\n\tstatic R = 6371000;\n\n\t// distance between two geographical points using Haversine approximation\n\tstatic distance(latlng1, latlng2) {\n\t\tconst rad = Math.PI / 180,\n\t\tlat1 = latlng1.lat * rad,\n\t\tlat2 = latlng2.lat * rad,\n\t\tsinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),\n\t\tsinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),\n\t\ta = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,\n\t\tc = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\t\treturn this.R * c;\n\t}\n}\n"],"mappings":";;AAYA,IAAa,WAAb,cAA8B,IAAI;CACjC,OAAO,UAAU,CAAC,MAAM,GAAG;CAK3B,OAAO,IAAI;CAGX,OAAO,SAAS,SAAS,SAAS;EACjC,MAAM,MAAM,KAAK,KAAK,KACtB,OAAO,QAAQ,MAAM,KACrB,OAAO,QAAQ,MAAM,KACrB,UAAU,KAAK,KAAK,QAAQ,MAAM,QAAQ,OAAO,MAAM,CAAC,GACxD,UAAU,KAAK,KAAK,QAAQ,MAAM,QAAQ,OAAO,MAAM,CAAC,GACxD,IAAI,UAAU,UAAU,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,UAAU,SACpE,IAAI,IAAI,KAAK,MAAM,KAAK,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC;EACjD,OAAO,KAAK,IAAI;CACjB;AACD"}
@@ -0,0 +1,23 @@
1
+ import { Transformation } from "../../geometry/Transformation.js";
2
+ import { CRS } from "./CRS.js";
3
+ import { LonLat } from "../projection/Projection.LonLat.js";
4
+ //#region src/geo/crs/SimpleCRS.js
5
+ var SimpleCRS = class extends CRS {
6
+ static projection = LonLat;
7
+ static transformation = new Transformation(1, 0, -1, 0);
8
+ static scale(zoom) {
9
+ return 2 ** zoom;
10
+ }
11
+ static zoom(scale) {
12
+ return Math.log(scale) / Math.LN2;
13
+ }
14
+ static distance(latlng1, latlng2) {
15
+ const dx = latlng2.lng - latlng1.lng, dy = latlng2.lat - latlng1.lat;
16
+ return Math.sqrt(dx * dx + dy * dy);
17
+ }
18
+ static infinite = true;
19
+ };
20
+ //#endregion
21
+ export { SimpleCRS };
22
+
23
+ //# sourceMappingURL=SimpleCRS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleCRS.js","names":[],"sources":["../../../../src/geo/crs/SimpleCRS.js"],"sourcesContent":["import {CRS} from './CRS.js';\nimport {LonLat} from '../projection/Projection.LonLat.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n\n/*\n * @namespace CRS\n * @crs SimpleCRS\n *\n * A simple CRS that maps longitude and latitude into `x` and `y` directly.\n * May be used for maps of flat surfaces (e.g. game maps). Note that the `y`\n * axis should still be inverted (going from bottom to top). `distance()` returns\n * simple euclidean distance.\n */\n\nexport class SimpleCRS extends CRS {\n\tstatic projection = LonLat;\n\tstatic transformation = new Transformation(1, 0, -1, 0);\n\n\tstatic scale(zoom) {\n\t\treturn 2 ** zoom;\n\t}\n\n\tstatic zoom(scale) {\n\t\treturn Math.log(scale) / Math.LN2;\n\t}\n\n\tstatic distance(latlng1, latlng2) {\n\t\tconst dx = latlng2.lng - latlng1.lng,\n\t\tdy = latlng2.lat - latlng1.lat;\n\n\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t}\n\n\tstatic infinite = true;\n}\n"],"mappings":";;;;AAcA,IAAa,YAAb,cAA+B,IAAI;CAClC,OAAO,aAAa;CACpB,OAAO,iBAAiB,IAAI,eAAe,GAAG,GAAG,IAAI,CAAC;CAEtD,OAAO,MAAM,MAAM;EAClB,OAAO,KAAK;CACb;CAEA,OAAO,KAAK,OAAO;EAClB,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK;CAC/B;CAEA,OAAO,SAAS,SAAS,SAAS;EACjC,MAAM,KAAK,QAAQ,MAAM,QAAQ,KACjC,KAAK,QAAQ,MAAM,QAAQ;EAE3B,OAAO,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE;CACnC;CAEA,OAAO,WAAW;AACnB"}
@@ -0,0 +1,19 @@
1
+ import { Point } from "../../geometry/Point.js";
2
+ import { Bounds } from "../../geometry/Bounds.js";
3
+ import { LatLng } from "../LatLng.js";
4
+ //#region src/geo/projection/Projection.LonLat.js
5
+ const LonLat = {
6
+ project(latlng) {
7
+ latlng = new LatLng(latlng);
8
+ return new Point(latlng.lng, latlng.lat);
9
+ },
10
+ unproject(point) {
11
+ point = new Point(point);
12
+ return new LatLng(point.y, point.x);
13
+ },
14
+ bounds: new Bounds([-180, -90], [180, 90])
15
+ };
16
+ //#endregion
17
+ export { LonLat };
18
+
19
+ //# sourceMappingURL=Projection.LonLat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Projection.LonLat.js","names":[],"sources":["../../../../src/geo/projection/Projection.LonLat.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/*\n * @namespace Projection\n * @section\n * Maplair comes with a set of already defined Projections out of the box:\n *\n * @projection Projection.LonLat\n *\n * Equirectangular, or Plate Carree projection — the most simple projection,\n * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as\n * latitude. Also suitable for flat worlds, e.g. game maps. Used by the\n * `EPSG:4326` and `Simple` CRS.\n */\n\nexport const LonLat = {\n\tproject(latlng) {\n\t\tlatlng = new LatLng(latlng);\n\t\treturn new Point(latlng.lng, latlng.lat);\n\t},\n\n\tunproject(point) {\n\t\tpoint = new Point(point);\n\t\treturn new LatLng(point.y, point.x);\n\t},\n\n\tbounds: new Bounds([-180, -90], [180, 90])\n};\n"],"mappings":";;;;AAiBA,MAAa,SAAS;CACrB,QAAQ,QAAQ;EACf,SAAS,IAAI,OAAO,MAAM;EAC1B,OAAO,IAAI,MAAM,OAAO,KAAK,OAAO,GAAG;CACxC;CAEA,UAAU,OAAO;EAChB,QAAQ,IAAI,MAAM,KAAK;EACvB,OAAO,IAAI,OAAO,MAAM,GAAG,MAAM,CAAC;CACnC;CAEA,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;AAC1C"}
@@ -0,0 +1,33 @@
1
+ import { Point } from "../../geometry/Point.js";
2
+ import { Bounds } from "../../geometry/Bounds.js";
3
+ import { LatLng } from "../LatLng.js";
4
+ const Mercator = {
5
+ R: 6378137,
6
+ R_MINOR: 6356752.314245179,
7
+ bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
8
+ project(latlng) {
9
+ latlng = new LatLng(latlng);
10
+ const d = Math.PI / 180, r = this.R, tmp = this.R_MINOR / r, e = Math.sqrt(1 - tmp * tmp);
11
+ let y = latlng.lat * d;
12
+ const con = e * Math.sin(y);
13
+ const ts = Math.tan(Math.PI / 4 - y / 2) / ((1 - con) / (1 + con)) ** (e / 2);
14
+ y = -r * Math.log(Math.max(ts, 1e-10));
15
+ return new Point(latlng.lng * d * r, y);
16
+ },
17
+ unproject(point) {
18
+ point = new Point(point);
19
+ const d = 180 / Math.PI, r = this.R, tmp = this.R_MINOR / r, e = Math.sqrt(1 - tmp * tmp), ts = Math.exp(-point.y / r);
20
+ let phi = Math.PI / 2 - 2 * Math.atan(ts);
21
+ for (let i = 0, dphi = .1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
22
+ con = e * Math.sin(phi);
23
+ con = ((1 - con) / (1 + con)) ** (e / 2);
24
+ dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;
25
+ phi += dphi;
26
+ }
27
+ return new LatLng(phi * d, point.x * d / r);
28
+ }
29
+ };
30
+ //#endregion
31
+ export { Mercator };
32
+
33
+ //# sourceMappingURL=Projection.Mercator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Projection.Mercator.js","names":[],"sources":["../../../../src/geo/projection/Projection.Mercator.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/*\n * @namespace Projection\n * @projection Projection.Mercator\n *\n * Elliptical Mercator projection — more complex than Spherical Mercator. Assumes that Earth is an ellipsoid. Used by the EPSG:3395 CRS.\n */\n\nconst earthRadius = 6378137;\n\nexport const Mercator = {\n\tR: earthRadius,\n\tR_MINOR: 6356752.314245179,\n\n\tbounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),\n\n\tproject(latlng) {\n\t\tlatlng = new LatLng(latlng);\n\t\tconst d = Math.PI / 180,\n\t\tr = this.R,\n\t\ttmp = this.R_MINOR / r,\n\t\te = Math.sqrt(1 - tmp * tmp);\n\t\tlet y = latlng.lat * d;\n\t\tconst con = e * Math.sin(y);\n\n\t\tconst ts = Math.tan(Math.PI / 4 - y / 2) / ((1 - con) / (1 + con)) ** (e / 2);\n\t\ty = -r * Math.log(Math.max(ts, 1E-10));\n\n\t\treturn new Point(latlng.lng * d * r, y);\n\t},\n\n\tunproject(point) {\n\t\tpoint = new Point(point);\n\t\tconst d = 180 / Math.PI,\n\t\tr = this.R,\n\t\ttmp = this.R_MINOR / r,\n\t\te = Math.sqrt(1 - tmp * tmp),\n\t\tts = Math.exp(-point.y / r);\n\t\tlet phi = Math.PI / 2 - 2 * Math.atan(ts);\n\n\t\tfor (let i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {\n\t\t\tcon = e * Math.sin(phi);\n\t\t\tcon = ((1 - con) / (1 + con)) ** (e / 2);\n\t\t\tdphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;\n\t\t\tphi += dphi;\n\t\t}\n\n\t\treturn new LatLng(phi * d, point.x * d / r);\n\t}\n};\n"],"mappings":";;;AAaA,MAAa,WAAW;CACvB,GAAG;CACH,SAAS;CAET,QAAQ,IAAI,OAAO,CAAC,iBAAiB,eAAe,GAAG,CAAC,gBAAgB,cAAc,CAAC;CAEvF,QAAQ,QAAQ;EACf,SAAS,IAAI,OAAO,MAAM;EAC1B,MAAM,IAAI,KAAK,KAAK,KACpB,IAAI,KAAK,GACT,MAAM,KAAK,UAAU,GACrB,IAAI,KAAK,KAAK,IAAI,MAAM,GAAG;EAC3B,IAAI,IAAI,OAAO,MAAM;EACrB,MAAM,MAAM,IAAI,KAAK,IAAI,CAAC;EAE1B,MAAM,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,IAAI,UAAU,IAAI;EAC3E,IAAI,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC;EAErC,OAAO,IAAI,MAAM,OAAO,MAAM,IAAI,GAAG,CAAC;CACvC;CAEA,UAAU,OAAO;EAChB,QAAQ,IAAI,MAAM,KAAK;EACvB,MAAM,IAAI,MAAM,KAAK,IACrB,IAAI,KAAK,GACT,MAAM,KAAK,UAAU,GACrB,IAAI,KAAK,KAAK,IAAI,MAAM,GAAG,GAC3B,KAAK,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC;EAC1B,IAAI,MAAM,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;EAExC,KAAK,IAAI,IAAI,GAAG,OAAO,IAAK,KAAK,IAAI,MAAM,KAAK,IAAI,IAAI,IAAI,MAAM,KAAK;GACtE,MAAM,IAAI,KAAK,IAAI,GAAG;GACtB,QAAQ,IAAI,QAAQ,IAAI,UAAU,IAAI;GACtC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,GAAG,IAAI;GAC/C,OAAO;EACR;EAEA,OAAO,IAAI,OAAO,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC;CAC3C;AACD"}
@@ -0,0 +1,27 @@
1
+ import { Point } from "../../geometry/Point.js";
2
+ import { Bounds } from "../../geometry/Bounds.js";
3
+ import { LatLng } from "../LatLng.js";
4
+ //#region src/geo/projection/Projection.SphericalMercator.js
5
+ const earthRadius = 6378137;
6
+ const SphericalMercator = {
7
+ R: earthRadius,
8
+ MAX_LATITUDE: 85.0511287798,
9
+ project(latlng) {
10
+ latlng = new LatLng(latlng);
11
+ const d = Math.PI / 180, max = this.MAX_LATITUDE, lat = Math.max(Math.min(max, latlng.lat), -max), sin = Math.sin(lat * d);
12
+ return new Point(this.R * latlng.lng * d, this.R * Math.log((1 + sin) / (1 - sin)) / 2);
13
+ },
14
+ unproject(point) {
15
+ point = new Point(point);
16
+ const d = 180 / Math.PI;
17
+ return new LatLng((2 * Math.atan(Math.exp(point.y / this.R)) - Math.PI / 2) * d, point.x * d / this.R);
18
+ },
19
+ bounds: (() => {
20
+ const d = earthRadius * Math.PI;
21
+ return new Bounds([-d, -d], [d, d]);
22
+ })()
23
+ };
24
+ //#endregion
25
+ export { SphericalMercator };
26
+
27
+ //# sourceMappingURL=Projection.SphericalMercator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Projection.SphericalMercator.js","names":[],"sources":["../../../../src/geo/projection/Projection.SphericalMercator.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/*\n * @namespace Projection\n * @projection Projection.SphericalMercator\n *\n * Spherical Mercator projection — the most common projection for online maps,\n * used by almost all free and commercial tile providers. Assumes that Earth is\n * a sphere. Used by the `EPSG:3857` CRS.\n */\n\nconst earthRadius = 6378137;\n\nexport const SphericalMercator = {\n\n\tR: earthRadius,\n\tMAX_LATITUDE: 85.0511287798,\n\n\tproject(latlng) {\n\t\tlatlng = new LatLng(latlng);\n\t\tconst d = Math.PI / 180,\n\t\tmax = this.MAX_LATITUDE,\n\t\tlat = Math.max(Math.min(max, latlng.lat), -max),\n\t\tsin = Math.sin(lat * d);\n\n\t\treturn new Point(\n\t\t\tthis.R * latlng.lng * d,\n\t\t\tthis.R * Math.log((1 + sin) / (1 - sin)) / 2);\n\t},\n\n\tunproject(point) {\n\t\tpoint = new Point(point);\n\t\tconst d = 180 / Math.PI;\n\n\t\treturn new LatLng(\n\t\t\t(2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,\n\t\t\tpoint.x * d / this.R);\n\t},\n\n\tbounds: (() => {\n\t\tconst d = earthRadius * Math.PI;\n\t\treturn new Bounds([-d, -d], [d, d]);\n\t})()\n};\n"],"mappings":";;;;AAaA,MAAM,cAAc;AAEpB,MAAa,oBAAoB;CAEhC,GAAG;CACH,cAAc;CAEd,QAAQ,QAAQ;EACf,SAAS,IAAI,OAAO,MAAM;EAC1B,MAAM,IAAI,KAAK,KAAK,KACpB,MAAM,KAAK,cACX,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,OAAO,GAAG,GAAG,CAAC,GAAG,GAC9C,MAAM,KAAK,IAAI,MAAM,CAAC;EAEtB,OAAO,IAAI,MACV,KAAK,IAAI,OAAO,MAAM,GACtB,KAAK,IAAI,KAAK,KAAK,IAAI,QAAQ,IAAI,IAAI,IAAI,CAAC;CAC9C;CAEA,UAAU,OAAO;EAChB,QAAQ,IAAI,MAAM,KAAK;EACvB,MAAM,IAAI,MAAM,KAAK;EAErB,OAAO,IAAI,QACT,IAAI,KAAK,KAAK,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,IAAK,KAAK,KAAK,KAAM,GAC9D,MAAM,IAAI,IAAI,KAAK,CAAC;CACtB;CAEA,eAAe;EACd,MAAM,IAAI,cAAc,KAAK;EAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnC,EAAA,CAAG;AACJ"}
@@ -0,0 +1,14 @@
1
+ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
+ import { LonLat } from "./Projection.LonLat.js";
3
+ import { Mercator } from "./Projection.Mercator.js";
4
+ import { SphericalMercator } from "./Projection.SphericalMercator.js";
5
+ //#region src/geo/projection/index.js
6
+ var projection_exports = /* @__PURE__ */ __exportAll({
7
+ LonLat: () => LonLat,
8
+ Mercator: () => Mercator,
9
+ SphericalMercator: () => SphericalMercator
10
+ });
11
+ //#endregion
12
+ export { LonLat, Mercator, SphericalMercator, projection_exports };
13
+
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/geo/projection/index.js"],"sourcesContent":["/*\n * @class Projection\n\n * An object with methods for projecting geographical coordinates of the world onto\n * a flat surface (and back). See [Map projection](https://en.wikipedia.org/wiki/Map_projection).\n\n * @property bounds: Bounds\n * The bounds (specified in CRS units) where the projection is valid\n\n * @method project(latlng: LatLng): Point\n * Projects geographical coordinates into a 2D point.\n * Only accepts actual `LatLng` instances, not arrays.\n\n * @method unproject(point: Point): LatLng\n * The inverse of `project`. Projects a 2D point into a geographical location.\n * Only accepts actual `Point` instances, not arrays.\n\n * Note that the projection instances do not inherit from Maplair's `Class` object,\n * and can't be instantiated. Also, new classes can't inherit from them,\n * and methods can't be added to them with the `include` function.\n\n */\n\nexport {LonLat} from './Projection.LonLat.js';\nexport {Mercator} from './Projection.Mercator.js';\nexport {SphericalMercator} from './Projection.SphericalMercator.js';\n"],"mappings":""}
@@ -0,0 +1,91 @@
1
+ import { Point } from "./Point.js";
2
+ //#region src/geometry/Bounds.js
3
+ var Bounds = class Bounds {
4
+ constructor(a, b) {
5
+ if (!a) return;
6
+ if (a instanceof Bounds) {
7
+ if (a.isValid()) {
8
+ this.min = new Point(a.min);
9
+ this.max = new Point(a.max);
10
+ }
11
+ return;
12
+ }
13
+ const points = b ? [a, b] : a;
14
+ for (const point of points) this.extend(point);
15
+ }
16
+ extend(obj) {
17
+ let min2, max2;
18
+ if (!obj) return this;
19
+ if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 = new Point(obj);
20
+ else {
21
+ obj = new Bounds(obj);
22
+ min2 = obj.min;
23
+ max2 = obj.max;
24
+ if (!min2 || !max2) return this;
25
+ }
26
+ if (!this.min && !this.max) {
27
+ this.min = new Point(min2);
28
+ this.max = new Point(max2);
29
+ } else {
30
+ this.min.x = Math.min(min2.x, this.min.x);
31
+ this.max.x = Math.max(max2.x, this.max.x);
32
+ this.min.y = Math.min(min2.y, this.min.y);
33
+ this.max.y = Math.max(max2.y, this.max.y);
34
+ }
35
+ return this;
36
+ }
37
+ getCenter(round) {
38
+ return new Point((this.min.x + this.max.x) / 2, (this.min.y + this.max.y) / 2, round);
39
+ }
40
+ getBottomLeft() {
41
+ return new Point(this.min.x, this.max.y);
42
+ }
43
+ getTopRight() {
44
+ return new Point(this.max.x, this.min.y);
45
+ }
46
+ getTopLeft() {
47
+ return this.min;
48
+ }
49
+ getBottomRight() {
50
+ return this.max;
51
+ }
52
+ getSize() {
53
+ return this.max.subtract(this.min);
54
+ }
55
+ contains(obj) {
56
+ let min, max;
57
+ if (typeof obj[0] === "number" || obj instanceof Point) obj = new Point(obj);
58
+ else obj = new Bounds(obj);
59
+ if (obj instanceof Bounds) {
60
+ min = obj.min;
61
+ max = obj.max;
62
+ } else min = max = obj;
63
+ return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
64
+ }
65
+ intersects(bounds) {
66
+ bounds = new Bounds(bounds);
67
+ const min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xIntersects = max2.x >= min.x && min2.x <= max.x, yIntersects = max2.y >= min.y && min2.y <= max.y;
68
+ return xIntersects && yIntersects;
69
+ }
70
+ overlaps(bounds) {
71
+ bounds = new Bounds(bounds);
72
+ const min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps = max2.x > min.x && min2.x < max.x, yOverlaps = max2.y > min.y && min2.y < max.y;
73
+ return xOverlaps && yOverlaps;
74
+ }
75
+ isValid() {
76
+ return !!(this.min && this.max);
77
+ }
78
+ pad(bufferRatio) {
79
+ const min = this.min, max = this.max, heightBuffer = Math.abs(min.x - max.x) * bufferRatio, widthBuffer = Math.abs(min.y - max.y) * bufferRatio;
80
+ return new Bounds(new Point(min.x - heightBuffer, min.y - widthBuffer), new Point(max.x + heightBuffer, max.y + widthBuffer));
81
+ }
82
+ equals(bounds) {
83
+ if (!bounds) return false;
84
+ bounds = new Bounds(bounds);
85
+ return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
86
+ }
87
+ };
88
+ //#endregion
89
+ export { Bounds };
90
+
91
+ //# sourceMappingURL=Bounds.js.map