MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_rinex.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_rinex.h : RINEX file I/O type definitions and functions
3 *
4 * Copyright (C) 2026 H.SHIONO (MRTKLIB Project)
5 * Copyright (C) 2023-2025 Cabinet Office, Japan
6 * Copyright (C) 2024-2025 Lighthouse Technology & Consulting Co. Ltd.
7 * Copyright (C) 2023-2025 Japan Aerospace Exploration Agency
8 * Copyright (C) 2023-2025 TOSHIBA ELECTRONIC TECHNOLOGIES CORPORATION
9 * Copyright (C) 2015- Mitsubishi Electric Corp.
10 * Copyright (C) 2014 Geospatial Information Authority of Japan
11 * Copyright (C) 2014 T.SUZUKI
12 * Copyright (C) 2007-2023 T.TAKASU
13 *
14 * SPDX-License-Identifier: BSD-2-Clause
15 *----------------------------------------------------------------------------*/
16/**
17 * @file mrtk_rinex.h
18 * @brief MRTKLIB RINEX Module — RINEX file read/write types and functions.
19 *
20 * This header provides the RINEX option type (rnxopt_t), RINEX control
21 * struct (rnxctr_t), and all public RINEX read/write function declarations
22 * extracted from rinex.c.
23 *
24 * @note All functions in this module are pure cut-and-paste extractions
25 * from rinex.c with zero algorithmic changes.
26 */
27#ifndef MRTK_RINEX_H
28#define MRTK_RINEX_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <stdio.h>
35
36#include "mrtklib/mrtk_eph.h"
38#include "mrtklib/mrtk_nav.h"
39#include "mrtklib/mrtk_obs.h"
40#include "mrtklib/mrtk_time.h"
41
42/*============================================================================
43 * RINEX Types
44 *===========================================================================*/
45
46/**
47 * @brief RINEX options type.
48 */
49typedef struct { /* RINEX options type */
50 gtime_t ts, te; /* time start/end */
51 double tint; /* time interval (s) */
52 double ttol; /* time tolerance (s) */
53 double tunit; /* time unit for multiple-session (s) */
54 int rnxver; /* RINEX version (x100) */
55 int navsys; /* navigation system */
56 int obstype; /* observation type */
57 int freqtype; /* frequency type */
58 char mask[7][MAXCODE]; /* code mask {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
59 char staid[32]; /* station id for RINEX file name */
60 char prog[32]; /* program */
61 char runby[32]; /* run-by */
62 char marker[64]; /* marker name */
63 char markerno[32]; /* marker number */
64 char markertype[32]; /* marker type (ver.3) */
65 char name[2][32]; /* observer/agency */
66 char rec[3][32]; /* receiver #/type/vers */
67 char ant[3][32]; /* antenna #/type */
68 double apppos[3]; /* approx position x/y/z */
69 double antdel[3]; /* antenna delta h/e/n */
70 double glo_cp_bias[4]; /* GLONASS code-phase biases (m) */
71 char comment[MAXCOMMENT][64]; /* comments */
72 char rcvopt[256]; /* receiver dependent options */
73 uint8_t exsats[MAXSAT]; /* excluded satellites */
74 int glofcn[32]; /* glonass fcn+8 */
75 int outiono; /* output iono correction */
76 int outtime; /* output time system correction */
77 int outleaps; /* output leap seconds */
78 int autopos; /* auto approx position */
79 int phshift; /* phase shift correction */
80 int halfcyc; /* half cycle correction */
81 int sep_nav; /* separated nav files */
82 gtime_t tstart; /* first obs time */
83 gtime_t tend; /* last obs time */
84 gtime_t trtcm; /* approx log start time for rtcm */
85 char tobs[7][MAXOBSTYPE][4]; /* obs types {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
86 double shift[7][MAXOBSTYPE]; /* phase shift (cyc) {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
87 int nobs[7]; /* number of obs types {GPS,GLO,GAL,QZS,SBS,CMP,IRN} */
88} rnxopt_t;
89
90/**
91 * @brief RINEX control struct type.
92 */
93typedef struct { /* RINEX control struct type */
94 gtime_t time; /* message time */
95 int ver; /* RINEX version * 100 */
96 char type; /* RINEX file type ('O','N',...) */
97 int sys; /* navigation system */
98 int tsys; /* time system */
99 char tobs[8][MAXOBSTYPE][4]; /* rinex obs types */
100 obs_t obs; /* observation data */
101 nav_t nav; /* navigation data */
102 sta_t sta; /* station info */
103 int ephsat; /* input ephemeris satellite number */
104 int ephset; /* input ephemeris set (0-1) */
105 char opt[256]; /* rinex dependent options */
106} rnxctr_t;
107
108/*============================================================================
109 * RINEX Read Functions
110 *===========================================================================*/
111
112/**
113 * @brief Read RINEX OBS and NAV files.
114 * @param[in] file File path (wild-card * expanded) ("": stdin)
115 * @param[in] rcv Receiver number for obs data
116 * @param[in] opt RINEX options ("": no option)
117 * @param[in,out] obs Observation data (NULL: no input)
118 * @param[in,out] nav Navigation data (NULL: no input)
119 * @param[in,out] sta Station parameters (NULL: no input)
120 * @return Status (1:ok, 0:no data, -1:error)
121 */
122int readrnx(const char* file, int rcv, const char* opt, obs_t* obs, nav_t* nav, sta_t* sta);
123
124/**
125 * @brief Read RINEX OBS and NAV files with time span.
126 * @param[in] file File path (wild-card * expanded) ("": stdin)
127 * @param[in] rcv Receiver number for obs data
128 * @param[in] ts Observation time start (ts.time==0: no limit)
129 * @param[in] te Observation time end (te.time==0: no limit)
130 * @param[in] tint Observation time interval (s) (0:all)
131 * @param[in] opt RINEX options ("": no option)
132 * @param[in,out] obs Observation data (NULL: no input)
133 * @param[in,out] nav Navigation data (NULL: no input)
134 * @param[in,out] sta Station parameters (NULL: no input)
135 * @return Status (1:ok, 0:no data, -1:error)
136 */
137int readrnxt(const char* file, int rcv, gtime_t ts, gtime_t te, double tint, const char* opt, obs_t* obs, nav_t* nav,
138 sta_t* sta);
139
140/**
141 * @brief Read RINEX clock files.
142 * @param[in] file File path (wild-card * expanded)
143 * @param[in,out] nav Navigation data (NULL: no input)
144 * @return Number of precise clock records
145 */
146int readrnxc(const char* file, nav_t* nav);
147
148/*============================================================================
149 * RINEX Write Functions
150 *===========================================================================*/
151
152/**
153 * @brief Output RINEX observation data file header.
154 * @param[in] fp Output file pointer
155 * @param[in] opt RINEX options
156 * @param[in] nav Navigation data
157 * @return Status (1:ok, 0:output error)
158 */
159int outrnxobsh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
160
161/**
162 * @brief Output RINEX observation data body.
163 * @param[in] fp Output file pointer
164 * @param[in] opt RINEX options
165 * @param[in] obs Observation data
166 * @param[in] n Number of observation data
167 * @param[in] flag Epoch flag (0:ok,1:power failure,>1:event flag)
168 * @return Status (1:ok, 0:output error)
169 */
170int outrnxobsb(FILE* fp, const rnxopt_t* opt, const obsd_t* obs, int n, int flag);
171
172/**
173 * @brief Output RINEX navigation data file header.
174 * @param[in] fp Output file pointer
175 * @param[in] opt RINEX options
176 * @param[in] nav Navigation data (NULL: no input)
177 * @return Status (1:ok, 0:output error)
178 */
179int outrnxnavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
180
181/**
182 * @brief Output RINEX navigation data file body.
183 * @param[in] fp Output file pointer
184 * @param[in] opt RINEX options
185 * @param[in] eph Ephemeris
186 * @return Status (1:ok, 0:output error)
187 */
188int outrnxnavb(FILE* fp, const rnxopt_t* opt, const eph_t* eph);
189
190/**
191 * @brief Output RINEX GLONASS navigation data file header.
192 * @param[in] fp Output file pointer
193 * @param[in] opt RINEX options
194 * @param[in] nav Navigation data (NULL: no input)
195 * @return Status (1:ok, 0:output error)
196 */
197int outrnxgnavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
198
199/**
200 * @brief Output RINEX GLONASS navigation data file body.
201 * @param[in] fp Output file pointer
202 * @param[in] opt RINEX options
203 * @param[in] geph GLONASS ephemeris
204 * @return Status (1:ok, 0:output error)
205 */
206int outrnxgnavb(FILE* fp, const rnxopt_t* opt, const geph_t* geph);
207
208/**
209 * @brief Output RINEX GEO navigation data file header.
210 * @param[in] fp Output file pointer
211 * @param[in] opt RINEX options
212 * @param[in] nav Navigation data (NULL: no input)
213 * @return Status (1:ok, 0:output error)
214 */
215int outrnxhnavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
216
217/**
218 * @brief Output RINEX GEO navigation data file body.
219 * @param[in] fp Output file pointer
220 * @param[in] opt RINEX options
221 * @param[in] seph SBAS ephemeris
222 * @return Status (1:ok, 0:output error)
223 */
224int outrnxhnavb(FILE* fp, const rnxopt_t* opt, const seph_t* seph);
225
226/**
227 * @brief Output RINEX Galileo navigation data file header.
228 * @param[in] fp Output file pointer
229 * @param[in] opt RINEX options
230 * @param[in] nav Navigation data (NULL: no input)
231 * @return Status (1:ok, 0:output error)
232 */
233int outrnxlnavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
234
235/**
236 * @brief Output RINEX QZSS navigation data file header.
237 * @param[in] fp Output file pointer
238 * @param[in] opt RINEX options
239 * @param[in] nav Navigation data (NULL: no input)
240 * @return Status (1:ok, 0:output error)
241 */
242int outrnxqnavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
243
244/**
245 * @brief Output RINEX BDS navigation data file header.
246 * @param[in] fp Output file pointer
247 * @param[in] opt RINEX options
248 * @param[in] nav Navigation data (NULL: no input)
249 * @return Status (1:ok, 0:output error)
250 */
251int outrnxcnavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
252
253/**
254 * @brief Output RINEX NavIC/IRNSS navigation data file header.
255 * @param[in] fp Output file pointer
256 * @param[in] opt RINEX options
257 * @param[in] nav Navigation data (NULL: no input)
258 * @return Status (1:ok, 0:output error)
259 */
260int outrnxinavh(FILE* fp, const rnxopt_t* opt, const nav_t* nav);
261
262/*============================================================================
263 * RINEX Control Functions
264 *===========================================================================*/
265
266/**
267 * @brief Initialize RINEX control struct.
268 * @param[in,out] rnx RINEX control struct
269 * @return Status (1:ok, 0:memory allocation error)
270 */
271int init_rnxctr(rnxctr_t* rnx);
272
273/**
274 * @brief Free RINEX control struct buffers.
275 * @param[in,out] rnx RINEX control struct
276 */
277void free_rnxctr(rnxctr_t* rnx);
278
279/**
280 * @brief Open RINEX data (read header).
281 * @param[in,out] rnx RINEX control struct
282 * @param[in] fp File pointer
283 * @return Status (-2:end of file, 0:no message, 1:ok)
284 */
285int open_rnxctr(rnxctr_t* rnx, FILE* fp);
286
287/**
288 * @brief Input RINEX control (read next message).
289 * @param[in,out] rnx RINEX control struct
290 * @param[in] fp File pointer
291 * @return Status (-2:end of file, 0:no message, 1:obs data, 2:nav data)
292 */
293int input_rnxctr(rnxctr_t* rnx, FILE* fp);
294
295#ifdef __cplusplus
296}
297#endif
298
299#endif /* MRTK_RINEX_H */
#define MAXSAT
Definition mrtk_coords.c:45
MRTKLIB Broadcast Ephemeris Module — Satellite orbit/clock types and Kepler/GLONASS/SBAS orbit comput...
struct nav_s nav_t
Definition mrtk_eph.h:40
MRTKLIB Foundation — Common types, standard includes, and system constants (MAXSAT,...
#define MAXCODE
#define MAXCOMMENT
#define MAXOBSTYPE
MRTKLIB Navigation Module — Navigation data types and satellite/nav utility functions.
MRTKLIB Observation Module — Observation data types and utility functions.
int readrnxt(const char *file, int rcv, gtime_t ts, gtime_t te, double tint, const char *opt, obs_t *obs, nav_t *nav, sta_t *sta)
Read RINEX OBS and NAV files with time span.
int outrnxobsh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX observation data file header.
int init_rnxctr(rnxctr_t *rnx)
Initialize RINEX control struct.
int outrnxlnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX Galileo navigation data file header.
int outrnxgnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX GLONASS navigation data file header.
int outrnxnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX navigation data file header.
int open_rnxctr(rnxctr_t *rnx, FILE *fp)
Open RINEX data (read header).
int outrnxqnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX QZSS navigation data file header.
int outrnxhnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX GEO navigation data file header.
int outrnxnavb(FILE *fp, const rnxopt_t *opt, const eph_t *eph)
Output RINEX navigation data file body.
int outrnxobsb(FILE *fp, const rnxopt_t *opt, const obsd_t *obs, int n, int flag)
Output RINEX observation data body.
int readrnxc(const char *file, nav_t *nav)
Read RINEX clock files.
int outrnxgnavb(FILE *fp, const rnxopt_t *opt, const geph_t *geph)
Output RINEX GLONASS navigation data file body.
int readrnx(const char *file, int rcv, const char *opt, obs_t *obs, nav_t *nav, sta_t *sta)
Read RINEX OBS and NAV files.
int input_rnxctr(rnxctr_t *rnx, FILE *fp)
Input RINEX control (read next message).
int outrnxinavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX NavIC/IRNSS navigation data file header.
int outrnxcnavh(FILE *fp, const rnxopt_t *opt, const nav_t *nav)
Output RINEX BDS navigation data file header.
void free_rnxctr(rnxctr_t *rnx)
Free RINEX control struct buffers.
int outrnxhnavb(FILE *fp, const rnxopt_t *opt, const seph_t *seph)
Output RINEX GEO navigation data file body.
MRTKLIB Time Module — GNSS time types and conversion functions.
GPS/GAL/QZS/BDS/IRN broadcast ephemeris type.
Definition mrtk_eph.h:77
GLONASS broadcast ephemeris type.
Definition mrtk_eph.h:111
GNSS time representation.
Definition mrtk_time.h:49
Observation data collection.
Definition mrtk_obs.h:59
Observation data record.
Definition mrtk_obs.h:44
RINEX control struct type.
Definition mrtk_rinex.h:93
nav_t nav
Definition mrtk_rinex.h:101
char opt[256]
Definition mrtk_rinex.h:105
gtime_t time
Definition mrtk_rinex.h:94
obs_t obs
Definition mrtk_rinex.h:100
sta_t sta
Definition mrtk_rinex.h:102
char type
Definition mrtk_rinex.h:96
char tobs[8][MAXOBSTYPE][4]
Definition mrtk_rinex.h:99
RINEX options type.
Definition mrtk_rinex.h:49
double tint
Definition mrtk_rinex.h:51
uint8_t exsats[MAXSAT]
Definition mrtk_rinex.h:73
char rcvopt[256]
Definition mrtk_rinex.h:72
char marker[64]
Definition mrtk_rinex.h:62
char markertype[32]
Definition mrtk_rinex.h:64
char staid[32]
Definition mrtk_rinex.h:59
double antdel[3]
Definition mrtk_rinex.h:69
char markerno[32]
Definition mrtk_rinex.h:63
int rnxver
Definition mrtk_rinex.h:54
int outleaps
Definition mrtk_rinex.h:77
int outiono
Definition mrtk_rinex.h:75
int freqtype
Definition mrtk_rinex.h:57
char mask[7][MAXCODE]
Definition mrtk_rinex.h:58
int obstype
Definition mrtk_rinex.h:56
int autopos
Definition mrtk_rinex.h:78
int nobs[7]
Definition mrtk_rinex.h:87
int sep_nav
Definition mrtk_rinex.h:81
double shift[7][MAXOBSTYPE]
Definition mrtk_rinex.h:86
double tunit
Definition mrtk_rinex.h:53
int navsys
Definition mrtk_rinex.h:55
gtime_t te
Definition mrtk_rinex.h:50
double apppos[3]
Definition mrtk_rinex.h:68
char rec[3][32]
Definition mrtk_rinex.h:66
double glo_cp_bias[4]
Definition mrtk_rinex.h:70
char prog[32]
Definition mrtk_rinex.h:60
int phshift
Definition mrtk_rinex.h:79
int glofcn[32]
Definition mrtk_rinex.h:74
double ttol
Definition mrtk_rinex.h:52
char ant[3][32]
Definition mrtk_rinex.h:67
gtime_t ts
Definition mrtk_rinex.h:50
gtime_t trtcm
Definition mrtk_rinex.h:84
gtime_t tend
Definition mrtk_rinex.h:83
char comment[MAXCOMMENT][64]
Definition mrtk_rinex.h:71
int halfcyc
Definition mrtk_rinex.h:80
gtime_t tstart
Definition mrtk_rinex.h:82
char runby[32]
Definition mrtk_rinex.h:61
int outtime
Definition mrtk_rinex.h:76
char tobs[7][MAXOBSTYPE][4]
Definition mrtk_rinex.h:85
char name[2][32]
Definition mrtk_rinex.h:65
SBAS ephemeris type.
Definition mrtk_eph.h:130