Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/app/home/home.component.html
#	src/app/service/readjson.service.ts
This commit is contained in:
2023-04-06 14:30:25 +02:00
5 changed files with 111 additions and 114 deletions

View File

@@ -0,0 +1,25 @@
import {Injectable} from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CalculateDistanceService{
getDistanceBetweenCoordinates(lat1: number, lon1: number, lat2: number, lon2: number) {
const earthRadius = 6371; // Radius of the earth in km
const dLat = this.deg2rad(lat2 - lat1); // deg2rad below
const dLon = this.deg2rad(lon2 - lon1);
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2)
;
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
// Distance in km
return earthRadius * c;
}
deg2rad(deg: number) {
return deg * (Math.PI / 180)
}
}

View File

@@ -38,16 +38,18 @@ export class ReadjsonService{
tap(data => console.log("data requested", data))
);
}
/*
getWaypoints(location: string, id: number): Observable<waypoint[]> {
return this.locations.pipe(
map((locations) => {
const foundLocation: Locations | undefined = locations.find((loc: Locations) => loc.location === location);
return foundLocation ? foundLocation.waypoints.filter((way: waypoint) => way.id === id) : [];
}),
tap(data => console.log("data requested", data))
);
}
*/
// getWaypoints(location: string, id: number): Observable<waypoint[]> {
// return this.locations.pipe(
// map((locations) => {
// const foundLocation: Locations | undefined = locations.find((loc: Locations) => loc.location === location);
// return foundLocation ? foundLocation.waypoints.filter((way: waypoint) => way.id === id) : [];
// }),
// tap(data => console.log("data requested", data))
// );
// }
}