GeographicLib  1.44
Utility.hpp
Go to the documentation of this file.
1 /**
2  * \file Utility.hpp
3  * \brief Header for GeographicLib::Utility class
4  *
5  * Copyright (c) Charles Karney (2011-2015) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9 
10 #if !defined(GEOGRAPHICLIB_UTILITY_HPP)
11 #define GEOGRAPHICLIB_UTILITY_HPP 1
12 
14 #include <iomanip>
15 #include <vector>
16 #include <sstream>
17 #include <cctype>
18 #include <ctime>
19 
20 #if defined(_MSC_VER)
21 // Squelch warnings about constant conditional expressions and unsafe gmtime
22 # pragma warning (push)
23 # pragma warning (disable: 4127 4996)
24 #endif
25 
26 namespace GeographicLib {
27 
28  /**
29  * \brief Some utility routines for %GeographicLib
30  *
31  * Example of use:
32  * \include example-Utility.cpp
33  **********************************************************************/
35  private:
36  static bool gregorian(int y, int m, int d) {
37  // The original cut over to the Gregorian calendar in Pope Gregory XIII's
38  // time had 1582-10-04 followed by 1582-10-15. Here we implement the
39  // switch over used by the English-speaking world where 1752-09-02 was
40  // followed by 1752-09-14. We also assume that the year always begins
41  // with January 1, whereas in reality it often was reckoned to begin in
42  // March.
43  return 100 * (100 * y + m) + d >= 17520914; // or 15821004
44  }
45  static bool gregorian(int s) {
46  return s >= 639799; // 1752-09-14
47  }
48  public:
49 
50  /**
51  * Convert a date to the day numbering sequentially starting with
52  * 0001-01-01 as day 1.
53  *
54  * @param[in] y the year (must be positive).
55  * @param[in] m the month, Jan = 1, etc. (must be positive). Default = 1.
56  * @param[in] d the day of the month (must be positive). Default = 1.
57  * @return the sequential day number.
58  **********************************************************************/
59  static int day(int y, int m = 1, int d = 1) {
60  // Convert from date to sequential day and vice versa
61  //
62  // Here is some code to convert a date to sequential day and vice
63  // versa. The sequential day is numbered so that January 1, 1 AD is day 1
64  // (a Saturday). So this is offset from the "Julian" day which starts the
65  // numbering with 4713 BC.
66  //
67  // This is inspired by a talk by John Conway at the John von Neumann
68  // National Supercomputer Center when he described his Doomsday algorithm
69  // for figuring the day of the week. The code avoids explicitly doing ifs
70  // (except for the decision of whether to use the Julian or Gregorian
71  // calendar). Instead the equivalent result is achieved using integer
72  // arithmetic. I got this idea from the routine for the day of the week
73  // in MACLisp (I believe that that routine was written by Guy Steele).
74  //
75  // There are three issues to take care of
76  //
77  // 1. the rules for leap years,
78  // 2. the inconvenient placement of leap days at the end of February,
79  // 3. the irregular pattern of month lengths.
80  //
81  // We deal with these as follows:
82  //
83  // 1. Leap years are given by simple rules which are straightforward to
84  // accommodate.
85  //
86  // 2. We simplify the calculations by moving January and February to the
87  // previous year. Here we internally number the months March–December,
88  // January, February as 0–9, 10, 11.
89  //
90  // 3. The pattern of month lengths from March through January is regular
91  // with a 5-month period—31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31. The
92  // 5-month period is 153 days long. Since February is now at the end of
93  // the year, we don't need to include its length in this part of the
94  // calculation.
95  bool greg = gregorian(y, m, d);
96  y += (m + 9) / 12 - 1; // Move Jan and Feb to previous year,
97  m = (m + 9) % 12; // making March month 0.
98  return
99  (1461 * y) / 4 // Julian years converted to days. Julian year is 365 +
100  // 1/4 = 1461/4 days.
101  // Gregorian leap year corrections. The 2 offset with respect to the
102  // Julian calendar synchronizes the vernal equinox with that at the time
103  // of the Council of Nicea (325 AD).
104  + (greg ? (y / 100) / 4 - (y / 100) + 2 : 0)
105  + (153 * m + 2) / 5 // The zero-based start of the m'th month
106  + d - 1 // The zero-based day
107  - 305; // The number of days between March 1 and December 31.
108  // This makes 0001-01-01 day 1
109  }
110 
111  /**
112  * Convert a date to the day numbering sequentially starting with
113  * 0001-01-01 as day 1.
114  *
115  * @param[in] y the year (must be positive).
116  * @param[in] m the month, Jan = 1, etc. (must be positive). Default = 1.
117  * @param[in] d the day of the month (must be positive). Default = 1.
118  * @param[in] check whether to check the date.
119  * @exception GeographicErr if the date is invalid and \e check is true.
120  * @return the sequential day number.
121  **********************************************************************/
122  static int day(int y, int m, int d, bool check) {
123  int s = day(y, m, d);
124  if (!check)
125  return s;
126  int y1, m1, d1;
127  date(s, y1, m1, d1);
128  if (!(s > 0 && y == y1 && m == m1 && d == d1))
129  throw GeographicErr("Invalid date " +
130  str(y) + "-" + str(m) + "-" + str(d)
131  + (s > 0 ? "; use " +
132  str(y1) + "-" + str(m1) + "-" + str(d1) :
133  " before 0001-01-01"));
134  return s;
135  }
136 
137  /**
138  * Given a day (counting from 0001-01-01 as day 1), return the date.
139  *
140  * @param[in] s the sequential day number (must be positive)
141  * @param[out] y the year.
142  * @param[out] m the month, Jan = 1, etc.
143  * @param[out] d the day of the month.
144  **********************************************************************/
145  static void date(int s, int& y, int& m, int& d) {
146  int c = 0;
147  bool greg = gregorian(s);
148  s += 305; // s = 0 on March 1, 1BC
149  if (greg) {
150  s -= 2; // The 2 day Gregorian offset
151  // Determine century with the Gregorian rules for leap years. The
152  // Gregorian year is 365 + 1/4 - 1/100 + 1/400 = 146097/400 days.
153  c = (4 * s + 3) / 146097;
154  s -= (c * 146097) / 4; // s = 0 at beginning of century
155  }
156  y = (4 * s + 3) / 1461; // Determine the year using Julian rules.
157  s -= (1461 * y) / 4; // s = 0 at start of year, i.e., March 1
158  y += c * 100; // Assemble full year
159  m = (5 * s + 2) / 153; // Determine the month
160  s -= (153 * m + 2) / 5; // s = 0 at beginning of month
161  d = s + 1; // Determine day of month
162  y += (m + 2) / 12; // Move Jan and Feb back to original year
163  m = (m + 2) % 12 + 1; // Renumber the months so January = 1
164  }
165 
166  /**
167  * Given a date as a string in the format yyyy, yyyy-mm, or yyyy-mm-dd,
168  * return the numeric values for the year, month, and day. No checking is
169  * done on these values. The string "now" is interpreted as the present
170  * date (in UTC).
171  *
172  * @param[in] s the date in string format.
173  * @param[out] y the year.
174  * @param[out] m the month, Jan = 1, etc.
175  * @param[out] d the day of the month.
176  * @exception GeographicErr is \e s is malformed.
177  **********************************************************************/
178  static void date(const std::string& s, int& y, int& m, int& d) {
179  if (s == "now") {
180  std::time_t t = std::time(0);
181  struct tm* now = gmtime(&t);
182  y = now->tm_year + 1900;
183  m = now->tm_mon + 1;
184  d = now->tm_mday;
185  return;
186  }
187  int y1, m1 = 1, d1 = 1;
188  const char* digits = "0123456789";
189  std::string::size_type p1 = s.find_first_not_of(digits);
190  if (p1 == std::string::npos)
191  y1 = num<int>(s);
192  else if (s[p1] != '-')
193  throw GeographicErr("Delimiter not hyphen in date " + s);
194  else if (p1 == 0)
195  throw GeographicErr("Empty year field in date " + s);
196  else {
197  y1 = num<int>(s.substr(0, p1));
198  if (++p1 == s.size())
199  throw GeographicErr("Empty month field in date " + s);
200  std::string::size_type p2 = s.find_first_not_of(digits, p1);
201  if (p2 == std::string::npos)
202  m1 = num<int>(s.substr(p1));
203  else if (s[p2] != '-')
204  throw GeographicErr("Delimiter not hyphen in date " + s);
205  else if (p2 == p1)
206  throw GeographicErr("Empty month field in date " + s);
207  else {
208  m1 = num<int>(s.substr(p1, p2 - p1));
209  if (++p2 == s.size())
210  throw GeographicErr("Empty day field in date " + s);
211  d1 = num<int>(s.substr(p2));
212  }
213  }
214  y = y1; m = m1; d = d1;
215  }
216 
217  /**
218  * Given the date, return the day of the week.
219  *
220  * @param[in] y the year (must be positive).
221  * @param[in] m the month, Jan = 1, etc. (must be positive).
222  * @param[in] d the day of the month (must be positive).
223  * @return the day of the week with Sunday, Monday--Saturday = 0,
224  * 1--6.
225  **********************************************************************/
226  static int dow(int y, int m, int d) { return dow(day(y, m, d)); }
227 
228  /**
229  * Given the sequential day, return the day of the week.
230  *
231  * @param[in] s the sequential day (must be positive).
232  * @return the day of the week with Sunday, Monday--Saturday = 0,
233  * 1--6.
234  **********************************************************************/
235  static int dow(int s) {
236  return (s + 5) % 7; // The 5 offset makes day 1 (0001-01-01) a Saturday.
237  }
238 
239  /**
240  * Convert a string representing a date to a fractional year.
241  *
242  * @tparam T the type of the argument.
243  * @param[in] s the string to be converted.
244  * @exception GeographicErr if \e s can't be interpreted as a date.
245  * @return the fractional year.
246  *
247  * The string is first read as an ordinary number (e.g., 2010 or 2012.5);
248  * if this is successful, the value is returned. Otherwise the string
249  * should be of the form yyyy-mm or yyyy-mm-dd and this is converted to a
250  * number with 2010-01-01 giving 2010.0 and 2012-07-03 giving 2012.5.
251  **********************************************************************/
252  template<typename T> static T fractionalyear(const std::string& s) {
253  try {
254  return num<T>(s);
255  }
256  catch (const std::exception&) {
257  }
258  int y, m, d;
259  date(s, y, m, d);
260  int t = day(y, m, d, true);
261  return T(y) + T(t - day(y)) / T(day(y + 1) - day(y));
262  }
263 
264  /**
265  * Convert a object of type T to a string.
266  *
267  * @tparam T the type of the argument.
268  * @param[in] x the value to be converted.
269  * @param[in] p the precision used (default &minus;1).
270  * @exception std::bad_alloc if memory for the string can't be allocated.
271  * @return the string representation.
272  *
273  * If \e p &ge; 0, then the number fixed format is used with p bits of
274  * precision. With p < 0, there is no manipulation of the format.
275  **********************************************************************/
276  template<typename T> static std::string str(T x, int p = -1) {
277  std::ostringstream s;
278  if (p >= 0) s << std::fixed << std::setprecision(p);
279  s << x; return s.str();
280  }
281 
282  /**
283  * Convert a Math::real object to a string.
284  *
285  * @param[in] x the value to be converted.
286  * @param[in] p the precision used (default &minus;1).
287  * @exception std::bad_alloc if memory for the string can't be allocated.
288  * @return the string representation.
289  *
290  * If \e p &ge; 0, then the number fixed format is used with p bits of
291  * precision. With p < 0, there is no manipulation of the format. This is
292  * an overload of str<T> which deals with inf and nan.
293  **********************************************************************/
294  static std::string str(Math::real x, int p = -1) {
295  if (!Math::isfinite(x))
296  return x < 0 ? std::string("-inf") :
297  (x > 0 ? std::string("inf") : std::string("nan"));
298  std::ostringstream s;
299 #if GEOGRAPHICLIB_PRECISION == 4
300  // boost-quadmath treats precision == 0 as "use as many digits as
301  // necessary", so...
302  using std::floor; using std::fmod;
303  if (p == 0) {
304  x += Math::real(0.5);
305  Math::real ix = floor(x);
306  // Implement the "round ties to even" rule
307  x = (ix == x && fmod(ix, Math::real(2)) == 1) ? ix - 1 : ix;
308  s << std::fixed << std::setprecision(1) << x;
309  std::string r(s.str());
310  // strip off trailing ".0"
311  return r.substr(0, (std::max)(int(r.size()) - 2, 0));
312  }
313 #endif
314  if (p >= 0) s << std::fixed << std::setprecision(p);
315  s << x; return s.str();
316  }
317 
318  /**
319  * Convert a string to an object of type T.
320  *
321  * @tparam T the type of the return value.
322  * @param[in] s the string to be converted.
323  * @exception GeographicErr is \e s is not readable as a T.
324  * @return object of type T
325  **********************************************************************/
326  template<typename T> static T num(const std::string& s) {
327  T x;
328  std::string errmsg;
329  do { // Executed once (provides the ability to break)
330  std::istringstream is(s);
331  if (!(is >> x)) {
332  errmsg = "Cannot decode " + s;
333  break;
334  }
335  int pos = int(is.tellg()); // Returns -1 at end of string?
336  if (!(pos < 0 || pos == int(s.size()))) {
337  errmsg = "Extra text " + s.substr(pos) + " at end of " + s;
338  break;
339  }
340  return x;
341  } while (false);
342  x = std::numeric_limits<T>::is_integer ? 0 : nummatch<T>(s);
343  if (x == 0)
344  throw GeographicErr(errmsg);
345  return x;
346  }
347 
348  /**
349  * Match "nan" and "inf" (and variants thereof) in a string.
350  *
351  * @tparam T the type of the return value.
352  * @param[in] s the string to be matched.
353  * @return appropriate special value (&plusmn;&infin;, nan) or 0 if none is
354  * found.
355  **********************************************************************/
356  template<typename T> static T nummatch(const std::string& s) {
357  if (s.length() < 3)
358  return 0;
359  std::string t;
360  t.resize(s.length());
361  std::transform(s.begin(), s.end(), t.begin(), (int(*)(int))std::toupper);
362  for (size_t i = s.length(); i--;)
363  t[i] = char(std::toupper(s[i]));
364  int sign = t[0] == '-' ? -1 : 1;
365  std::string::size_type p0 = t[0] == '-' || t[0] == '+' ? 1 : 0;
366  std::string::size_type p1 = t.find_last_not_of('0');
367  if (p1 == std::string::npos || p1 + 1 < p0 + 3)
368  return 0;
369  // Strip off sign and trailing 0s
370  t = t.substr(p0, p1 + 1 - p0); // Length at least 3
371  if (t == "NAN" || t == "1.#QNAN" || t == "1.#SNAN" || t == "1.#IND" ||
372  t == "1.#R")
373  return Math::NaN<T>();
374  else if (t == "INF" || t == "1.#INF")
375  return sign * Math::infinity<T>();
376  return 0;
377  }
378 
379  /**
380  * Read a simple fraction, e.g., 3/4, from a string to an object of type T.
381  *
382  * @tparam T the type of the return value.
383  * @param[in] s the string to be converted.
384  * @exception GeographicErr is \e s is not readable as a fraction of type T.
385  * @return object of type T
386  **********************************************************************/
387  template<typename T> static T fract(const std::string& s) {
388  std::string::size_type delim = s.find('/');
389  return
390  !(delim != std::string::npos && delim >= 1 && delim + 2 <= s.size()) ?
391  num<T>(s) :
392  // delim in [1, size() - 2]
393  num<T>(s.substr(0, delim)) / num<T>(s.substr(delim + 1));
394  }
395 
396  /**
397  * Lookup up a character in a string.
398  *
399  * @param[in] s the string to be searched.
400  * @param[in] c the character to look for.
401  * @return the index of the first occurrence character in the string or
402  * &minus;1 is the character is not present.
403  *
404  * \e c is converted to upper case before search \e s. Therefore, it is
405  * intended that \e s should not contain any lower case letters.
406  **********************************************************************/
407  static int lookup(const std::string& s, char c) {
408  std::string::size_type r = s.find(char(toupper(c)));
409  return r == std::string::npos ? -1 : int(r);
410  }
411 
412  /**
413  * Read data of type ExtT from a binary stream to an array of type IntT.
414  * The data in the file is in (bigendp ? big : little)-endian format.
415  *
416  * @tparam ExtT the type of the objects in the binary stream (external).
417  * @tparam IntT the type of the objects in the array (internal).
418  * @tparam bigendp true if the external storage format is big-endian.
419  * @param[in] str the input stream containing the data of type ExtT
420  * (external).
421  * @param[out] array the output array of type IntT (internal).
422  * @param[in] num the size of the array.
423  * @exception GeographicErr if the data cannot be read.
424  **********************************************************************/
425  template<typename ExtT, typename IntT, bool bigendp>
426  static inline void readarray(std::istream& str,
427  IntT array[], size_t num) {
428 #if GEOGRAPHICLIB_PRECISION < 4
429  if (sizeof(IntT) == sizeof(ExtT) &&
430  std::numeric_limits<IntT>::is_integer ==
431  std::numeric_limits<ExtT>::is_integer)
432  {
433  // Data is compatible (aside from the issue of endian-ness).
434  str.read(reinterpret_cast<char*>(array), num * sizeof(ExtT));
435  if (!str.good())
436  throw GeographicErr("Failure reading data");
437  if (bigendp != Math::bigendian) { // endian mismatch -> swap bytes
438  for (size_t i = num; i--;)
439  array[i] = Math::swab<IntT>(array[i]);
440  }
441  }
442  else
443 #endif
444  {
445  const int bufsize = 1024; // read this many values at a time
446  ExtT buffer[bufsize]; // temporary buffer
447  int k = int(num); // data values left to read
448  int i = 0; // index into output array
449  while (k) {
450  int n = (std::min)(k, bufsize);
451  str.read(reinterpret_cast<char*>(buffer), n * sizeof(ExtT));
452  if (!str.good())
453  throw GeographicErr("Failure reading data");
454  for (int j = 0; j < n; ++j)
455  // fix endian-ness and cast to IntT
456  array[i++] = IntT(bigendp == Math::bigendian ? buffer[j] :
457  Math::swab<ExtT>(buffer[j]));
458  k -= n;
459  }
460  }
461  return;
462  }
463 
464  /**
465  * Read data of type ExtT from a binary stream to a vector array of type
466  * IntT. The data in the file is in (bigendp ? big : little)-endian
467  * format.
468  *
469  * @tparam ExtT the type of the objects in the binary stream (external).
470  * @tparam IntT the type of the objects in the array (internal).
471  * @tparam bigendp true if the external storage format is big-endian.
472  * @param[in] str the input stream containing the data of type ExtT
473  * (external).
474  * @param[out] array the output vector of type IntT (internal).
475  * @exception GeographicErr if the data cannot be read.
476  **********************************************************************/
477  template<typename ExtT, typename IntT, bool bigendp>
478  static inline void readarray(std::istream& str,
479  std::vector<IntT>& array) {
480  if (array.size() > 0)
481  readarray<ExtT, IntT, bigendp>(str, &array[0], array.size());
482  }
483 
484  /**
485  * Write data in an array of type IntT as type ExtT to a binary stream.
486  * The data in the file is in (bigendp ? big : little)-endian format.
487  *
488  * @tparam ExtT the type of the objects in the binary stream (external).
489  * @tparam IntT the type of the objects in the array (internal).
490  * @tparam bigendp true if the external storage format is big-endian.
491  * @param[out] str the output stream for the data of type ExtT (external).
492  * @param[in] array the input array of type IntT (internal).
493  * @param[in] num the size of the array.
494  * @exception GeographicErr if the data cannot be written.
495  **********************************************************************/
496  template<typename ExtT, typename IntT, bool bigendp>
497  static inline void writearray(std::ostream& str,
498  const IntT array[], size_t num) {
499 #if GEOGRAPHICLIB_PRECISION < 4
500  if (sizeof(IntT) == sizeof(ExtT) &&
501  std::numeric_limits<IntT>::is_integer ==
502  std::numeric_limits<ExtT>::is_integer &&
503  bigendp == Math::bigendian)
504  {
505  // Data is compatible (including endian-ness).
506  str.write(reinterpret_cast<const char*>(array), num * sizeof(ExtT));
507  if (!str.good())
508  throw GeographicErr("Failure writing data");
509  }
510  else
511 #endif
512  {
513  const int bufsize = 1024; // write this many values at a time
514  ExtT buffer[bufsize]; // temporary buffer
515  int k = int(num); // data values left to write
516  int i = 0; // index into output array
517  while (k) {
518  int n = (std::min)(k, bufsize);
519  for (int j = 0; j < n; ++j)
520  // cast to ExtT and fix endian-ness
521  buffer[j] = bigendp == Math::bigendian ? ExtT(array[i++]) :
522  Math::swab<ExtT>(ExtT(array[i++]));
523  str.write(reinterpret_cast<const char*>(buffer), n * sizeof(ExtT));
524  if (!str.good())
525  throw GeographicErr("Failure writing data");
526  k -= n;
527  }
528  }
529  return;
530  }
531 
532  /**
533  * Write data in an array of type IntT as type ExtT to a binary stream.
534  * The data in the file is in (bigendp ? big : little)-endian format.
535  *
536  * @tparam ExtT the type of the objects in the binary stream (external).
537  * @tparam IntT the type of the objects in the array (internal).
538  * @tparam bigendp true if the external storage format is big-endian.
539  * @param[out] str the output stream for the data of type ExtT (external).
540  * @param[in] array the input vector of type IntT (internal).
541  * @exception GeographicErr if the data cannot be written.
542  **********************************************************************/
543  template<typename ExtT, typename IntT, bool bigendp>
544  static inline void writearray(std::ostream& str,
545  std::vector<IntT>& array) {
546  if (array.size() > 0)
547  writearray<ExtT, IntT, bigendp>(str, &array[0], array.size());
548  }
549 
550  /**
551  * Parse a KEY VALUE line.
552  *
553  * @param[in] line the input line.
554  * @param[out] key the key.
555  * @param[out] val the value.
556  * @exception std::bad_alloc if memory for the internal strings can't be
557  * allocated.
558  * @return whether a key was found.
559  *
560  * A # character and everything after it are discarded. If the result is
561  * just white space, the routine returns false (and \e key and \e val are
562  * not set). Otherwise the first token is taken to be the key and the rest
563  * of the line (trimmed of leading and trailing white space) is the value.
564  **********************************************************************/
565  static bool ParseLine(const std::string& line,
566  std::string& key, std::string& val);
567 
568  /**
569  * Set the binary precision of a real number.
570  *
571  * @param[in] ndigits the number of bits of precision. If ndigits is 0
572  * (the default), then determine the precision from the environment
573  * variable GEOGRAPHICLIB_DIGITS. If this is undefined, use ndigits =
574  * 256 (i.e., about 77 decimal digits).
575  * @return the resulting number of bits of precision.
576  *
577  * This only has an effect when GEOGRAPHICLIB_PRECISION == 5. The
578  * precision should only be set once and before calls to any other
579  * GeographicLib functions. (Several functions, for example Math::pi(),
580  * cache the return value in a static local variable. The precision needs
581  * to be set before a call to any such functions.) In multi-threaded
582  * applications, it is necessary also to set the precision in each thread
583  * (see the example GeoidToGTX.cpp).
584  **********************************************************************/
585  static int set_digits(int ndigits = 0);
586 
587  };
588 
589 } // namespace GeographicLib
590 
591 #if defined(_MSC_VER)
592 # pragma warning (pop)
593 #endif
594 
595 #endif // GEOGRAPHICLIB_UTILITY_HPP
static T fract(const std::string &s)
Definition: Utility.hpp:387
static int day(int y, int m, int d, bool check)
Definition: Utility.hpp:122
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:90
static void readarray(std::istream &str, std::vector< IntT > &array)
Definition: Utility.hpp:478
static void readarray(std::istream &str, IntT array[], size_t num)
Definition: Utility.hpp:426
Some utility routines for GeographicLib.
Definition: Utility.hpp:34
static void date(const std::string &s, int &y, int &m, int &d)
Definition: Utility.hpp:178
static bool isfinite(T x)
Definition: Math.hpp:768
static T fractionalyear(const std::string &s)
Definition: Utility.hpp:252
static void writearray(std::ostream &str, std::vector< IntT > &array)
Definition: Utility.hpp:544
static T nummatch(const std::string &s)
Definition: Utility.hpp:356
static void writearray(std::ostream &str, const IntT array[], size_t num)
Definition: Utility.hpp:497
static std::string str(Math::real x, int p=-1)
Definition: Utility.hpp:294
static int dow(int s)
Definition: Utility.hpp:235
static void date(int s, int &y, int &m, int &d)
Definition: Utility.hpp:145
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
static std::string str(T x, int p=-1)
Definition: Utility.hpp:276
static int dow(int y, int m, int d)
Definition: Utility.hpp:226
static const bool bigendian
Definition: Math.hpp:210
static T num(const std::string &s)
Definition: Utility.hpp:326
Exception handling for GeographicLib.
Definition: Constants.hpp:386
Header for GeographicLib::Constants class.
static int lookup(const std::string &s, char c)
Definition: Utility.hpp:407
static int day(int y, int m=1, int d=1)
Definition: Utility.hpp:59