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

This commit is contained in:
tito
2023-04-23 14:41:51 +02:00
3 changed files with 33 additions and 32 deletions

View File

@@ -14,7 +14,6 @@
<h1>
{{location.location}}
</h1>
{{location.waypoints[0].name}}
<div *ngFor="let waypoinst of location.waypoints, let i = index">
<h3>
<a class="link link-primary" href="location/{{location.location}}/{{waypoinst.id}}"> {{waypoinst.name}}</a>

View File

@@ -42,7 +42,7 @@ export class ListComponent implements OnInit, OnChanges {
});
}
});
this.getPosition();
}
ngOnChanges(changes: SimpleChanges) {
@@ -69,31 +69,33 @@ export class ListComponent implements OnInit, OnChanges {
}
private setDistance(): void {
const intervalId = setInterval(() => {
if (this.location) {
if (this.location?.waypoints) {
console.log("setDistance"+this.location);
for (let i = 0; i < this.location.waypoints.length; i++) {
console.log("for")
this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.location.waypoints[i].lat, this.location?.lon, this.positionCord.lat, this.positionCord.lon));
}
clearInterval(intervalId);
if (this.locations && this.location){
if (this.isNear){
console.log("location lenght " + this.locations.length);
for (let i = 0; i < this.locations.length; i++) {
console.log("for"+i);
console.log("lat" + this.locations[i].lat);
this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.locations[i].lat, this.locations[i].lon, this.positionCord.lat, this.positionCord.lon));
}
} else{
if (this.location?.waypoints) {
console.log("waypoints lenght " + this.location.waypoints.length);
for (let i = 0; i < this.location.waypoints.length; i++) {
console.log("for"+i);
console.log("lat" + this.location.waypoints[i].lat);
this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.location.waypoints[i].lat, this.location.waypoints[i].lon, this.positionCord.lat, this.positionCord.lon));
}
}
}
}
console.log("ciao" + this.distance[0])
}}, 1000);
//da aggiungere il cambiamento in tutti i punti, forse fatto ma sono stanco
}
getDistance(latLocation: number | undefined, lonLocation: number | undefined): any {
getPosition(): any {
setInterval(async () => {
this.positionCord = await this.positionService.getLocation();
if (this.location) {
return this.positionService.getDistanceBetweenCoordinates(latLocation, lonLocation, this.positionCord.lat, this.positionCord.lon);
} else {
return 0;
}
}, 1000);
this.setDistance();
}, 2000);
}