CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pynmea2

Python library for parsing and generating NMEA 0183 protocol messages used in GPS and marine navigation systems

77

1.11x
Overview
Eval results
Files

task.mdevals/scenario-5/

NMEA Log File Analyzer

A tool for analyzing NMEA 0183 log files containing GPS and navigation data from marine or GPS equipment.

Overview

Build a tool that processes NMEA log files to extract and analyze GPS position data from marine or aviation navigation equipment.

Requirements

File Processing

Read an NMEA log file containing multiple sentence types (GGA, RMC, etc.). The file has one sentence per line.

Data Extraction

Extract all valid GGA (GPS Fix Data) sentences from the log file. For each valid GGA sentence:

  • Record the timestamp
  • Extract latitude and longitude in decimal degrees
  • Extract altitude in meters
  • Validate that the GPS quality indicator shows a valid fix (quality > 0)

Summary Report

Generate a summary containing:

  • Total sentences processed from the file
  • Count of valid GGA fixes found
  • Average altitude across all valid fixes (2 decimal places)
  • First and last valid position with their timestamps

Implementation

@generates

API

def analyze_nmea_log(filepath: str) -> dict:
    """
    Analyzes an NMEA log file and extracts GPS position data.

    Args:
        filepath: Path to the NMEA log file

    Returns:
        A dictionary containing:
        - 'total_sentences': Total number of sentences in file
        - 'valid_fixes': Number of valid GGA fixes
        - 'average_altitude': Average altitude in meters (2 decimals)
        - 'first_fix': Dict with 'timestamp', 'lat', 'lon', 'altitude'
        - 'last_fix': Dict with 'timestamp', 'lat', 'lon', 'altitude'
    """
    pass

Test Cases

Counts sentences and valid fixes correctly

  • Given a log file with 10 sentences including 3 valid GGA fixes, returns total_sentences=10 and valid_fixes=3. @test

Extracts position data in decimal degrees

  • Given a log file with GGA sentences, extracts latitude and longitude as decimal degrees (e.g., 37.7749 for latitude). @test

Calculates average altitude

  • Given GGA fixes with altitudes 100m, 150m, and 200m, calculates average_altitude as 150.00. @test

Records first and last positions

  • Given multiple GGA fixes, correctly identifies the first and last valid fix with their timestamps. @test

Dependencies { .dependencies }

pynmea2 { .dependency }

Provides NMEA 0183 sentence parsing and file processing support.

Install with Tessl CLI

npx tessl i tessl/pypi-pynmea2

tile.json