MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_madoca_local_corr.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_madoca_local_corr.h : MADOCA local correction 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_madoca_local_corr.h
18 * @brief MRTKLIB MADOCA Local Correction Module — local correction common
19 * functions and constants.
20 *
21 * This header provides functions for local tropospheric and ionospheric
22 * correction data processing, extracted from lclcmn.c with zero algorithmic
23 * changes.
24 *
25 * @note Functions declared here are implemented in mrtk_madoca_local_corr.c.
26 */
27#ifndef MRTK_MADOCA_LOCAL_CORR_H
28#define MRTK_MADOCA_LOCAL_CORR_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
35#include "mrtklib/mrtk_nav.h"
36#include "mrtklib/mrtk_rtcm.h"
37#include "mrtklib/mrtk_time.h"
38
39/*============================================================================
40 * Local Correction Constants
41 *===========================================================================*/
42
43#define TYPE_TRP 0 /* data type of troposphere */
44#define TYPE_ION 1 /* data type of ionosphere */
45#define MAX_DIST_TRP 100.0 /* max distance for tropospheric correction (km) */
46#define MAX_DIST_ION 50.0 /* max distance for ionospheric correction (km) */
47#define MODE_PLANE 0 /* interpolation mode planer fitting */
48#define MODE_DISTWGT 1 /* interpolation mode weighted average of distance */
49#define BTYPE_GRID 0 /* block type grid */
50#define BTYPE_STA 1 /* block type station */
51#define ION_BLKSIZE 2.0 /* ionosphere block size */
52#define TRP_BLKSIZE 4.0 /* troposphere block size */
53#define MAX_STANAME 16 /* max length of station name */
54
55/*============================================================================
56 * Local Correction Common Functions
57 *===========================================================================*/
58
59/**
60 * @brief Search for a point by name or add a new point if not found.
61 * @param[in,out] stat Local correction data
62 * @param[in] pntname Point name
63 * @return Point index (>=0: found or added, 0: error)
64 */
65int getstano(stat_t* stat, const char* pntname);
66
67/**
68 * @brief Stack stat message and synchronize frame with stat preamble.
69 * @param[in,out] sstat Local correction data
70 * @param[in] data Stat 1-byte data
71 * @param[out] buff Buffer for message
72 * @param[in,out] nbyte Number of bytes
73 * @return Status (-1: error, 0: no message, 11: input stat messages)
74 */
75int input_stat(sstat_t* sstat, const char data, char* buff, int* nbyte);
76
77/**
78 * @brief Fetch next stat message and input a message from file.
79 * @param[in,out] sstat Local correction data
80 * @param[in] fp File pointer
81 * @param[out] buff Buffer for message
82 * @param[in,out] nbyte Number of bytes
83 * @return Status (-2: end of file, -1...11: same as input_stat())
84 */
85int input_statf(sstat_t* sstat, FILE* fp, char* buff, int* nbyte);
86
87/**
88 * @brief Calculate the Euclidean distance between two ECEF positions.
89 * @param[in] ecef1 Position 1 (ECEF coordinates)
90 * @param[in] ecef2 Position 2 (ECEF coordinates)
91 * @return Distance between the two positions (m)
92 */
93double posdist(const double* ecef1, const double* ecef2);
94
95/**
96 * @brief Get tropospheric correction for a point.
97 * @param[in] time Time (GPST)
98 * @param[in] trpd Tropospheric correction data
99 * @param[out] trp Tropospheric parameters {ztd, grade, gradn} (m)
100 * @param[out] std Standard deviation (m)
101 * @return Status (1:ok, 0:error)
102 */
103int get_trop_sta(gtime_t time, const trp_t* trpd, double* trp, double* std);
104
105/**
106 * @brief Get ionospheric correction for a point.
107 * @param[in] time Time (GPST)
108 * @param[in] iond Ionospheric correction data (MAXSAT elements)
109 * @param[out] ion Ionospheric delay for each satellite (m)
110 * @param[out] std Standard deviation (m)
111 * @param[out] el Elevation angle (rad)
112 * @return Number of valid corrections
113 */
114int get_iono_sta(gtime_t time, const ion_t* iond, double* ion, double* std, double* el);
115
116/**
117 * @brief Calculate tropospheric correction using weighted interpolation by
118 * distance.
119 * @param[in] stat Correction data
120 * @param[in] time Time (GPST)
121 * @param[in] llh Receiver position {lat, lon, hgt} (rad, m)
122 * @param[in] maxdist Max distance threshold (km)
123 * @param[out] trp Tropospheric parameters {ztd, grade, gradn} (m)
124 * @param[out] std Standard deviation (m)
125 * @return Status (1:ok, 0:error)
126 */
127int corr_trop_distwgt(const stat_t* stat, gtime_t time, const double* llh, double maxdist, double* trp, double* std);
128
129/**
130 * @brief Calculate ionospheric correction using weighted interpolation by
131 * distance.
132 * @param[in] stat Local correction data
133 * @param[in] time Time (GPST)
134 * @param[in] llh Receiver position {lat, lon, hgt} (rad, m)
135 * @param[in] el Receiver to satellite elevation (rad)
136 * @param[in] maxdist Max distance threshold (km)
137 * @param[out] ion L1 slant ionospheric delay for each sat (MAXSAT x 1)
138 * @param[out] std Standard deviation (m)
139 * @param[in] maxres Maximum residual threshold (m)
140 * @param[out] nrej Number of rejected stations
141 * @param[out] ncnt Number of counted stations
142 * @return Status (1:ok, 0:error)
143 */
144int corr_iono_distwgt(const stat_t* stat, gtime_t time, const double* llh, const double* el, double maxdist,
145 double* ion, double* std, double maxres, int* nrej, int* ncnt);
146
147/**
148 * @brief Convert RTCM3 block data to station statistics.
149 * @param[in,out] rtcm RTCM control struct
150 * @param[in,out] stat Station data struct
151 * @return Status (0: error, 1: success)
152 */
153int block2stat(rtcm_t* rtcm, stat_t* stat);
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* MRTK_MADOCA_LOCAL_CORR_H */
MRTKLIB Foundation — Common types, standard includes, and system constants (MAXSAT,...
double posdist(const double *ecef1, const double *ecef2)
Calculate the Euclidean distance between two ECEF positions.
int corr_trop_distwgt(const stat_t *stat, gtime_t time, const double *llh, double maxdist, double *trp, double *std)
Calculate tropospheric correction using weighted interpolation by distance.
int get_trop_sta(gtime_t time, const trp_t *trpd, double *trp, double *std)
Get tropospheric correction for a point.
int get_iono_sta(gtime_t time, const ion_t *iond, double *ion, double *std, double *el)
Get ionospheric correction for a point.
int input_statf(sstat_t *sstat, FILE *fp, char *buff, int *nbyte)
Fetch next stat message and input a message from file.
int getstano(stat_t *stat, const char *pntname)
Search for a point by name or add a new point if not found.
int corr_iono_distwgt(const stat_t *stat, gtime_t time, const double *llh, const double *el, double maxdist, double *ion, double *std, double maxres, int *nrej, int *ncnt)
Calculate ionospheric correction using weighted interpolation by distance.
int block2stat(rtcm_t *rtcm, stat_t *stat)
Convert RTCM3 block data to station statistics.
int input_stat(sstat_t *sstat, const char data, char *buff, int *nbyte)
Stack stat message and synchronize frame with stat preamble.
MRTKLIB Navigation Module — Navigation data types and satellite/nav utility functions.
static rtcm_t * rtcm
MRTKLIB RTCM Module — RTCM message types and functions.
MRTKLIB Time Module — GNSS time types and conversion functions.
GNSS time representation.
Definition mrtk_time.h:49
RTCM control struct type.
Definition mrtk_rtcm.h:50