protected function parseGpsCoordinate($coordinate, $hemisphere)
{
$coordinates = explode(' ', $coordinate);
for ($i = 0; $i < 3; $i++) {
$part = explode('/', $coordinates[$i]);
$parts = count($part);
if ($parts === 1) {
$coordinates[$i] = $part[0];
} else {
if ($parts === 2) {
$coordinates[$i] = floatval($part[0]) / floatval($part[1]);
} else {
$coordinates[$i] = 0;
}
}
}
$sign = $hemisphere === 'W' || $hemisphere === 'S' ? -1 : 1;
$degrees = $coordinates[0] + $coordinates[1] / 60 + $coordinates[2] / 3600;
return $sign * $degrees;
}