Some more updates

This commit is contained in:
Zakary Timson 2019-08-23 17:56:52 -04:00
parent 110c841d9d
commit 37a6ae92ae
3 changed files with 7 additions and 19 deletions

View File

@ -16,6 +16,7 @@ import {AngularFireModule} from "@angular/fire";
import {AngularFirestoreModule} from "@angular/fire/firestore";
import {ToolbarComponent} from "./components/toolbar/toolbar.component";
import {PaletteComponent} from "./components/palette/palette.component";
import {MarkerComponent} from "./components/marker/marker.component";
@NgModule({
declarations: [
@ -23,6 +24,7 @@ import {PaletteComponent} from "./components/palette/palette.component";
CalibrateComponent,
HomeComponent,
MapComponent,
MarkerComponent,
PaletteComponent,
PermissionsComponent,
ToolbarComponent
@ -39,7 +41,7 @@ import {PaletteComponent} from "./components/palette/palette.component";
MatInputModule,
],
providers: [],
entryComponents: [CalibrateComponent, PermissionsComponent],
entryComponents: [CalibrateComponent, MarkerComponent, PermissionsComponent],
bootstrap: [AppComponent]
})
export class AppModule {

View File

@ -19,7 +19,7 @@ export enum WeatherLayers {
TEMP_NEW
}
export const ARROW = L.icon({iconUrl: '/assets/images/arrow.png', iconSize: [50, 55], iconAnchor: [25, 28]});
export const ARROW = L.icon({iconUrl: '/assets/images/arrow.png', iconSize: [40, 45], iconAnchor: [20, 23]});
export const MARKER = L.icon({iconUrl: '/assets/images/marker.png', iconSize: [40, 55], iconAnchor: [20, 55]});
export class MapService {

View File

@ -15,7 +15,6 @@ export class PhysicsService {
motion = new BehaviorSubject<DeviceMotionEvent>(null);
orientation = new BehaviorSubject<DeviceOrientationEvent>(null);
position = new BehaviorSubject<Position>(null);
speed = new BehaviorSubject(null);
constructor(permissionsService: PermissionsService) {
permissionsService.requestPermission('geolocation', 'gps_fixed', 'Can we use your location?').then(granted => {
@ -24,23 +23,11 @@ export class PhysicsService {
window.addEventListener('deviceorientation', orientation => this.orientation.next(orientation));
window.addEventListener('devicemotion', motion => this.motion.next(motion));
navigator.geolocation.watchPosition(position => this.position.next(position));
// Calculate speed from motion events
this.motion.subscribe(event => {
if (!this.motionTimestamp) return this.motionTimestamp = new Date().getTime();
let currentTime = new Date().getTime();
let {speedX, speedY, speedZ} = this.speed.value || {speedX: 0, speedY: 0, speedZ: 0};
this.speed.next({
speedX: speedX + event.acceleration.x / 1000 * ((currentTime - this.motionTimestamp) / 1000) / 3600,
speedY: speedY + event.acceleration.y / 1000 * ((currentTime - this.motionTimestamp) / 1000) / 3600,
speedZ: speedZ + event.acceleration.z / 1000 * ((currentTime - this.motionTimestamp) / 1000) / 3600
});
this.motionTimestamp = currentTime;
});
navigator.geolocation.getCurrentPosition(e => console.log(e));
this.position.subscribe(e => console.log(e));
// Combine data into one nice package
combineLatest(this.position, this.orientation, this.calibrate, this.speed).subscribe(data => {
combineLatest(this.position, this.orientation, this.calibrate).subscribe(data => {
if(!data[0]) return;
let info = {
@ -63,7 +50,6 @@ export class PhysicsService {
if(info.heading < 0) info.heading += 360;
if(info.heading >= 360) info.heading -= 360;
}
if(info.speed == null && !!data[3]) info.speed = Math.sqrt(data[3].x**2 + data[3].y**2 + data[3].z**2);
this.info.next(info);
})