Changeset 8ef59a1 for src/webapp/webservice/inc
- Timestamp:
- Oct 30, 2017, 9:53:22 AM (9 years ago)
- Branches:
- debian/bullseye, debian/jessie
- Children:
- 8fd7454
- Parents:
- e86d691 (diff), 26f77a6 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Rmc.php
re86d691 r8ef59a1 55 55 $this->_status = Nmea0183RmcStatus::A; 56 56 57 $this->_latitude = Nmea0183Rmc::nmea ToDecimalDegrees($content[3]);57 $this->_latitude = Nmea0183Rmc::nmeaLatitudeToDecimalDegrees($content[3]); 58 58 if(Nmea0183Rmc::directionToEnum($content[4]) == Nmea0183Direction::South) 59 59 $this->_latitude = $this->_latitude * -1; 60 60 61 $this->_longitude = Nmea0183Rmc::nmea ToDecimalDegrees($content[5]);61 $this->_longitude = Nmea0183Rmc::nmeaLongitudeToDecimalDegrees($content[5]); 62 62 if(Nmea0183Rmc::directionToEnum($content[6]) == Nmea0183Direction::West) 63 63 $this->_longitude = $this->_longitude * -1; … … 162 162 } 163 163 164 private static function nmea ToDecimalDegrees($nmeaValue)164 private static function nmeaLatitudeToDecimalDegrees($nmeaValue) 165 165 { 166 166 if((float)$nmeaValue == 0) … … 168 168 169 169 $matches = array(); 170 $result = preg_match('/^([0-9] +)([0-9]{2}\.[0-9]+)$/', $nmeaValue, $matches);170 $result = preg_match('/^([0-9]{2})([0-9]{2}\.[0-9]+)$/', $nmeaValue, $matches); 171 171 if($result === false || $result != 1 || count($matches) != 3){ 172 $message = "Could not convert nmea position into decimal degress ". $nmeaValue;172 $message = "Could not convert nmea latitude position into decimal degress ". $nmeaValue; 173 173 error_log($message); 174 if($debug > 0)175 print $message ."\n";176 174 return 0; 177 175 } … … 180 178 return $decimalDegrees + ($decimalMinutes / 60.0); 181 179 } 182 180 181 private static function nmeaLongitudeToDecimalDegrees($nmeaValue) 182 { 183 if((float)$nmeaValue == 0) 184 return 0; 185 186 $matches = array(); 187 $result = preg_match('/^([0-9]{3})([0-9]{2}\.[0-9]+)$/', $nmeaValue, $matches); 188 if($result === false || $result != 1 || count($matches) != 3){ 189 $message = "Could not convert nmea longitude position into decimal degress ". $nmeaValue; 190 error_log($message); 191 return 0; 192 } 193 $decimalDegrees = (float)$matches[1]; 194 $decimalMinutes = (float)$matches[2]; 195 return $decimalDegrees + ($decimalMinutes / 60.0); 196 } 197 183 198 private $_dateTimeUtc; 184 199 private $_status;
Note:
See TracChangeset
for help on using the changeset viewer.
