das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
form_geoloc.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Chris Piker <chris-piker@uiowa.edu>
2 *
3 * Author: C. Piker, via Claude Opus 5
4 *
5 * This file is part of das2C, the Core Das2 C Library.
6 *
7 * Das2C is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License version 2.1 as published
9 * by the Free Software Foundation.
10 *
11 * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
18 */
19
73#ifndef _das_form_geoloc_h_
74#define _das_form_geoloc_h_
75
76#include <das3/form.h>
77#include <das3/form_vector.h>
78
79#ifdef __cplusplus
80extern "C" {
81#endif
82
83/* --- component systems, the ellipsoidal half ----------------------------- *
84 *
85 * A surface is an ellipsoid reference, and detic/graphic are lat/lon/alt ON
86 * that ellipsoid, so the systems that need a surface are exactly the systems
87 * that need a center. They are therefore geoloc's, and a free vector cannot
88 * hold them -- form_vector.c refuses them by range.
89 *
90 * The codes CONTINUE form_vector.h's numbering rather than starting a second
91 * space, so one ubyte reads the same next to either formalism and a consumer
92 * like das3_spice can switch over all six in one statement.
93 *
94 * The das_geosys_* lookups below are the SUPERSET: they answer for all six by
95 * handling these two and delegating the rest downward. Call these when you
96 * may be holding either kind of form; call das_vsys_* only when you know it
97 * is a free vector.
98 */
99
100#define DAS_VSYS_DETIC 0x00000005 /* eastward lon, lat, alt (Earth) */
101#define DAS_VSYS_GRAPHIC 0x00000006 /* WESTWARD lon, lat, alt */
102
103#define DAS_VSYS_MAX 0x00000006
104
106DAS_API const char* das_geosys_str(ubyte uSys);
107
109DAS_API ubyte das_geosys_id(const char* sSys);
110
112DAS_API const char* das_geosys_desc(ubyte uSys);
113
115DAS_API const char* das_geosys_symbol(ubyte uSys, int iDir);
116
118DAS_API int8_t das_geosys_index(ubyte uSys, const char* sSymbol);
119
121#define das_geosys_isEllipsoidal(S) \
122 (((S) == DAS_VSYS_DETIC)||((S) == DAS_VSYS_GRAPHIC))
123
124/* Exported so that its address can be compared. Client code uses the
125 DAS_FORM_GEOLOC macro below and has no reason to name this directly. */
126DAS_API extern const DasForm_VTbl das_form_geoloc_vtbl;
127
131#define DAS_FORM_GEOLOC (&das_form_geoloc_vtbl)
132
144DAS_API DasForm* new_DasFormGeoLoc(
145 const char* sBody, const char* sFrame, const char* sSurface,
146 ubyte uSysType, const ubyte* pDirs
147);
148
151DAS_API const char* DasFormGeoLoc_body(const DasForm* pThis);
152
154DAS_API const char* DasFormGeoLoc_frame(const DasForm* pThis);
155
158DAS_API const char* DasFormGeoLoc_surface(const DasForm* pThis);
159
161DAS_API ubyte DasFormGeoLoc_sysType(const DasForm* pThis);
162
166DAS_API const ubyte* DasFormGeoLoc_dirs(const DasForm* pThis);
167
168/* For a component's display symbol -- "λ", "φ", "h" -- use DasVar_compSym(),
169 which works for every kind of composite value and not just this one. */
170
171/* To read a position datum's components use das_datum_toDoubles(). It returns
172 them in storage order.
173
174 A missing component of a position is zero, and there is no
175 das_geosys_default() to call because the answer is zero for every slot of all
176 six systems. This is where the two geometric formalisms differ:
177 das_vsys_default() gives a free vector's missing radius a value of 1, so that
178 a vector sent as angles alone reads as a direction. Positions get no such
179 treatment, since a radius of 1 would place a spacecraft one kilometre from
180 the body's center. */
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /* _das_form_geoloc_h_ */
What a variable's values (i.e.
DAS_API const char * das_geosys_symbol(ubyte uSys, int iDir)
The canonical symbol for direction iDir of any of the six.
DAS_API const char * das_geosys_desc(ubyte uSys)
One line of prose about any of the six, for a "notes" property.
DAS_API ubyte das_geosys_id(const char *sSys)
Wire token to code across all six, 0 if unrecognized.
DAS_API int8_t das_geosys_index(ubyte uSys, const char *sSymbol)
The inverse of das_geosys_symbol(), or -1 if the symbol is not in it.
DAS_API const char * das_geosys_str(ubyte uSys)
Wire token for any of the six system codes, NULL if unrecognized.
A frame-tagged geometric vector.