Filtres test ok

This commit is contained in:
Romain Verger 2022-02-18 10:11:52 +01:00
parent a97d444fe1
commit e96f370497
6 changed files with 134 additions and 114 deletions

View file

@ -85,8 +85,5 @@
<button type="button" class="button">Réserver</button>
</div>
</div>
</div>
</div>

View file

@ -1,4 +1,5 @@
import { Component,EventEmitter, Input, Output, OnInit } from '@angular/core';
import { ApiBackService } from '../services/api-back.service';
@Component({
selector: 'app-card-resto',
@ -13,7 +14,7 @@ export class CardRestoComponent implements OnInit {
@Output() clickLike = new EventEmitter<boolean>();
isLiked : boolean = false;
constructor() {
constructor(private apiBackService : ApiBackService) {
this.distance = 0 ;
}
@ -22,7 +23,7 @@ export class CardRestoComponent implements OnInit {
console.log(this.restaurant);
this.distance = Math.round(
this.getDistanceFromLatLonInKm(
this.apiBackService.setDistance(
48.86201110271593 , //latitude Simplon
2.4361804827725417, //longitude Simplon
this.restaurant.latitude,
@ -39,23 +40,6 @@ export class CardRestoComponent implements OnInit {
this.clickLike.emit(this.isLiked);
}
getDistanceFromLatLonInKm(lat1 : number , lon1 : number, lat2 : number, lon2 : number) {
let R = 6371; // Radius of the earth in km
let dLat = this.deg2rad(lat2-lat1); // deg2rad below
let dLon = this.deg2rad(lon2-lon1);
let 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)
;
let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
let d = R * c * 1000; // Distance in meters
return d;
}
deg2rad(deg : number) {
return deg * (Math.PI/180)
}