Changes in / [8ef59a1:e86d691]


Ignore:
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • debian/changelog

    r8ef59a1 re86d691  
    1 gnuboat (0.5.2) jessie; urgency=low
    2 
    3   * Fixed NMEA0183 position format
    4   * Added checksum fix feature to gnuboat-log-converter
    5 
    6  -- EngSaS - Maintainer <info@engsas.de>  Mon, 30 Oct 2017 11:00:00 +0100
    71gnuboat (0.5.1) jessie; urgency=low
    82
  • setup.py

    r8ef59a1 re86d691  
    2626setup(
    2727  name="gnuboat",
    28   version="0.4.8",
     28  version="0.4.7",
    2929  maintainer="EngSaS - Langenbach",
    3030  maintainer_email="info@engsas.de",
    … …  
    3232  license="GNU General Public License v3 or later (GPLv3+)",
    3333  keywords="",
    34   url="http://trac.engsas.de/gnuboat",
     34  url="http://trac.falaba.de/gnuboat",
    3535  package_dir={'': 'src/python'},
    3636  packages=find_packages("src/python"),
  • src/python/bin/gnuboat

    r8ef59a1 re86d691  
    107107        nmeafile.write('{}{}\r\n'.format(logsystemtime, str(pynmea2.RMC('GN', 'RMC',
    108108                                                     (gpsTime.strftime("%H%M%S"), gpsStatus,
    109                                                      '{:02d}{:07.4f}'.format(latitude['degrees'], latitude['minutes']),
     109                                                     '{:02d}{}'.format(latitude['degrees'], latitude['minutes']),
    110110                                                     latitudeDirection,
    111                                                      '{:03d}{:07.4f}'.format(longitude['degrees'], longitude['minutes']),
     111                                                     '{:03d}{}'.format(longitude['degrees'], longitude['minutes']),
    112112                                                     longitudeDirection,
    113113                                                     '{:04.1f}'.format(speedOverGround), '{:04.1f}'.format(courseOverGround),
  • src/python/bin/gnuboat-log-converter

    r8ef59a1 re86d691  
    3434
    3535regex_nmea_sentence = re.compile(r"^([^\$!]{0,})([\$!]{1}[\w]{2}[\w]{3}[^\*]+\*[\da-zA-Z]+)$")
    36 regex_nmea_sentence_without_checksum = re.compile(r"^([^\$!]{0,})([\$!]{1}[\w]{2}[\w]{3}[^\*]+)\*[\da-zA-Z]+$")
    37 regex_nmea_position_latitude = re.compile(r"^([0-9]{2})([0-9]{2}\.[0-9]+)$")
    38 regex_nmea_position_longitude = re.compile(r"^([0-9]{3})([0-9]{2}\.[0-9]+)$")
     36regex_nmea_position = re.compile(r"^([0-9]+)([0-9]{2}\.[0-9]+)$")
    3937
    4038def toFloat(string, current_row):
    … …  
    4846           return 0
    4947
    50 def nmeaLatitudeToDecimalDegrees(nmea_value, current_row):
    51     global regex_nmea_position_latitude
     48def nmeaToDecimalDegrees(nmea_value, current_row):
     49    global regex_nmea_position
    5250
    5351    if toFloat(nmea_value, current_row) == 0:
    5452        return 0
    5553
    56     matches = regex_nmea_position_latitude.match(nmea_value)
     54    matches = regex_nmea_position.match(nmea_value)
    5755    if matches is None:
    58         print('INFO: Failed to convert latitude position value from line {} into decimal degrees: {}'.format(current_row, nmea_value))
     56        print('INFO: Failed to convert position value from line {} into decimal degrees: {}'.format(current_row, nmea_value))
    5957        return
    6058    decimalDegrees = toFloat(matches.group(1), current_row)
    … …  
    6260    return decimalDegrees + (decimalMinutes / 60.0)
    6361
    64 def nmeaLongitudeToDecimalDegrees(nmea_value, current_row):
    65     global regex_nmea_position_longitude
    66 
    67     if toFloat(nmea_value, current_row) == 0:
    68         return 0
    69 
    70     matches = regex_nmea_position_longitude.match(nmea_value)
    71     if matches is None:
    72         print('INFO: Failed to convert longitude position value from line {} into decimal degrees: {}'.format(current_row, nmea_value))
    73         return
    74     decimalDegrees = toFloat(matches.group(1), current_row)
    75     decimalMinutes = toFloat(matches.group(2), current_row)
    76     return decimalDegrees + (decimalMinutes / 60.0)
    77 
    78 def convertToCsv(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time):
     62def convertToCsv(input_file_path, output_file_path, errors_ignore, strip_time):
    7963    global regex_nmea_sentence
    80     global regex_nmea_sentence_without_checksum
    8164
    8265    try:
    … …  
    10487    for line in input_file:
    10588        line = line.strip()
    106         if checksums_fix:
    107             matches = regex_nmea_sentence_without_checksum.match(line)
    108             pynmea_parse_check = False
    109         else:
    110             matches = regex_nmea_sentence.match(line)
    111             pynmea_parse_check = True
     89        matches = regex_nmea_sentence.match(line)
    11290        if matches is None:
    11391            print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row))
    … …  
    11795                sys.exit(4)
    11896        else:
    119             nmea_sentence = pynmea2.parse(matches.group(2), check=pynmea_parse_check)
     97            nmea_sentence = pynmea2.parse(matches.group(2))
    12098            if nmea_sentence.sentence_type == 'RMC':
    12199                if last_row is not None:
    … …  
    123101                last_row = {'datetime': '{} {}'.format(nmea_sentence.datestamp, nmea_sentence.timestamp),
    124102                            'gps_status': nmea_sentence.status,
    125                             'latitude': nmeaLatitudeToDecimalDegrees(nmea_sentence.lat, current_row),
     103                            'latitude': nmeaToDecimalDegrees(nmea_sentence.lat, current_row),
    126104                            'latitude_direction': nmea_sentence.lat_dir,
    127                             'longitude': nmeaLongitudeToDecimalDegrees(nmea_sentence.lon, current_row),
     105                            'longitude': nmeaToDecimalDegrees(nmea_sentence.lon, current_row),
    128106                            'longitude_direction': nmea_sentence.lon_dir,
    129107                            'speed_over_ground': toFloat(nmea_sentence.spd_over_grnd, current_row),
    … …  
    141119    input_file.close()
    142120
    143 def convertToNmea0183(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time):
     121def convertToNmea0183(input_file_path, output_file_path, errors_ignore, strip_time):
    144122    global regex_nmea_sentence
    145     global regex_nmea_sentence_without_checksum
    146123
    147124    try:
    … …  
    161138    for line in input_file:
    162139        line = line.strip()
    163         if checksums_fix:
    164             matches = regex_nmea_sentence_without_checksum.match(line)
    165             pynmea_parse_check = False
    166         else:
    167             matches = regex_nmea_sentence.match(line)
    168             pynmea_parse_check = True
     140        matches = regex_nmea_sentence.match(line)
    169141        if matches is None:
    170142            print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row))
    … …  
    174146                sys.exit(4)
    175147        else:
    176             nmea_sentence = pynmea2.parse(matches.group(2), check=pynmea_parse_check)
     148            nmea_sentence = pynmea2.parse(matches.group(2))
    177149            output_string = str(nmea_sentence)
    178150            if not strip_time and matches.group(1):
    … …  
    182154    input_file.close()
    183155   
    184 def convertToGpx(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time):
     156def convertToGpx(input_file_path, output_file_path, errors_ignore, strip_time):
     157    global regex_nmea_sentence
     158   
    185159    # make sure, nmea input file, does not have timestamps in front of the nmea
    186160    # sentences
    187161    [nmea_without_timestamps_handle, nmea_without_timestamp_file_path] = tempfile.mkstemp(text=True)
    188     convertToNmea0183(input_file_path, nmea_without_timestamp_file_path, errors_ignore, checksums_fix, True)
     162    convertToNmea0183(input_file_path, nmea_without_timestamp_file_path, errors_ignore, True)
    189163   
    190164    subprocess.call(['gpsbabel', '-i', 'nmea', '-f', nmea_without_timestamp_file_path, '-o', 'gpx', '-F', output_file_path])
    … …  
    208182    parser.add_argument('-i', '--ignore-errors', dest='errors_ignore', action='store_false',
    209183                        help='Ignore any errors reading the log file')
    210     parser.add_argument('-c', '--checksums-fix', dest='checksums_fix', action='store_true',
    211                         help='Ignore all checksums (and replace them with a new correct one, if needed)')
    212184    parser.add_argument('input_file', metavar='input_file_path', type=str,
    213185                        help='File to be converted (input)')
    … …  
    231203        errors_ignore = arguments.errors_ignore
    232204       
    233     if arguments.checksums_fix is not None:
    234         checksums_fix = arguments.checksums_fix
    235        
    236205    if arguments.strip_time is not None:
    237206        strip_time = arguments.strip_time
    … …  
    240209        print('ERROR: No input file specified')
    241210        sys.exit(2)
    242     #elif not os.path.exists(arguments.input_file):
     211    elif not os.path.exists(arguments.input_file):
    243212        print('ERROR: Specified input file does not exists: {}'.format(arguments.input_file))
    244213        sys.exit(3)
    … …  
    256225
    257226    if output_format == Format.CSV.value:
    258         convertToCsv(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time)
     227        convertToCsv(input_file_path, output_file_path, errors_ignore, strip_time)
    259228    elif output_format == Format.NMEA0183.value:
    260         convertToNmea0183(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time)
     229        convertToNmea0183(input_file_path, output_file_path, errors_ignore, strip_time)
    261230    elif output_format == Format.GPX.value:
    262         convertToGpx(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time)
     231        convertToGpx(input_file_path, output_file_path, errors_ignore, strip_time)
    263232    else:
    264233        print('ERROR: Undefined output format!\n')
  • src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Rmc.php

    r8ef59a1 re86d691  
    5555                        $this->_status = Nmea0183RmcStatus::A;
    5656               
    57                 $this->_latitude = Nmea0183Rmc::nmeaLatitudeToDecimalDegrees($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 = Nmea0183Rmc::nmeaLongitudeToDecimalDegrees($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 nmeaLatitudeToDecimalDegrees($nmeaValue)
     164        private static function nmeaToDecimalDegrees($nmeaValue)
    165165        {
    166166                if((float)$nmeaValue == 0)
    … …  
    168168
    169169                $matches = array();
    170                 $result = preg_match('/^([0-9]{2})([0-9]{2}\.[0-9]+)$/', $nmeaValue, $matches);
     170                $result = preg_match('/^([0-9]+)([0-9]{2}\.[0-9]+)$/', $nmeaValue, $matches);
    171171                if($result === false || $result != 1 || count($matches) != 3){
    172                         $message = "Could not convert nmea latitude position into decimal degress ". $nmeaValue;
     172                        $message = "Could not convert nmea position into decimal degress ". $nmeaValue;
    173173                        error_log($message);
     174                        if($debug > 0)
     175                                print $message ."\n";
    174176                        return 0;
    175177                }
    … …  
    178180                return $decimalDegrees + ($decimalMinutes / 60.0);
    179181        }
    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 
     182       
    198183        private $_dateTimeUtc;
    199184        private $_status;
  • src/webapp/webservice/tests/Nmea0183RmcTest.php

    r8ef59a1 re86d691  
    8383                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 22, false
    8484                        ],
    85                         "position_conversion" => [
    86                                 '$GPRMC,191410,A,4735.5634,N,00739.3538,E,0.0,0.0,181102,0.4,E,A*19',
    87                                 "GP", "rmc", DateTime::createFromFormat($format, "2002-11-18 19:14:10", new DateTimeZone("UTC")),
    88                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 47.5927, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    89                                 7.6558, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    90                                 0, 0, 0.4, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    91                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 19, true
    92                         ],
    93                         "position_conversion_lon" => [
    94                                 '$GNRMC,133014,A,4825.64749998,N,01002.55130002,E,00.0,337.9,281017,,,A*51',
    95                                 "GN", "rmc", DateTime::createFromFormat($format, "2017-10-28 13:30:14", new DateTimeZone("UTC")),
    96                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 48.4274, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    97                                 10.0425, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    98                                 0, 337.9, 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid,
    99                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 51, true
    100                         ],
    10185                        "valid1" => [
    102                                 '$GPRMC,122548,A,4735.4480,N,01042.6240,E,10.0,115.6,131006,1.2,E,A*2D',
     86                                '$GPRMC,122548,A,4735.4480,N,1042.6240,E,10.0,115.6,131006,1.2,E,A*1D',
    10387                                "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 12:25:48", new DateTimeZone("UTC")),
    10488                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 47.5908, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    10589                                10.7104, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    10690                                10, 115.6, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    107                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '2d', true
     91                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1d', true
    10892                        ],
    10993                        "valid2" => [
    110                                 '!GPRMC,162614,A,4735.4480,S,01042.6240,E,10.0,90,131006,,,A*72',
     94                                '!GPRMC,162614,A,4735.4480,S,1042.6240,E,10.0,90,131006,,,A*42',
    11195                                "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
    11296                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, -47.5908, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::South,
    11397                                10.7104, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    11498                                10, 90, 0, false,
    115                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '72', true
     99                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '42', true
    116100                        ],
    117101                        "valid3" => [
    118                                 '$GNRMC,162614,A,7305.4480,N,01042.6240,W,10.0,90,131006,1.2,E,A*F',
     102                                '$GNRMC,162614,A,735.4480,N,01042.6240,W,10.0,90,131006,1.2,E,A*3F',
    119103                                "GN", "rmc", DateTime::createFromFormat($formatMilli, "2006-10-13 16:26:14.123", new DateTimeZone("UTC")),
    120                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 73.0908, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
     104                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 7.5908, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    121105                                -10.7104, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::West,
    122106                                10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    123                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 'f', true
     107                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '3f', true
    124108                        ]
    125109                ];
  • src/webapp/webservice/tests/NmeaTest.php

    r8ef59a1 re86d691  
    6666                                "empty" => ['0183', '', null, false],
    6767                                "unsupported_format" => ['abc', '', null, false],
    68                                 "rmc0183" => ['0183', '$GNRMC,122548,A,4735.4480,N,01042.6240,E,00.0,115.6,110917,,,A*50', Nmea0183\Nmea0183Rmc::class, true],
     68                                "rmc0183" => ['0183', '$GNRMC,122548,A,4735.4480,N,1042.6240,E,00.0,115.6,110917,,,A*60', Nmea0183\Nmea0183Rmc::class, true],
    6969                                "dpt0183" => ['0183', '$SDDPT,00.71,00.00*51', Nmea0183\Nmea0183Dpt::class, true],
    7070                                "mtw0183" => ['0183', '$YXMTW,26.3,C*15', Nmea0183\Nmea0183Mtw::class, true],
    71                                 "rmc0183timestamp" => ['0183', '2017-09-11 13:20:42: $GNRMC,122548,A,4735.4480,N,01042.6240,E,00.0,115.6,110917,,,A*50', Nmea0183\Nmea0183Rmc::class, true],
     71                                "rmc0183timestamp" => ['0183', '2017-09-11 13:20:42: $GNRMC,122548,A,4735.4480,N,1042.6240,E,00.0,115.6,110917,,,A*60', Nmea0183\Nmea0183Rmc::class, true],
    7272                        ];
    7373                }
  • src/webapp/webservice/tests/ServiceTest.php

    r8ef59a1 re86d691  
    6666                $webservice->process();
    6767                $output = $this->getActualOutput();
    68                 $this->assertJsonStringEqualsJsonString('{"track":{"1503767412":{"latitude":1.001,"longitude":1.001,"speedthroughwater":"-","speedoverground":11,"courseoverground":21,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767413":{"latitude":2.0186666666667001,"longitude":2.0186666666667001,"speedthroughwater":"-","speedoverground":12,"courseoverground":22,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767414":{"latitude":3.1696666666666999,"longitude":3.1696666666666999,"speedthroughwater":"-","speedoverground":13,"courseoverground":23,"waterdepth":1,"watertemperature":21,"gpsfix":"-"},"1503767415":{"latitude":4.004,"longitude":4.004,"speedthroughwater":"-","speedoverground":14,"courseoverground":24,"waterdepth":2,"watertemperature":22,"gpsfix":"-"},"1503767416":{"latitude":5.005,"longitude":5.005,"speedthroughwater":"-","speedoverground":15,"courseoverground":25,"waterdepth":3,"watertemperature":23,"gpsfix":"-"}}}', $output);
     68                $this->assertJsonStringEqualsJsonString('{"track":{"1503767412":{"latitude":10.001,"longitude":1.001,"speedthroughwater":"-","speedoverground":11,"courseoverground":21,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767413":{"latitude":20.002,"longitude":2.002,"speedthroughwater":"-","speedoverground":12,"courseoverground":22,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767414":{"latitude":30.003,"longitude":3.003,"speedthroughwater":"-","speedoverground":13,"courseoverground":23,"waterdepth":1,"watertemperature":21,"gpsfix":"-"},"1503767415":{"latitude":40.004,"longitude":4.004,"speedthroughwater":"-","speedoverground":14,"courseoverground":24,"waterdepth":2,"watertemperature":22,"gpsfix":"-"},"1503767416":{"latitude":50.005,"longitude":5.005,"speedthroughwater":"-","speedoverground":15,"courseoverground":25,"waterdepth":3,"watertemperature":23,"gpsfix":"-"}}}', $output);
    6969        }
    7070}
  • src/webapp/webservice/tests/logs/replay-test.log

    r8ef59a1 re86d691  
    1 $GNRMC,171012,A,0100.060,N,00100.060,E,11.0,21.0,260817,,,A*63
    2 $GNRMC,171013,A,0201.120,N,00201.120,E,12.0,22.0,260817,,,A*62
    3 $GNRMC,171014,A,0310.180,N,00310.180,E,13.0,23.0,260817,,,A*65
     1$GNRMC,171012,A,001000.060,N,0000100.060,E,11.0,21.0,260817,,,A*63
     2$GNRMC,171013,A,002000.120,N,0000200.120,E,12.0,22.0,260817,,,A*62
     3$GNRMC,171014,A,003000.180,N,0000300.180,E,13.0,23.0,260817,,,A*65
    44$SDDPT,01.00,00.00*56
    55$YXMTW,21.0,C*11
    6 $GNRMC,171015,A,0400.240,N,00400.240,E,14.0,24.0,260817,,,A*64
     6$GNRMC,171015,A,004000.240,N,0000400.240,E,14.0,24.0,260817,,,A*64
    77$SDDPT,02.00,00.00*55
    88$YXMTW,22.0,C*12
    9 $GNRMC,171016,A,0500.300,N,00500.300,E,15.0,25.0,260817,,,A*67
     9$GNRMC,171016,A,005000.300,N,0000500.300,E,15.0,25.0,260817,,,A*67
    1010$SDDPT,03.00,00.00*54
    1111$YXMTW,23.0,C*13
Note: See TracChangeset for help on using the changeset viewer.