POStoNav

Description

POStoNav converts ASCII .pos PPP/GNSS position files generated by NRCan’s GPSpace software into OMG/JHC binary navigation files (.nav). Written by Ian Church in June 2007 as a modification of John Hughes Clarke’s NJWtoNav.c, POStoNav parses the fixed-column ASCII records after skipping the 8-line GPSpace header, converts degrees-minutes-seconds coordinates into signed decimal degrees, converts UTC calendar dates into standard Unix epoch timestamps, and stores the ellipsoidal/orthometric height (HGT) in the navigation record’s azi field.

The utility supports concatenating up to 300 input .pos files into a single continuous .nav file, decimating high-rate GNSS solutions via a record skip factor (-skip), and optionally generating a time-reversed copy of the binary navigation stream (-flip, producing <nav_outfile>.flip).

Usage

POStoNav [-v] [-flip] [-skip <N>] -comp <nav_outfile> <pos_infile1> [pos_infile2 ...]

Example Commands

Convert a single GPSpace .pos file into an OMG binary .nav file:

POStoNav -comp gps_solution.nav rover_day182.pos

Concatenate multiple .pos files, decimate by keeping every 6th record, and also write a time-reversed .nav.flip file:

POStoNav -v -flip -skip 6 -comp merged_gps.nav day182.pos day183.pos

CLI Arguments and Options

Flag / Argument Parameters Description
-v None Enables verbose mode (verbose_flag), printing parsed <lat> <lon> <HGT> <dtime> for each written record.
-flip None Creates an additional output file named <nav_outfile>.flip containing the output binary navigation records in reverse chronological order.
-skip <int> Record decimation interval (default: 1, meaning every record after the first is written). Setting -skip 6 writes 1 record out of every 6 input lines.
-comp <nav_outfile> Required. Path to the output OMG binary navigation file (.nav).
<pos_infile(s)> <file1> [...] One or more input ASCII .pos files produced by GPSpace (up to 300 files).

File Formats

Input Format: GPSpace ASCII (.pos)

Each input file begins with an 8-line text header (which POStoNav reads and echoes to stdout before printing Skipped Header), followed by fixed-width data lines containing columns:

STATION   DD-MM-YY   HR:MN:SS     GDOP   RES   ECEF-X(m)   ECEF-Y(m)   ECEF-Z(m)   LATDD LATMN LATSS   LONDD LONMN LONSS   HGT(m) ...

Specifically, POStoNav parses two fixed byte offsets from each line (my_string):

  • Byte offset +33: sscanf(my_string+33, "%f-%f-%f %f:%f:%f", &Year, &Month, &Day, &Hour, &Minute, &Second)
  • Byte offset +193: sscanf(my_string+193, "%lf %lf %lf %lf %lf %lf %f", &LatDD, &LatMN, &LatSS, &LonDD, &LonMN, &LonSS, &HGT)

Output Format: OMG Binary Navigation (.nav and .nav.flip)

  • Written via nav_write(FILE *, int rec_no, jcu_nav_rec *).
  • Fields populated in each jcu_nav_rec:
    • lat: Signed decimal degrees (LatDD +/- LatMN/60.0 +/- LatSS/3600.0).
    • lon: Signed decimal degrees (LonDD +/- LonMN/60.0 +/- LonSS/3600.0).
    • azi: Set to HGT (antenna height in meters from the .pos solution), allowing Check_Nav -minmax -stdev to analyze GNSS vertical height statistics.
    • time: Unix epoch timestamp (dtime) computed via stdtime_dmy_to_jul_day() and stdtime_from_jul_day().
    • centisecs: 0.
    • velocity: 0.0.
    • flag[0..3]: 0.

How It Works

  1. Initialization & File Opening: POStoNav parses command-line flags, opens the target -comp file in "w+" mode (allowing both writing and subsequent reading for -flip), and if -flip is specified, opens <nav_outfile>.flip in "w+" mode.
  2. Header Skipping & Line Parsing: For each input .pos file, the first 8 header lines are read with fgets() and echoed to standard output. Every subsequent line is parsed at character offsets +33 (date/time) and +193 (DMS latitude, DMS longitude, and height).
  3. Coordinate & Time Conversion:
    • Calendar date (Day, Month, Year) is converted to Julian day of year (JDay) using stdtime_dmy_to_jul_day(), and then to integer epoch seconds (dtime) via stdtime_from_jul_day().
    • Degrees, minutes, and seconds are combined into decimal degrees, preserving the sign of LatDD and LonDD (subtracting minutes and seconds when degrees are negative).
  4. Decimation & Reversal: A rolling counter count (1 to skip) writes a jcu_nav_rec via nav_write() whenever count == skip. Progress is printed every 1,000 input lines. After each input file finishes, if -flip is active, the program loops backward from tide_rec_no - 1 down to 0, reading each record from tidefile with nav_read() and writing it in reverse order to flipfile.