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 toHGT(antenna height in meters from the.possolution), allowingCheck_Nav -minmax -stdevto analyze GNSS vertical height statistics.time: Unix epoch timestamp (dtime) computed viastdtime_dmy_to_jul_day()andstdtime_from_jul_day().centisecs:0.velocity:0.0.flag[0..3]:0.
How It Works
- Initialization & File Opening:
POStoNavparses command-line flags, opens the target-compfile in"w+"mode (allowing both writing and subsequent reading for-flip), and if-flipis specified, opens<nav_outfile>.flipin"w+"mode. - Header Skipping & Line Parsing: For each input
.posfile, the first 8 header lines are read withfgets()and echoed to standard output. Every subsequent line is parsed at character offsets+33(date/time) and+193(DMS latitude, DMS longitude, and height). - Coordinate & Time Conversion:
- Calendar date
(Day, Month, Year)is converted to Julian day of year (JDay) usingstdtime_dmy_to_jul_day(), and then to integer epoch seconds (dtime) viastdtime_from_jul_day(). - Degrees, minutes, and seconds are combined into decimal degrees, preserving the sign of
LatDDandLonDD(subtracting minutes and seconds when degrees are negative).
- Calendar date
- Decimation & Reversal: A rolling counter
count(1 toskip) writes ajcu_nav_recvianav_write()whenevercount == skip. Progress is printed every 1,000 input lines. After each input file finishes, if-flipis active, the program loops backward fromtide_rec_no - 1down to0, reading each record fromtidefilewithnav_read()and writing it in reverse order toflipfile.