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