OpenCPN Partial API docs
tcmgr.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Tide and Current Manager
5  * Author: David Register
6  * Todo add original author
7  *
8  ***************************************************************************
9  * Copyright (C) 2010 by David S. Register *
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  * This program is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19  * GNU General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU General Public License *
22  * along with this program; if not, write to the *
23  * Free Software Foundation, Inc., *
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25  **************************************************************************/
26 
27 #ifndef __TCMGR_H__
28 #define __TCMGR_H__
29 
30 #include <map>
31 #include <vector>
32 
33 #include "Station_Data.h"
34 #include "IDX_entry.h"
35 #include "TC_Error_Code.h"
36 #include "TCDataSource.h"
37 
38 // ----------------------------------------------------------------------------
39 // external C linkages
40 // ----------------------------------------------------------------------------
41 
42 //----------------------------------------------------------------------------
43 // constants
44 //----------------------------------------------------------------------------
45 
46 #define USF_REMOVE 1
47 #define USF_UPDATE 2
48 #define USF_WRITE 3
49 
50 #ifndef M_PI
51 #define M_PI 3.141592654
52 #endif
53 
54 #define TIDE_MAX_DERIV (2) // Maximum derivative supported
55 /* TIDE_TIME_PREC
56  * Precision (in seconds) to which we will find roots
57  */
58 #define TIDE_TIME_PREC (15)
59 
60 /* TIDE_TIME_BLEND
61  * Half the number of seconds over which to blend the tides from
62  * one epoch to the next.
63  */
64 #define TIDE_BLEND_TIME (3600)
65 
66 /* TIDE_TIME_STEP
67  * We are guaranteed to find all high and low tides as long as their
68  * spacing is greater than this value (in seconds).
69  */
70 #define TIDE_TIME_STEP (TIDE_TIME_PREC)
71 #define TIDE_BAD_TIME ((time_t)-1)
72 
73 //----------------------------------------------------------------------------
74 // Reference Station Data
75 //----------------------------------------------------------------------------
76 
77 typedef struct {
78  Station_Data *sta_data;
79  void *next;
80 } mru_entry;
81 
82 //----------------------------------------------------------------------------
83 // TCMgr
84 //----------------------------------------------------------------------------
85 
86 class TCMgr {
87 public:
88  TCMgr();
89  ~TCMgr();
90 
91  TC_Error_Code LoadDataSources(std::vector<std::string> &sources);
92  std::vector<std::string> GetDataSet(void) { return m_sourcefile_array; }
93 
94  bool IsReady(void) { return bTCMReady; }
95 
96  bool GetTideOrCurrent(time_t t, int idx, float &value, float &dir);
97  bool GetTideOrCurrent15(time_t t, int idx, float &tcvalue, float &dir,
98  bool &bnew_val);
99  bool GetTideFlowSens(time_t t, int sch_step, int idx, float &tcvalue_now,
100  float &tcvalue_prev, bool &w_t);
101  void GetHightOrLowTide(time_t t, int sch_step_1, int sch_step_2,
102  float tide_val, bool w_t, int idx, float &tcvalue,
103  time_t &tctime);
104 
105  int GetStationTimeOffset(IDX_entry *pIDX);
106  int GetNextBigEvent(time_t *tm, int idx);
107  double GetStationLat(IDX_entry *pIDX);
108  double GetStationLon(IDX_entry *pIDX);
109 
110  const IDX_entry *GetIDX_entry(int index) const;
111 
112  int Get_max_IDX() const { return m_Combined_IDX_array.size() - 1; }
113 
114  std::map<double, const IDX_entry *> GetStationsForLL(double xlat,
115  double xlon) const;
116 
117  int GetStationIDXbyName(const wxString &prefix, double xlat,
118  double xlon) const;
119  int GetStationIDXbyNameType(const wxString &prefix, double xlat, double xlon,
120  char type) const;
121  void ScrubCurrentDepths();
122 
123 private:
124  void PurgeData();
125 
126  void LoadMRU(void);
127  void SaveMRU(void);
128  void AddMRU(Station_Data *psd);
129  void FreeMRU(void);
130 
131  bool bTCMReady;
132  wxString pmru_file_name;
133 
134  ArrayOfTCDSources m_source_array;
135  std::vector<std::string> m_sourcefile_array;
136 
137  std::vector<IDX_entry *> m_Combined_IDX_array;
138 };
139 
140 /* $Id: tcd.h.in 3744 2010-08-17 22:34:46Z flaterco $ */
141 /* tcd.h. Generated from tcd.h.in by configure. */
142 
143 #ifndef __OAML_TIDES_H__
144 #define __OAML_TIDES_H__
145 
146 /*****************************************************************************
147  *
148  * DISTRIBUTION STATEMENT
149  *
150  * This source file is unclassified, distribution unlimited, public
151  * domain. It is distributed in the hope that it will be useful, but
152  * WITHOUT ANY WARRANTY; without even the implied warranty of
153  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
154  *
155  ******************************************************************************/
156 
157 /*
158  * Data types for libtcd API
159  * Formerly nvtypes.h, NAVO Standard Data Type Definitions
160  *
161  * This section may appear slightly different from one platform to the
162  * next. The build process for libtcd generates #includes and data
163  * type definitions as needed to provide integer types of specific
164  * sizes.
165  */
166 
167 /* Generated includes */
168 #include <sys/types.h>
169 #ifndef __WXMSW__
170 #include <inttypes.h>
171 
172 /* Generated data types */
173 #define NV_BYTE int8_t
174 #define NV_INT16 int16_t
175 #define NV_INT32 int32_t
176 #define NV_INT64 int64_t
177 #define NV_U_BYTE uint8_t
178 #define NV_U_INT16 uint16_t
179 #define NV_U_INT32 uint32_t
180 #define NV_U_INT64 uint64_t
181 #else
182 #define NV_BYTE unsigned char
183 #define NV_INT16 short
184 #define NV_INT32 int
185 #define NV_INT64 long
186 #define NV_U_BYTE unsigned char
187 #define NV_U_INT16 unsigned short
188 #define NV_U_INT32 unsigned int
189 #define NV_U_INT64 unsigned long
190 
191 #endif
192 
193 /* Hard-coded data types */
194 #define NV_BOOL unsigned char
195 #define NV_CHAR char
196 #define NV_U_CHAR unsigned char
197 #define NV_FLOAT32 float
198 #define NV_FLOAT64 double
199 
200 /* Defined values */
201 #define NVFalse 0
202 #define NVTrue 1
203 #define NV_U_INT32_MAX 4294967295
204 #define NV_INT32_MAX 2147483647
205 #define NV_U_INT16_MAX 65535
206 #define NV_INT16_MAX 32767
207 
208 #define LIBTCD_VERSION "PFM Software - libtcd v2.2.5 - 2010-08-17"
209 #define LIBTCD_MAJOR_REV 2
210 #define LIBTCD_MINOR_REV 2
211 
212 /*
213  * COMPAT114 is defined here if and only if libtcd was compiled with
214  * --enable-COMPAT114. COMPAT114 forces API changes to enable
215  * applications written against the v1 API to build with more recent
216  * libraries and successfully interact with v2 TCD files. This will
217  * BREAK applications expecting the v2 API. It is for localized use
218  * only (libraries built with this option should not be distributed).
219  */
220 #undef COMPAT114
221 
222 /* Select #warning versus #pragma message (whichever works) */
223 #undef USE_PRAGMA_MESSAGE
224 
225 #ifdef COMPAT114
226 #ifdef USE_PRAGMA_MESSAGE
227 #pragma message("WARNING: COMPAT114 is enabled! See libtcd.html.")
228 #else
229 #warning COMPAT114 is enabled! See libtcd.html.
230 #endif
231 #endif
232 
233 /* Maximum values. */
234 
235 /* One-line character strings */
236 #define ONELINER_LENGTH 90
237 /* Verbose character strings */
238 #define MONOLOGUE_LENGTH 10000
239 #define MAX_CONSTITUENTS 255
240 
241 #ifdef __cplusplus
242 extern "C" {
243 #endif
244 
245 /* Public portion of the database header. */
246 /* See libtcd.html for documentation */
247 
248 typedef struct {
249  NV_CHAR version[ONELINER_LENGTH];
250  NV_U_INT32 major_rev;
251  NV_U_INT32 minor_rev;
252  NV_CHAR last_modified[ONELINER_LENGTH];
253  NV_U_INT32 number_of_records;
254  NV_INT32 start_year;
255  NV_U_INT32 number_of_years;
256  NV_U_INT32 constituents;
257  NV_U_INT32 level_unit_types;
258  NV_U_INT32 dir_unit_types;
259  NV_U_INT32 restriction_types;
260  NV_U_INT32 datum_types;
261  NV_U_INT32 countries;
262  NV_U_INT32 tzfiles;
263  NV_U_INT32 legaleses;
264 
265  /* Need this to read V1 files. */
266  NV_U_INT32 pedigree_types;
268 
269 /* Header portion of each station record. */
270 /* See libtcd.html for documentation */
271 
272 enum TIDE_RECORD_TYPE { REFERENCE_STATION = 1, SUBORDINATE_STATION = 2 };
273 
274 typedef struct {
275  NV_INT32 record_number;
276  NV_U_INT32 record_size;
277  NV_U_BYTE record_type;
278  NV_FLOAT64 latitude;
279  NV_FLOAT64 longitude;
280  NV_INT32 reference_station;
281  NV_INT16 tzfile;
282  NV_CHAR name[ONELINER_LENGTH];
284 
285 /* Tide station record. */
286 /* See libtcd.html for documentation */
287 
288 typedef struct {
289  /* Common */
290  TIDE_STATION_HEADER header;
291  NV_INT16 country;
292  NV_CHAR source[ONELINER_LENGTH];
293  NV_U_BYTE restriction;
294  NV_CHAR comments[MONOLOGUE_LENGTH];
295  NV_CHAR notes[MONOLOGUE_LENGTH];
296  NV_U_BYTE legalese;
297  NV_CHAR station_id_context[ONELINER_LENGTH];
298  NV_CHAR station_id[ONELINER_LENGTH];
299  NV_U_INT32 date_imported;
300  NV_CHAR xfields[MONOLOGUE_LENGTH];
301  NV_U_BYTE direction_units;
302  NV_INT32 min_direction;
303  NV_INT32 max_direction;
304  NV_U_BYTE level_units;
305 
306  /* Type 1 */
307  NV_FLOAT32 datum_offset;
308  NV_INT16 datum;
309  NV_INT32 zone_offset;
310  NV_U_INT32 expiration_date;
311  NV_U_INT16 months_on_station;
312  NV_U_INT32 last_date_on_station;
313  NV_U_BYTE confidence;
314  NV_FLOAT32 amplitude[MAX_CONSTITUENTS];
315  NV_FLOAT32 epoch[MAX_CONSTITUENTS];
316 
317  /* Type 2 */
318  NV_INT32 min_time_add;
319  NV_FLOAT32 min_level_add;
320  NV_FLOAT32 min_level_multiply;
321  NV_INT32 max_time_add;
322  NV_FLOAT32 max_level_add;
323  NV_FLOAT32 max_level_multiply;
324  NV_INT32 flood_begins;
325  NV_INT32 ebb_begins;
326 
327 #ifdef COMPAT114
328  /* Deprecated */
329  NV_INT16 pedigree;
330  NV_U_BYTE units;
331  NV_U_BYTE avg_level_units;
332  NV_FLOAT32 min_avg_level;
333  NV_FLOAT32 max_avg_level;
334 #endif
335 } TIDE_RECORD;
336 
337 /* DWF: This value signifies "null" or "omitted" slack offsets
338  * (flood_begins, ebb_begins). Zero is *not* the same. */
339 /* Time offsets are represented as hours * 100 plus minutes.
340  * 0xA00 = 2560
341  * It turns out that offsets do exceed 24 hours (long story), but we
342  * should still be safe with the 60.
343  */
344 #define NULLSLACKOFFSET 0xA00
345 
346 /* This is the level below which an amplitude rounds to zero. */
347 /* It should be exactly (0.5 / DEFAULT_AMPLITUDE_SCALE). */
348 #define AMPLITUDE_EPSILON 0.00005
349 
350 /* Rounding function. */
351 #define NINT(a) ((a) < 0.0 ? (NV_INT32)((a)-0.5) : (NV_INT32)((a) + 0.5))
352 
353 /* Public function prototypes. */
354 
355 /* Prints a low-level dump of the tide record to stderr. */
356 void dump_tide_record(const TIDE_RECORD *rec);
357 
358 /* For fields in the tide record that are indices into tables of
359  * character string values, these functions are used to retrieve the
360  * character string value corresponding to a particular index. The
361  * value "Unknown" is returned when no translation exists. The return
362  * value is a pointer into static memory. */
363 const NV_CHAR *get_country(NV_INT32 num);
364 const NV_CHAR *get_tzfile(NV_INT32 num);
365 const NV_CHAR *get_level_units(NV_INT32 num);
366 const NV_CHAR *get_dir_units(NV_INT32 num);
367 const NV_CHAR *get_restriction(NV_INT32 num);
368 const NV_CHAR *get_datum(NV_INT32 num);
369 const NV_CHAR *get_legalese(NV_INT32 num);
370 
371 /* Get the name of the constituent corresponding to index num
372  * [0,constituents-1]. The return value is a pointer into static
373  * memory. */
374 const NV_CHAR *get_constituent(NV_INT32 num);
375 
376 /* Get the name of the station whose record_number is num
377  * [0,number_of_records-1]. The return value is a pointer into static
378  * memory. */
379 const NV_CHAR *get_station(NV_INT32 num);
380 
381 /* Returns the speed of the constituent indicated by num
382  * [0,constituents-1]. */
383 NV_FLOAT64 get_speed(NV_INT32 num);
384 
385 /* Get the equilibrium argument and node factor for the constituent
386  * indicated by num [0,constituents-1], for the year
387  * start_year+year. */
388 NV_FLOAT32 get_equilibrium(NV_INT32 num, NV_INT32 year);
389 NV_FLOAT32 get_node_factor(NV_INT32 num, NV_INT32 year);
390 
391 /* Get all available equilibrium arguments and node factors for the
392  * constituent indicated by num [0,constituents-1]. The return value
393  * is a pointer into static memory which is an array of
394  * number_of_years floats, corresponding to the years start_year
395  * through start_year+number_of_years-1. */
396 NV_FLOAT32 *get_equilibriums(NV_INT32 num);
397 NV_FLOAT32 *get_node_factors(NV_INT32 num);
398 
399 /* Convert between character strings of the form "[+-]HH:MM" and the
400  * encoding Hours * 100 + Minutes. ret_time pads the hours with a
401  * leading zero when less than 10; ret_time_neat omits the leading
402  * zero and omits the sign when the value is 0:00. Returned pointers
403  * point into static memory. */
404 NV_INT32 get_time(const NV_CHAR *string);
405 NV_CHAR *ret_time(NV_INT32 time);
406 NV_CHAR *ret_time_neat(NV_INT32 time);
407 
408 /* Convert the encoding Year * 10000 + Month [1, 12] * 100 + Day [1,
409  * 31] to a character string of the form "YYYY-MM-DD", or "NULL" if
410  * the value is zero. The returned pointer points into static memory.
411  * (The compact form, without hyphens, is obtainable just by printing
412  * the integer.) */
413 NV_CHAR *ret_date(NV_U_INT32 date);
414 
415 /* When invoked multiple times with the same string, returns record
416  * numbers of all stations that have that string anywhere in the
417  * station name. This search is case insensitive. When no more
418  * records are found it returns -1. */
419 NV_INT32 search_station(const NV_CHAR *string);
420 
421 /* Inverses of the corresponding get_ operations. Return -1 for not
422  * found. */
423 NV_INT32 find_station(const NV_CHAR *name);
424 NV_INT32 find_tzfile(const NV_CHAR *name);
425 NV_INT32 find_country(const NV_CHAR *name);
426 NV_INT32 find_level_units(const NV_CHAR *name);
427 NV_INT32 find_dir_units(const NV_CHAR *name);
428 NV_INT32 find_restriction(const NV_CHAR *name);
429 NV_INT32 find_datum(const NV_CHAR *name);
430 NV_INT32 find_constituent(const NV_CHAR *name);
431 NV_INT32 find_legalese(const NV_CHAR *name);
432 
433 /* Add the value of name to the corresponding lookup table and return
434  * the index of the new value. If db is not NULL, the database header
435  * struct pointed to will be updated to reflect the changes. */
436 NV_INT32 add_restriction(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
437 NV_INT32 add_tzfile(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
438 NV_INT32 add_country(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
439 NV_INT32 add_datum(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
440 NV_INT32 add_legalese(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
441 
442 /* Add the value of name to the corresponding lookup table if and
443  * only if it is not already present. Return the index of the value.
444  * If db is not NULL, the database header struct pointed to will be
445  * updated to reflect the changes. */
446 NV_INT32 find_or_add_restriction(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
447 NV_INT32 find_or_add_tzfile(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
448 NV_INT32 find_or_add_country(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
449 NV_INT32 find_or_add_datum(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
450 NV_INT32 find_or_add_legalese(const NV_CHAR *name, DB_HEADER_PUBLIC *db);
451 
452 /* Set the speed for the constituent corresponding to index num
453  * [0,constituents-1]. */
454 void set_speed(NV_INT32 num, NV_FLOAT64 value);
455 
456 /* Set the equilibrium argument and node factor for the constituent
457  * corresponding to index num [0,constituents-1], for the year
458  * start_year+year. */
459 void set_equilibrium(NV_INT32 num, NV_INT32 year, NV_FLOAT32 value);
460 void set_node_factor(NV_INT32 num, NV_INT32 year, NV_FLOAT32 value);
461 
462 /* Opens the specified TCD file. If a different database is already
463  * open, it will be closed. libtcd maintains considerable internal
464  * state and can only handle one open database at a time. Returns
465  * false if the open failed. */
466 NV_BOOL open_tide_db(const NV_CHAR *file);
467 
468 /* Closes the open database. */
469 void close_tide_db();
470 
471 /* Creates a TCD file with the supplied constituents and no tide
472  * stations. Returns false if creation failed. The database is left
473  * in an open state. */
474 NV_BOOL create_tide_db(const NV_CHAR *file, NV_U_INT32 constituents,
475  NV_CHAR const *const constituent[],
476  const NV_FLOAT64 *speed, NV_INT32 start_year,
477  NV_U_INT32 num_years,
478  NV_FLOAT32 const *const equilibrium[],
479  NV_FLOAT32 const *const node_factor[]);
480 
481 /* Returns a copy of the database header for the open database. */
482 DB_HEADER_PUBLIC get_tide_db_header();
483 
484 /* Gets "header" portion of tide record for the station whose
485  * record_number is num [0,number_of_records-1] and writes it into
486  * rec. Returns false if num is out of range. num is preserved in
487  * the static variable current_index. */
488 NV_BOOL get_partial_tide_record(NV_INT32 num, TIDE_STATION_HEADER *rec);
489 
490 /* Invokes get_partial_tide_record for current_index+1. Returns the
491  * record number or -1 for failure. */
492 NV_INT32 get_next_partial_tide_record(TIDE_STATION_HEADER *rec);
493 
494 /* Invokes get_partial_tide_record for a station that appears closest
495  * to the specified lat and lon in the Cylindrical Equidistant
496  * projection. Returns the record number or -1 for failure. */
497 NV_INT32 get_nearest_partial_tide_record(NV_FLOAT64 lat, NV_FLOAT64 lon,
498  TIDE_STATION_HEADER *rec);
499 
500 /* Gets tide record for the station whose record_number is num
501  * [0,number_of_records-1] and writes it into rec. num is preserved
502  * in the static variable current_record. Returns num, or -1 if num is
503  * out of range. */
504 NV_INT32 read_tide_record(NV_INT32 num, TIDE_RECORD *rec);
505 
506 /* Invokes read_tide_record for current_record+1. Returns the record
507  * number or -1 for failure. */
508 NV_INT32 read_next_tide_record(TIDE_RECORD *rec);
509 
510 /* Add a new record, update an existing record, or delete an existing
511  * record. If the deleted record is a reference station, all
512  * dependent subordinate stations will also be deleted. Add and
513  * update return false if the new record is invalid; delete and update
514  * return false if the specified num is invalid. If db is not NULL,
515  * the database header struct pointed to will be updated to reflect
516  * the changes. */
517 NV_BOOL add_tide_record(TIDE_RECORD *rec, DB_HEADER_PUBLIC *db);
518 #ifdef COMPAT114
519 /* Omission of db parameter was a bug. */
520 NV_BOOL update_tide_record(NV_INT32 num, TIDE_RECORD *rec);
521 #else
522 NV_BOOL update_tide_record(NV_INT32 num, TIDE_RECORD *rec,
523  DB_HEADER_PUBLIC *db);
524 #endif
525 NV_BOOL delete_tide_record(NV_INT32 num, DB_HEADER_PUBLIC *db);
526 
527 /* Computes inferred constituents when M2, S2, K1, and O1 are given
528  * and fills in the remaining unfilled constituents. The inferred
529  * constituents are developed or decided based on Article 230 of
530  * "Manual of Harmonic Analysis and Prediction of Tides," Paul
531  * Schureman, C&GS Special Publication No. 98, October 1971. Returns
532  * false if M2, S2, K1, or O1 is missing. */
533 NV_BOOL infer_constituents(TIDE_RECORD *rec);
534 
535 #ifdef COMPAT114
536 /* Deprecated stuff. */
537 #define NAME_LENGTH ONELINER_LENGTH
538 #define SOURCE_LENGTH ONELINER_LENGTH
539 #define COMMENTS_LENGTH MONOLOGUE_LENGTH
540 NV_CHAR *get_pedigree(NV_INT32 num);
541 NV_INT32 find_pedigree(const NV_CHAR *name);
542 NV_INT32 add_pedigree(const NV_CHAR *name, const DB_HEADER_PUBLIC *db);
543 NV_BOOL check_simple(TIDE_RECORD rec);
544 #endif
545 
546 #ifdef __cplusplus
547 }
548 #endif
549 
550 #endif
551 
552 /* $Id: tide_db_header.h 1092 2006-11-16 03:02:42Z flaterco $ */
553 
554 /*****************************************************************************\
555  *
556  * DISTRIBUTION STATEMENT
557  *
558  * This source file is unclassified, distribution unlimited, public
559  * domain. It is distributed in the hope that it will be useful, but
560  * WITHOUT ANY WARRANTY; without even the implied warranty of
561  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
562  *
563  * \*****************************************************************************/
564 
565 /***************************************************************************\
566  *
567  * Module Name: TIDE DB option header file
568  *
569  * Programmer(s): Jan C. Depner
570  *
571  * Date Written: July 2002
572  *
573  * Purpose: This header file defines all of the format options
574  * that are stored in the TIDE DB file header. To add a
575  * new option you simply add it to the header_data
576  * structure, then put a definition in the keys
577  structure.
578  * The keys structure contains a keyphrase such as
579  * "[DATE]", a format like "%s", a datatype (see the
580  * union in the TIDE_HEADER_DATA structure, a pointer to
581  * the location at which to store the value(s), a count
582  * if it is a repeating field (array), and a version
583  * dependency flag (major.minor * 10).
584  *
585  *
586  *
587  *****************************************************************************
588 
589  This header file uses the NAVO standard data types. You must set one of
590  the following options on the compile command line:
591 
592  NVDOS, NVHPUX, NVIRIX, NVCLIX, NVLinux, NVSUNOS, NVWINNT, or NVWIN3X
593 
594  The only one referenced in libtcd is NVWIN3X. -- DWF, 2004-09-29
595 
596  \***************************************************************************/
597 
598 #ifndef __TIDE_HEADER__
599 #define __TIDE_HEADER__
600 
601 //#include "tcd.h"
602 
603 typedef struct {
604  const NV_CHAR *keyphrase;
605  const NV_CHAR *datatype;
606  union {
607  const NV_CHAR *cstr;
608  NV_INT32 *i32;
609  NV_U_INT32 *ui32;
610  } address;
611 } KEY;
612 
613 typedef struct {
614  DB_HEADER_PUBLIC pub;
615  NV_CHAR **constituent;
616  NV_FLOAT64 *speed;
617  NV_FLOAT32 **equilibrium;
618  NV_FLOAT32 **node_factor;
619  NV_CHAR **level_unit;
620  NV_CHAR **dir_unit;
621  NV_CHAR **restriction;
622  NV_CHAR **tzfile;
623  NV_CHAR **country;
624  NV_CHAR **datum;
625  NV_CHAR **legalese;
626  NV_U_INT32 header_size;
627  NV_U_INT32 speed_bits;
628  NV_U_INT32 speed_scale;
629  NV_INT32 speed_offset;
630  NV_U_INT32 equilibrium_bits;
631  NV_U_INT32 equilibrium_scale;
632  NV_INT32 equilibrium_offset;
633  NV_U_INT32 node_bits;
634  NV_U_INT32 node_scale;
635  NV_INT32 node_offset;
636  NV_U_INT32 amplitude_bits;
637  NV_U_INT32 amplitude_scale;
638  NV_U_INT32 epoch_bits;
639  NV_U_INT32 epoch_scale;
640  NV_U_INT32 constituent_bits;
641  NV_U_INT32 record_type_bits;
642  NV_U_INT32 latitude_scale;
643  NV_U_INT32 latitude_bits;
644  NV_U_INT32 longitude_scale;
645  NV_U_INT32 longitude_bits;
646  NV_U_INT32 record_size_bits;
647  NV_U_INT32 station_bits;
648  NV_U_INT32 level_unit_bits;
649  NV_U_INT32 dir_unit_bits;
650  NV_U_INT32 restriction_bits;
651  NV_U_INT32 max_restriction_types;
652  NV_U_INT32 tzfile_bits;
653  NV_U_INT32 max_tzfiles;
654  NV_U_INT32 country_bits;
655  NV_U_INT32 max_countries;
656  NV_U_INT32 datum_bits;
657  NV_U_INT32 max_datum_types;
658  NV_U_INT32 legalese_bits;
659  NV_U_INT32 max_legaleses;
660  NV_U_INT32 datum_offset_bits;
661  NV_U_INT32 datum_offset_scale;
662  NV_U_INT32 date_bits;
663  NV_U_INT32 months_on_station_bits;
664  NV_U_INT32 confidence_value_bits;
665  NV_U_INT32 time_bits;
666  NV_U_INT32 level_add_bits;
667  NV_U_INT32 level_add_scale;
668  NV_U_INT32 level_multiply_bits;
669  NV_U_INT32 level_multiply_scale;
670  NV_U_INT32 direction_bits;
671  NV_U_INT32 constituent_size;
672  NV_U_INT32 level_unit_size;
673  NV_U_INT32 dir_unit_size;
674  NV_U_INT32 restriction_size;
675  NV_U_INT32 tzfile_size;
676  NV_U_INT32 country_size;
677  NV_U_INT32 datum_size;
678  NV_U_INT32 legalese_size;
679  NV_U_INT32 end_of_file;
680 
681  /* Need these to read V1 files. */
682  NV_U_INT32 pedigree_bits;
683  NV_U_INT32 pedigree_size;
685 
686 static TIDE_HEADER_DATA hd;
687 
688 /* "The initializer for a union with no constructor is either a single
689  * expression of the same type, or a brace-enclosed initializer for
690  * the first member of the union." -- Ellis & Stroustrup, The Annotated
691  * C++ Reference Manual, 1990, Section 8.4.1. */
692 
693 static KEY keys[] = {{
694  "[VERSION]",
695  "cstr",
696  {(NV_CHAR *)hd.pub.version},
697  },
698  {
699  "[MAJOR REV]",
700  "ui32",
701  {(NV_CHAR *)&hd.pub.major_rev},
702  },
703  {
704  "[MINOR REV]",
705  "ui32",
706  {(NV_CHAR *)&hd.pub.minor_rev},
707  },
708  {
709  "[LAST MODIFIED]",
710  "cstr",
711  {(NV_CHAR *)hd.pub.last_modified},
712  },
713  {
714  "[NUMBER OF RECORDS]",
715  "ui32",
716  {(NV_CHAR *)&hd.pub.number_of_records},
717  },
718  {
719  "[START YEAR]",
720  "i32",
721  {(NV_CHAR *)&hd.pub.start_year},
722  },
723  {
724  "[NUMBER OF YEARS]",
725  "ui32",
726  {(NV_CHAR *)&hd.pub.number_of_years},
727  },
728  {
729  "[CONSTITUENTS]",
730  "ui32",
731  {(NV_CHAR *)&hd.pub.constituents},
732  },
733  {
734  "[LEVEL UNIT TYPES]",
735  "ui32",
736  {(NV_CHAR *)&hd.pub.level_unit_types},
737  },
738  {
739  "[DIRECTION UNIT TYPES]",
740  "ui32",
741  {(NV_CHAR *)&hd.pub.dir_unit_types},
742  },
743  {
744  "[RESTRICTION TYPES]",
745  "ui32",
746  {(NV_CHAR *)&hd.pub.restriction_types},
747  },
748  {
749  "[PEDIGREE TYPES]",
750  "ui32",
751  {(NV_CHAR *)&hd.pub.pedigree_types},
752  },
753  {
754  "[TZFILES]",
755  "ui32",
756  {(NV_CHAR *)&hd.pub.tzfiles},
757  },
758  {
759  "[COUNTRIES]",
760  "ui32",
761  {(NV_CHAR *)&hd.pub.countries},
762  },
763  {
764  "[DATUM TYPES]",
765  "ui32",
766  {(NV_CHAR *)&hd.pub.datum_types},
767  },
768  {
769  "[LEGALESES]",
770  "ui32",
771  {(NV_CHAR *)&hd.pub.legaleses},
772  },
773  {
774  "[HEADER SIZE]",
775  "ui32",
776  {(NV_CHAR *)&hd.header_size},
777  },
778  {
779  "[SPEED BITS]",
780  "ui32",
781  {(NV_CHAR *)&hd.speed_bits},
782  },
783  {
784  "[SPEED SCALE]",
785  "ui32",
786  {(NV_CHAR *)&hd.speed_scale},
787  },
788  {
789  "[SPEED OFFSET]",
790  "i32",
791  {(NV_CHAR *)&hd.speed_offset},
792  },
793  {
794  "[EQUILIBRIUM BITS]",
795  "ui32",
796  {(NV_CHAR *)&hd.equilibrium_bits},
797  },
798  {
799  "[EQUILIBRIUM SCALE]",
800  "ui32",
801  {(NV_CHAR *)&hd.equilibrium_scale},
802  },
803  {
804  "[EQUILIBRIUM OFFSET]",
805  "i32",
806  {(NV_CHAR *)&hd.equilibrium_offset},
807  },
808  {
809  "[NODE BITS]",
810  "ui32",
811  {(NV_CHAR *)&hd.node_bits},
812  },
813  {
814  "[NODE SCALE]",
815  "ui32",
816  {(NV_CHAR *)&hd.node_scale},
817  },
818  {
819  "[NODE OFFSET]",
820  "i32",
821  {(NV_CHAR *)&hd.node_offset},
822  },
823  {
824  "[AMPLITUDE BITS]",
825  "ui32",
826  {(NV_CHAR *)&hd.amplitude_bits},
827  },
828  {
829  "[AMPLITUDE SCALE]",
830  "ui32",
831  {(NV_CHAR *)&hd.amplitude_scale},
832  },
833  {
834  "[EPOCH BITS]",
835  "ui32",
836  {(NV_CHAR *)&hd.epoch_bits},
837  },
838  {
839  "[EPOCH SCALE]",
840  "ui32",
841  {(NV_CHAR *)&hd.epoch_scale},
842  },
843  {
844  "[CONSTITUENT BITS]",
845  "ui32",
846  {(NV_CHAR *)&hd.constituent_bits},
847  },
848  {
849  "[LEVEL UNIT BITS]",
850  "ui32",
851  {(NV_CHAR *)&hd.level_unit_bits},
852  },
853  {
854  "[DIRECTION UNIT BITS]",
855  "ui32",
856  {(NV_CHAR *)&hd.dir_unit_bits},
857  },
858  {
859  "[RESTRICTION BITS]",
860  "ui32",
861  {(NV_CHAR *)&hd.restriction_bits},
862  },
863  {
864  "[PEDIGREE BITS]",
865  "ui32",
866  {(NV_CHAR *)&hd.pedigree_bits},
867  },
868  {
869  "[TZFILE BITS]",
870  "ui32",
871  {(NV_CHAR *)&hd.tzfile_bits},
872  },
873  {
874  "[COUNTRY BITS]",
875  "ui32",
876  {(NV_CHAR *)&hd.country_bits},
877  },
878  {
879  "[DATUM BITS]",
880  "ui32",
881  {(NV_CHAR *)&hd.datum_bits},
882  },
883  {
884  "[LEGALESE BITS]",
885  "ui32",
886  {(NV_CHAR *)&hd.legalese_bits},
887  },
888  {
889  "[RECORD TYPE BITS]",
890  "ui32",
891  {(NV_CHAR *)&hd.record_type_bits},
892  },
893  {
894  "[LATITUDE SCALE]",
895  "ui32",
896  {(NV_CHAR *)&hd.latitude_scale},
897  },
898  {
899  "[LATITUDE BITS]",
900  "ui32",
901  {(NV_CHAR *)&hd.latitude_bits},
902  },
903  {
904  "[LONGITUDE SCALE]",
905  "ui32",
906  {(NV_CHAR *)&hd.longitude_scale},
907  },
908  {
909  "[LONGITUDE BITS]",
910  "ui32",
911  {(NV_CHAR *)&hd.longitude_bits},
912  },
913  {
914  "[RECORD SIZE BITS]",
915  "ui32",
916  {(NV_CHAR *)&hd.record_size_bits},
917  },
918  {
919  "[STATION BITS]",
920  "ui32",
921  {(NV_CHAR *)&hd.station_bits},
922  },
923  {
924  "[DATUM OFFSET BITS]",
925  "ui32",
926  {(NV_CHAR *)&hd.datum_offset_bits},
927  },
928  {
929  "[DATUM OFFSET SCALE]",
930  "ui32",
931  {(NV_CHAR *)&hd.datum_offset_scale},
932  },
933  {
934  "[DATE BITS]",
935  "ui32",
936  {(NV_CHAR *)&hd.date_bits},
937  },
938  {
939  "[MONTHS ON STATION BITS]",
940  "ui32",
941  {(NV_CHAR *)&hd.months_on_station_bits},
942  },
943  {
944  "[CONFIDENCE VALUE BITS]",
945  "ui32",
946  {(NV_CHAR *)&hd.confidence_value_bits},
947  },
948  {
949  "[TIME BITS]",
950  "ui32",
951  {(NV_CHAR *)&hd.time_bits},
952  },
953  {
954  "[LEVEL ADD BITS]",
955  "ui32",
956  {(NV_CHAR *)&hd.level_add_bits},
957  },
958  {
959  "[LEVEL ADD SCALE]",
960  "ui32",
961  {(NV_CHAR *)&hd.level_add_scale},
962  },
963  {
964  "[LEVEL MULTIPLY BITS]",
965  "ui32",
966  {(NV_CHAR *)&hd.level_multiply_bits},
967  },
968  {
969  "[LEVEL MULTIPLY SCALE]",
970  "ui32",
971  {(NV_CHAR *)&hd.level_multiply_scale},
972  },
973  {
974  "[DIRECTION BITS]",
975  "ui32",
976  {(NV_CHAR *)&hd.direction_bits},
977  },
978  {
979  "[CONSTITUENT SIZE]",
980  "ui32",
981  {(NV_CHAR *)&hd.constituent_size},
982  },
983  {
984  "[LEVEL UNIT SIZE]",
985  "ui32",
986  {(NV_CHAR *)&hd.level_unit_size},
987  },
988  {
989  "[DIRECTION UNIT SIZE]",
990  "ui32",
991  {(NV_CHAR *)&hd.dir_unit_size},
992  },
993  {
994  "[RESTRICTION SIZE]",
995  "ui32",
996  {(NV_CHAR *)&hd.restriction_size},
997  },
998  {
999  "[PEDIGREE SIZE]",
1000  "ui32",
1001  {(NV_CHAR *)&hd.pedigree_size},
1002  },
1003  {
1004  "[TZFILE SIZE]",
1005  "ui32",
1006  {(NV_CHAR *)&hd.tzfile_size},
1007  },
1008  {
1009  "[COUNTRY SIZE]",
1010  "ui32",
1011  {(NV_CHAR *)&hd.country_size},
1012  },
1013  {
1014  "[DATUM SIZE]",
1015  "ui32",
1016  {(NV_CHAR *)&hd.datum_size},
1017  },
1018  {
1019  "[LEGALESE SIZE]",
1020  "ui32",
1021  {(NV_CHAR *)&hd.legalese_size},
1022  },
1023  {
1024  "[END OF FILE]",
1025  "ui32",
1026  {(NV_CHAR *)&hd.end_of_file},
1027  }};
1028 #endif
1029 
1030 #endif
Definition: IDX_entry.h:41
Definition: tcmgr.h:86
Definition: tcmgr.h:603
Definition: tcmgr.h:77