import { Toggle_default } from "./chunk-NNBJMTCH.js"; import "./chunk-VCBXDRBT.js"; import { Vector_default as Vector_default2 } from "./chunk-PD2E5XZ4.js"; import "./chunk-S3QBQTEW.js"; import "./chunk-V7WRBSQ6.js"; import "./chunk-W7BDJOQY.js"; import { Circle_default, LineString_default } from "./chunk-7JXPN73Q.js"; import { Feature_default } from "./chunk-E53S5GN6.js"; import { Vector_default } from "./chunk-T3TT2KJN.js"; import "./chunk-HM3IY3H4.js"; import "./chunk-JFXZSSOM.js"; import "./chunk-ZUI5NXIU.js"; import "./chunk-I4Q72WOW.js"; import "./chunk-RTVPCGIJ.js"; import { Interaction_default } from "./chunk-MSWSBYBR.js"; import "./chunk-QCJTGAWF.js"; import "./chunk-CAVOO5JW.js"; import "./chunk-VRTURNK3.js"; import "./chunk-2C73OZ6M.js"; import "./chunk-M5TTSD4C.js"; import "./chunk-ZCRXKB7J.js"; import "./chunk-RW3V7S4F.js"; import { Circle_default as Circle_default2, Fill_default, RegularShape_default, Stroke_default, Style_default } from "./chunk-PAB2HIXK.js"; import "./chunk-I6K7MRGV.js"; import "./chunk-PGWX4545.js"; import "./chunk-AYBYZSAV.js"; import "./chunk-YLJGUH5Z.js"; import { Point_default, Polygon_default, circular, fromCircle } from "./chunk-AZGMK675.js"; import "./chunk-BHVDQB66.js"; import "./chunk-6EWLK2BW.js"; import "./chunk-6Y7C6NBJ.js"; import "./chunk-5D2XPBR2.js"; import "./chunk-SHUBVYN4.js"; import "./chunk-FM44FOIC.js"; import "./chunk-LMC3RO5P.js"; import "./chunk-X52LGBOS.js"; import "./chunk-QFCIXVZ3.js"; import { get, getTransformFromProjections, identityTransform, transform } from "./chunk-A3RXLHYB.js"; import { getDistance } from "./chunk-ZLPTRF2L.js"; import { toRadians } from "./chunk-54BTDBAD.js"; import "./chunk-UPTVWZ45.js"; import "./chunk-5XHD7RSF.js"; import { Object_default } from "./chunk-Q5ZULJHM.js"; import { Event_default } from "./chunk-NGFXCWUF.js"; import "./chunk-K25ZO44T.js"; import { containsCoordinate, containsExtent } from "./chunk-SRXHWJOY.js"; import "./chunk-5RHQVMYD.js"; import "./chunk-DC5AMYBS.js"; // node_modules/ol/Geolocation.js var Property = { ACCURACY: "accuracy", ACCURACY_GEOMETRY: "accuracyGeometry", ALTITUDE: "altitude", ALTITUDE_ACCURACY: "altitudeAccuracy", HEADING: "heading", POSITION: "position", PROJECTION: "projection", SPEED: "speed", TRACKING: "tracking", TRACKING_OPTIONS: "trackingOptions" }; var GeolocationErrorType = { /** * Triggered when a `GeolocationPositionError` occurs. * @event module:ol/Geolocation.GeolocationError#error * @api */ ERROR: "error" }; var GeolocationError = class extends Event_default { /** * @param {GeolocationPositionError} error error object. */ constructor(error) { super(GeolocationErrorType.ERROR); this.code = error.code; this.message = error.message; } }; var Geolocation = class extends Object_default { /** * @param {Options} [options] Options. */ constructor(options) { super(); this.on; this.once; this.un; options = options || {}; this.position_ = null; this.transform_ = identityTransform; this.watchId_ = void 0; this.addChangeListener(Property.PROJECTION, this.handleProjectionChanged_); this.addChangeListener(Property.TRACKING, this.handleTrackingChanged_); if (options.projection !== void 0) { this.setProjection(options.projection); } if (options.trackingOptions !== void 0) { this.setTrackingOptions(options.trackingOptions); } this.setTracking(options.tracking !== void 0 ? options.tracking : false); } /** * Clean up. * @override */ disposeInternal() { this.setTracking(false); super.disposeInternal(); } /** * @private */ handleProjectionChanged_() { const projection = this.getProjection(); if (projection) { this.transform_ = getTransformFromProjections( get("EPSG:4326"), projection ); if (this.position_) { this.set(Property.POSITION, this.transform_(this.position_)); } } } /** * @private */ handleTrackingChanged_() { if ("geolocation" in navigator) { const tracking = this.getTracking(); if (tracking && this.watchId_ === void 0) { this.watchId_ = navigator.geolocation.watchPosition( this.positionChange_.bind(this), this.positionError_.bind(this), this.getTrackingOptions() ); } else if (!tracking && this.watchId_ !== void 0) { navigator.geolocation.clearWatch(this.watchId_); this.watchId_ = void 0; } } } /** * @private * @param {GeolocationPosition} position position event. */ positionChange_(position) { const coords = position.coords; this.set(Property.ACCURACY, coords.accuracy); this.set( Property.ALTITUDE, coords.altitude === null ? void 0 : coords.altitude ); this.set( Property.ALTITUDE_ACCURACY, coords.altitudeAccuracy === null ? void 0 : coords.altitudeAccuracy ); this.set( Property.HEADING, coords.heading === null ? void 0 : toRadians(coords.heading) ); if (!this.position_) { this.position_ = [coords.longitude, coords.latitude]; } else { this.position_[0] = coords.longitude; this.position_[1] = coords.latitude; } const projectedPosition = this.transform_(this.position_); this.set(Property.POSITION, projectedPosition.slice()); this.set(Property.SPEED, coords.speed === null ? void 0 : coords.speed); const geometry = circular(this.position_, coords.accuracy); geometry.applyTransform(this.transform_); this.set(Property.ACCURACY_GEOMETRY, geometry); this.changed(); } /** * @private * @param {GeolocationPositionError} error error object. */ positionError_(error) { this.dispatchEvent(new GeolocationError(error)); } /** * Get the accuracy of the position in meters. * @return {number|undefined} The accuracy of the position measurement in * meters. * @observable * @api */ getAccuracy() { return ( /** @type {number|undefined} */ this.get(Property.ACCURACY) ); } /** * Get a geometry of the position accuracy. * @return {?import("./geom/Polygon.js").default} A geometry of the position accuracy. * @observable * @api */ getAccuracyGeometry() { return ( /** @type {?import("./geom/Polygon.js").default} */ this.get(Property.ACCURACY_GEOMETRY) || null ); } /** * Get the altitude associated with the position. * @return {number|undefined} The altitude of the position in meters above mean * sea level. * @observable * @api */ getAltitude() { return ( /** @type {number|undefined} */ this.get(Property.ALTITUDE) ); } /** * Get the altitude accuracy of the position. * @return {number|undefined} The accuracy of the altitude measurement in * meters. * @observable * @api */ getAltitudeAccuracy() { return ( /** @type {number|undefined} */ this.get(Property.ALTITUDE_ACCURACY) ); } /** * Get the heading as radians clockwise from North. * Note: depending on the browser, the heading is only defined if the `enableHighAccuracy` * is set to `true` in the tracking options. * @return {number|undefined} The heading of the device in radians from north. * @observable * @api */ getHeading() { return ( /** @type {number|undefined} */ this.get(Property.HEADING) ); } /** * Get the position of the device. * @return {import("./coordinate.js").Coordinate|undefined} The current position of the device reported * in the current projection. * @observable * @api */ getPosition() { return ( /** @type {import("./coordinate.js").Coordinate|undefined} */ this.get(Property.POSITION) ); } /** * Get the projection associated with the position. * @return {import("./proj/Projection.js").default|undefined} The projection the position is * reported in. * @observable * @api */ getProjection() { return ( /** @type {import("./proj/Projection.js").default|undefined} */ this.get(Property.PROJECTION) ); } /** * Get the speed in meters per second. * @return {number|undefined} The instantaneous speed of the device in meters * per second. * @observable * @api */ getSpeed() { return ( /** @type {number|undefined} */ this.get(Property.SPEED) ); } /** * Determine if the device location is being tracked. * @return {boolean} The device location is being tracked. * @observable * @api */ getTracking() { return ( /** @type {boolean} */ this.get(Property.TRACKING) ); } /** * Get the tracking options. * See https://www.w3.org/TR/geolocation-API/#position-options. * @return {PositionOptions|undefined} PositionOptions as defined by * the [HTML5 Geolocation spec * ](https://www.w3.org/TR/geolocation-API/#position_options_interface). * @observable * @api */ getTrackingOptions() { return ( /** @type {PositionOptions|undefined} */ this.get(Property.TRACKING_OPTIONS) ); } /** * Set the projection to use for transforming the coordinates. * @param {import("./proj.js").ProjectionLike} projection The projection the position is * reported in. * @observable * @api */ setProjection(projection) { this.set(Property.PROJECTION, get(projection)); } /** * Enable or disable tracking. * @param {boolean} tracking Enable tracking. * @observable * @api */ setTracking(tracking) { this.set(Property.TRACKING, tracking); } /** * Set the tracking options. * See http://www.w3.org/TR/geolocation-API/#position-options. * @param {PositionOptions} options PositionOptions as defined by the * [HTML5 Geolocation spec * ](http://www.w3.org/TR/geolocation-API/#position_options_interface). * @observable * @api */ setTrackingOptions(options) { this.set(Property.TRACKING_OPTIONS, options); } }; var Geolocation_default = Geolocation; // node_modules/ol-ext/interaction/GeolocationDraw.js var ol_interaction_GeolocationDraw = class olinteractionGeolocationDraw extends Interaction_default { constructor(options) { options = options || {}; super({ handleEvent: function() { return !this.get("followTrack") || this.get("followTrack") == "auto"; } }); this.geolocation = new Geolocation_default({ projection: "EPSG:4326", trackingOptions: { maximumAge: 1e4, enableHighAccuracy: true, timeout: 6e5 } }); this.geolocation.on("change", this.draw_.bind(this)); this.path_ = []; this.lastPosition_ = false; var white = [255, 255, 255, 1]; var blue = [0, 153, 255, 1]; var width = 3; var circle = new Circle_default2({ radius: width * 2, fill: new Fill_default({ color: blue }), stroke: new Stroke_default({ color: white, width: width / 2 }) }); var style = [ new Style_default({ stroke: new Stroke_default({ color: white, width: width + 2 }) }), new Style_default({ stroke: new Stroke_default({ color: blue, width }), fill: new Fill_default({ color: [255, 255, 255, 0.5] }) }) ]; var triangle = new RegularShape_default({ radius: width * 3.5, points: 3, rotation: 0, fill: new Fill_default({ color: blue }), stroke: new Stroke_default({ color: white, width: width / 2 }) }); var c = triangle.getImage(); var ctx = c.getContext("2d"); var c2 = document.createElement("canvas"); c2.width = c2.height = c.width; c2.getContext("2d").drawImage(c, 0, 0); ctx.clearRect(0, 0, c.width, c.height); ctx.drawImage(c2, 0, 0, c.width, c.height, width, 0, c.width - 2 * width, c.height); var defaultStyle = function(f) { if (f.get("heading") === void 0) { style[1].setImage(circle); } else { style[1].setImage(triangle); triangle.setRotation(f.get("heading") || 0); } return style; }; this.locStyle = { error: new Style_default({ fill: new Fill_default({ color: [255, 0, 0, 0.2] }) }), warn: new Style_default({ fill: new Fill_default({ color: [255, 192, 0, 0.2] }) }), ok: new Style_default({ fill: new Fill_default({ color: [0, 255, 0, 0.2] }) }) }; this.overlayLayer_ = new Vector_default({ source: new Vector_default2(), name: "GeolocationDraw overlay", style: options.style || defaultStyle }); this.sketch_ = [new Feature_default(), new Feature_default(), new Feature_default()]; this.overlayLayer_.getSource().addFeatures(this.sketch_); this.features_ = options.features; this.source_ = options.source; this.condition_ = options.condition || function(loc) { return loc.getAccuracy() < this.get("minAccuracy"); }; this.set("type", options.type || "LineString"); this.set("attributes", options.attributes || {}); this.set("minAccuracy", options.minAccuracy || 20); this.set("tolerance", options.tolerance || 5); this.set("zoom", options.zoom); this.set("minZoom", options.minZoom); this.setFollowTrack(options.followTrack === void 0 ? true : options.followTrack); this.setActive(false); } /** Simplify 3D geometry * @param {ol.geom.Geometry} geo * @param {number} tolerance */ simplify3D(geo, tolerance) { var geom = geo.getCoordinates(); var proj = this.getMap().getView().getProjection(); if (this.get("type") === "Polygon") { geom = geom[0]; } var simply = [geom[0]]; var pi, p = transform(geom[0], proj, "EPSG:4326"); for (var i = 1; i < geom.length; i++) { pi = transform(geom[i], proj, "EPSG:4326"); var d = getDistance(p, pi); if (d > tolerance) { simply.push(geom[i]); p = pi; } } if (simply[simply.length - 1] !== geom[geom.length - 1]) { simply.push(geom[geom.length - 1]); } if (this.get("type") === "Polygon") { geo = new Polygon_default([simply], "XYZM"); } else { geo = new LineString_default(simply, "XYZM"); } return geo; } /** * Remove the interaction from its current map, if any, and attach it to a new * map, if any. Pass `null` to just remove the interaction from the current map. * @param {ol.Map} map Map. * @api stable */ setMap(map) { if (this.getMap()) this.getMap().removeLayer(this.overlayLayer_); super.setMap(map); this.overlayLayer_.setMap(map); if (map) this.geolocation.setProjection(map.getView().getProjection()); } /** Activate or deactivate the interaction. * @param {boolean} active */ setActive(active) { if (active === this.getActive()) return; super.setActive(active); if (this.getMap()) { this.geolocation.setTracking(active); try { this.getMap().renderSync(); } catch (e) { } } if (!this.overlayLayer_) return; this.overlayLayer_.setVisible(active); this.pause(!active); if (active) { this.reset(); this.dispatchEvent({ type: "drawstart", feature: this.sketch_[1] }); } else { var f = this.sketch_[1].clone(); if (f.getGeometry()) { if (this.features_) this.features_.push(f); if (this.source_) this.source_.addFeature(f); } this.dispatchEvent({ type: "drawend", feature: f }); } } /** Simulate a track and override current geolocation * @param {Array