Ignore:
Timestamp:
Sep 21, 2017, 4:05:40 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, debian/jessie
Children:
d3bfa78
Parents:
36a36bf (diff), 9773514 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into debian/jessie

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Rmc.php

    r36a36bf recee2e6  
    5555                        $this->_status = Nmea0183RmcStatus::A;
    5656               
    57                 $this->_latitude = (float)$content[3];
     57                $this->_latitude = Nmea0183Rmc::nmeaToDecimalDegrees($content[3]);
    5858                if(Nmea0183Rmc::directionToEnum($content[4]) == Nmea0183Direction::South)
    5959                        $this->_latitude = $this->_latitude * -1;
    6060               
    61                 $this->_longitude = (float)$content[5];
     61                $this->_longitude = Nmea0183Rmc::nmeaToDecimalDegrees($content[5]);
    6262                if(Nmea0183Rmc::directionToEnum($content[6]) == Nmea0183Direction::West)
    6363                        $this->_longitude = $this->_longitude * -1;
    … …  
    162162        }
    163163       
     164        private static function nmeaToDecimalDegrees($nmeaValue)
     165        {
     166                if((float)$nmeaValue == 0)
     167                        return 0;
     168
     169                $matches = array();
     170                $result = preg_match('/^([0-9]+)([0-9]{2}\.[0-9]+)$/', $nmeaValue, $matches);
     171                if($result === false || $result != 1 || count($matches) != 3){
     172                        $message = "Could not convert nmea position into decimal degress ". $nmeaValue;
     173                        error_log($message);
     174                        if($debug > 0)
     175                                print $message ."\n";
     176                        return 0;
     177                }
     178                $decimalDegrees = (float)$matches[1];
     179                $decimalMinutes = (float)$matches[2];
     180                return $decimalDegrees + ($decimalMinutes / 60.0);
     181        }
     182       
    164183        private $_dateTimeUtc;
    165184        private $_status;
Note: See TracChangeset for help on using the changeset viewer.