8 #include <dballe/fwd.h> 42 Date(
int ye,
int mo = 1,
int da = 1);
75 bool operator<(
const Date& dt)
const;
76 bool operator>(
const Date& dt)
const;
77 bool operator==(
const Date& dt)
const;
78 bool operator!=(
const Date& dt)
const;
81 static void validate(
int ye,
int mo,
int da);
88 unsigned char& month,
unsigned char& day);
91 std::ostream& operator<<(std::ostream& out,
const Date& dt);
102 unsigned char minute;
103 unsigned char second;
114 Time(
int ho,
int mi = 0,
int se = 0);
141 bool operator<(
const Time& dt)
const;
142 bool operator>(
const Time& dt)
const;
143 bool operator==(
const Time& dt)
const;
144 bool operator!=(
const Time& dt)
const;
152 static void validate(
int ho,
int mi,
int se);
155 std::ostream& operator<<(std::ostream& out,
const Time& t);
169 unsigned char minute;
170 unsigned char second;
182 Datetime(
int ye,
int mo = 1,
int da = 1,
int ho = 0,
int mi = 0,
227 bool operator==(
const Datetime& o)
const;
228 bool operator!=(
const Datetime& o)
const;
229 bool operator<(
const Datetime& o)
const;
230 bool operator>(
const Datetime& o)
const;
231 bool operator<=(
const Datetime& o)
const;
232 bool operator>=(
const Datetime& o)
const;
237 int print_iso8601(FILE* out,
char sep =
'T',
const char* end =
"\n")
const;
242 int print(FILE* out,
const char* end =
"\n")
const;
252 const char* tz =
"")
const;
258 const char* tz =
"")
const;
261 std::string
to_string(
char sep =
'T',
const char* tz =
"")
const;
278 static void validate(
int ye,
int mo,
int da,
int ho,
int mi,
int se);
284 static void normalise_h24(
int& ye,
int& mo,
int& da,
int& ho,
int& mi,
288 std::ostream& operator<<(std::ostream& out,
const Datetime& dt);
307 DatetimeRange(
int yemin,
int momin,
int damin,
int homin,
int mimin,
308 int semin,
int yemax,
int momax,
int damax,
int homax,
309 int mimax,
int semax);
336 void set(
int yemin,
int momin,
int damin,
int homin,
int mimin,
int semin,
337 int yemax,
int momax,
int damax,
int homax,
int mimax,
int semax);
355 int print(FILE* out,
const char* end =
"\n")
const;
358 std::ostream& operator<<(std::ostream& out,
const DatetimeRange& dtr);
405 void set(
int lat,
int lon);
408 void set(
double lat,
double lon);
428 bool operator==(
const Coords& o)
const;
429 bool operator!=(
const Coords& o)
const;
430 bool operator<(
const Coords& o)
const;
431 bool operator>(
const Coords& o)
const;
432 bool operator<=(
const Coords& o)
const;
433 bool operator>=(
const Coords& o)
const;
436 int print(FILE* out,
const char* end =
"\n")
const;
439 std::string
to_string(
const char* undef =
"-")
const;
454 std::ostream& operator<<(std::ostream&,
const Coords&);
472 static constexpr
int IMIN = -9000000;
474 static constexpr
int IMAX = 9000000;
476 static constexpr
double DMIN = -90.0;
478 static constexpr
double DMAX = 90.0;
492 bool operator==(
const LatRange& lr)
const;
493 bool operator!=(
const LatRange& lr)
const;
505 void get(
double& min,
double& max)
const;
508 void set(
int min,
int max);
511 void set(
double min,
double max);
528 int print(FILE* out,
const char* end =
"\n")
const;
531 std::ostream& operator<<(std::ostream& out,
const LatRange& lr);
566 bool operator==(
const LonRange& lr)
const;
567 bool operator!=(
const LonRange& lr)
const;
583 void get(
double& min,
double& max)
const;
589 void set(
int min,
int max);
595 void set(
double min,
double max);
618 int print(FILE* out,
const char* end =
"\n")
const;
621 std::ostream& operator<<(std::ostream& out,
const LonRange& lr);
636 int ltype2 = MISSING_INT,
int l2 = MISSING_INT)
644 bool operator==(
const Level& o)
const;
645 bool operator!=(
const Level& o)
const;
646 bool operator<(
const Level& o)
const;
647 bool operator>(
const Level& o)
const;
648 bool operator<=(
const Level& o)
const;
649 bool operator>=(
const Level& o)
const;
666 void to_stream(std::ostream& out,
const char* undef =
"-")
const;
669 std::string
to_string(
const char* undef =
"-")
const;
680 int print(FILE* out,
const char* undef =
"-",
const char* end =
"\n")
const;
683 std::ostream& operator<<(std::ostream& out,
const Level& l);
697 Trange(
int pind = MISSING_INT,
int p1 = MISSING_INT,
int p2 = MISSING_INT)
714 bool operator==(
const Trange& o)
const;
715 bool operator!=(
const Trange& o)
const;
716 bool operator<(
const Trange& o)
const;
717 bool operator>(
const Trange& o)
const;
718 bool operator<=(
const Trange& o)
const;
719 bool operator>=(
const Trange& o)
const;
727 void to_stream(std::ostream& out,
const char* undef =
"-")
const;
730 std::string
to_string(
const char* undef =
"-")
const;
741 int print(FILE* out,
const char* undef =
"-",
const char* end =
"\n")
const;
744 std::ostream& operator<<(std::ostream& out,
const Trange& l);
753 char* value =
nullptr;
757 Ident(
const char* value);
758 Ident(
const std::string& value);
764 Ident& operator=(
const char* o);
765 Ident& operator=(
const std::string& o);
768 const char*
get()
const {
return value; }
773 int compare(
const Ident& o)
const;
774 int compare(
const char* o)
const;
775 int compare(
const std::string& o)
const;
776 template <
typename T>
bool operator==(
const T& o)
const 778 return compare(o) == 0;
780 template <
typename T>
bool operator!=(
const T& o)
const 782 return compare(o) != 0;
784 template <
typename T>
bool operator<(
const T& o)
const 786 return compare(o) < 0;
788 template <
typename T>
bool operator<=(
const T& o)
const 790 return compare(o) <= 0;
792 template <
typename T>
bool operator>(
const T& o)
const 794 return compare(o) > 0;
796 template <
typename T>
bool operator>=(
const T& o)
const 798 return compare(o) >= 0;
804 operator const char*()
const {
return value; }
805 operator std::string()
const;
808 std::ostream& operator<<(std::ostream&,
const Ident&);
823 Report(
const char* value);
825 Report(
const std::string& value);
829 Report& operator=(
const char* value);
830 Report& operator=(
const std::string& value);
836 operator const char*()
const {
return value.c_str(); }
837 operator std::string()
const {
return value; }
839 bool operator<(
const Report& o)
const {
return value < o.value; }
840 template <
typename T>
bool operator<(
const T& o)
const 844 bool operator<=(
const Report& o)
const {
return value <= o.value; }
845 template <
typename T>
bool operator<=(
const T& o)
const 847 return *
this <=
Report(o);
849 bool operator>(
const Report& o)
const {
return value > o.value; }
850 template <
typename T>
bool operator>(
const T& o)
const 854 bool operator>=(
const Report& o)
const {
return value >= o.value; }
855 template <
typename T>
bool operator>=(
const T& o)
const 857 return *
this >=
Report(o);
859 bool operator==(
const Report& o)
const {
return value == o.value; }
860 template <
typename T>
bool operator==(
const T& o)
const 862 return *
this ==
Report(o);
864 bool operator!=(
const Report& o)
const {
return value != o.value; }
865 template <
typename T>
bool operator!=(
const T& o)
const 867 return *
this !=
Report(o);
870 bool empty()
const {
return value.empty(); }
871 void clear() {
return value.clear(); }
872 const char* c_str()
const {
return value.c_str(); }
894 bool operator==(
const Station& o)
const 899 bool operator!=(
const Station& o)
const 904 bool operator<(
const Station& o)
const 907 std::tie(o.report, o.coords, o.ident);
909 bool operator<=(
const Station& o)
const 912 std::tie(o.report, o.coords, o.ident);
914 bool operator>(
const Station& o)
const 917 std::tie(o.report, o.coords, o.ident);
919 bool operator>=(
const Station& o)
const 922 std::tie(o.report, o.coords, o.ident);
931 int print(FILE* out,
const char* end =
"\n")
const;
934 std::string
to_string(
const char* undef =
"-")
const;
937 std::ostream& operator<<(std::ostream&,
const Station&);
946 int id = MISSING_INT;
953 bool operator==(
const DBStation& o)
const 958 bool operator!=(
const DBStation& o)
const 963 bool operator<(
const DBStation& o)
const 966 std::tie(o.id, o.report, o.coords, o.ident);
968 bool operator<=(
const DBStation& o)
const 971 std::tie(o.id, o.report, o.coords, o.ident);
973 bool operator>(
const DBStation& o)
const 976 std::tie(o.id, o.report, o.coords, o.ident);
978 bool operator>=(
const DBStation& o)
const 981 std::tie(o.id, o.report, o.coords, o.ident);
990 int print(FILE* out,
const char* end =
"\n")
const;
993 std::string
to_string(
const char* undef =
"-")
const;
996 std::ostream& operator<<(std::ostream&,
const DBStation&);
1005 typedef size_t result_type;
1006 result_type operator()(
argument_type const& o)
const noexcept;
1012 typedef size_t result_type;
1013 result_type operator()(
argument_type const& o)
const noexcept;
1019 typedef size_t result_type;
1020 result_type operator()(
argument_type const& o)
const noexcept;
1026 typedef size_t result_type;
1027 result_type operator()(
argument_type const& o)
const noexcept;
1033 typedef size_t result_type;
1034 result_type operator()(
argument_type const& o)
const noexcept;
1040 typedef size_t result_type;
1041 result_type operator()(
argument_type const& o)
const noexcept;
double dmax() const
Get the upper extreme as double.
Time time() const
Return a Time with this time.
int ltype1
Type of the level or the first layer.
Definition: types.h:627
static constexpr int IMIN
Minimum possible integer value.
Definition: types.h:472
void to_stream_iso8601(std::ostream &out) const
Write the time to an output stream in ISO8601 extended format (hh:mm:ss).
LonRange()=default
Construct a range that matches any longitude.
int ltype2
Type of the the second layer.
Definition: types.h:631
void to_csv_iso8601(CSVWriter &out) const
Write the time as a CSV field in ISO8601 date format.
Ident ident
Mobile station identifier.
Definition: types.h:887
Coords()=default
Construct a missing Coords.
std::string describe() const
Return a string description of this time range.
double dlat() const
Get the latitude in degrees.
Datetime()
Construct a missing datetime.
bool contains(int lat) const
Check if a point is inside this range (extremes included)
Station information.
Definition: types.h:878
bool is_missing() const
Check if the Ident is set to the missing value.
Date date() const
Return a Date with this date.
static void validate(int ye, int mo, int da)
Raise an exception if the three values do not represent a valid date.
Time()
Construct a missing time.
int compare(const Time &other) const
Generic comparison.
static Trange instant()
Time range for instant values.
bool is_missing() const
Return true if the LatRange matches any latitude.
int print(FILE *out, const char *undef="-", const char *end="\) const
Print to an output stream.
static void julian_to_calendar(int jday, unsigned short &year, unsigned char &month, unsigned char &day)
Convert a Julian day into a calendar date.
int compare(const Trange &t) const
Generic comparison.
Report report
Report name for this station.
Definition: types.h:881
Calendar date.
Definition: types.h:27
bool is_missing() const
Check if this range is open on both sides.
bool is_missing() const
Return true if all the station fields are empty.
Coords coords
Station coordinates.
Definition: types.h:884
static Datetime upper_bound(int ye, int mo, int da, int ho, int mi, int se)
Return a Datetime filling the parts set to MISSING_INT with their highest possible values...
Coordinates.
Definition: types.h:371
static constexpr int IMAX
Maximum possible integer value.
Definition: types.h:474
std::string to_string(const char *undef="-") const
Format to a string.
int p1
Time range P1 indicator.
Definition: types.h:693
void to_csv(CSVWriter &out) const
Write the datetime to a CSV writer as 3 fields.
int print_iso8601(FILE *out, char sep='T', const char *end="\) const
Print to an output stream in ISO8601 combined format.
std::string to_string(const char *undef="-") const
Format to a string.
static int calendar_to_julian(int year, int month, int day)
Convert a calendar date into a Julian day.
int imin
Initial point of the longitude range.
Definition: types.h:555
std::string to_string(const char *undef="-") const
Format to a string.
void set_lat(double lat)
Set the latitude only.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:688
int print(FILE *out, const char *end="\) const
Print to an output stream.
static constexpr double DMAX
Maximum possible double value.
Definition: types.h:478
static void normalise_h24(int &ye, int &mo, int &da, int &ho, int &mi, int &se)
Convert a datetime with an hour of 24:00:00 to hour 00:00:00 of the following day.
void to_stream(std::ostream &out, const char *undef="-") const
Format to an output stream.
int pind
Time range type indicator.
Definition: types.h:691
static int lon_to_int(double lat)
Convert a longitude to the internal integer representation.
void set_lower_bound()
Fill possibly missing fields with their lowest valid value.
double dmax() const
Get the upper extreme as double, or 180.0 if missing.
void to_stream_iso8601(std::ostream &out) const
Write the date to an output stream in ISO8601 date format.
int print(FILE *out, const char *end="\) const
Print the Station to a FILE*.
static int lat_to_int(double lat)
Convert a latitude to the internal integer representation.
static Datetime from_julian(int jday, int ho=0, int mi=0, int se=0)
Set the date from a Julian day.
int to_julian() const
Convert the date to Julian day.
int print(FILE *out, const char *end="\) const
Print to an output stream in ISO8601 combined format.
static Date from_julian(int jday)
Create a date from a Julian day.
static constexpr double DMIN
Minimum possible double value.
Definition: types.h:476
bool is_missing() const
Return true if all the station fields are empty.
bool contains(int lon) const
Check if a point is inside this range (extremes included)
void to_stream_iso8601(std::ostream &out, char sep='T', const char *tz="") const
Write the datetime to an output stream in ISO8601 combined format.
int print(FILE *out, const char *end="\) const
Print the Station to a FILE*.
Vertical level or layer.
Definition: types.h:624
int print(FILE *out, const char *end="\) const
Print the LonRange to a FILE*.
bool is_missing() const
Return true if the LonRange matches any longitude.
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: types.h:750
static Datetime lower_bound(int ye, int mo, int da, int ho, int mi, int se)
Return a Datetime filling the parts set to MISSING_INT with their lowest possible values...
static double lon_from_int(int lon)
Convert a longitude from the internal integer representation.
std::string to_string(char sep='T', const char *tz="") const
Write to a string in ISO8601 combined format.
int l2
L2 value of the second layer.
Definition: types.h:633
int to_julian() const
Convert the date to Julian day.
bool is_missing() const
Check if this date is the missing value.
bool contains(const Datetime &dt) const
Check if a Datetime is inside this range.
void set_upper_bound()
Fill possibly missing fields with their highest valid value.
Range of datetimes.
Definition: types.h:296
std::string to_string(const char *undef="-") const
Format to a string.
int imax
Final point of the longitude range.
Definition: types.h:557
void to_csv_iso8601(CSVWriter &out) const
Write the date as a CSV field in ISO8601 date format.
Datetime max
Upper bound of the range.
Definition: types.h:301
bool is_missing() const
Check if this time is the missing value.
void clear()
Set to missing value.
void to_stream(std::ostream &out, const char *undef="-") const
Format to an output stream.
int lat
Latitude in 1/100000 of a degree (5 significant digits preserved)
Definition: types.h:374
int imin
Minimum latitude.
Definition: types.h:481
int id
Database ID of the station.
Definition: types.h:946
Range of latitudes.
Definition: types.h:469
static void validate(int ye, int mo, int da, int ho, int mi, int se)
Raise an exception if the three values do not represent a valid date/time.
Time of the day.
Definition: types.h:99
LatRange()=default
Construct a LatRange matching any latitude.
Datetime min
Lower bound of the range.
Definition: types.h:299
int lon
Longitude in 1/100000 of a degree (5 significant digits preserved) and normalised between -180...
Definition: types.h:380
int compare(const Coords &o) const
Compare two Coords strutures, for use in sorting.
double dmin() const
Get the lower extreme as double.
int print(FILE *out, const char *end="\) const
Print to an output stream in ISO8601 combined format.
void to_csv_iso8601(CSVWriter &out, char sep='T', const char *tz="") const
Write the datetime as a CSV field in ISO8601 date format.
Date and time.
Definition: types.h:163
int imax
Maximum latitude.
Definition: types.h:483
int compare(const Level &l) const
Generic comparison.
A report name.
Definition: types.h:815
bool is_disjoint(const DatetimeRange &dtr) const
Check if the two ranges are completely disjoint.
static Datetime from_iso8601(const char *str)
Parse an ISO8601 datetime string.
int compare(const Date &other) const
Generic comparison.
double dlon() const
Get the longitude in degrees.
bool is_missing() const
Check if this datetime is the missing value.
Date()
Construct a missing date.
bool is_missing() const
Check if these coordinates are undefined.
std::string describe() const
Return a string description of this level.
static double lat_from_int(int lat)
Convert a latitude from the internal integer representation.
void merge(const DatetimeRange &range)
Merge range into this one, resulting in the smallest range that contains both.
static int days_in_month(int year, int month)
Return the number of days in the given month.
Range of longitudes.
Definition: types.h:552
int print(FILE *out, const char *undef="-", const char *end="\) const
Print to an output stream.
int l1
L1 value of the level or the first layer.
Definition: types.h:629
int compare(const Datetime &other) const
Generic comparison.
static Level cloud(int ltype2=MISSING_INT, int l2=MISSING_INT)
Create a cloud special level.
int p2
Time range P2 indicator.
Definition: types.h:695
void set_lon(double lon)
Set the longitude only.
bool is_missing() const
Check if this level is fully set to the missing value.
std::string to_string(const char *undef="-") const
Format to a string.
int print(FILE *out, const char *end="\) const
Print the LatRange to a FILE*.
static void validate(int ho, int mi, int se)
Raise an exception if the three values do not represent a valid time.
double dmin() const
Get the lower extreme as double, or -180.0 if missing.
void to_csv(CSVWriter &out) const
Write the datetime to a CSV writer as 4 fields.
bool is_missing() const
Check if this level is fully set to the missing value.