?>

Translation coordinates nmea in degrees for use in Yandex and Google maps. Php gist.

Translation coordinates nmea in degrees for use in Yandex and Google maps. Php gist.

During the implementation of one interesting project (related to GPS navigation), the data comes to the server from GPS in the nmea format. And the coordinates, in turn, for use in the web need additional processing.

I leave a small gist coordinate transformation in the php language.

During the implementation of one interesting project (related to GPS navigation), the data comes to the server from GPS in the nmea format. And the coordinates, in turn, for use in the web need additional processing.

I leave a small gist coordinate transformation in the php language.

Php Function:

/**
* Перевод координат nmea в градусы
*
* @param $nmeagps
* @return float|int
*/
static public function nmeaCoordinatesToDouble($nmeagps)
{
    $intDeg = (int) ($nmeagps/100);
    $result = $intDeg + ($nmeagps - 100*$intDeg)/60;
    return $result;
}

Usage example:

class Test{
    function test() {
       self::nmeaCoordinatesToDouble(5501.2346); //результат 55.020576666667
    }
}

All Comments (0)
No Comments