From 432150f41b6bf34c9197af56111cd3bf4b6b466e Mon Sep 17 00:00:00 2001 From: ztimson Date: Thu, 11 Jul 2019 16:34:50 -0400 Subject: [PATCH] fixed calibrating --- package.json | 2 +- src/app/map/map.component.html | 6 +++--- src/app/map/map.component.ts | 3 +++ src/app/physics/physics.service.ts | 11 ++++++----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 834b5c6..54ee770 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "map-alliance", - "version": "1.0.0", + "version": "1.1.0", "scripts": { "ng": "ng", "start": "ng serve --host 0.0.0.0", diff --git a/src/app/map/map.component.html b/src/app/map/map.component.html index f423883..b377ae4 100644 --- a/src/app/map/map.component.html +++ b/src/app/map/map.component.html @@ -8,7 +8,7 @@ - + @@ -32,8 +32,8 @@ No GPS
Heading: - No Heading - {{position.heading | number : '0.0-0'}}° + No Heading + {{position.heading | number : '0.0-0'}}°
Latitude: {{position.latitude | number : '0.0-5'}}
diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index 93d2f8f..62de25c 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -24,9 +24,12 @@ export class MapComponent { style: 'satellite' | 'terrain' | 'roadmap' | 'hybrid' = 'terrain'; version = version; + isNaN = isNaN; + constructor(private bpObserver: BreakpointObserver, public physicsService: PhysicsService, private snackBar: MatSnackBar, private bottomSheet: MatBottomSheet) { bpObserver.observe([Breakpoints.Handset]).subscribe(results => this.mobile = results.matches); physicsService.info.pipe(filter(coord => !!coord), debounceTime(50)).subscribe(pos => { + console.log('fire'); if(this.mapApi) { if(!this.position) this.center(pos); this.position = pos; diff --git a/src/app/physics/physics.service.ts b/src/app/physics/physics.service.ts index d799b44..f4f637c 100644 --- a/src/app/physics/physics.service.ts +++ b/src/app/physics/physics.service.ts @@ -10,7 +10,7 @@ export class PhysicsService { private motionTimestamp; requireCalibration = new EventEmitter(); - calibrate = new BehaviorSubject(0); + calibrate = new BehaviorSubject(Infinity); info = new BehaviorSubject(null); motion = new BehaviorSubject(null); @@ -54,13 +54,14 @@ export class PhysicsService { speed: data[0].coords.speed }; - if(info.heading == null && !!data[1] && data[1].alpha) { - if(!data[1].absolute && this.calibrate.value == null) { - this.requireCalibration.emit(); + // TODO-debug + if(info.heading == null && data[1]) { + if(!data[1].absolute && data[2] == Infinity) { this.calibrate.next(0); + this.requireCalibration.emit(); } - info.heading = data[1].alpha + this.calibrate.value; + info.heading = data[1].alpha + (data[2] == Infinity ? 0 : data[2]); if(info.heading > 360) info.heading -= 360; if(info.heading < 0) info.heading += 360; }