From d170a1f611384a4eb6ce43b894e3a936a3828ad1 Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 7 Nov 2022 17:22:00 +0100 Subject: [PATCH] Swap to english + new folder position --- Sources/dafl_project_flutter/lib/main.dart | 2 +- .../lib/position/.gitkeep | 0 .../lib/{model => position}/location.dart | 5 ++- Sources/phpLocation/distance.php | 35 ++++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 Sources/dafl_project_flutter/lib/position/.gitkeep rename Sources/dafl_project_flutter/lib/{model => position}/location.dart (83%) diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index cb038cc..7abb724 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:dafl_project_flutter/views/pages/main/w_bottomsheet.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import './model/location.dart'; +import 'position/location.dart'; import 'package:vibration/vibration.dart'; import 'dart:math'; import './views/pages/home/p_home.dart'; diff --git a/Sources/dafl_project_flutter/lib/position/.gitkeep b/Sources/dafl_project_flutter/lib/position/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Sources/dafl_project_flutter/lib/model/location.dart b/Sources/dafl_project_flutter/lib/position/location.dart similarity index 83% rename from Sources/dafl_project_flutter/lib/model/location.dart rename to Sources/dafl_project_flutter/lib/position/location.dart index 4524c1a..c7e6884 100644 --- a/Sources/dafl_project_flutter/lib/model/location.dart +++ b/Sources/dafl_project_flutter/lib/position/location.dart @@ -8,13 +8,12 @@ class Location { if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); if (permission == LocationPermission.deniedForever) { + //faire l'interface graphique pour gérer ça return Future.error('Location Not Available'); } } Position current = await Geolocator.getCurrentPosition(); - double long = current.longitude; - double lat = current.latitude; - return Tuple2(long,lat); + return Tuple2(current.longitude,current.latitude); } } diff --git a/Sources/phpLocation/distance.php b/Sources/phpLocation/distance.php index 7924fa0..3bd8552 100644 --- a/Sources/phpLocation/distance.php +++ b/Sources/phpLocation/distance.php @@ -2,10 +2,10 @@ class distance { - public function distentre2co($lat1, $lng1, $lat2, $lng2) { - // Rayon de la Terre en mètres : + public function meters($lat1, $lng1, $lat2, $lng2) { + // Radius of the Earth in meters : $earth_radius = 6378137; - // Calcul de la distance entre 2 coordonées GPS : + // Calculation of the distance between 2 GPS coordinates: $rlo1 = deg2rad($lng1); $rla1 = deg2rad($lat1); $rlo2 = deg2rad($lng2); @@ -14,34 +14,35 @@ class distance $dla = ($rla2 - $rla1) / 2; $a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo)); $d = 2 * atan2(sqrt($a), sqrt(1 - $a)); - // Return la distance en mètre entre les deux coordonées + // Return the distance in meters between 2 GPS points return round($earth_radius * $d); } } -class ListeUser +class ListUser { - public function Liste() { - $listeUser = ["001","002","003"]; - // Coordonées actuelles de l'User dans $lat1 et $lng1 + public function ListOfUser() { + $listUser = ["001","002","003"]; + // Actual coordinates of User in $lat1 and $lng1 $lat1 = 45.891773; $lng1 = 4.662613; - //parcours de toute les coordonées stockées dans le serveur PHP et entrée dans dist - // for les co : + //traverse of all the coordinates stored in the PHP server $userID = "004"; - $dist = (new distance)->distentre2co($lat1,$lng1,45.777222,3.087025); + $dist = (new distance)->meters($lat1,$lng1,45.777222,3.087025); if ($dist <= 100 ){ - $listeUser[] = $userID; + $listUser[] = $userID; } - return $listeUser; + return $listUser; } } + +echo "Normalement pas bcp = "; +echo (new distance)->meters(45.762595,3.108837,45.762524,3.1088743); /* -echo "Normalement 597833 = "; -echo (new distance)->distentre2co(48.86417880,2.34250440,43.6008177,3.8873392); -*/ echo "Normalement pas beaucoup = "; echo (new distance)->distentre2co(45.891773, 4.662613,45.777222,3.087025); +*/ echo "\nListe User = "; -echo implode(",",(new ListeUser)->Liste()); +echo implode(",",(new ListUser)->ListOfUser()); +