33 #include "Station_Data.h"
34 #include "IDX_entry.h"
35 #include "TC_Error_Code.h"
36 #include "TCDataSource.h"
51 #define M_PI 3.141592654
54 #define TIDE_MAX_DERIV (2)
58 #define TIDE_TIME_PREC (15)
64 #define TIDE_BLEND_TIME (3600)
70 #define TIDE_TIME_STEP (TIDE_TIME_PREC)
71 #define TIDE_BAD_TIME ((time_t)-1)
91 TC_Error_Code LoadDataSources(std::vector<std::string> &sources);
92 std::vector<std::string> GetDataSet(
void) {
return m_sourcefile_array; }
94 bool IsReady(
void) {
return bTCMReady; }
96 bool GetTideOrCurrent(time_t t,
int idx,
float &value,
float &dir);
97 bool GetTideOrCurrent15(time_t t,
int idx,
float &tcvalue,
float &dir,
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,
105 int GetStationTimeOffset(
IDX_entry *pIDX);
106 int GetNextBigEvent(time_t *tm,
int idx);
110 const IDX_entry *GetIDX_entry(
int index)
const;
112 int Get_max_IDX()
const {
return m_Combined_IDX_array.size() - 1; }
114 std::map<double, const IDX_entry *> GetStationsForLL(
double xlat,
117 int GetStationIDXbyName(
const wxString &prefix,
double xlat,
119 int GetStationIDXbyNameType(
const wxString &prefix,
double xlat,
double xlon,
121 void ScrubCurrentDepths();
132 wxString pmru_file_name;
134 ArrayOfTCDSources m_source_array;
135 std::vector<std::string> m_sourcefile_array;
137 std::vector<IDX_entry *> m_Combined_IDX_array;
143 #ifndef __OAML_TIDES_H__
144 #define __OAML_TIDES_H__
168 #include <sys/types.h>
170 #include <inttypes.h>
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
182 #define NV_BYTE unsigned char
183 #define NV_INT16 short
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
194 #define NV_BOOL unsigned char
196 #define NV_U_CHAR unsigned char
197 #define NV_FLOAT32 float
198 #define NV_FLOAT64 double
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
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
223 #undef USE_PRAGMA_MESSAGE
226 #ifdef USE_PRAGMA_MESSAGE
227 #pragma message("WARNING: COMPAT114 is enabled! See libtcd.html.")
229 #warning COMPAT114 is enabled! See libtcd.html.
236 #define ONELINER_LENGTH 90
238 #define MONOLOGUE_LENGTH 10000
239 #define MAX_CONSTITUENTS 255
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;
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;
263 NV_U_INT32 legaleses;
266 NV_U_INT32 pedigree_types;
272 enum TIDE_RECORD_TYPE { REFERENCE_STATION = 1, SUBORDINATE_STATION = 2 };
275 NV_INT32 record_number;
276 NV_U_INT32 record_size;
277 NV_U_BYTE record_type;
279 NV_FLOAT64 longitude;
280 NV_INT32 reference_station;
282 NV_CHAR name[ONELINER_LENGTH];
292 NV_CHAR source[ONELINER_LENGTH];
293 NV_U_BYTE restriction;
294 NV_CHAR comments[MONOLOGUE_LENGTH];
295 NV_CHAR notes[MONOLOGUE_LENGTH];
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;
307 NV_FLOAT32 datum_offset;
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];
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;
331 NV_U_BYTE avg_level_units;
332 NV_FLOAT32 min_avg_level;
333 NV_FLOAT32 max_avg_level;
344 #define NULLSLACKOFFSET 0xA00
348 #define AMPLITUDE_EPSILON 0.00005
351 #define NINT(a) ((a) < 0.0 ? (NV_INT32)((a)-0.5) : (NV_INT32)((a) + 0.5))
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);
374 const NV_CHAR *get_constituent(NV_INT32 num);
379 const NV_CHAR *get_station(NV_INT32 num);
383 NV_FLOAT64 get_speed(NV_INT32 num);
388 NV_FLOAT32 get_equilibrium(NV_INT32 num, NV_INT32 year);
389 NV_FLOAT32 get_node_factor(NV_INT32 num, NV_INT32 year);
396 NV_FLOAT32 *get_equilibriums(NV_INT32 num);
397 NV_FLOAT32 *get_node_factors(NV_INT32 num);
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);
413 NV_CHAR *ret_date(NV_U_INT32 date);
419 NV_INT32 search_station(
const NV_CHAR *
string);
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);
446 NV_INT32 find_or_add_restriction(
const NV_CHAR *name,
DB_HEADER_PUBLIC *db);
454 void set_speed(NV_INT32 num, NV_FLOAT64 value);
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);
466 NV_BOOL open_tide_db(
const NV_CHAR *file);
469 void close_tide_db();
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[]);
497 NV_INT32 get_nearest_partial_tide_record(NV_FLOAT64 lat, NV_FLOAT64 lon,
504 NV_INT32 read_tide_record(NV_INT32 num,
TIDE_RECORD *rec);
520 NV_BOOL update_tide_record(NV_INT32 num,
TIDE_RECORD *rec);
522 NV_BOOL update_tide_record(NV_INT32 num,
TIDE_RECORD *rec,
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);
598 #ifndef __TIDE_HEADER__
599 #define __TIDE_HEADER__
604 const NV_CHAR *keyphrase;
605 const NV_CHAR *datatype;
615 NV_CHAR **constituent;
617 NV_FLOAT32 **equilibrium;
618 NV_FLOAT32 **node_factor;
619 NV_CHAR **level_unit;
621 NV_CHAR **restriction;
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;
682 NV_U_INT32 pedigree_bits;
683 NV_U_INT32 pedigree_size;
693 static KEY keys[] = {{
696 {(NV_CHAR *)hd.pub.version},
701 {(NV_CHAR *)&hd.pub.major_rev},
706 {(NV_CHAR *)&hd.pub.minor_rev},
711 {(NV_CHAR *)hd.pub.last_modified},
714 "[NUMBER OF RECORDS]",
716 {(NV_CHAR *)&hd.pub.number_of_records},
721 {(NV_CHAR *)&hd.pub.start_year},
726 {(NV_CHAR *)&hd.pub.number_of_years},
731 {(NV_CHAR *)&hd.pub.constituents},
734 "[LEVEL UNIT TYPES]",
736 {(NV_CHAR *)&hd.pub.level_unit_types},
739 "[DIRECTION UNIT TYPES]",
741 {(NV_CHAR *)&hd.pub.dir_unit_types},
744 "[RESTRICTION TYPES]",
746 {(NV_CHAR *)&hd.pub.restriction_types},
751 {(NV_CHAR *)&hd.pub.pedigree_types},
756 {(NV_CHAR *)&hd.pub.tzfiles},
761 {(NV_CHAR *)&hd.pub.countries},
766 {(NV_CHAR *)&hd.pub.datum_types},
771 {(NV_CHAR *)&hd.pub.legaleses},
776 {(NV_CHAR *)&hd.header_size},
781 {(NV_CHAR *)&hd.speed_bits},
786 {(NV_CHAR *)&hd.speed_scale},
791 {(NV_CHAR *)&hd.speed_offset},
794 "[EQUILIBRIUM BITS]",
796 {(NV_CHAR *)&hd.equilibrium_bits},
799 "[EQUILIBRIUM SCALE]",
801 {(NV_CHAR *)&hd.equilibrium_scale},
804 "[EQUILIBRIUM OFFSET]",
806 {(NV_CHAR *)&hd.equilibrium_offset},
811 {(NV_CHAR *)&hd.node_bits},
816 {(NV_CHAR *)&hd.node_scale},
821 {(NV_CHAR *)&hd.node_offset},
826 {(NV_CHAR *)&hd.amplitude_bits},
831 {(NV_CHAR *)&hd.amplitude_scale},
836 {(NV_CHAR *)&hd.epoch_bits},
841 {(NV_CHAR *)&hd.epoch_scale},
844 "[CONSTITUENT BITS]",
846 {(NV_CHAR *)&hd.constituent_bits},
851 {(NV_CHAR *)&hd.level_unit_bits},
854 "[DIRECTION UNIT BITS]",
856 {(NV_CHAR *)&hd.dir_unit_bits},
859 "[RESTRICTION BITS]",
861 {(NV_CHAR *)&hd.restriction_bits},
866 {(NV_CHAR *)&hd.pedigree_bits},
871 {(NV_CHAR *)&hd.tzfile_bits},
876 {(NV_CHAR *)&hd.country_bits},
881 {(NV_CHAR *)&hd.datum_bits},
886 {(NV_CHAR *)&hd.legalese_bits},
889 "[RECORD TYPE BITS]",
891 {(NV_CHAR *)&hd.record_type_bits},
896 {(NV_CHAR *)&hd.latitude_scale},
901 {(NV_CHAR *)&hd.latitude_bits},
906 {(NV_CHAR *)&hd.longitude_scale},
911 {(NV_CHAR *)&hd.longitude_bits},
914 "[RECORD SIZE BITS]",
916 {(NV_CHAR *)&hd.record_size_bits},
921 {(NV_CHAR *)&hd.station_bits},
924 "[DATUM OFFSET BITS]",
926 {(NV_CHAR *)&hd.datum_offset_bits},
929 "[DATUM OFFSET SCALE]",
931 {(NV_CHAR *)&hd.datum_offset_scale},
936 {(NV_CHAR *)&hd.date_bits},
939 "[MONTHS ON STATION BITS]",
941 {(NV_CHAR *)&hd.months_on_station_bits},
944 "[CONFIDENCE VALUE BITS]",
946 {(NV_CHAR *)&hd.confidence_value_bits},
951 {(NV_CHAR *)&hd.time_bits},
956 {(NV_CHAR *)&hd.level_add_bits},
961 {(NV_CHAR *)&hd.level_add_scale},
964 "[LEVEL MULTIPLY BITS]",
966 {(NV_CHAR *)&hd.level_multiply_bits},
969 "[LEVEL MULTIPLY SCALE]",
971 {(NV_CHAR *)&hd.level_multiply_scale},
976 {(NV_CHAR *)&hd.direction_bits},
979 "[CONSTITUENT SIZE]",
981 {(NV_CHAR *)&hd.constituent_size},
986 {(NV_CHAR *)&hd.level_unit_size},
989 "[DIRECTION UNIT SIZE]",
991 {(NV_CHAR *)&hd.dir_unit_size},
994 "[RESTRICTION SIZE]",
996 {(NV_CHAR *)&hd.restriction_size},
1001 {(NV_CHAR *)&hd.pedigree_size},
1006 {(NV_CHAR *)&hd.tzfile_size},
1011 {(NV_CHAR *)&hd.country_size},
1016 {(NV_CHAR *)&hd.datum_size},
1021 {(NV_CHAR *)&hd.legalese_size},
1026 {(NV_CHAR *)&hd.end_of_file},