fixed calibrating
This commit is contained in:
parent
3b0d69b4c9
commit
432150f41b
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "map-alliance",
|
"name": "map-alliance",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve --host 0.0.0.0",
|
"start": "ng serve --host 0.0.0.0",
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<button mat-icon-button (click)="draw()" [ngClass]="{'selected': drawListener.length}"><mat-icon>create</mat-icon></button>
|
<button mat-icon-button (click)="draw()" [ngClass]="{'selected': drawListener.length}"><mat-icon>create</mat-icon></button>
|
||||||
<button mat-icon-button><mat-icon>straighten</mat-icon></button>
|
<button mat-icon-button><mat-icon>straighten</mat-icon></button>
|
||||||
<button mat-icon-button (click)="remove = !remove" [ngClass]="{'selected': remove}"><mat-icon>delete</mat-icon></button>
|
<button mat-icon-button (click)="remove = !remove" [ngClass]="{'selected': remove}"><mat-icon>delete</mat-icon></button>
|
||||||
<button *ngIf="physicsService.calibrate.value != null" mat-icon-button (click)="calibrate()"><mat-icon>explore</mat-icon></button>
|
<button *ngIf="!isNaN(position?.heading)" mat-icon-button (click)="calibrate()"><mat-icon>explore</mat-icon></button>
|
||||||
<button mat-icon-button [matMenuTriggerFor]="styleMenu"><mat-icon>layers</mat-icon></button>
|
<button mat-icon-button [matMenuTriggerFor]="styleMenu"><mat-icon>layers</mat-icon></button>
|
||||||
<mat-menu #styleMenu="matMenu">
|
<mat-menu #styleMenu="matMenu">
|
||||||
<button mat-menu-item (click)="style = 'satellite'" [ngClass]="{'selected': style == 'satellite'}">Satellite</button>
|
<button mat-menu-item (click)="style = 'satellite'" [ngClass]="{'selected': style == 'satellite'}">Satellite</button>
|
||||||
@ -32,8 +32,8 @@
|
|||||||
<span *ngIf="!position" class="text-danger">No GPS</span>
|
<span *ngIf="!position" class="text-danger">No GPS</span>
|
||||||
<div *ngIf="position" class="text-white">
|
<div *ngIf="position" class="text-white">
|
||||||
Heading:
|
Heading:
|
||||||
<span *ngIf="!position.heading" class="text-danger">No Heading</span>
|
<span *ngIf="isNaN(position.heading)" class="text-danger">No Heading</span>
|
||||||
<span *ngIf="position.heading">{{position.heading | number : '0.0-0'}}°</span>
|
<span *ngIf="!isNaN(position.heading)">{{position.heading | number : '0.0-0'}}°</span>
|
||||||
<br>
|
<br>
|
||||||
Latitude: {{position.latitude | number : '0.0-5'}}
|
Latitude: {{position.latitude | number : '0.0-5'}}
|
||||||
<br>
|
<br>
|
||||||
|
@ -24,9 +24,12 @@ export class MapComponent {
|
|||||||
style: 'satellite' | 'terrain' | 'roadmap' | 'hybrid' = 'terrain';
|
style: 'satellite' | 'terrain' | 'roadmap' | 'hybrid' = 'terrain';
|
||||||
version = version;
|
version = version;
|
||||||
|
|
||||||
|
isNaN = isNaN;
|
||||||
|
|
||||||
constructor(private bpObserver: BreakpointObserver, public physicsService: PhysicsService, private snackBar: MatSnackBar, private bottomSheet: MatBottomSheet) {
|
constructor(private bpObserver: BreakpointObserver, public physicsService: PhysicsService, private snackBar: MatSnackBar, private bottomSheet: MatBottomSheet) {
|
||||||
bpObserver.observe([Breakpoints.Handset]).subscribe(results => this.mobile = results.matches);
|
bpObserver.observe([Breakpoints.Handset]).subscribe(results => this.mobile = results.matches);
|
||||||
physicsService.info.pipe(filter(coord => !!coord), debounceTime(50)).subscribe(pos => {
|
physicsService.info.pipe(filter(coord => !!coord), debounceTime(50)).subscribe(pos => {
|
||||||
|
console.log('fire');
|
||||||
if(this.mapApi) {
|
if(this.mapApi) {
|
||||||
if(!this.position) this.center(pos);
|
if(!this.position) this.center(pos);
|
||||||
this.position = pos;
|
this.position = pos;
|
||||||
|
@ -10,7 +10,7 @@ export class PhysicsService {
|
|||||||
private motionTimestamp;
|
private motionTimestamp;
|
||||||
|
|
||||||
requireCalibration = new EventEmitter();
|
requireCalibration = new EventEmitter();
|
||||||
calibrate = new BehaviorSubject(0);
|
calibrate = new BehaviorSubject<number>(Infinity);
|
||||||
|
|
||||||
info = new BehaviorSubject(null);
|
info = new BehaviorSubject(null);
|
||||||
motion = new BehaviorSubject<DeviceMotionEvent>(null);
|
motion = new BehaviorSubject<DeviceMotionEvent>(null);
|
||||||
@ -54,13 +54,14 @@ export class PhysicsService {
|
|||||||
speed: data[0].coords.speed
|
speed: data[0].coords.speed
|
||||||
};
|
};
|
||||||
|
|
||||||
if(info.heading == null && !!data[1] && data[1].alpha) {
|
// TODO-debug
|
||||||
if(!data[1].absolute && this.calibrate.value == null) {
|
if(info.heading == null && data[1]) {
|
||||||
this.requireCalibration.emit();
|
if(!data[1].absolute && data[2] == Infinity) {
|
||||||
this.calibrate.next(0);
|
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 > 360) info.heading -= 360;
|
||||||
if(info.heading < 0) info.heading += 360;
|
if(info.heading < 0) info.heading += 360;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user