Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][inne][MySQL]GPS i koordynaty
Skorpiono
post 7.08.2016, 16:18:20
Post #1





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 31.10.2007

Ostrzeżenie: (0%)
-----


Witam, wlasnie po latach przerwy w programowaniu zaczalem pisac apke na komorke i musze zamienic koordynaty GPS wgs84 na metry, ktos z was zna przelicznik?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
Rysh
post 7.08.2016, 18:31:24
Post #2





Grupa: Zarejestrowani
Postów: 821
Pomógł: 111
Dołączył: 11.09.2006
Skąd: Biała Podlaska

Ostrzeżenie: (0%)
-----


Nie wiem co to ma wspólnego z PHP i MySQL ale znalazłem coś takiego:
http://gis.stackexchange.com/questions/865...itude/8674#8674


--------------------
Go to the top of the page
+Quote Post
Skorpiono
post 7.08.2016, 19:42:27
Post #3





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 31.10.2007

Ostrzeżenie: (0%)
-----


dzieki tego szukalem, ale mam jeszcze

Haversine
formula: a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
oblicza mi metry

umial by ktos to napisac w php?

Ten post edytował Skorpiono 7.08.2016, 19:46:48
Go to the top of the page
+Quote Post
Rysh
post 7.08.2016, 23:04:04
Post #4





Grupa: Zarejestrowani
Postów: 821
Pomógł: 111
Dołączył: 11.09.2006
Skąd: Biała Podlaska

Ostrzeżenie: (0%)
-----


Kolega ma chyba problem z szukaniem.
https://rosettacode.org/wiki/Haversine_formula#PHP
  1. class POI {
  2. private $latitude;
  3. private $longitude;
  4. public function __construct($latitude, $longitude) {
  5. $this->latitude = deg2rad($latitude);
  6. $this->longitude = deg2rad($longitude);
  7. }
  8. public function getLatitude() return $this->latitude;
  9. public function getLongitude() return $this->longitude;
  10. public function getDistanceInMetersTo(POI $other) {
  11. $radiusOfEarth = 6371000;// Earth's radius in meters.
  12. $diffLatitude = $other->getLatitude() - $this->latitude;
  13. $diffLongitude = $other->getLongitude() - $this->longitude;
  14. $a = sin($diffLatitude / 2) * sin($diffLatitude / 2) +
  15. cos($this->latitude) * cos($other->getLatitude()) *
  16. sin($diffLongitude / 2) * sin($diffLongitude / 2);
  17. $c = 2 * asin(sqrt($a));
  18. $distance = $radiusOfEarth * $c;
  19. return $distance;
  20. }
  21. }

  1. $user = new POI($_GET["latitude"], $_GET["longitude"]);
  2. $poi = new POI(19,69276, -98,84350); // Piramide del Sol, Mexico
  3. echo $user->getDistanceInMetersTo($poi);


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 12:55