@wemap/positioning 14.7.1 → 14.8.0-beta.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/dist/cdn/wemap-positioning.umd.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -16
- package/dist/src/location-sources/LocationSource.d.ts +17 -3
- package/dist/src/location-sources/LocationSource.d.ts.map +1 -1
- package/dist/src/location-sources/VPSLocationSource.d.ts +13 -0
- package/dist/src/location-sources/VPSLocationSource.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@wemap/providers"),require("@wemap/core"),require("@wemap/geo")):typeof define==`function`&&define.amd?define([`exports`,`@wemap/providers`,`@wemap/core`,`@wemap/geo`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.Wemap=e.Wemap||{},e.Wemap.Positioning={}),e.Wemap.Providers,e.Wemap.Core,e.Wemap.Geo))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=class{currentPose={};updateCallbacks=new Set;errorCallbacks=new Set;isStarted=!1;_locationState=`no_positioning`;locationStateCallbacks=new Set;async dispose(){await this.stop(),this.updateCallbacks.clear(),this.errorCallbacks.clear(),this.locationStateCallbacks.clear()}onUpdate(e){if(this.updateCallbacks.add(e),Object.keys(this.currentPose).length>0)try{e({...this.currentPose})}catch(e){console.error(`Error in ${this.constructor.name} initial callback:`,e)}}offUpdate(e){this.updateCallbacks.delete(e)}onError(e){this.errorCallbacks.add(e)}offError(e){this.errorCallbacks.delete(e)}configureMapMatching(e){e?.maxDistance!==void 0&&(t.MapMatchingHandler.maxDistance=e.maxDistance),e?.maxAngleBearing!==void 0&&(t.MapMatchingHandler.maxAngleBearing=e.maxAngleBearing),e?.maxDistance===void 0&&(t.MapMatchingHandler.maxDistance=30),e?.useOrientationMatching!==void 0&&(t.MapMatchingHandler.useOrientationMatching=e.useOrientationMatching),e?.useStrict!==void 0&&(t.MapMatchingHandler.useStrict=e.useStrict)}mergeAndEmitUpdate(e){e.position!==void 0&&(this.currentPose.position=e.position),e.attitude!==void 0&&(this.currentPose.attitude=e.attitude),e.inclination!==void 0&&(this.currentPose.inclination=e.inclination),e.time!==void 0&&(this.currentPose.time=e.time),e.accuracy!==void 0&&(this.currentPose.accuracy=e.accuracy),this.emitUpdate({...this.currentPose})}emitUpdate(e){this.updateCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`Error in ${this.constructor.name} callback:`,e)}})}emitError(e){this.errorCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`Error in ${this.constructor.name} error callback:`,e)}})}get locationState(){return this._locationState}onLocationStateChange(e){this.locationStateCallbacks.add(e)}offLocationStateChange(e){this.locationStateCallbacks.delete(e)}setLocationState(e){this._locationState!==e&&(this._locationState=e,this.locationStateCallbacks.forEach(t=>{t(e)}))}},a=3e4,o=!0,s=50,c=100,l=class extends i{absolutePositionProviderId=null;absoluteAttitudeProviderId=null;vpsProviderListenerId=null;positionSmoother;_scanStatus=`stopped`;scanPromise=null;scanResolve=null;firstScan=!1;lastPosition=null;lastScanPosition=null;distanceSinceLastScan=0;backgroundScanEnabled;_backgroundScanStatus;scanStatusCallbacks=new Set;backgroundScanStatusCallbacks=new Set;backgroundScanner=null;backgroundScanStatusUnsubscribe=null;lastBackgroundCandidatePosition=null;ACCURACY_BACKGROUND_SCAN_THRESHOLD=15;degradedLocationStateThreshold;noPositioningLocationStateThreshold;constructor(e={}){super(),this.backgroundScanEnabled=e.vps?.backgroundScan??o,this.degradedLocationStateThreshold=e.vps?.degradedLocationStateThreshold??s,this.noPositioningLocationStateThreshold=e.vps?.noPositioningLocationStateThreshold??c,this.configureVpsProvider(e.vps),this.configureMapMatching(e),e.usePositionSmoother!==!1&&(this.positionSmoother=new t.PositionSmoother(e=>{this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})})),t.ProvidersOptions.ignoreProviders=[`GnssWifi`];let n=e.vps?.backgroundScanIntervalMs??a;this.backgroundScanner=new t.VpsBackgroundScanner({enabled:this.backgroundScanEnabled,intervalMs:n},e=>this.handleBackgroundVpsEvent(e),e=>{this.emitError(e)}),this._backgroundScanStatus=this.backgroundScanEnabled?`idle`:`disabled`,this.backgroundScanner&&(this.backgroundScanStatusUnsubscribe=this.backgroundScanner.onStatusChange(e=>{this.setBackgroundScanStatus(e)}))}get scanStatus(){return this._scanStatus}get backgroundScanStatus(){return this._backgroundScanStatus}onScanStatusChange(e){return this.scanStatusCallbacks.add(e),()=>{this.offScanStatusChange(e)}}offScanStatusChange(e){this.scanStatusCallbacks.delete(e)}onBackgroundScanStatusChange(e){return this.backgroundScanStatusCallbacks.add(e),()=>{this.offBackgroundScanStatusChange(e)}}offBackgroundScanStatusChange(e){this.backgroundScanStatusCallbacks.delete(e)}setScanStatus(e){this._scanStatus!==e&&(this._scanStatus=e,this.scanStatusCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`[VPSLocationSource] Error in scanStatus listener`,e)}}))}setBackgroundScanStatus(e){this._backgroundScanStatus!==e&&(this._backgroundScanStatus=e,this.backgroundScanStatusCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`[VPSLocationSource] Error in backgroundScanStatus listener`,e)}}))}configureVpsProvider(e){let r=n.CoreConfig.getConfig()?.arNavigationData?.providers?.vps,i=e?.endpoint??r?.endpoint;if(!i)throw Error(`VPSLocationSource requires an endpoint URL. Provide it in config or ensure CoreConfig is initialized with arNavigationData.providers.vps.endpoint`);let a=new URL(i);a.href+=`geopose`,t.VpsProvider.endpoint=a.toString();let o=e?.minInclinationForRequest??(r?.minInclinationForRequest?r.minInclinationForRequest*Math.PI/180:void 0);o!==void 0&&(t.VpsProvider.minInclinationForRequest=o);let s=e?.waitTimeMinInclinationForRequest??r?.waitTimeMinInclinationForRequest;s!==void 0&&(t.VpsProvider.waitTimeMinInclinationForRequest=s);let c=e?.useCoarsePose??r?.useCoarsePose;c!==void 0&&(t.VpsProvider.useCoarsePose=c),e?.requestCaller!==void 0&&(t.VpsProvider.requestCaller=e.requestCaller)}async start(){this.isStarted||(this.setupListeners(),this.isStarted=!0,this.backgroundScanEnabled?this.backgroundScanner?.schedule():this.setBackgroundScanStatus(`disabled`))}async stop(){this.isStarted&&(this.vpsProviderListenerId!==null&&(t.VpsProvider.removeEventListener(this.vpsProviderListenerId),this.vpsProviderListenerId=null,t.VpsProvider.stop()),this.absolutePositionProviderId!==null&&(t.AbsolutePositionProvider.removeEventListener(this.absolutePositionProviderId),this.absolutePositionProviderId=null),this.absoluteAttitudeProviderId!==null&&(t.AbsoluteAttitudeProvider.removeEventListener(this.absoluteAttitudeProviderId),this.absoluteAttitudeProviderId=null),this.backgroundScanner?.clear(),this.setBackgroundScanStatus(this.backgroundScanEnabled?`idle`:`disabled`),this.isStarted=!1,this.setLocationState(`no_positioning`))}async dispose(){await super.dispose(),this.backgroundScanStatusUnsubscribe?.(),this.backgroundScanStatusUnsubscribe=null,this.backgroundScanner?.clear(),this.scanStatusCallbacks.clear(),this.backgroundScanStatusCallbacks.clear()}async startScan(){return await this.backgroundScanner?.cancelRunningScan(),this.startScanInternal()}async startScanInternal(){if(this.firstScan=!0,this.isStarted||await this.start(),await this.setupListeners(),this.vpsProviderListenerId!==null)return this.scanPromise??Promise.resolve(!1);let e=await t.VpsProvider.getAvailability();if(e instanceof Error)throw e;return this.setScanStatus(`scanning`),this.scanPromise=new Promise(e=>{this.scanResolve=e,this.vpsProviderListenerId=t.VpsProvider.addEventListener(t=>{this.scanResolve=null,this.stopScan(),this.handleVpsEvent(t),this.backgroundScanner?.schedule(),e(!0)},t=>{this.scanResolve=null,this.emitError(t),this.backgroundScanner?.schedule(),e(!1)})}),this.scanPromise}async stopScan(e=!1){e&&this.scanResolve&&(this.scanResolve(!1),this.scanResolve=null),this.vpsProviderListenerId!==null&&(t.VpsProvider.removeEventListener(this.vpsProviderListenerId),this.vpsProviderListenerId=null,t.VpsProvider.stop(),this.setScanStatus(`stopped`))}async setupListeners(){if(!this.absolutePositionProviderId&&this.firstScan&&(await t.AbsolutePositionProvider.getAvailability()instanceof Error||(this.absolutePositionProviderId=t.AbsolutePositionProvider.addEventListener(e=>{this.scanStatus!==`scanning`&&this.handleAbsolutePosition(e)},e=>{this.emitError(e)}))),!this.absoluteAttitudeProviderId&&this.firstScan){let e=await t.AbsoluteAttitudeProvider.getAvailability();e instanceof Error?console.warn(`AbsoluteAttitudeProvider not available:`,e):this.absoluteAttitudeProviderId=t.AbsoluteAttitudeProvider.addEventListener(e=>{this.mergeAndEmitUpdate({attitude:e,time:`time`in e?e.time:Date.now()})},e=>{this.emitError(e)})}}handleAbsolutePosition(e){this.updateDistanceAndLocationState(e),this.positionSmoother?this.positionSmoother.feed(e):this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})}handleVpsEvent(e){let t={};if(e.absolutePosition){this.registerScanSuccess(e.absolutePosition),t.position=e.absolutePosition;let n=`time`in e.absolutePosition?e.absolutePosition.time:Date.now(),r=`accuracy`in e.absolutePosition?e.absolutePosition.accuracy:void 0;t.time=n,r!==void 0&&(t.accuracy=r)}e.absoluteAttitude&&(t.attitude=e.absoluteAttitude),this.mergeAndEmitUpdate(t)}getCurrentAbsolutePosition(){let e=this.currentPose.position;return!e||!(`latitude`in e)||!(`longitude`in e)?null:e}handleBackgroundVpsEvent(e){let t=e.absolutePosition;if(!t){this.backgroundScanner?.schedule();return}let n=this.getCurrentAbsolutePosition();if(!this.lastBackgroundCandidatePosition){if(n&&t.distanceTo(n)<this.ACCURACY_BACKGROUND_SCAN_THRESHOLD){this.handleVpsEvent(e),this.backgroundScanner?.schedule();return}this.lastBackgroundCandidatePosition=t,this.backgroundScanner?.runNow();return}let r=this.lastBackgroundCandidatePosition;this.lastBackgroundCandidatePosition=null;let i=!1;n&&t.distanceTo(n)<this.ACCURACY_BACKGROUND_SCAN_THRESHOLD&&(i=!0),!i&&r&&t.distanceTo(r)<this.ACCURACY_BACKGROUND_SCAN_THRESHOLD&&(i=!0),i&&this.handleVpsEvent(e),this.backgroundScanner?.schedule()}registerScanSuccess(e){this.lastScanPosition=e,this.lastPosition=e,this.distanceSinceLastScan=0,this.setLocationState(`accurate`)}updateDistanceAndLocationState(e){if(this.scanStatus===`scanning`)return;if(!this.lastPosition){this.lastPosition=e;return}let t=this.lastPosition.distanceTo(e);this.lastPosition=e,this.lastScanPosition&&(this.distanceSinceLastScan+=t,this.distanceSinceLastScan>=this.noPositioningLocationStateThreshold?this.setLocationState(`no_positioning`):this.distanceSinceLastScan>=this.degradedLocationStateThreshold?this.setLocationState(`degraded`):this.setLocationState(`accurate`))}},u=class extends i{absolutePositionProviderId=null;absoluteAttitudeProviderId=null;gnssWifiErrorListenerId=null;positionSmoother;config;constructor(e={}){super(),this.config=e,this.configureGnssWifi(e.gnssWifi),this.configureMapMatching(e),e.usePositionSmoother!==!1&&(this.positionSmoother=new t.PositionSmoother(e=>{this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})})),this.gnssWifiErrorListenerId=t.GnssWifiProvider.addEventListener(()=>{},e=>{this.emitError(e)},!1)}configureGnssWifi(e){let r=n.CoreConfig.getConfig()?.arNavigationData?.providers,i=e??r?.gnssWifi;i&&(i.discardPositionsAbove!==void 0&&(t.GnssWifiProvider.discardPositionsAbove=i.discardPositionsAbove),i.enableHighAccuracy!==void 0&&(t.GnssWifiProvider.enableHighAccuracy=i.enableHighAccuracy))}async start(){if(!this.isStarted)try{let e=await t.AbsolutePositionProvider.getAvailability();if(e instanceof Error)throw e;if(this.absolutePositionProviderId=t.AbsolutePositionProvider.addEventListener(e=>{this.setLocationState(`accurate`),this.positionSmoother?this.positionSmoother.feed(e):this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})},e=>{this.emitError(e)}),this.config.enableAttitude!==!1)try{this.startAttitude()}catch(e){console.warn(`Failed to start AbsoluteAttitudeProvider:`,e)}this.isStarted=!0}catch(e){throw this.emitError(e instanceof Error?e:Error(String(e))),e}}async startAttitude(){let e=await t.AbsoluteAttitudeProvider.getAvailability();e instanceof Error?console.warn(`AbsoluteAttitudeProvider not available:`,e):this.absoluteAttitudeProviderId=t.AbsoluteAttitudeProvider.addEventListener(e=>{this.mergeAndEmitUpdate({attitude:e,time:`time`in e?e.time:Date.now()})},e=>{this.emitError(e)})}async stopAttitude(){this.absoluteAttitudeProviderId!==null&&(t.AbsoluteAttitudeProvider.removeEventListener(this.absoluteAttitudeProviderId),this.absoluteAttitudeProviderId=null)}async stop(){this.isStarted&&(this.absolutePositionProviderId!==null&&(t.AbsolutePositionProvider.removeEventListener(this.absolutePositionProviderId),this.absolutePositionProviderId=null),this.absoluteAttitudeProviderId!==null&&(t.AbsoluteAttitudeProvider.removeEventListener(this.absoluteAttitudeProviderId),this.absoluteAttitudeProviderId=null),this.isStarted=!1,this.setLocationState(`no_positioning`))}async dispose(){this.gnssWifiErrorListenerId!==null&&(t.GnssWifiProvider.removeEventListener(this.gnssWifiErrorListenerId),this.gnssWifiErrorListenerId=null),await super.dispose()}},d=class{static itinerary=null;static setItinerary(e){this.itinerary=e,t.MapMatchingHandler.itinerary=e}static getItinerary(){return this.itinerary??null}static clearItinerary(){this.itinerary=null,t.MapMatchingHandler.itinerary=null}};async function f(){if(typeof DeviceMotionEvent<`u`&&`requestPermission`in DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission==`function`)try{if(await DeviceMotionEvent.requestPermission()!==`granted`)return!1}catch{return!1}return!0}async function p(){return new Promise(e=>{t.GnssWifiProvider.addEventListener(()=>{e(!0)},()=>{e(!1)})})}Object.defineProperty(e,"Coordinates",{enumerable:!0,get:function(){return r.Coordinates}}),e.GnssWifiLocationSource=u,e.LocationSource=i,e.MapMatching=d,Object.defineProperty(e,"UserPosition",{enumerable:!0,get:function(){return r.UserPosition}}),e.VPSLocationSource=l,e.requestLocationPermissions=p,e.requestSensorPermissions=f});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@wemap/providers"),require("@wemap/core"),require("@wemap/geo")):typeof define==`function`&&define.amd?define([`exports`,`@wemap/providers`,`@wemap/core`,`@wemap/geo`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.Wemap=e.Wemap||{},e.Wemap.Positioning={}),e.Wemap.Providers,e.Wemap.Core,e.Wemap.Geo))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=30,a=30*Math.PI/180,o=class{currentPose={};updateCallbacks=new Set;errorCallbacks=new Set;isStarted=!1;_locationState=`no_positioning`;locationStateCallbacks=new Set;async dispose(){await this.stop(),this.updateCallbacks.clear(),this.errorCallbacks.clear(),this.locationStateCallbacks.clear()}onUpdate(e){if(this.updateCallbacks.add(e),Object.keys(this.currentPose).length>0)try{e({...this.currentPose})}catch(e){console.error(`Error in ${this.constructor.name} initial callback:`,e)}}offUpdate(e){this.updateCallbacks.delete(e)}onError(e){this.errorCallbacks.add(e)}offError(e){this.errorCallbacks.delete(e)}configureMapMatching(e,r=`indoor`){let o=n.CoreConfig.getConfig()?.arNavigationData?.[r]?.mapmatching,s=typeof o?.maxAngleBearing==`number`?o.maxAngleBearing*Math.PI/180:void 0;t.MapMatchingHandler.maxDistance=e?.maxDistance??o?.maxDistance??i,t.MapMatchingHandler.maxAngleBearing=e?.maxAngleBearing??s??a,t.MapMatchingHandler.useOrientationMatching=e?.useOrientationMatching??o?.useOrientationMatching??!1,t.MapMatchingHandler.useStrict=e?.useStrict??o?.useStrict??!1}mergeAndEmitUpdate(e){e.position!==void 0&&(this.currentPose.position=e.position),e.attitude!==void 0&&(this.currentPose.attitude=e.attitude),e.inclination!==void 0&&(this.currentPose.inclination=e.inclination),e.time!==void 0&&(this.currentPose.time=e.time),e.accuracy!==void 0&&(this.currentPose.accuracy=e.accuracy),this.emitUpdate({...this.currentPose})}emitUpdate(e){this.updateCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`Error in ${this.constructor.name} callback:`,e)}})}emitError(e){this.errorCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`Error in ${this.constructor.name} error callback:`,e)}})}get locationState(){return this._locationState}onLocationStateChange(e){this.locationStateCallbacks.add(e)}offLocationStateChange(e){this.locationStateCallbacks.delete(e)}setLocationState(e){this._locationState!==e&&(this._locationState=e,this.locationStateCallbacks.forEach(t=>{t(e)}))}},s=3e4,c=30*6e4,l=!0,u=50,d=100,f=class extends o{absolutePositionProviderId=null;absoluteAttitudeProviderId=null;vpsProviderListenerId=null;positionSmoother;_scanStatus=`stopped`;scanPromise=null;scanResolve=null;firstScan=!1;lastPosition=null;lastScanPosition=null;distanceSinceLastScan=0;backgroundScanEnabled;_backgroundScanStatus;scanStatusCallbacks=new Set;backgroundScanStatusCallbacks=new Set;backgroundScanner=null;backgroundScanStatusUnsubscribe=null;lastBackgroundCandidatePosition=null;ACCURACY_BACKGROUND_SCAN_THRESHOLD=15;degradedLocationStateThreshold;noPositioningLocationStateThreshold;constructor(e={}){super(),this.backgroundScanEnabled=e.vps?.backgroundScan??l,this.degradedLocationStateThreshold=e.vps?.degradedLocationStateThreshold??u,this.noPositioningLocationStateThreshold=e.vps?.noPositioningLocationStateThreshold??d,this.configureVpsProvider(e.vps),this.configureMapMatching(e,`indoor`),e.usePositionSmoother!==!1&&(this.positionSmoother=new t.PositionSmoother(e=>{this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})})),t.ProvidersOptions.ignoreProviders=[`GnssWifi`];let n=e.vps?.backgroundScanIntervalMs??s,r=e.vps?.backgroundScanMaxDurationMs??c;this.backgroundScanner=new t.VpsBackgroundScanner({enabled:this.backgroundScanEnabled,intervalMs:n,maxDurationMs:r},e=>this.handleBackgroundVpsEvent(e),e=>{this.emitError(e)}),this._backgroundScanStatus=this.backgroundScanEnabled?`idle`:`disabled`,this.backgroundScanner&&(this.backgroundScanStatusUnsubscribe=this.backgroundScanner.onStatusChange(e=>{this.setBackgroundScanStatus(e)}))}get scanStatus(){return this._scanStatus}get backgroundScanStatus(){return this._backgroundScanStatus}onScanStatusChange(e){return this.scanStatusCallbacks.add(e),()=>{this.offScanStatusChange(e)}}offScanStatusChange(e){this.scanStatusCallbacks.delete(e)}onBackgroundScanStatusChange(e){return this.backgroundScanStatusCallbacks.add(e),()=>{this.offBackgroundScanStatusChange(e)}}offBackgroundScanStatusChange(e){this.backgroundScanStatusCallbacks.delete(e)}setScanStatus(e){this._scanStatus!==e&&(this._scanStatus=e,this.scanStatusCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`[VPSLocationSource] Error in scanStatus listener`,e)}}))}setBackgroundScanStatus(e){this._backgroundScanStatus!==e&&(this._backgroundScanStatus=e,this.backgroundScanStatusCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`[VPSLocationSource] Error in backgroundScanStatus listener`,e)}}))}configureVpsProvider(e){let r=n.CoreConfig.getConfig()?.arNavigationData?.providers?.vps,i=e?.endpoint??r?.endpoint;if(!i)throw Error(`VPSLocationSource requires an endpoint URL. Provide it in config or ensure CoreConfig is initialized with arNavigationData.providers.vps.endpoint`);let a=new URL(i);a.href+=`geopose`,t.VpsProvider.endpoint=a.toString();let o=e?.minInclinationForRequest??(r?.minInclinationForRequest?r.minInclinationForRequest*Math.PI/180:void 0);o!==void 0&&(t.VpsProvider.minInclinationForRequest=o);let s=e?.waitTimeMinInclinationForRequest??r?.waitTimeMinInclinationForRequest;s!==void 0&&(t.VpsProvider.waitTimeMinInclinationForRequest=s);let c=e?.useCoarsePose??r?.useCoarsePose;c!==void 0&&(t.VpsProvider.useCoarsePose=c),e?.maxScanDurationMs!==void 0&&(t.VpsProvider.maxScanDuration=e.maxScanDurationMs),e?.requestCaller!==void 0&&(t.VpsProvider.requestCaller=e.requestCaller)}async start(){this.isStarted||(this.setupListeners(),this.isStarted=!0,this.backgroundScanEnabled?this.backgroundScanner?.schedule():this.setBackgroundScanStatus(`disabled`))}async stop(){this.isStarted&&(this.vpsProviderListenerId!==null&&(t.VpsProvider.removeEventListener(this.vpsProviderListenerId),this.vpsProviderListenerId=null,t.VpsProvider.stop()),this.absolutePositionProviderId!==null&&(t.AbsolutePositionProvider.removeEventListener(this.absolutePositionProviderId),this.absolutePositionProviderId=null),this.absoluteAttitudeProviderId!==null&&(t.AbsoluteAttitudeProvider.removeEventListener(this.absoluteAttitudeProviderId),this.absoluteAttitudeProviderId=null),this.backgroundScanner?.clear(),this.setBackgroundScanStatus(this.backgroundScanEnabled?`idle`:`disabled`),this.isStarted=!1,this.setLocationState(`no_positioning`))}async dispose(){await super.dispose(),this.backgroundScanStatusUnsubscribe?.(),this.backgroundScanStatusUnsubscribe=null,this.backgroundScanner?.clear(),this.scanStatusCallbacks.clear(),this.backgroundScanStatusCallbacks.clear()}async startScan(){return this.backgroundScanner?.resetBudget(),await this.backgroundScanner?.cancelRunningScan(),this.startScanInternal()}async startScanInternal(){if(this.firstScan=!0,this.isStarted||await this.start(),await this.setupListeners(),this.vpsProviderListenerId!==null)return this.scanPromise??Promise.resolve(!1);let e=await t.VpsProvider.getAvailability();if(e instanceof Error)throw e;return this.setScanStatus(`scanning`),this.scanPromise=new Promise(e=>{this.scanResolve=e,this.vpsProviderListenerId=t.VpsProvider.addEventListener(t=>{this.scanResolve=null,this.stopScan(),this.handleVpsEvent(t),this.backgroundScanner?.schedule(),e(!0)},t=>{this.scanResolve=null,this.stopScan(),this.emitError(t),this.backgroundScanner?.schedule(),e(!1)})}),this.scanPromise}async stopScan(e=!1){e&&this.scanResolve&&(this.scanResolve(!1),this.scanResolve=null),this.vpsProviderListenerId!==null&&(t.VpsProvider.removeEventListener(this.vpsProviderListenerId),this.vpsProviderListenerId=null,t.VpsProvider.stop(),this.setScanStatus(`stopped`))}async setupListeners(){if(!this.absolutePositionProviderId&&this.firstScan&&(await t.AbsolutePositionProvider.getAvailability()instanceof Error||(this.absolutePositionProviderId=t.AbsolutePositionProvider.addEventListener(e=>{this.scanStatus!==`scanning`&&this.handleAbsolutePosition(e)},e=>{this.emitError(e)}))),!this.absoluteAttitudeProviderId&&this.firstScan){let e=await t.AbsoluteAttitudeProvider.getAvailability();e instanceof Error?console.warn(`AbsoluteAttitudeProvider not available:`,e):this.absoluteAttitudeProviderId=t.AbsoluteAttitudeProvider.addEventListener(e=>{this.mergeAndEmitUpdate({attitude:e,time:`time`in e?e.time:Date.now()})},e=>{this.emitError(e)})}}handleAbsolutePosition(e){this.updateDistanceAndLocationState(e),this.positionSmoother?this.positionSmoother.feed(e):this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})}handleVpsEvent(e){let t={};if(e.absolutePosition){this.registerScanSuccess(e.absolutePosition),t.position=e.absolutePosition;let n=`time`in e.absolutePosition?e.absolutePosition.time:Date.now(),r=`accuracy`in e.absolutePosition?e.absolutePosition.accuracy:void 0;t.time=n,r!==void 0&&(t.accuracy=r)}e.absoluteAttitude&&(t.attitude=e.absoluteAttitude),this.mergeAndEmitUpdate(t)}getCurrentAbsolutePosition(){let e=this.currentPose.position;return!e||!(`latitude`in e)||!(`longitude`in e)?null:e}handleBackgroundVpsEvent(e){let t=e.absolutePosition;if(!t){this.backgroundScanner?.schedule();return}let n=this.getCurrentAbsolutePosition();if(!this.lastBackgroundCandidatePosition){if(n&&t.distanceTo(n)<this.ACCURACY_BACKGROUND_SCAN_THRESHOLD){this.handleVpsEvent(e),this.backgroundScanner?.schedule();return}this.lastBackgroundCandidatePosition=t,this.backgroundScanner?.runNow();return}let r=this.lastBackgroundCandidatePosition;this.lastBackgroundCandidatePosition=null;let i=!1;n&&t.distanceTo(n)<this.ACCURACY_BACKGROUND_SCAN_THRESHOLD&&(i=!0),!i&&r&&t.distanceTo(r)<this.ACCURACY_BACKGROUND_SCAN_THRESHOLD&&(i=!0),i&&this.handleVpsEvent(e),this.backgroundScanner?.schedule()}registerScanSuccess(e){this.lastScanPosition=e,this.lastPosition=e,this.distanceSinceLastScan=0,this.setLocationState(`accurate`)}updateDistanceAndLocationState(e){if(this.scanStatus===`scanning`)return;if(!this.lastPosition){this.lastPosition=e;return}let t=this.lastPosition.distanceTo(e);this.lastPosition=e,this.lastScanPosition&&(this.distanceSinceLastScan+=t,this.distanceSinceLastScan>=this.noPositioningLocationStateThreshold?this.setLocationState(`no_positioning`):this.distanceSinceLastScan>=this.degradedLocationStateThreshold?this.setLocationState(`degraded`):this.setLocationState(`accurate`))}},p=class extends o{absolutePositionProviderId=null;absoluteAttitudeProviderId=null;gnssWifiErrorListenerId=null;positionSmoother;config;constructor(e={}){super(),this.config=e,this.configureGnssWifi(e.gnssWifi),this.configureMapMatching(e,`outdoor`),e.usePositionSmoother!==!1&&(this.positionSmoother=new t.PositionSmoother(e=>{this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})})),this.gnssWifiErrorListenerId=t.GnssWifiProvider.addEventListener(()=>{},e=>{this.emitError(e)},!1)}configureGnssWifi(e){let r=n.CoreConfig.getConfig()?.arNavigationData?.providers,i=e??r?.gnssWifi;i&&(i.discardPositionsAbove!==void 0&&(t.GnssWifiProvider.discardPositionsAbove=i.discardPositionsAbove),i.enableHighAccuracy!==void 0&&(t.GnssWifiProvider.enableHighAccuracy=i.enableHighAccuracy))}async start(){if(!this.isStarted)try{let e=await t.AbsolutePositionProvider.getAvailability();if(e instanceof Error)throw e;if(this.absolutePositionProviderId=t.AbsolutePositionProvider.addEventListener(e=>{this.setLocationState(`accurate`),this.positionSmoother?this.positionSmoother.feed(e):this.mergeAndEmitUpdate({position:e,time:`time`in e?e.time:Date.now(),accuracy:`accuracy`in e?e.accuracy:void 0})},e=>{this.emitError(e)}),this.config.enableAttitude!==!1)try{this.startAttitude()}catch(e){console.warn(`Failed to start AbsoluteAttitudeProvider:`,e)}this.isStarted=!0}catch(e){throw this.emitError(e instanceof Error?e:Error(String(e))),e}}async startAttitude(){let e=await t.AbsoluteAttitudeProvider.getAvailability();e instanceof Error?console.warn(`AbsoluteAttitudeProvider not available:`,e):this.absoluteAttitudeProviderId=t.AbsoluteAttitudeProvider.addEventListener(e=>{this.mergeAndEmitUpdate({attitude:e,time:`time`in e?e.time:Date.now()})},e=>{this.emitError(e)})}async stopAttitude(){this.absoluteAttitudeProviderId!==null&&(t.AbsoluteAttitudeProvider.removeEventListener(this.absoluteAttitudeProviderId),this.absoluteAttitudeProviderId=null)}async stop(){this.isStarted&&(this.absolutePositionProviderId!==null&&(t.AbsolutePositionProvider.removeEventListener(this.absolutePositionProviderId),this.absolutePositionProviderId=null),this.absoluteAttitudeProviderId!==null&&(t.AbsoluteAttitudeProvider.removeEventListener(this.absoluteAttitudeProviderId),this.absoluteAttitudeProviderId=null),this.isStarted=!1,this.setLocationState(`no_positioning`))}async dispose(){this.gnssWifiErrorListenerId!==null&&(t.GnssWifiProvider.removeEventListener(this.gnssWifiErrorListenerId),this.gnssWifiErrorListenerId=null),await super.dispose()}},m=class{static itinerary=null;static setItinerary(e){this.itinerary=e,t.MapMatchingHandler.itinerary=e}static getItinerary(){return this.itinerary??null}static clearItinerary(){this.itinerary=null,t.MapMatchingHandler.itinerary=null}};async function h(){if(typeof DeviceMotionEvent<`u`&&`requestPermission`in DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission==`function`)try{if(await DeviceMotionEvent.requestPermission()!==`granted`)return!1}catch{return!1}return!0}async function g(){return new Promise(e=>{t.GnssWifiProvider.addEventListener(()=>{e(!0)},()=>{e(!1)})})}Object.defineProperty(e,"Coordinates",{enumerable:!0,get:function(){return r.Coordinates}}),e.GnssWifiLocationSource=p,e.LocationSource=o,e.MapMatching=m,Object.defineProperty(e,"UserPosition",{enumerable:!0,get:function(){return r.UserPosition}}),e.VPSLocationSource=f,e.requestLocationPermissions=g,e.requestSensorPermissions=h});
|
package/dist/index.d.ts
CHANGED
|
@@ -12,5 +12,6 @@ export type { GnssWifiLocationSourceConfig } from './src/location-sources/GnssWi
|
|
|
12
12
|
export { MapMatching } from './src/MapMatching';
|
|
13
13
|
export { requestSensorPermissions, requestLocationPermissions } from './src/utils/permissions';
|
|
14
14
|
export { Coordinates, UserPosition } from '@wemap/geo';
|
|
15
|
-
export type { Pose, PartialPose } from './src/types';
|
|
15
|
+
export type { Pose, PartialPose, LocationState, LocationSourceOptions, MapMatchingOptions } from './src/types';
|
|
16
|
+
export type { ScanStatus, BackgroundScanStatus } from './src/location-sources/VPSLocationSource';
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAGvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,YAAY,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAGlG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG/F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGvD,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAGvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,YAAY,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAGlG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG/F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGvD,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC/G,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AbsoluteAttitudeProvider as e, AbsolutePositionProvider as t, GnssWifiP
|
|
|
2
2
|
import { CoreConfig as c } from "@wemap/core";
|
|
3
3
|
import { Coordinates as l, UserPosition as u } from "@wemap/geo";
|
|
4
4
|
//#region src/location-sources/LocationSource.ts
|
|
5
|
-
var d = class {
|
|
5
|
+
var d = 30, f = 30 * Math.PI / 180, p = class {
|
|
6
6
|
currentPose = {};
|
|
7
7
|
updateCallbacks = /* @__PURE__ */ new Set();
|
|
8
8
|
errorCallbacks = /* @__PURE__ */ new Set();
|
|
@@ -28,8 +28,9 @@ var d = class {
|
|
|
28
28
|
offError(e) {
|
|
29
29
|
this.errorCallbacks.delete(e);
|
|
30
30
|
}
|
|
31
|
-
configureMapMatching(e) {
|
|
32
|
-
|
|
31
|
+
configureMapMatching(e, t = "indoor") {
|
|
32
|
+
let n = c.getConfig()?.arNavigationData?.[t]?.mapmatching, i = typeof n?.maxAngleBearing == "number" ? n.maxAngleBearing * Math.PI / 180 : void 0;
|
|
33
|
+
r.maxDistance = e?.maxDistance ?? n?.maxDistance ?? d, r.maxAngleBearing = e?.maxAngleBearing ?? i ?? f, r.useOrientationMatching = e?.useOrientationMatching ?? n?.useOrientationMatching ?? !1, r.useStrict = e?.useStrict ?? n?.useStrict ?? !1;
|
|
33
34
|
}
|
|
34
35
|
mergeAndEmitUpdate(e) {
|
|
35
36
|
e.position !== void 0 && (this.currentPose.position = e.position), e.attitude !== void 0 && (this.currentPose.attitude = e.attitude), e.inclination !== void 0 && (this.currentPose.inclination = e.inclination), e.time !== void 0 && (this.currentPose.time = e.time), e.accuracy !== void 0 && (this.currentPose.accuracy = e.accuracy), this.emitUpdate({ ...this.currentPose });
|
|
@@ -66,7 +67,7 @@ var d = class {
|
|
|
66
67
|
t(e);
|
|
67
68
|
}));
|
|
68
69
|
}
|
|
69
|
-
},
|
|
70
|
+
}, m = 3e4, h = 30 * 6e4, g = !0, _ = 50, v = 100, y = class extends p {
|
|
70
71
|
absolutePositionProviderId = null;
|
|
71
72
|
absoluteAttitudeProviderId = null;
|
|
72
73
|
vpsProviderListenerId = null;
|
|
@@ -89,17 +90,18 @@ var d = class {
|
|
|
89
90
|
degradedLocationStateThreshold;
|
|
90
91
|
noPositioningLocationStateThreshold;
|
|
91
92
|
constructor(e = {}) {
|
|
92
|
-
super(), this.backgroundScanEnabled = e.vps?.backgroundScan ??
|
|
93
|
+
super(), this.backgroundScanEnabled = e.vps?.backgroundScan ?? g, this.degradedLocationStateThreshold = e.vps?.degradedLocationStateThreshold ?? _, this.noPositioningLocationStateThreshold = e.vps?.noPositioningLocationStateThreshold ?? v, this.configureVpsProvider(e.vps), this.configureMapMatching(e, "indoor"), e.usePositionSmoother !== !1 && (this.positionSmoother = new i((e) => {
|
|
93
94
|
this.mergeAndEmitUpdate({
|
|
94
95
|
position: e,
|
|
95
96
|
time: "time" in e ? e.time : Date.now(),
|
|
96
97
|
accuracy: "accuracy" in e ? e.accuracy : void 0
|
|
97
98
|
});
|
|
98
99
|
})), a.ignoreProviders = ["GnssWifi"];
|
|
99
|
-
let t = e.vps?.backgroundScanIntervalMs ??
|
|
100
|
+
let t = e.vps?.backgroundScanIntervalMs ?? m, n = e.vps?.backgroundScanMaxDurationMs ?? h;
|
|
100
101
|
this.backgroundScanner = new o({
|
|
101
102
|
enabled: this.backgroundScanEnabled,
|
|
102
|
-
intervalMs: t
|
|
103
|
+
intervalMs: t,
|
|
104
|
+
maxDurationMs: n
|
|
103
105
|
}, (e) => this.handleBackgroundVpsEvent(e), (e) => {
|
|
104
106
|
this.emitError(e);
|
|
105
107
|
}), this._backgroundScanStatus = this.backgroundScanEnabled ? "idle" : "disabled", this.backgroundScanner && (this.backgroundScanStatusUnsubscribe = this.backgroundScanner.onStatusChange((e) => {
|
|
@@ -156,7 +158,7 @@ var d = class {
|
|
|
156
158
|
let a = e?.waitTimeMinInclinationForRequest ?? t?.waitTimeMinInclinationForRequest;
|
|
157
159
|
a !== void 0 && (s.waitTimeMinInclinationForRequest = a);
|
|
158
160
|
let o = e?.useCoarsePose ?? t?.useCoarsePose;
|
|
159
|
-
o !== void 0 && (s.useCoarsePose = o), e?.requestCaller !== void 0 && (s.requestCaller = e.requestCaller);
|
|
161
|
+
o !== void 0 && (s.useCoarsePose = o), e?.maxScanDurationMs !== void 0 && (s.maxScanDuration = e.maxScanDurationMs), e?.requestCaller !== void 0 && (s.requestCaller = e.requestCaller);
|
|
160
162
|
}
|
|
161
163
|
async start() {
|
|
162
164
|
this.isStarted || (this.setupListeners(), this.isStarted = !0, this.backgroundScanEnabled ? this.backgroundScanner?.schedule() : this.setBackgroundScanStatus("disabled"));
|
|
@@ -168,7 +170,7 @@ var d = class {
|
|
|
168
170
|
await super.dispose(), this.backgroundScanStatusUnsubscribe?.(), this.backgroundScanStatusUnsubscribe = null, this.backgroundScanner?.clear(), this.scanStatusCallbacks.clear(), this.backgroundScanStatusCallbacks.clear();
|
|
169
171
|
}
|
|
170
172
|
async startScan() {
|
|
171
|
-
return await this.backgroundScanner?.cancelRunningScan(), this.startScanInternal();
|
|
173
|
+
return this.backgroundScanner?.resetBudget(), await this.backgroundScanner?.cancelRunningScan(), this.startScanInternal();
|
|
172
174
|
}
|
|
173
175
|
async startScanInternal() {
|
|
174
176
|
if (this.firstScan = !0, this.isStarted || await this.start(), await this.setupListeners(), this.vpsProviderListenerId !== null) return this.scanPromise ?? Promise.resolve(!1);
|
|
@@ -178,7 +180,7 @@ var d = class {
|
|
|
178
180
|
this.scanResolve = e, this.vpsProviderListenerId = s.addEventListener((t) => {
|
|
179
181
|
this.scanResolve = null, this.stopScan(), this.handleVpsEvent(t), this.backgroundScanner?.schedule(), e(!0);
|
|
180
182
|
}, (t) => {
|
|
181
|
-
this.scanResolve = null, this.emitError(t), this.backgroundScanner?.schedule(), e(!1);
|
|
183
|
+
this.scanResolve = null, this.stopScan(), this.emitError(t), this.backgroundScanner?.schedule(), e(!1);
|
|
182
184
|
});
|
|
183
185
|
}), this.scanPromise;
|
|
184
186
|
}
|
|
@@ -254,14 +256,14 @@ var d = class {
|
|
|
254
256
|
let t = this.lastPosition.distanceTo(e);
|
|
255
257
|
this.lastPosition = e, this.lastScanPosition && (this.distanceSinceLastScan += t, this.distanceSinceLastScan >= this.noPositioningLocationStateThreshold ? this.setLocationState("no_positioning") : this.distanceSinceLastScan >= this.degradedLocationStateThreshold ? this.setLocationState("degraded") : this.setLocationState("accurate"));
|
|
256
258
|
}
|
|
257
|
-
},
|
|
259
|
+
}, b = class extends p {
|
|
258
260
|
absolutePositionProviderId = null;
|
|
259
261
|
absoluteAttitudeProviderId = null;
|
|
260
262
|
gnssWifiErrorListenerId = null;
|
|
261
263
|
positionSmoother;
|
|
262
264
|
config;
|
|
263
265
|
constructor(e = {}) {
|
|
264
|
-
super(), this.config = e, this.configureGnssWifi(e.gnssWifi), this.configureMapMatching(e), e.usePositionSmoother !== !1 && (this.positionSmoother = new i((e) => {
|
|
266
|
+
super(), this.config = e, this.configureGnssWifi(e.gnssWifi), this.configureMapMatching(e, "outdoor"), e.usePositionSmoother !== !1 && (this.positionSmoother = new i((e) => {
|
|
265
267
|
this.mergeAndEmitUpdate({
|
|
266
268
|
position: e,
|
|
267
269
|
time: "time" in e ? e.time : Date.now(),
|
|
@@ -317,7 +319,7 @@ var d = class {
|
|
|
317
319
|
async dispose() {
|
|
318
320
|
this.gnssWifiErrorListenerId !== null && (n.removeEventListener(this.gnssWifiErrorListenerId), this.gnssWifiErrorListenerId = null), await super.dispose();
|
|
319
321
|
}
|
|
320
|
-
},
|
|
322
|
+
}, x = class {
|
|
321
323
|
static itinerary = null;
|
|
322
324
|
static setItinerary(e) {
|
|
323
325
|
this.itinerary = e, r.itinerary = e;
|
|
@@ -331,7 +333,7 @@ var d = class {
|
|
|
331
333
|
};
|
|
332
334
|
//#endregion
|
|
333
335
|
//#region src/utils/permissions.ts
|
|
334
|
-
async function
|
|
336
|
+
async function S() {
|
|
335
337
|
if (typeof DeviceMotionEvent < "u" && "requestPermission" in DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission == "function") try {
|
|
336
338
|
if (await DeviceMotionEvent.requestPermission() !== "granted") return !1;
|
|
337
339
|
} catch {
|
|
@@ -339,7 +341,7 @@ async function y() {
|
|
|
339
341
|
}
|
|
340
342
|
return !0;
|
|
341
343
|
}
|
|
342
|
-
async function
|
|
344
|
+
async function C() {
|
|
343
345
|
return new Promise((e) => {
|
|
344
346
|
n.addEventListener(() => {
|
|
345
347
|
e(!0);
|
|
@@ -349,4 +351,4 @@ async function b() {
|
|
|
349
351
|
});
|
|
350
352
|
}
|
|
351
353
|
//#endregion
|
|
352
|
-
export { l as Coordinates,
|
|
354
|
+
export { l as Coordinates, b as GnssWifiLocationSource, p as LocationSource, x as MapMatching, u as UserPosition, y as VPSLocationSource, C as requestLocationPermissions, S as requestSensorPermissions };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ILocationSource } from '../ILocationSource';
|
|
2
2
|
import { PartialPose, Pose, MapMatchingOptions, LocationState } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Which `arnavigationdata` section of the livemap snippet holds the map matching
|
|
5
|
+
* defaults for a source: VPS is an indoor sensor, GNSS/WiFi an outdoor one.
|
|
6
|
+
*/
|
|
7
|
+
export type MapMatchingProfile = 'indoor' | 'outdoor';
|
|
3
8
|
/**
|
|
4
9
|
* Base class for all location sources
|
|
5
10
|
*
|
|
@@ -92,11 +97,20 @@ export declare abstract class LocationSource implements ILocationSource {
|
|
|
92
97
|
*/
|
|
93
98
|
offError(callback: (error: Error) => void): void;
|
|
94
99
|
/**
|
|
95
|
-
* Configure map matching parameters
|
|
100
|
+
* Configure map matching parameters.
|
|
101
|
+
*
|
|
102
|
+
* Values come from the livemap snippet (`arnavigationdata.<profile>.mapmatching`)
|
|
103
|
+
* so a venue can tune matching without touching integration code; anything
|
|
104
|
+
* passed in `options` wins over the snippet.
|
|
105
|
+
*
|
|
106
|
+
* `MapMatchingHandler` is a singleton shared by every source, so each value is
|
|
107
|
+
* assigned unconditionally — leaving one out would silently keep whatever the
|
|
108
|
+
* previously created source put there.
|
|
96
109
|
*
|
|
97
|
-
* @param options - Map matching
|
|
110
|
+
* @param options - Map matching overrides from the integrator
|
|
111
|
+
* @param profile - Snippet section to read the defaults from
|
|
98
112
|
*/
|
|
99
|
-
protected configureMapMatching(options?: MapMatchingOptions): void;
|
|
113
|
+
protected configureMapMatching(options?: MapMatchingOptions, profile?: MapMatchingProfile): void;
|
|
100
114
|
/**
|
|
101
115
|
* Merge partial pose update into current pose and emit the complete pose
|
|
102
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationSource.d.ts","sourceRoot":"","sources":["../../../src/location-sources/LocationSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version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OAaG;IACH,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,kBAAkB,EAAE,OAAO,GAAE,kBAA6B,GAAG,IAAI;IAkB1G;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAsB5D;;;;OAIG;IACH,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAU7C;;;;OAIG;IACH,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAUvC;;;;OAIG;IACH,IAAI,aAAa,IAAI,aAAa,CAEjC;IAEM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI;IAItE,sBAAsB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI;IAI9E,SAAS,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI;CAS/D"}
|
|
@@ -26,6 +26,19 @@ export interface VPSLocationSourceConfig extends LocationSourceOptions {
|
|
|
26
26
|
backgroundScan?: boolean;
|
|
27
27
|
/** Interval in ms before triggering a background scan when no scan was triggered (default: 30000) */
|
|
28
28
|
backgroundScanIntervalMs?: number;
|
|
29
|
+
/**
|
|
30
|
+
* How long background scanning keeps running on its own before it stops and
|
|
31
|
+
* waits for the user to scan again (default: 30 minutes, `0` to never stop).
|
|
32
|
+
*
|
|
33
|
+
* Without it a page left open keeps scanning — and requesting — for as long
|
|
34
|
+
* as the tab lives. A manual {@link VPSLocationSource.startScan} re-arms it.
|
|
35
|
+
*/
|
|
36
|
+
backgroundScanMaxDurationMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* How long a single scan may keep requesting before giving up, in ms
|
|
39
|
+
* (default: 120000, `0` to never give up).
|
|
40
|
+
*/
|
|
41
|
+
maxScanDurationMs?: number;
|
|
29
42
|
/** Threshold for degraded location state (default: 50m) */
|
|
30
43
|
degradedLocationStateThreshold?: number;
|
|
31
44
|
/** Threshold for no positioning location state (default: 100m) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VPSLocationSource.d.ts","sourceRoot":"","sources":["../../../src/location-sources/VPSLocationSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAe,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,yCAAyC;IACzC,GAAG,CAAC,EAAE;QACJ,8DAA8D;QAC9D,iBAAiB;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,qEAAqE;QACrE,iBAAiB;QACjB,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,iFAAiF;QACjF,iBAAiB;QACjB,gCAAgC,CAAC,EAAE,MAAM,CAAC;QAC1C,sCAAsC;QACtC,iBAAiB;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gCAAgC;QAChC,iBAAiB;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,0GAA0G;QAC1G,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,qGAAqG;QACrG,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,2DAA2D;QAC3D,8BAA8B,CAAC,EAAE,MAAM,CAAC;QACxC,kEAAkE;QAClE,mCAAmC,CAAC,EAAE,MAAM,CAAC;KAC9C,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"VPSLocationSource.d.ts","sourceRoot":"","sources":["../../../src/location-sources/VPSLocationSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAe,MAAM,UAAU,CAAC;AACnE,OAAO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,IAAI,OAAO,CAAC,OAAO,CAAC;YAOrB,iBAAiB;IAkD/B;;;;;;;;;OASG;IACH;;OAEG;IACG,QAAQ,CAAC,SAAS,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;YAgBlC,cAAc;IAwC5B,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,0BAA0B;IAQlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAuDhC,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,8BAA8B;CA2BvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wemap/positioning",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.8.0-beta.0",
|
|
4
4
|
"description": "Indoor/outdoor positioning for the Wemap SDK.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Wemap SAS",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@wemap/core": "14.
|
|
41
|
-
"@wemap/geo": "14.
|
|
42
|
-
"@wemap/providers": "14.
|
|
43
|
-
"@wemap/routers": "14.
|
|
44
|
-
"@wemap/utils": "14.
|
|
40
|
+
"@wemap/core": "14.8.0-beta.0",
|
|
41
|
+
"@wemap/geo": "14.8.0-beta.0",
|
|
42
|
+
"@wemap/providers": "14.8.0-beta.0",
|
|
43
|
+
"@wemap/routers": "14.8.0-beta.0",
|
|
44
|
+
"@wemap/utils": "14.8.0-beta.0"
|
|
45
45
|
}
|
|
46
46
|
}
|