maplair 4.1.0 → 4.2.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.
- package/CHANGELOG.md +60 -0
- package/dist/esm/Maplair.js +5 -4
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +1 -2
- package/dist/esm/control/ButtonControl.js +1 -2
- package/dist/esm/control/ContextMenu.js +1 -2
- package/dist/esm/control/Control.js +1 -2
- package/dist/esm/control/FullscreenControl.js +1 -2
- package/dist/esm/control/LayersControl.js +27 -31
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +1 -2
- package/dist/esm/control/MiniMapControl.js +1 -2
- package/dist/esm/control/RotateControl.js +1 -2
- package/dist/esm/control/ScaleControl.js +1 -2
- package/dist/esm/control/SearchControl.js +1 -2
- package/dist/esm/control/SideBySideControl.js +1 -2
- package/dist/esm/control/TextControl.js +1 -2
- package/dist/esm/control/TimeControl.js +1 -2
- package/dist/esm/control/ZoomControl.js +18 -29
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +2 -9
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +1 -2
- package/dist/esm/core/Handler.js +10 -3
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +2 -3
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
- package/dist/esm/dom/DomEvent.js +10 -18
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +1 -2
- package/dist/esm/dom/Draggable.js +4 -3
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +1 -2
- package/dist/esm/geo/LatLng.js +1 -2
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +4 -5
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +4 -5
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +3 -4
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +1 -2
- package/dist/esm/geo/crs/SimpleCRS.js +3 -4
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +2 -3
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +17 -25
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +1 -2
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +2 -3
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +8 -10
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +1 -2
- package/dist/esm/layer/HeatLayer.js +2 -3
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +2 -3
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -2
- package/dist/esm/layer/LayerGroup.js +2 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +9 -16
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +1 -2
- package/dist/esm/layer/Tooltip.js +16 -17
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +1 -2
- package/dist/esm/layer/marker/DefaultIcon.js +29 -7
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +1 -2
- package/dist/esm/layer/marker/Icon.js +2 -2
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +43 -4
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +4 -6
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +54 -14
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
- package/dist/esm/layer/marker/SvgIcon.js +1 -2
- package/dist/esm/layer/tile/GridLayer.js +4 -4
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +8 -8
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +7 -14
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +4 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +2 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +1 -2
- package/dist/esm/layer/vector/Polygon.js +2 -3
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
- package/dist/esm/layer/vector/Polyline.js +2 -3
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +7 -4
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +31 -16
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +10 -17
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +1 -2
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +1 -2
- package/dist/esm/map/handler/KeyboardHandler.js +23 -43
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +1 -2
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +487 -613
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +483 -609
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1263
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +3 -8
- package/src/Maplair.all.js +0 -1
- package/src/control/LayersControl.js +39 -52
- package/src/control/ZoomControl.js +17 -31
- package/src/core/Class.js +5 -14
- package/src/core/Handler.js +11 -1
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.js +9 -19
- package/src/dom/Draggable.js +5 -1
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +3 -3
- package/src/geo/crs/EPSG3857.js +3 -3
- package/src/geo/crs/EPSG4326.js +2 -2
- package/src/geo/crs/SimpleCRS.js +2 -2
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +1 -1
- package/src/geometry/PolyUtil.js +23 -31
- package/src/layer/DivOverlay.js +1 -1
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +10 -13
- package/src/layer/HeatLayer.js +1 -1
- package/src/layer/ImageOverlay.js +2 -2
- package/src/layer/LayerGroup.js +1 -1
- package/src/layer/Popup.js +9 -19
- package/src/layer/Tooltip.js +19 -17
- package/src/layer/marker/DefaultIcon.js +33 -5
- package/src/layer/marker/Icon.js +2 -0
- package/src/layer/marker/Marker.Drag.js +53 -5
- package/src/layer/marker/Marker.Move.js +3 -4
- package/src/layer/marker/Marker.js +64 -13
- package/src/layer/tile/GridLayer.js +5 -2
- package/src/layer/tile/TileLayer.js +9 -6
- package/src/layer/tile/WMSTileLayer.js +5 -2
- package/src/layer/vector/Canvas.js +10 -14
- package/src/layer/vector/Circle.js +4 -1
- package/src/layer/vector/CircleMarker.js +2 -1
- package/src/layer/vector/Polygon.js +1 -1
- package/src/layer/vector/Polyline.js +1 -1
- package/src/layer/vector/Renderer.getRenderer.js +4 -3
- package/src/layer/vector/SVG.js +12 -2
- package/src/map/Map.Rotation.js +28 -4
- package/src/map/Map.js +17 -21
- package/src/map/handler/BoxZoomHandler.js +21 -42
- package/src/map/handler/KeyboardHandler.js +34 -53
- package/src/maplair.css +5 -0
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
|
@@ -4,7 +4,7 @@ import { getPointers } from "./DomEvent.PointerEvents.js";
|
|
|
4
4
|
import { off, on } from "./DomEvent.js";
|
|
5
5
|
import { disableImageDrag, enableImageDrag, getPosition, getScale, getSizedParentNode, setPosition } from "./DomUtil.js";
|
|
6
6
|
import { Evented } from "../core/Events.js";
|
|
7
|
-
|
|
7
|
+
// src/dom/Draggable.js
|
|
8
8
|
/** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */
|
|
9
9
|
/**
|
|
10
10
|
* Options of `Draggable`.
|
|
@@ -77,7 +77,8 @@ var Draggable = class Draggable extends Evented {
|
|
|
77
77
|
_onDown(e) {
|
|
78
78
|
this._moved = false;
|
|
79
79
|
if (this._element.classList.contains("maplair-zoom-anim")) return;
|
|
80
|
-
|
|
80
|
+
const pointers = getPointers().length;
|
|
81
|
+
if (pointers > 1) {
|
|
81
82
|
if (Draggable._dragging === this) this.finishDrag();
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
@@ -85,6 +86,7 @@ var Draggable = class Draggable extends Evented {
|
|
|
85
86
|
Draggable._dragging = this;
|
|
86
87
|
disableImageDrag();
|
|
87
88
|
if (this._moving) return;
|
|
89
|
+
if (!pointers && e.isTrusted) e.target.setPointerCapture(e.pointerId);
|
|
88
90
|
this.fire("down");
|
|
89
91
|
const sizedParent = getSizedParentNode(this._element);
|
|
90
92
|
this._startPoint = new Point(e.clientX, e.clientY);
|
|
@@ -154,7 +156,6 @@ var Draggable = class Draggable extends Evented {
|
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
158
|
};
|
|
157
|
-
//#endregion
|
|
158
159
|
export { Draggable };
|
|
159
160
|
|
|
160
161
|
//# sourceMappingURL=Draggable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Draggable.js","names":["PointerEvents.getPointers","DomUtil.getSizedParentNode","DomUtil.getPosition","DomUtil.getScale"],"sources":["../../../src/dom/Draggable.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as DomEvent from './DomEvent.js';\nimport * as DomUtil from './DomUtil.js';\nimport * as Util from '../core/Util.js';\nimport {Point} from '../geometry/Point.js';\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\n/** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */\n\n/**\n * Options of `Draggable`.\n * @typedef {object} DraggableOptions\n * @property {number} [clickTolerance=3] The max number of pixels a user can shift the\n * pointer during a click for it to be considered a valid click (as opposed to a\n * pointer drag).\n */\n\n/**\n * The event object of `dragstart`, `predrag` and `drag` of `Draggable`.\n * @typedef {object} DraggableEvent\n * @property {PointerEvent} originalEvent The DOM event of the pointer which drags.\n * @extends MaplairEvent\n */\n\n/**\n * A class for making DOM elements draggable.\n * Used internally for map and marker dragging. Works on any DOM element.\n *\n * @example\n * ```js\n * const draggable = new Draggable(elementToDrag);\n * draggable.enable();\n * ```\n *\n * @fires down {MaplairEvent} Fired when a drag is about to start.\n * @fires dragstart {DraggableEvent} Fired when a drag starts.\n * @fires predrag {DraggableEvent} Fired continuously during dragging *before* each\n * corresponding update of the element's position.\n * @fires drag {DraggableEvent} Fired continuously during dragging.\n * @fires dragend {DragEndEvent} Fired when the drag ends (with `noInertia: true` if\n * the drag was finished without inertia, e.g. by disabling the draggable).\n */\nexport class Draggable extends Evented {\n\n\tstatic defaultOptions = {\n\t\tclickTolerance: 3\n\t};\n\n\t/**\n\t * Creates a `Draggable` object for moving `element` when you start dragging the\n\t * `dragStartTarget` element (equals `element` itself by default).\n\t * @param {HTMLElement} element\n\t * @param {HTMLElement} [dragStartTarget]\n\t * @param {DraggableOptions} [options]\n\t */\n\tconstructor(element, dragStartTarget, options) {\n\t\tif (typeof options === 'boolean') {\n\t\t\tthrow new Error('Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.');\n\t\t}\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis._element = element;\n\t\tthis._dragStartTarget = dragStartTarget ?? element;\n\n\t\tthis.callInitHooks(Draggable);\n\t}\n\n\t/**\n\t * Enables the dragging ability.\n\t * @returns {void}\n\t */\n\tenable() {\n\t\tif (this._enabled) { return; }\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = true;\n\t}\n\n\t/**\n\t * Disables the dragging ability.\n\t * @returns {void}\n\t */\n\tdisable() {\n\t\tif (!this._enabled) { return; }\n\n\t\t// If we're currently dragging this draggable,\n\t\t// disabling it counts as first ending the drag.\n\t\tif (Draggable._dragging === this) {\n\t\t\tthis.finishDrag(true);\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = false;\n\t\tthis._moved = false;\n\t}\n\n\t_onDown(e) {\n\t\tthis._moved = false;\n\n\t\tif (this._element.classList.contains('maplair-zoom-anim')) { return; }\n\n\t\tif (PointerEvents.getPointers().length !== 1) {\n\t\t\t// Finish dragging to avoid conflict with touchZoom\n\t\t\tif (Draggable._dragging === this) {\n\t\t\t\tthis.finishDrag();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (Draggable._dragging || e.shiftKey || (e.button !== 0 && e.pointerType !== 'touch')) { return; }\n\t\tDraggable._dragging = this; // Prevent dragging multiple objects at once.\n\n\t\tDomUtil.disableImageDrag();\n\n\t\tif (this._moving) { return; }\n\n\t\tthis.fire('down');\n\n\t\tconst sizedParent = DomUtil.getSizedParentNode(this._element);\n\n\t\tthis._startPoint = new Point(e.clientX, e.clientY);\n\t\tthis._startPos = DomUtil.getPosition(this._element);\n\n\t\t// Cache the scale, so that we can continuously compensate for it during drag (_onMove).\n\t\tthis._parentScale = DomUtil.getScale(sizedParent);\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.on(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);\n\t}\n\n\t_onMove(e) {\n\t\tif (PointerEvents.getPointers().length > 1) {\n\t\t\tthis._moved = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);\n\n\t\t// once the drag has started, the pointer must be followed even when it comes back near the start point\n\t\tconst dist = Math.abs(offset.x) + Math.abs(offset.y);\n\t\tif (!this._moved && (!dist || dist < this.options.clickTolerance)) { return; }\n\n\t\t// We assume that the parent container's position, border and scale do not change for the duration of the drag.\n\t\t// Therefore there is no need to account for the position and border (they are eliminated by the subtraction)\n\t\t// and we can use the cached value for the scale.\n\t\toffset.x /= this._parentScale.x;\n\t\toffset.y /= this._parentScale.y;\n\n\t\tif (e.cancelable) {\n\t\t\te.preventDefault();\n\t\t}\n\n\t\tif (!this._moved) {\n\t\t\tthis.fire('dragstart', {originalEvent: e});\n\n\t\t\tthis._moved = true;\n\n\t\t\t// on the map container rather than the body, so that toggling it doesn't restyle the whole page\n\t\t\tthis._draggingContainer = this._element.closest('.maplair-container') ?? this._element;\n\t\t\tthis._draggingContainer.classList.add('maplair-dragging');\n\n\t\t\tthis._lastTarget = e.target;\n\t\t\tthis._lastTarget.classList.add('maplair-drag-target');\n\t\t}\n\n\t\tthis._newPos = this._startPos.add(offset);\n\t\tthis._moving = true;\n\n\t\tthis._lastEvent = e;\n\t\tthis._updatePosition();\n\t}\n\n\t_updatePosition() {\n\t\tconst e = {originalEvent: this._lastEvent};\n\n\t\tthis.fire('predrag', e);\n\n\t\t// pointer events can have fractional coordinates; snap them to device pixels, since an edge in the middle of\n\t\t// one is drawn partly transparent on both sides and shows a seam between tiles\n\t\tconst dpr = window.devicePixelRatio;\n\t\tthis._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);\n\t\tDomUtil.setPosition(this._element, this._newPos);\n\n\t\tthis.fire('drag', e);\n\t}\n\n\t_onUp(e) {\n\t\t// releasing the button outside the window may fire no pointerup, only a lostpointercapture with no buttons;\n\t\t// capture lost while the button is still held (e.g. the pressed element was removed) shouldn't end the drag\n\t\tif (e.type === 'lostpointercapture' && e.buttons) { return; }\n\t\tthis.finishDrag();\n\t}\n\n\t/**\n\t * Ends the current drag.\n\t * @internal\n\t * @param {boolean} [noInertia]\n\t * @returns {void}\n\t */\n\tfinishDrag(noInertia) {\n\t\tthis._draggingContainer?.classList.remove('maplair-dragging');\n\t\tthis._draggingContainer = null;\n\n\t\tif (this._lastTarget) {\n\t\t\tthis._lastTarget.classList.remove('maplair-drag-target');\n\t\t\tthis._lastTarget = null;\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.off(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);\n\n\t\tDomUtil.enableImageDrag();\n\n\t\tconst fireDragend = this._moved && this._moving;\n\n\t\tthis._moving = false;\n\t\tDraggable._dragging = false;\n\n\t\tif (fireDragend) {\n\t\t\tthis.fire('dragend', {\n\t\t\t\tnoInertia,\n\t\t\t\tdistance: this._newPos.distanceTo(this._startPos)\n\t\t\t});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;;;;;;CAQA,WAAW,WAAW;EACrB,KAAK,oBAAoB,UAAU,OAAO,kBAAkB;EAC5D,KAAK,qBAAqB;EAE1B,IAAI,KAAK,aAAa;GACrB,KAAK,YAAY,UAAU,OAAO,qBAAqB;GACvD,KAAK,cAAc;EACpB;EAEA,IAAa,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EACrE,IAAa,KAAK,kBAAkB,8CAA8C,KAAK,OAAO,IAAI;EAElG,gBAAwB;EAExB,MAAM,cAAc,KAAK,UAAU,KAAK;EAExC,KAAK,UAAU;EACf,UAAU,YAAY;EAEtB,IAAI,aACH,KAAK,KAAK,WAAW;GACpB;GACA,UAAU,KAAK,QAAQ,WAAW,KAAK,SAAS;EACjD,CAAC;CAEH;AAED"}
|
|
1
|
+
{"version":3,"file":"Draggable.js","names":["PointerEvents.getPointers","DomUtil.getSizedParentNode","DomUtil.getPosition","DomUtil.getScale"],"sources":["../../../src/dom/Draggable.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as DomEvent from './DomEvent.js';\nimport * as DomUtil from './DomUtil.js';\nimport * as Util from '../core/Util.js';\nimport {Point} from '../geometry/Point.js';\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\n/** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */\n\n/**\n * Options of `Draggable`.\n * @typedef {object} DraggableOptions\n * @property {number} [clickTolerance=3] The max number of pixels a user can shift the\n * pointer during a click for it to be considered a valid click (as opposed to a\n * pointer drag).\n */\n\n/**\n * The event object of `dragstart`, `predrag` and `drag` of `Draggable`.\n * @typedef {object} DraggableEvent\n * @property {PointerEvent} originalEvent The DOM event of the pointer which drags.\n * @extends MaplairEvent\n */\n\n/**\n * A class for making DOM elements draggable.\n * Used internally for map and marker dragging. Works on any DOM element.\n *\n * @example\n * ```js\n * const draggable = new Draggable(elementToDrag);\n * draggable.enable();\n * ```\n *\n * @fires down {MaplairEvent} Fired when a drag is about to start.\n * @fires dragstart {DraggableEvent} Fired when a drag starts.\n * @fires predrag {DraggableEvent} Fired continuously during dragging *before* each\n * corresponding update of the element's position.\n * @fires drag {DraggableEvent} Fired continuously during dragging.\n * @fires dragend {DragEndEvent} Fired when the drag ends (with `noInertia: true` if\n * the drag was finished without inertia, e.g. by disabling the draggable).\n */\nexport class Draggable extends Evented {\n\n\tstatic defaultOptions = {\n\t\tclickTolerance: 3\n\t};\n\n\t/**\n\t * Creates a `Draggable` object for moving `element` when you start dragging the\n\t * `dragStartTarget` element (equals `element` itself by default).\n\t * @param {HTMLElement} element\n\t * @param {HTMLElement} [dragStartTarget]\n\t * @param {DraggableOptions} [options]\n\t */\n\tconstructor(element, dragStartTarget, options) {\n\t\tif (typeof options === 'boolean') {\n\t\t\tthrow new Error('Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.');\n\t\t}\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis._element = element;\n\t\tthis._dragStartTarget = dragStartTarget ?? element;\n\n\t\tthis.callInitHooks(Draggable);\n\t}\n\n\t/**\n\t * Enables the dragging ability.\n\t * @returns {void}\n\t */\n\tenable() {\n\t\tif (this._enabled) { return; }\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = true;\n\t}\n\n\t/**\n\t * Disables the dragging ability.\n\t * @returns {void}\n\t */\n\tdisable() {\n\t\tif (!this._enabled) { return; }\n\n\t\t// If we're currently dragging this draggable,\n\t\t// disabling it counts as first ending the drag.\n\t\tif (Draggable._dragging === this) {\n\t\t\tthis.finishDrag(true);\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = false;\n\t\tthis._moved = false;\n\t}\n\n\t_onDown(e) {\n\t\tthis._moved = false;\n\n\t\tif (this._element.classList.contains('maplair-zoom-anim')) { return; }\n\n\t\tconst pointers = PointerEvents.getPointers().length;\n\t\tif (pointers > 1) {\n\t\t\t// Finish dragging to avoid conflict with touchZoom\n\t\t\tif (Draggable._dragging === this) {\n\t\t\t\tthis.finishDrag();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (Draggable._dragging || e.shiftKey || (e.button !== 0 && e.pointerType !== 'touch')) { return; }\n\t\tDraggable._dragging = this; // Prevent dragging multiple objects at once.\n\n\t\tDomUtil.disableImageDrag();\n\n\t\tif (this._moving) { return; }\n\n\t\t// outside a map, nothing tracks pointers or captures them, so capture this one to keep its moves coming\n\t\tif (!pointers && e.isTrusted) { e.target.setPointerCapture(e.pointerId); }\n\n\t\tthis.fire('down');\n\n\t\tconst sizedParent = DomUtil.getSizedParentNode(this._element);\n\n\t\tthis._startPoint = new Point(e.clientX, e.clientY);\n\t\tthis._startPos = DomUtil.getPosition(this._element);\n\n\t\t// Cache the scale, so that we can continuously compensate for it during drag (_onMove).\n\t\tthis._parentScale = DomUtil.getScale(sizedParent);\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.on(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);\n\t}\n\n\t_onMove(e) {\n\t\tif (PointerEvents.getPointers().length > 1) {\n\t\t\tthis._moved = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);\n\n\t\t// once the drag has started, the pointer must be followed even when it comes back near the start point\n\t\tconst dist = Math.abs(offset.x) + Math.abs(offset.y);\n\t\tif (!this._moved && (!dist || dist < this.options.clickTolerance)) { return; }\n\n\t\t// We assume that the parent container's position, border and scale do not change for the duration of the drag.\n\t\t// Therefore there is no need to account for the position and border (they are eliminated by the subtraction)\n\t\t// and we can use the cached value for the scale.\n\t\toffset.x /= this._parentScale.x;\n\t\toffset.y /= this._parentScale.y;\n\n\t\tif (e.cancelable) {\n\t\t\te.preventDefault();\n\t\t}\n\n\t\tif (!this._moved) {\n\t\t\tthis.fire('dragstart', {originalEvent: e});\n\n\t\t\tthis._moved = true;\n\n\t\t\t// on the map container rather than the body, so that toggling it doesn't restyle the whole page\n\t\t\tthis._draggingContainer = this._element.closest('.maplair-container') ?? this._element;\n\t\t\tthis._draggingContainer.classList.add('maplair-dragging');\n\n\t\t\tthis._lastTarget = e.target;\n\t\t\tthis._lastTarget.classList.add('maplair-drag-target');\n\t\t}\n\n\t\tthis._newPos = this._startPos.add(offset);\n\t\tthis._moving = true;\n\n\t\tthis._lastEvent = e;\n\t\tthis._updatePosition();\n\t}\n\n\t_updatePosition() {\n\t\tconst e = {originalEvent: this._lastEvent};\n\n\t\tthis.fire('predrag', e);\n\n\t\t// pointer events can have fractional coordinates; snap them to device pixels, since an edge in the middle of\n\t\t// one is drawn partly transparent on both sides and shows a seam between tiles\n\t\tconst dpr = window.devicePixelRatio;\n\t\tthis._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);\n\t\tDomUtil.setPosition(this._element, this._newPos);\n\n\t\tthis.fire('drag', e);\n\t}\n\n\t_onUp(e) {\n\t\t// releasing the button outside the window may fire no pointerup, only a lostpointercapture with no buttons;\n\t\t// capture lost while the button is still held (e.g. the pressed element was removed) shouldn't end the drag\n\t\tif (e.type === 'lostpointercapture' && e.buttons) { return; }\n\t\tthis.finishDrag();\n\t}\n\n\t/**\n\t * Ends the current drag.\n\t * @internal\n\t * @param {boolean} [noInertia]\n\t * @returns {void}\n\t */\n\tfinishDrag(noInertia) {\n\t\tthis._draggingContainer?.classList.remove('maplair-dragging');\n\t\tthis._draggingContainer = null;\n\n\t\tif (this._lastTarget) {\n\t\t\tthis._lastTarget.classList.remove('maplair-drag-target');\n\t\t\tthis._lastTarget = null;\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.off(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);\n\n\t\tDomUtil.enableImageDrag();\n\n\t\tconst fireDragend = this._moved && this._moving;\n\n\t\tthis._moving = false;\n\t\tDraggable._dragging = false;\n\n\t\tif (fireDragend)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,CAAC,UAAU,GAAG;EAClE,YAAoB,KAAK,UAAU,KAAK,OAAO;EAE/C,KAAK,KAAK,QAAQ,CAAC;CACpB;CAEA,MAAM,GAAG;EAGR,IAAI,EAAE,SAAS,wBAAwB,EAAE,SAAW;EACpD,KAAK,WAAW;CACjB;;;;;;;CAQA,WAAW,WAAW;EACrB,KAAK,oBAAoB,UAAU,OAAO,kBAAkB;EAC5D,KAAK,qBAAqB;EAE1B,IAAI,KAAK,aAAa;GACrB,KAAK,YAAY,UAAU,OAAO,qBAAqB;GACvD,KAAK,cAAc;EACpB;EAEA,IAAa,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EACrE,IAAa,KAAK,kBAAkB,8CAA8C,KAAK,OAAO,IAAI;EAElG,gBAAwB;EAExB,MAAM,cAAc,KAAK,UAAU,KAAK;EAExC,KAAK,UAAU;EACf,UAAU,YAAY;EAEtB,IAAI,aACH,KAAK,KAAK,WAAW;GACpB;GACA,UAAU,KAAK,QAAQ,WAAW,KAAK,SAAS;EACjD,CAAC;CAEH;AAED"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getPosition, setPosition } from "./DomUtil.js";
|
|
2
2
|
import { Evented } from "../core/Events.js";
|
|
3
|
-
|
|
3
|
+
// src/dom/PosAnimation.js
|
|
4
4
|
/** @import {Point} from '../geometry/Point.js' */
|
|
5
5
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
6
6
|
/**
|
|
@@ -76,7 +76,6 @@ var PosAnimation = class PosAnimation extends Evented {
|
|
|
76
76
|
return 1 - (1 - t) ** this._easeOutPower;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
//#endregion
|
|
80
79
|
export { PosAnimation };
|
|
81
80
|
|
|
82
81
|
//# sourceMappingURL=PosAnimation.js.map
|
package/dist/esm/geo/LatLng.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatNum, wrapNum } from "../core/Util.js";
|
|
2
2
|
import { LatLngBounds } from "./LatLngBounds.js";
|
|
3
|
-
|
|
3
|
+
// src/geo/LatLng.js
|
|
4
4
|
const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
|
|
5
5
|
const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
|
|
6
6
|
const plainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`);
|
|
@@ -220,7 +220,6 @@ function haversineDistance(latlng1, latlng2, R) {
|
|
|
220
220
|
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;
|
|
221
221
|
return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
|
|
222
222
|
}
|
|
223
|
-
//#endregion
|
|
224
223
|
export { LatLng, haversineDistance };
|
|
225
224
|
|
|
226
225
|
//# sourceMappingURL=LatLng.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LatLng } from "./LatLng.js";
|
|
2
|
-
|
|
2
|
+
// src/geo/LatLngBounds.js
|
|
3
3
|
/** @import {LatLngExpression} from './LatLng.js' */
|
|
4
4
|
/**
|
|
5
5
|
* A geographical area: a `LatLngBounds`, or an array of geographical points (usually
|
|
@@ -79,19 +79,14 @@ var LatLngBounds = class LatLngBounds {
|
|
|
79
79
|
extend(obj) {
|
|
80
80
|
const sw = this._southWest, ne = this._northEast;
|
|
81
81
|
let sw2, ne2;
|
|
82
|
-
if (obj instanceof LatLng)
|
|
83
|
-
|
|
84
|
-
ne2 = obj;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!obj) return this;
|
|
91
|
-
if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
|
|
92
|
-
return this.extend(LatLngBounds.from(obj));
|
|
93
|
-
}
|
|
94
|
-
if (!sw && !ne) {
|
|
82
|
+
if (obj instanceof LatLng) sw2 = ne2 = obj;
|
|
83
|
+
else if (obj instanceof LatLngBounds) {
|
|
84
|
+
({_southWest: sw2, _northEast: ne2} = obj);
|
|
85
|
+
if (!sw2) return this;
|
|
86
|
+
} else if (!obj) return this;
|
|
87
|
+
else if (LatLng.validate(obj)) sw2 = ne2 = LatLng.from(obj);
|
|
88
|
+
else return this.extend(LatLngBounds.from(obj));
|
|
89
|
+
if (!sw) {
|
|
95
90
|
this._southWest = new LatLng(sw2.lat, sw2.lng);
|
|
96
91
|
this._northEast = new LatLng(ne2.lat, ne2.lng);
|
|
97
92
|
} else {
|
|
@@ -249,7 +244,6 @@ var LatLngBounds = class LatLngBounds {
|
|
|
249
244
|
return !!(this._southWest && this._northEast);
|
|
250
245
|
}
|
|
251
246
|
};
|
|
252
|
-
//#endregion
|
|
253
247
|
export { LatLngBounds };
|
|
254
248
|
|
|
255
249
|
//# sourceMappingURL=LatLngBounds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n/** @import {LatLngExpression} from './LatLng.js' */\n\n/**\n * A geographical area: a `LatLngBounds`, or an array of geographical points (usually\n * two diagonally opposite corners), e.g. `[[40.712, -74.227], [40.774, -74.125]]`.\n * Accepted by all Maplair methods which accept `LatLngBounds` objects (unless noted\n * otherwise).\n * @typedef {LatLngBounds|LatLngExpression[]} LatLngBoundsExpression\n */\n\n// TODO International date line?\n\n/**\n * Represents a rectangular geographical area on a map.\n *\n * @example\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\n * Array form (unless noted otherwise), so the bounds example above can be passed like\n * 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\n * 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 */\nexport class LatLngBounds {\n\t/**\n\t * Creates a `LatLngBounds` object by defining two diagonally opposite corners of the\n\t * rectangle. Alternatively, creates a `LatLngBounds` object defined by the\n\t * geographical points it contains (very useful for zooming the map to fit a\n\t * particular set of locations with [`fitBounds`](#map-fitbounds)), or a copy of the\n\t * given `LatLngBounds` object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds to copy.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t */\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/**\n\t * Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`\n\t * object created from the given arguments (the same as of the constructor) — unlike\n\t * the constructor, which always creates a new object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t * @returns {LatLngBounds}\n\t */\n\tstatic from(corner1, corner2) {\n\t\treturn corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);\n\t}\n\n\t/**\n\t * Extend the bounds to contain the given point or bounds.\n\t * @param {LatLngExpression|LatLngBoundsExpression} obj\n\t * @returns {this}\n\t */\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(LatLng.from(obj));\n\t\t\t}\n\t\t\treturn this.extend(LatLngBounds.from(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/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {LatLngBounds}\n\t */\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/**\n\t * Returns the center point of the bounds.\n\t * @returns {LatLng}\n\t */\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/**\n\t * Returns the south-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t/**\n\t * Returns the north-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t/**\n\t * Returns the north-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t/**\n\t * Returns the south-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t/**\n\t * Returns the west longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t/**\n\t * Returns the south latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t/**\n\t * Returns the east longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t/**\n\t * Returns the north latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {LatLngBoundsExpression|LatLngExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = LatLng.from(obj);\n\t\t} else {\n\t\t\tobj = LatLngBounds.from(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/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds intersect\n\t * if they have at least one point in common.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) {\n\t\tbounds = LatLngBounds.from(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/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if\n\t * their intersection is an area.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) {\n\t\tbounds = LatLngBounds.from(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/**\n\t * Returns a string with bounding box coordinates in a\n\t * 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for\n\t * sending requests to web services that return geo data.\n\t * @returns {string}\n\t */\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent (within a small margin of error) to\n\t * the given bounds. The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = LatLngBounds.from(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/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,eAAb,MAAa,aAAa;;;;;;;;;;;CAWzB,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;;;;;;;;;;CAWA,OAAO,KAAK,SAAS,SAAS;EAC7B,OAAO,mBAAmB,eAAe,UAAU,IAAI,aAAa,SAAS,OAAO;CACrF;;;;;;CAOA,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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,QAAQ,WAAW;EACzB,IAAI,CAAC,QAAU,OAAO;EAEtB,SAAS,aAAa,KAAK,MAAM;EAEjC,OAAO,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS,KACvD,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS;CAC/D;;;;;CAMA,UAAU;EACT,OAAO,CAAC,EAAE,KAAK,cAAc,KAAK;CACnC;AACD"}
|
|
1
|
+
{"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n/** @import {LatLngExpression} from './LatLng.js' */\n\n/**\n * A geographical area: a `LatLngBounds`, or an array of geographical points (usually\n * two diagonally opposite corners), e.g. `[[40.712, -74.227], [40.774, -74.125]]`.\n * Accepted by all Maplair methods which accept `LatLngBounds` objects (unless noted\n * otherwise).\n * @typedef {LatLngBounds|LatLngExpression[]} LatLngBoundsExpression\n */\n\n// TODO International date line?\n\n/**\n * Represents a rectangular geographical area on a map.\n *\n * @example\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\n * Array form (unless noted otherwise), so the bounds example above can be passed like\n * 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\n * 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 */\nexport class LatLngBounds {\n\t/**\n\t * Creates a `LatLngBounds` object by defining two diagonally opposite corners of the\n\t * rectangle. Alternatively, creates a `LatLngBounds` object defined by the\n\t * geographical points it contains (very useful for zooming the map to fit a\n\t * particular set of locations with [`fitBounds`](#map-fitbounds)), or a copy of the\n\t * given `LatLngBounds` object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds to copy.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t */\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/**\n\t * Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`\n\t * object created from the given arguments (the same as of the constructor) — unlike\n\t * the constructor, which always creates a new object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t * @returns {LatLngBounds}\n\t */\n\tstatic from(corner1, corner2) {\n\t\treturn corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);\n\t}\n\n\t/**\n\t * Extend the bounds to contain the given point or bounds.\n\t * @param {LatLngExpression|LatLngBoundsExpression} obj\n\t * @returns {this}\n\t */\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 = ne2 = obj;\n\t\t} else if (obj instanceof LatLngBounds) {\n\t\t\t({_southWest: sw2, _northEast: ne2} = obj);\n\t\t\tif (!sw2) { return this; }\n\t\t} else if (!obj) {\n\t\t\treturn this;\n\t\t} else if (LatLng.validate(obj)) {\n\t\t\tsw2 = ne2 = LatLng.from(obj);\n\t\t} else {\n\t\t\treturn this.extend(LatLngBounds.from(obj));\n\t\t}\n\n\t\tif (!sw) {\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/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {LatLngBounds}\n\t */\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/**\n\t * Returns the center point of the bounds.\n\t * @returns {LatLng}\n\t */\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/**\n\t * Returns the south-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t/**\n\t * Returns the north-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t/**\n\t * Returns the north-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t/**\n\t * Returns the south-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t/**\n\t * Returns the west longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t/**\n\t * Returns the south latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t/**\n\t * Returns the east longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t/**\n\t * Returns the north latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {LatLngBoundsExpression|LatLngExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = LatLng.from(obj);\n\t\t} else {\n\t\t\tobj = LatLngBounds.from(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/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds intersect\n\t * if they have at least one point in common.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) {\n\t\tbounds = LatLngBounds.from(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/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if\n\t * their intersection is an area.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) {\n\t\tbounds = LatLngBounds.from(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/**\n\t * Returns a string with bounding box coordinates in a\n\t * 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for\n\t * sending requests to web services that return geo data.\n\t * @returns {string}\n\t */\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent (within a small margin of error) to\n\t * the given bounds. The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = LatLngBounds.from(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/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,e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W,QAAQ;EAClB,SAAS,aAAa,KAAK,MAAM;EAEjC,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;;;;;;;CAQA,SAAS,QAAQ;EAChB,SAAS,aAAa,KAAK,MAAM;EAEjC,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;;;;;;;CAQA,eAAe;EACd,OAAO;GAAC,KAAK,QAAQ;GAAG,KAAK,SAAS;GAAG,KAAK,QAAQ;GAAG,KAAK,SAAS;EAAC,CAAC,CAAC,KAAK,GAAG;CACnF;;;;;;;;;CAUA,OAAO,QAAQ,WAAW;EACzB,IAAI,CAAC,QAAU,OAAO;EAEtB,SAAS,aAAa,KAAK,MAAM;EAEjC,OAAO,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS,KACvD,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS;CAC/D;;;;;CAMA,UAAU;EACT,OAAO,CAAC,EAAE,KAAK,cAAc,KAAK;CACnC;AACD"}
|
package/dist/esm/geo/crs/CRS.js
CHANGED
|
@@ -2,7 +2,7 @@ import { wrapNum } from "../../core/Util.js";
|
|
|
2
2
|
import { Bounds } from "../../geometry/Bounds.js";
|
|
3
3
|
import { LatLngBounds } from "../LatLngBounds.js";
|
|
4
4
|
import { LatLng } from "../LatLng.js";
|
|
5
|
-
|
|
5
|
+
// src/geo/crs/CRS.js
|
|
6
6
|
/** @import {LatLngExpression} from '../LatLng.js' */
|
|
7
7
|
/** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */
|
|
8
8
|
/** @import {Point} from '../../geometry/Point.js' */
|
|
@@ -146,7 +146,6 @@ var CRS = class {
|
|
|
146
146
|
return new LatLngBounds(newSw, newNe);
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
|
-
//#endregion
|
|
150
149
|
export { CRS };
|
|
151
150
|
|
|
152
151
|
//# sourceMappingURL=CRS.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EarthCRS } from "./EarthCRS.js";
|
|
2
2
|
import { Transformation } from "../../geometry/Transformation.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { MercatorProjection } from "../projection/MercatorProjection.js";
|
|
4
|
+
// src/geo/crs/EPSG3395.js
|
|
5
5
|
/** @import {Projection} from '../projection/index.js' */
|
|
6
6
|
/**
|
|
7
7
|
* Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
|
|
@@ -10,14 +10,13 @@ var EPSG3395 = class extends EarthCRS {
|
|
|
10
10
|
/** @type {string} */
|
|
11
11
|
static code = "EPSG:3395";
|
|
12
12
|
/** @type {Projection} */
|
|
13
|
-
static projection =
|
|
13
|
+
static projection = MercatorProjection;
|
|
14
14
|
/** @type {Transformation} */
|
|
15
15
|
static transformation = /* @__PURE__ */ (() => {
|
|
16
|
-
const scale = .5 / (Math.PI *
|
|
16
|
+
const scale = .5 / (Math.PI * MercatorProjection.R);
|
|
17
17
|
return new Transformation(scale, .5, -scale, .5);
|
|
18
18
|
})();
|
|
19
19
|
};
|
|
20
|
-
//#endregion
|
|
21
20
|
export { EPSG3395 };
|
|
22
21
|
|
|
23
22
|
//# sourceMappingURL=EPSG3395.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EPSG3395.js","names":[],"sources":["../../../../src/geo/crs/EPSG3395.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {
|
|
1
|
+
{"version":3,"file":"EPSG3395.js","names":[],"sources":["../../../../src/geo/crs/EPSG3395.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {MercatorProjection} from '../projection/MercatorProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.\n */\nexport class EPSG3395 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:3395';\n\t/** @type {Projection} */\n\tstatic projection = MercatorProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ (() => {\n\t\tconst scale = 0.5 / (Math.PI * MercatorProjection.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iBAAiC,uBAAO;EAC9C,MAAM,QAAQ,MAAO,KAAK,KAAK,mBAAmB;EAClD,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EarthCRS } from "./EarthCRS.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SphericalMercatorProjection } from "../projection/SphericalMercatorProjection.js";
|
|
3
3
|
import { Transformation } from "../../geometry/Transformation.js";
|
|
4
|
-
|
|
4
|
+
// src/geo/crs/EPSG3857.js
|
|
5
5
|
/** @import {Projection} from '../projection/index.js' */
|
|
6
6
|
/**
|
|
7
7
|
* The most common CRS for online maps, used by almost all free and commercial
|
|
@@ -12,10 +12,10 @@ var EPSG3857 = class extends EarthCRS {
|
|
|
12
12
|
/** @type {string} */
|
|
13
13
|
static code = "EPSG:3857";
|
|
14
14
|
/** @type {Projection} */
|
|
15
|
-
static projection =
|
|
15
|
+
static projection = SphericalMercatorProjection;
|
|
16
16
|
/** @type {Transformation} */
|
|
17
17
|
static transformation = /* @__PURE__ */ (() => {
|
|
18
|
-
const scale = .5 / (Math.PI *
|
|
18
|
+
const scale = .5 / (Math.PI * SphericalMercatorProjection.R);
|
|
19
19
|
return new Transformation(scale, .5, -scale, .5);
|
|
20
20
|
})();
|
|
21
21
|
};
|
|
@@ -26,7 +26,6 @@ var EPSG900913 = class extends EPSG3857 {
|
|
|
26
26
|
/** @type {string} */
|
|
27
27
|
static code = "EPSG:900913";
|
|
28
28
|
};
|
|
29
|
-
//#endregion
|
|
30
29
|
export { EPSG3857, EPSG900913 };
|
|
31
30
|
|
|
32
31
|
//# sourceMappingURL=EPSG3857.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EPSG3857.js","names":[],"sources":["../../../../src/geo/crs/EPSG3857.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {
|
|
1
|
+
{"version":3,"file":"EPSG3857.js","names":[],"sources":["../../../../src/geo/crs/EPSG3857.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {SphericalMercatorProjection} from '../projection/SphericalMercatorProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\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 */\nexport class EPSG3857 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:3857';\n\t/** @type {Projection} */\n\tstatic projection = SphericalMercatorProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ (() => {\n\t\tconst scale = 0.5 / (Math.PI * SphericalMercatorProjection.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n\n/**\n * The same as `EPSG3857`, with its former unofficial code `EPSG:900913`.\n */\nexport class EPSG900913 extends EPSG3857 {\n\t/** @type {string} */\n\tstatic code = 'EPSG:900913';\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iBAAiC,uBAAO;EAC9C,MAAM,QAAQ,MAAO,KAAK,KAAK,4BAA4B;EAC3D,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ;;;;AAKA,IAAa,aAAb,cAAgC,SAAS;;CAExC,OAAO,OAAO;AACf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EarthCRS } from "./EarthCRS.js";
|
|
2
2
|
import { Transformation } from "../../geometry/Transformation.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { LonLatProjection } from "../projection/LonLatProjection.js";
|
|
4
|
+
// src/geo/crs/EPSG4326.js
|
|
5
5
|
/** @import {Projection} from '../projection/index.js' */
|
|
6
6
|
/**
|
|
7
7
|
* A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
|
|
@@ -17,11 +17,10 @@ var EPSG4326 = class extends EarthCRS {
|
|
|
17
17
|
/** @type {string} */
|
|
18
18
|
static code = "EPSG:4326";
|
|
19
19
|
/** @type {Projection} */
|
|
20
|
-
static projection =
|
|
20
|
+
static projection = LonLatProjection;
|
|
21
21
|
/** @type {Transformation} */
|
|
22
22
|
static transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, .5);
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
export { EPSG4326 };
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=EPSG4326.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EPSG4326.js","names":[],"sources":["../../../../src/geo/crs/EPSG4326.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {
|
|
1
|
+
{"version":3,"file":"EPSG4326.js","names":[],"sources":["../../../../src/geo/crs/EPSG4326.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {LonLatProjection} from '../projection/LonLatProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.\n *\n * Maplair complies with the\n * [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\n * pixel tiles covering the whole earth at zoom level zero, and that the tile\n * coordinate origin is (-180,+90), or (-180,-90) for `TileLayer`s with\n * [the `tms` option](#tilelayer-tms) set.\n */\nexport class EPSG4326 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:4326';\n\t/** @type {Projection} */\n\tstatic projection = LonLatProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, 0.5);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iCAAiC,IAAI,eAAe,IAAI,KAAK,GAAG,KAAK,KAAK,EAAG;AACrF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { haversineDistance } from "../LatLng.js";
|
|
2
2
|
import { CRS } from "./CRS.js";
|
|
3
|
-
|
|
3
|
+
// src/geo/crs/EarthCRS.js
|
|
4
4
|
/** @import {LatLng} from '../LatLng.js' */
|
|
5
5
|
/**
|
|
6
6
|
* Serves as the base for CRS that are global such that they cover the earth.
|
|
@@ -32,7 +32,6 @@ var EarthCRS = class extends CRS {
|
|
|
32
32
|
return haversineDistance(latlng1, latlng2, this.R);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
//#endregion
|
|
36
35
|
export { EarthCRS };
|
|
37
36
|
|
|
38
37
|
//# sourceMappingURL=EarthCRS.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CRS } from "./CRS.js";
|
|
2
2
|
import { Transformation } from "../../geometry/Transformation.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { LonLatProjection } from "../projection/LonLatProjection.js";
|
|
4
|
+
// src/geo/crs/SimpleCRS.js
|
|
5
5
|
/** @import {LatLng} from '../LatLng.js' */
|
|
6
6
|
/** @import {Projection} from '../projection/index.js' */
|
|
7
7
|
/**
|
|
@@ -12,7 +12,7 @@ import { LonLat } from "../projection/Projection.LonLat.js";
|
|
|
12
12
|
*/
|
|
13
13
|
var SimpleCRS = class extends CRS {
|
|
14
14
|
/** @type {Projection} */
|
|
15
|
-
static projection =
|
|
15
|
+
static projection = LonLatProjection;
|
|
16
16
|
/** @type {Transformation} */
|
|
17
17
|
static transformation = /* @__PURE__ */ new Transformation(1, 0, -1, 0);
|
|
18
18
|
/**
|
|
@@ -44,7 +44,6 @@ var SimpleCRS = class extends CRS {
|
|
|
44
44
|
/** @type {boolean} */
|
|
45
45
|
static infinite = true;
|
|
46
46
|
};
|
|
47
|
-
//#endregion
|
|
48
47
|
export { SimpleCRS };
|
|
49
48
|
|
|
50
49
|
//# sourceMappingURL=SimpleCRS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleCRS.js","names":[],"sources":["../../../../src/geo/crs/SimpleCRS.js"],"sourcesContent":["import {CRS} from './CRS.js';\nimport {
|
|
1
|
+
{"version":3,"file":"SimpleCRS.js","names":[],"sources":["../../../../src/geo/crs/SimpleCRS.js"],"sourcesContent":["import {CRS} from './CRS.js';\nimport {LonLatProjection} from '../projection/LonLatProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {LatLng} from '../LatLng.js' */\n/** @import {Projection} from '../projection/index.js' */\n\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 */\nexport class SimpleCRS extends CRS {\n\t/** @type {Projection} */\n\tstatic projection = LonLatProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ new Transformation(1, 0, -1, 0);\n\n\t/**\n\t * Returns `2^zoom`.\n\t * @param {number} zoom\n\t * @returns {number}\n\t */\n\tstatic scale(zoom) {\n\t\treturn 2 ** zoom;\n\t}\n\n\t/**\n\t * Inverse of `scale()`.\n\t * @param {number} scale\n\t * @returns {number}\n\t */\n\tstatic zoom(scale) {\n\t\treturn Math.log(scale) / Math.LN2;\n\t}\n\n\t/**\n\t * Returns the euclidean distance between two points.\n\t * @param {LatLng} latlng1\n\t * @param {LatLng} latlng2\n\t * @returns {number}\n\t */\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\t/** @type {boolean} */\n\tstatic infinite = true;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,YAAb,cAA+B,IAAI;;CAElC,OAAO,aAAa;;CAEpB,OAAO,iCAAiC,IAAI,eAAe,GAAG,GAAG,IAAI,CAAC;;;;;;CAOtE,OAAO,MAAM,MAAM;EAClB,OAAO,KAAK;CACb;;;;;;CAOA,OAAO,KAAK,OAAO;EAClB,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK;CAC/B;;;;;;;CAQA,OAAO,SAAS,SAAS,SAAS;EACjC,MAAM,KAAK,QAAQ,MAAM,QAAQ,KACjC,KAAK,QAAQ,MAAM,QAAQ;EAE3B,OAAO,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE;CACnC;;CAGA,OAAO,WAAW;AACnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Point } from "../../geometry/Point.js";
|
|
2
2
|
import { Bounds } from "../../geometry/Bounds.js";
|
|
3
3
|
import { LatLng } from "../LatLng.js";
|
|
4
|
-
|
|
4
|
+
// src/geo/projection/LonLatProjection.js
|
|
5
5
|
/** @import {Projection} from './index.js' */
|
|
6
6
|
/**
|
|
7
7
|
* Equirectangular, or Plate Carree projection — the most simple projection,
|
|
@@ -10,7 +10,7 @@ import { LatLng } from "../LatLng.js";
|
|
|
10
10
|
* `EPSG4326` and `SimpleCRS` CRS.
|
|
11
11
|
* @type {Projection}
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
13
|
+
const LonLatProjection = {
|
|
14
14
|
project(latlng) {
|
|
15
15
|
latlng = LatLng.from(latlng);
|
|
16
16
|
return new Point(latlng.lng, latlng.lat);
|
|
@@ -21,7 +21,6 @@ const LonLat = {
|
|
|
21
21
|
},
|
|
22
22
|
bounds: /* @__PURE__ */ new Bounds([-180, -90], [180, 90])
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
export { LonLat };
|
|
24
|
+
export { LonLatProjection };
|
|
26
25
|
|
|
27
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=LonLatProjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LonLatProjection.js","names":[],"sources":["../../../../src/geo/projection/LonLatProjection.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Projection} from './index.js' */\n\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 * `EPSG4326` and `SimpleCRS` CRS.\n * @type {Projection}\n */\nexport const LonLatProjection = {\n\tproject(latlng) {\n\t\tlatlng = LatLng.from(latlng);\n\t\treturn new Point(latlng.lng, latlng.lat);\n\t},\n\n\tunproject(point) {\n\t\tpoint = Point.from(point);\n\t\treturn new LatLng(point.y, point.x);\n\t},\n\n\tbounds: /* @__PURE__ */ new Bounds([-180, -90], [180, 90])\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,mBAAmB;CAC/B,QAAQ,QAAQ;EACf,SAAS,OAAO,KAAK,MAAM;EAC3B,OAAO,IAAI,MAAM,OAAO,KAAK,OAAO,GAAG;CACxC;CAEA,UAAU,OAAO;EAChB,QAAQ,MAAM,KAAK,KAAK;EACxB,OAAO,IAAI,OAAO,MAAM,GAAG,MAAM,CAAC;CACnC;CAEA,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;AAC1D"}
|
|
@@ -6,7 +6,7 @@ import { LatLng } from "../LatLng.js";
|
|
|
6
6
|
* Earth is an ellipsoid. Used by the EPSG:3395 CRS.
|
|
7
7
|
* @type {Projection & {R: number, R_MINOR: number}}
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const MercatorProjection = {
|
|
10
10
|
R: 6378137,
|
|
11
11
|
R_MINOR: 6356752.314245179,
|
|
12
12
|
bounds: /* @__PURE__ */ new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
|
|
@@ -32,7 +32,6 @@ const Mercator = {
|
|
|
32
32
|
return new LatLng(phi * d, point.x * d / r);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
export { Mercator };
|
|
35
|
+
export { MercatorProjection };
|
|
37
36
|
|
|
38
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=MercatorProjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MercatorProjection.js","names":[],"sources":["../../../../src/geo/projection/MercatorProjection.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Projection} from './index.js' */\n\nconst earthRadius = 6378137;\n\n/**\n * Elliptical Mercator projection — more complex than Spherical Mercator. Assumes that\n * Earth is an ellipsoid. Used by the EPSG:3395 CRS.\n * @type {Projection & {R: number, R_MINOR: number}}\n */\nexport const MercatorProjection = {\n\tR: earthRadius,\n\tR_MINOR: 6356752.314245179,\n\n\tbounds: /* @__PURE__ */ new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),\n\n\tproject(latlng) {\n\t\tlatlng = LatLng.from(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 = Point.from(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,qBAAqB;CACjC,GAAG;CACH,SAAS;CAET,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,eAAe,GAAG,CAAC,gBAAgB,cAAc,CAAC;CAEvG,QAAQ,QAAQ;EACf,SAAS,OAAO,KAAK,MAAM;EAC3B,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,MAAM,KAAK,KAAK;EACxB,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"}
|
package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Point } from "../../geometry/Point.js";
|
|
2
2
|
import { Bounds } from "../../geometry/Bounds.js";
|
|
3
3
|
import { LatLng } from "../LatLng.js";
|
|
4
|
-
|
|
4
|
+
// src/geo/projection/SphericalMercatorProjection.js
|
|
5
5
|
/** @import {Projection} from './index.js' */
|
|
6
6
|
const earthRadius = 6378137;
|
|
7
7
|
/**
|
|
@@ -10,7 +10,7 @@ const earthRadius = 6378137;
|
|
|
10
10
|
* a sphere. Used by the `EPSG:3857` CRS.
|
|
11
11
|
* @type {Projection & {R: number, MAX_LATITUDE: number}}
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
13
|
+
const SphericalMercatorProjection = {
|
|
14
14
|
R: earthRadius,
|
|
15
15
|
MAX_LATITUDE: 85.0511287798,
|
|
16
16
|
project(latlng) {
|
|
@@ -28,7 +28,6 @@ const SphericalMercator = {
|
|
|
28
28
|
return new Bounds([-d, -d], [d, d]);
|
|
29
29
|
})()
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
export { SphericalMercator };
|
|
31
|
+
export { SphericalMercatorProjection };
|
|
33
32
|
|
|
34
|
-
//# sourceMappingURL=
|
|
33
|
+
//# sourceMappingURL=SphericalMercatorProjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SphericalMercatorProjection.js","names":[],"sources":["../../../../src/geo/projection/SphericalMercatorProjection.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Projection} from './index.js' */\n\nconst earthRadius = 6378137;\n\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 * @type {Projection & {R: number, MAX_LATITUDE: number}}\n */\nexport const SphericalMercatorProjection = {\n\n\tR: earthRadius,\n\tMAX_LATITUDE: 85.0511287798,\n\n\tproject(latlng) {\n\t\tlatlng = LatLng.from(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 = Point.from(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: /* @__PURE__ */ (() => {\n\t\tconst d = earthRadius * Math.PI;\n\t\treturn new Bounds([-d, -d], [d, d]);\n\t})()\n};\n"],"mappings":";;;;;AAMA,MAAM,cAAc;;;;;;;AAQpB,MAAa,8BAA8B;CAE1C,GAAG;CACH,cAAc;CAEd,QAAQ,QAAQ;EACf,SAAS,OAAO,KAAK,MAAM;EAC3B,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,MAAM,KAAK,KAAK;EACxB,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,QAAwB,uBAAO;EAC9B,MAAM,IAAI,cAAc,KAAK;EAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnC,EAAA,CAAG;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Point } from "./Point.js";
|
|
2
|
-
|
|
2
|
+
// src/geometry/Bounds.js
|
|
3
3
|
/** @import {PointExpression} from './Point.js' */
|
|
4
4
|
/**
|
|
5
5
|
* A rectangular area in pixel coordinates: a `Bounds`, or an array of points (usually
|
|
@@ -76,14 +76,12 @@ var Bounds = class Bounds {
|
|
|
76
76
|
extend(obj) {
|
|
77
77
|
let min2, max2;
|
|
78
78
|
if (!obj) return this;
|
|
79
|
-
if (obj
|
|
79
|
+
if (isPointExpression(obj)) min2 = max2 = Point.from(obj);
|
|
80
80
|
else {
|
|
81
|
-
|
|
82
|
-
min2
|
|
83
|
-
max2 = obj.max;
|
|
84
|
-
if (!min2 || !max2) return this;
|
|
81
|
+
({min: min2, max: max2} = Bounds.from(obj));
|
|
82
|
+
if (!min2) return this;
|
|
85
83
|
}
|
|
86
|
-
if (!this.min
|
|
84
|
+
if (!this.min) {
|
|
87
85
|
this.min = new Point(min2);
|
|
88
86
|
this.max = new Point(max2);
|
|
89
87
|
} else {
|
|
@@ -144,12 +142,8 @@ var Bounds = class Bounds {
|
|
|
144
142
|
*/
|
|
145
143
|
contains(obj) {
|
|
146
144
|
let min, max;
|
|
147
|
-
if (
|
|
148
|
-
else
|
|
149
|
-
if (obj instanceof Bounds) {
|
|
150
|
-
min = obj.min;
|
|
151
|
-
max = obj.max;
|
|
152
|
-
} else min = max = obj;
|
|
145
|
+
if (isPointExpression(obj)) min = max = Point.from(obj);
|
|
146
|
+
else ({min, max} = Bounds.from(obj));
|
|
153
147
|
return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
|
|
154
148
|
}
|
|
155
149
|
/**
|
|
@@ -203,7 +197,9 @@ var Bounds = class Bounds {
|
|
|
203
197
|
return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
|
|
204
198
|
}
|
|
205
199
|
};
|
|
206
|
-
|
|
200
|
+
function isPointExpression(obj) {
|
|
201
|
+
return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] === "number" : "x" in obj);
|
|
202
|
+
}
|
|
207
203
|
export { Bounds };
|
|
208
204
|
|
|
209
205
|
//# sourceMappingURL=Bounds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bounds.js","names":[],"sources":["../../../src/geometry/Bounds.js"],"sourcesContent":["import {Point} from './Point.js';\n/** @import {PointExpression} from './Point.js' */\n\n/**\n * A rectangular area in pixel coordinates: a `Bounds`, or an array of points (usually\n * two diagonally opposite corners), e.g. `[[10, 10], [40, 60]]`. Accepted by all\n * Maplair methods which accept `Bounds` objects (unless noted otherwise).\n * @typedef {Bounds|PointExpression[]} BoundsExpression\n */\n\n/**\n * Represents a rectangular area in pixel coordinates.\n *\n * @example\n * ```js\n * const p1 = new Point(10, 10),\n * p2 = new Point(40, 60),\n * bounds = new Bounds(p1, p2);\n * ```\n *\n * All Maplair methods that accept `Bounds` objects also accept them in a simple Array\n * form (unless noted otherwise), so the bounds example above can be passed like this:\n *\n * ```js\n * otherBounds.intersects([[10, 10], [40, 60]]);\n * ```\n *\n * Note that `Bounds` 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 */\nexport class Bounds {\n\t/**\n\t * Creates a Bounds object from two corners coordinate pairs. Alternatively, creates a\n\t * Bounds object from the given array of points, or a copy of the given Bounds object.\n\t * @param {PointExpression|BoundsExpression} [a] The first corner, the points or the\n\t * bounds to copy.\n\t * @param {PointExpression} [b] The opposite corner.\n\t */\n\tconstructor(a, b) {\n\t\tif (!a) { return; }\n\n\t\tif (a instanceof Bounds) {\n\t\t\tif (a.isValid()) {\n\t\t\t\t/**\n\t\t\t\t * The top left corner of the rectangle.\n\t\t\t\t * @type {Point}\n\t\t\t\t */\n\t\t\t\tthis.min = new Point(a.min);\n\t\t\t\t/**\n\t\t\t\t * The bottom right corner of the rectangle.\n\t\t\t\t * @type {Point}\n\t\t\t\t */\n\t\t\t\tthis.max = new Point(a.max);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst points = b ? [a, b] : a;\n\t\tfor (const point of points) {\n\t\t\tthis.extend(point);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `Bounds` object as it is, or else a new `Bounds` object created\n\t * from the given arguments (the same as of the constructor) — unlike the\n\t * constructor, which always creates a new object.\n\t * @param {PointExpression|BoundsExpression} [a] The first corner, the points or the\n\t * bounds.\n\t * @param {PointExpression} [b] The opposite corner.\n\t * @returns {Bounds}\n\t */\n\tstatic from(a, b) {\n\t\treturn a instanceof Bounds ? a : new Bounds(a, b);\n\t}\n\n\t/**\n\t * Extends the bounds to contain the given point or bounds.\n\t * @param {PointExpression|BoundsExpression} obj\n\t * @returns {this}\n\t */\n\textend(obj) {\n\t\tlet min2, max2;\n\t\tif (!obj) { return this; }\n\n\t\tif (obj instanceof Point || typeof obj[0] === 'number' || 'x' in obj) {\n\t\t\tmin2 = max2 = Point.from(obj);\n\t\t} else {\n\t\t\tobj = Bounds.from(obj);\n\t\t\tmin2 = obj.min;\n\t\t\tmax2 = obj.max;\n\n\t\t\tif (!min2 || !max2) { return this; }\n\t\t}\n\n\t\tif (!this.min && !this.max) {\n\t\t\tthis.min = new Point(min2);\n\t\t\tthis.max = new Point(max2);\n\t\t} else {\n\t\t\tthis.min.x = Math.min(min2.x, this.min.x);\n\t\t\tthis.max.x = Math.max(max2.x, this.max.x);\n\t\t\tthis.min.y = Math.min(min2.y, this.min.y);\n\t\t\tthis.max.y = Math.max(max2.y, this.max.y);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the center point of the bounds.\n\t * @param {boolean} [round]\n\t * @returns {Point}\n\t */\n\tgetCenter(round) {\n\t\treturn new Point(\n\t\t\t(this.min.x + this.max.x) / 2,\n\t\t\t(this.min.y + this.max.y) / 2, round);\n\t}\n\n\t/**\n\t * Returns the bottom-left point of the bounds.\n\t * @returns {Point}\n\t */\n\tgetBottomLeft() {\n\t\treturn new Point(this.min.x, this.max.y);\n\t}\n\n\t/**\n\t * Returns the top-right point of the bounds.\n\t * @returns {Point}\n\t */\n\tgetTopRight() { // -> Point\n\t\treturn new Point(this.max.x, this.min.y);\n\t}\n\n\t/**\n\t * Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)).\n\t * @returns {Point}\n\t */\n\tgetTopLeft() {\n\t\treturn this.min; // left, top\n\t}\n\n\t/**\n\t * Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)).\n\t * @returns {Point}\n\t */\n\tgetBottomRight() {\n\t\treturn this.max; // right, bottom\n\t}\n\n\t/**\n\t * Returns the size of the given bounds.\n\t * @returns {Point}\n\t */\n\tgetSize() {\n\t\treturn this.max.subtract(this.min);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {BoundsExpression|PointExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) {\n\t\tlet min, max;\n\n\t\tif (typeof obj[0] === 'number' || obj instanceof Point) {\n\t\t\tobj = Point.from(obj);\n\t\t} else {\n\t\t\tobj = Bounds.from(obj);\n\t\t}\n\n\t\tif (obj instanceof Bounds) {\n\t\t\tmin = obj.min;\n\t\t\tmax = obj.max;\n\t\t} else {\n\t\t\tmin = max = obj;\n\t\t}\n\n\t\treturn (min.x >= this.min.x) &&\n\t\t (max.x <= this.max.x) &&\n\t\t (min.y >= this.min.y) &&\n\t\t (max.y <= this.max.y);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds\n\t * intersect if they have at least one point in common.\n\t * @param {BoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) { // (Bounds) -> Boolean\n\t\tbounds = Bounds.from(bounds);\n\n\t\tconst min = this.min,\n\t\tmax = this.max,\n\t\tmin2 = bounds.min,\n\t\tmax2 = bounds.max,\n\t\txIntersects = (max2.x >= min.x) && (min2.x <= max.x),\n\t\tyIntersects = (max2.y >= min.y) && (min2.y <= max.y);\n\n\t\treturn xIntersects && yIntersects;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds\n\t * overlap if their intersection is an area.\n\t * @param {BoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) { // (Bounds) -> Boolean\n\t\tbounds = Bounds.from(bounds);\n\n\t\tconst min = this.min,\n\t\tmax = this.max,\n\t\tmin2 = bounds.min,\n\t\tmax2 = bounds.max,\n\t\txOverlaps = (max2.x > min.x) && (min2.x < max.x),\n\t\tyOverlaps = (max2.y > min.y) && (min2.y < max.y);\n\n\t\treturn xOverlaps && yOverlaps;\n\t}\n\n\t/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this.min && this.max);\n\t}\n\n\n\t/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {Bounds}\n\t */\n\tpad(bufferRatio) {\n\t\tconst min = this.min,\n\t\tmax = this.max,\n\t\theightBuffer = Math.abs(min.x - max.x) * bufferRatio,\n\t\twidthBuffer = Math.abs(min.y - max.y) * bufferRatio;\n\n\n\t\treturn new Bounds(\n\t\t\tnew Point(min.x - heightBuffer, min.y - widthBuffer),\n\t\t\tnew Point(max.x + heightBuffer, max.y + widthBuffer));\n\t}\n\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent to the given bounds.\n\t * @param {BoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tequals(bounds) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = Bounds.from(bounds);\n\n\t\treturn this.min.equals(bounds.getTopLeft()) &&\n\t\t\tthis.max.equals(bounds.getBottomRight());\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,SAAb,MAAa,OAAO;;;;;;;;CAQnB,YAAY,GAAG,GAAG;EACjB,IAAI,CAAC,GAAK;EAEV,IAAI,aAAa,QAAQ;GACxB,IAAI,EAAE,QAAQ,GAAG;;;;;IAKhB,KAAK,MAAM,IAAI,MAAM,EAAE,GAAG;;;;;IAK1B,KAAK,MAAM,IAAI,MAAM,EAAE,GAAG;GAC3B;GACA;EACD;EAEA,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AAI,IAAI,IAAI,CAAC,IAAI;EAGxC,OAAO,IAAI,OACV,IAAI,MAAM,IAAI,IAAI,cAAc,IAAI,IAAI,WAAW,GACnD,IAAI,MAAM,IAAI,IAAI,cAAc,IAAI,IAAI,WAAW,CAAC;CACtD;;;;;;CAQA,OAAO,QAAQ;EACd,IAAI,CAAC,QAAU,OAAO;EAEtB,SAAS,OAAO,KAAK,MAAM;EAE3B,OAAO,KAAK,IAAI,OAAO,OAAO,WAAW,CAAC,KACzC,KAAK,IAAI,OAAO,OAAO,eAAe,CAAC;CACzC;AACD"}
|
|
1
|
+
{"version":3,"file":"Bounds.js","names":[],"sources":["../../../src/geometry/Bounds.js"],"sourcesContent":["import {Point} from './Point.js';\n/** @import {PointExpression} from './Point.js' */\n\n/**\n * A rectangular area in pixel coordinates: a `Bounds`, or an array of points (usually\n * two diagonally opposite corners), e.g. `[[10, 10], [40, 60]]`. Accepted by all\n * Maplair methods which accept `Bounds` objects (unless noted otherwise).\n * @typedef {Bounds|PointExpression[]} BoundsExpression\n */\n\n/**\n * Represents a rectangular area in pixel coordinates.\n *\n * @example\n * ```js\n * const p1 = new Point(10, 10),\n * p2 = new Point(40, 60),\n * bounds = new Bounds(p1, p2);\n * ```\n *\n * All Maplair methods that accept `Bounds` objects also accept them in a simple Array\n * form (unless noted otherwise), so the bounds example above can be passed like this:\n *\n * ```js\n * otherBounds.intersects([[10, 10], [40, 60]]);\n * ```\n *\n * Note that `Bounds` 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 */\nexport class Bounds {\n\t/**\n\t * Creates a Bounds object from two corners coordinate pairs. Alternatively, creates a\n\t * Bounds object from the given array of points, or a copy of the given Bounds object.\n\t * @param {PointExpression|BoundsExpression} [a] The first corner, the points or the\n\t * bounds to copy.\n\t * @param {PointExpression} [b] The opposite corner.\n\t */\n\tconstructor(a, b) {\n\t\tif (!a) { return; }\n\n\t\tif (a instanceof Bounds) {\n\t\t\tif (a.isValid()) {\n\t\t\t\t/**\n\t\t\t\t * The top left corner of the rectangle.\n\t\t\t\t * @type {Point}\n\t\t\t\t */\n\t\t\t\tthis.min = new Point(a.min);\n\t\t\t\t/**\n\t\t\t\t * The bottom right corner of the rectangle.\n\t\t\t\t * @type {Point}\n\t\t\t\t */\n\t\t\t\tthis.max = new Point(a.max);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst points = b ? [a, b] : a;\n\t\tfor (const point of points) {\n\t\t\tthis.extend(point);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `Bounds` object as it is, or else a new `Bounds` object created\n\t * from the given arguments (the same as of the constructor) — unlike the\n\t * constructor, which always creates a new object.\n\t * @param {PointExpression|BoundsExpression} [a] The first corner, the points or the\n\t * bounds.\n\t * @param {PointExpression} [b] The opposite corner.\n\t * @returns {Bounds}\n\t */\n\tstatic from(a, b) {\n\t\treturn a instanceof Bounds ? a : new Bounds(a, b);\n\t}\n\n\t/**\n\t * Extends the bounds to contain the given point or bounds.\n\t * @param {PointExpression|BoundsExpression} obj\n\t * @returns {this}\n\t */\n\textend(obj) {\n\t\tlet min2, max2;\n\t\tif (!obj) { return this; }\n\n\t\tif (isPointExpression(obj)) {\n\t\t\tmin2 = max2 = Point.from(obj);\n\t\t} else {\n\t\t\t({min: min2, max: max2} = Bounds.from(obj));\n\t\t\tif (!min2) { return this; }\n\t\t}\n\n\t\tif (!this.min) {\n\t\t\tthis.min = new Point(min2);\n\t\t\tthis.max = new Point(max2);\n\t\t} else {\n\t\t\tthis.min.x = Math.min(min2.x, this.min.x);\n\t\t\tthis.max.x = Math.max(max2.x, this.max.x);\n\t\t\tthis.min.y = Math.min(min2.y, this.min.y);\n\t\t\tthis.max.y = Math.max(max2.y, this.max.y);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the center point of the bounds.\n\t * @param {boolean} [round]\n\t * @returns {Point}\n\t */\n\tgetCenter(round) {\n\t\treturn new Point(\n\t\t\t(this.min.x + this.max.x) / 2,\n\t\t\t(this.min.y + this.max.y) / 2, round);\n\t}\n\n\t/**\n\t * Returns the bottom-left point of the bounds.\n\t * @returns {Point}\n\t */\n\tgetBottomLeft() {\n\t\treturn new Point(this.min.x, this.max.y);\n\t}\n\n\t/**\n\t * Returns the top-right point of the bounds.\n\t * @returns {Point}\n\t */\n\tgetTopRight() { // -> Point\n\t\treturn new Point(this.max.x, this.min.y);\n\t}\n\n\t/**\n\t * Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)).\n\t * @returns {Point}\n\t */\n\tgetTopLeft() {\n\t\treturn this.min; // left, top\n\t}\n\n\t/**\n\t * Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)).\n\t * @returns {Point}\n\t */\n\tgetBottomRight() {\n\t\treturn this.max; // right, bottom\n\t}\n\n\t/**\n\t * Returns the size of the given bounds.\n\t * @returns {Point}\n\t */\n\tgetSize() {\n\t\treturn this.max.subtract(this.min);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {BoundsExpression|PointExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) {\n\t\tlet min, max;\n\n\t\tif (isPointExpression(obj)) {\n\t\t\tmin = max = Point.from(obj);\n\t\t} else {\n\t\t\t({min, max} = Bounds.from(obj));\n\t\t}\n\n\t\treturn (min.x >= this.min.x) &&\n\t\t (max.x <= this.max.x) &&\n\t\t (min.y >= this.min.y) &&\n\t\t (max.y <= this.max.y);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds\n\t * intersect if they have at least one point in common.\n\t * @param {BoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) { // (Bounds) -> Boolean\n\t\tbounds = Bounds.from(bounds);\n\n\t\tconst min = this.min,\n\t\tmax = this.max,\n\t\tmin2 = bounds.min,\n\t\tmax2 = bounds.max,\n\t\txIntersects = (max2.x >= min.x) && (min2.x <= max.x),\n\t\tyIntersects = (max2.y >= min.y) && (min2.y <= max.y);\n\n\t\treturn xIntersects && yIntersects;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds\n\t * overlap if their intersection is an area.\n\t * @param {BoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) { // (Bounds) -> Boolean\n\t\tbounds = Bounds.from(bounds);\n\n\t\tconst min = this.min,\n\t\tmax = this.max,\n\t\tmin2 = bounds.min,\n\t\tmax2 = bounds.max,\n\t\txOverlaps = (max2.x > min.x) && (min2.x < max.x),\n\t\tyOverlaps = (max2.y > min.y) && (min2.y < max.y);\n\n\t\treturn xOverlaps && yOverlaps;\n\t}\n\n\t/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this.min && this.max);\n\t}\n\n\n\t/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {Bounds}\n\t */\n\tpad(bufferRatio) {\n\t\tconst min = this.min,\n\t\tmax = this.max,\n\t\theightBuffer = Math.abs(min.x - max.x) * bufferRatio,\n\t\twidthBuffer = Math.abs(min.y - max.y) * bufferRatio;\n\n\n\t\treturn new Bounds(\n\t\t\tnew Point(min.x - heightBuffer, min.y - widthBuffer),\n\t\t\tnew Point(max.x + heightBuffer, max.y + widthBuffer));\n\t}\n\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent to the given bounds.\n\t * @param {BoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tequals(bounds) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = Bounds.from(bounds);\n\n\t\treturn this.min.equals(bounds.getTopLeft()) &&\n\t\t\tthis.max.equals(bounds.getBottomRight());\n\t}\n}\n\n// Whether `obj` is a point (or an array or object literal of one) rather than bounds\nfunction isPointExpression(obj) {\n\treturn obj instanceof Point || (Array.is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