Swap to english + new folder position
continuous-integration/drone/push Build is passing Details

messagerie_lucas_test
Dorian HODIN 2 years ago
parent 9cb2612da0
commit d170a1f611

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:dafl_project_flutter/views/pages/main/w_bottomsheet.dart'; import 'package:dafl_project_flutter/views/pages/main/w_bottomsheet.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import './model/location.dart'; import 'position/location.dart';
import 'package:vibration/vibration.dart'; import 'package:vibration/vibration.dart';
import 'dart:math'; import 'dart:math';
import './views/pages/home/p_home.dart'; import './views/pages/home/p_home.dart';

@ -8,13 +8,12 @@ class Location {
if (permission == LocationPermission.denied) { if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission(); permission = await Geolocator.requestPermission();
if (permission == LocationPermission.deniedForever) { if (permission == LocationPermission.deniedForever) {
//faire l'interface graphique pour gérer ça
return Future.error('Location Not Available'); return Future.error('Location Not Available');
} }
} }
Position current = await Geolocator.getCurrentPosition(); Position current = await Geolocator.getCurrentPosition();
double long = current.longitude; return Tuple2(current.longitude,current.latitude);
double lat = current.latitude;
return Tuple2(long,lat);
} }
} }

@ -2,10 +2,10 @@
class distance class distance
{ {
public function distentre2co($lat1, $lng1, $lat2, $lng2) { public function meters($lat1, $lng1, $lat2, $lng2) {
// Rayon de la Terre en mètres : // Radius of the Earth in meters :
$earth_radius = 6378137; $earth_radius = 6378137;
// Calcul de la distance entre 2 coordonées GPS : // Calculation of the distance between 2 GPS coordinates:
$rlo1 = deg2rad($lng1); $rlo1 = deg2rad($lng1);
$rla1 = deg2rad($lat1); $rla1 = deg2rad($lat1);
$rlo2 = deg2rad($lng2); $rlo2 = deg2rad($lng2);
@ -14,34 +14,35 @@ class distance
$dla = ($rla2 - $rla1) / 2; $dla = ($rla2 - $rla1) / 2;
$a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo)); $a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo));
$d = 2 * atan2(sqrt($a), sqrt(1 - $a)); $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); return round($earth_radius * $d);
} }
} }
class ListeUser class ListUser
{ {
public function Liste() { public function ListOfUser() {
$listeUser = ["001","002","003"]; $listUser = ["001","002","003"];
// Coordonées actuelles de l'User dans $lat1 et $lng1 // Actual coordinates of User in $lat1 and $lng1
$lat1 = 45.891773; $lat1 = 45.891773;
$lng1 = 4.662613; $lng1 = 4.662613;
//parcours de toute les coordonées stockées dans le serveur PHP et entrée dans dist //traverse of all the coordinates stored in the PHP server
// for les co :
$userID = "004"; $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 ){ 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 "Normalement pas beaucoup = ";
echo (new distance)->distentre2co(45.891773, 4.662613,45.777222,3.087025); echo (new distance)->distentre2co(45.891773, 4.662613,45.777222,3.087025);
*/
echo "\nListe User = "; echo "\nListe User = ";
echo implode(",",(new ListeUser)->Liste()); echo implode(",",(new ListUser)->ListOfUser());

Loading…
Cancel
Save