Skip to content

Commit

Permalink
Another GPS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpop committed Mar 19, 2024
1 parent 98bee1f commit 283557a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,24 @@ function unmask_param($param)
*/
function gps($coordinate, $hemisphere)
{
if (is_string($coordinate)) {
$coordinate = array_map('trim', explode(',', $coordinate));
}
for ($i = 0; $i < 3; $i++) {
$part = explode('/', $coordinate[$i]);
if (count($part) == 1) {
$coordinate[$i] = $part[0];
} else if (count($part) == 2) {
$coordinate[$i] = floatval($part[0]) / floatval($part[1]);
} else {
$coordinate[$i] = 0;
if (!empty($coordinate) && !empty($hemisphere)) {
if (is_string($coordinate)) {
$coordinate = array_map('trim', explode(',', $coordinate));
}
for ($i = 0; $i < 3; $i++) {
$part = explode('/', $coordinate[$i]);
if (count($part) == 1) {
$coordinate[$i] = $part[0];
} else if (count($part) == 2) {
$coordinate[$i] = floatval($part[0]) / floatval($part[1]);
} else {
$coordinate[$i] = 0;
}
}
list($degrees, $minutes, $seconds) = $coordinate;
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
return $sign * ($degrees + $minutes / 60 + $seconds / 3600);
}
list($degrees, $minutes, $seconds) = $coordinate;
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
return $sign * ($degrees + $minutes / 60 + $seconds / 3600);
}
/* EXTRACT LATITUDE AND LONGITUDE ---END--- */

Expand Down

0 comments on commit 283557a

Please sign in to comment.