GeographicLib  1.43
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-2014) <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;
303  if (p == 0) {
304  long long ix = (long long)(floor(x + Math::real(0.5)));
305  // Implement the "round ties to even" rule
306  if (Math::real(ix) == x + Math::real(0.5) && (ix % 2) == 1)
307  --ix;
308  s << ix;
309  return s.str();
310  }
311 #endif
312  if (p >= 0) s << std::fixed << std::setprecision(p);
313  s << x; return s.str();
314  }
315 
316  /**
317  * Convert a string to an object of type T.
318  *
319  * @tparam T the type of the return value.
320  * @param[in] s the string to be converted.
321  * @exception GeographicErr is \e s is not readable as a T.
322  * @return object of type T
323  **********************************************************************/
324  template<typename T> static T num(const std::string& s) {
325  T x;
326  std::string errmsg;
327  do { // Executed once (provides the ability to break)
328  std::istringstream is(s);
329  if (!(is >> x)) {
330  errmsg = "Cannot decode " + s;
331  break;
332  }
333  int pos = int(is.tellg()); // Returns -1 at end of string?
334  if (!(pos < 0 || pos == int(s.size()))) {
335  errmsg = "Extra text " + s.substr(pos) + " at end of " + s;
336  break;
337  }
338  return x;
339  } while (false);
340  x = std::numeric_limits<T>::is_integer ? 0 : nummatch<T>(s);
341  if (x == 0)
342  throw GeographicErr(errmsg);
343  return x;
344  }
345 
346  /**
347  * Match "nan" and "inf" (and variants thereof) in a string.
348  *
349  * @tparam T the type of the return value.
350  * @param[in] s the string to be matched.
351  * @return appropriate special value (&plusmn;&infin;, nan) or 0 if none is
352  * found.
353  **********************************************************************/
354  template<typename T> static T nummatch(const std::string& s) {
355  if (s.length() < 3)
356  return 0;
357  std::string t;
358  t.resize(s.length());
359  std::transform(s.begin(), s.end(), t.begin(), (int(*)(int))std::toupper);
360  for (size_t i = s.length(); i--;)
361  t[i] = char(std::toupper(s[i]));
362  int sign = t[0] == '-' ? -1 : 1;
363  std::string::size_type p0 = t[0] == '-' || t[0] == '+' ? 1 : 0;
364  std::string::size_type p1 = t.find_last_not_of('0');
365  if (p1 == std::string::npos || p1 + 1 < p0 + 3)
366  return 0;
367  // Strip off sign and trailing 0s
368  t = t.substr(p0, p1 + 1 - p0); // Length at least 3
369  if (t == "NAN" || t == "1.#QNAN" || t == "1.#SNAN" || t == "1.#IND" ||
370  t == "1.#R")
371  return Math::NaN<T>();
372  else if (t == "INF" || t == "1.#INF")
373  return sign * Math::infinity<T>();
374  return 0;
375  }
376 
377  /**
378  * Read a simple fraction, e.g., 3/4, from a string to an object of type T.
379  *
380  * @tparam T the type of the return value.
381  * @param[in] s the string to be converted.
382  * @exception GeographicErr is \e s is not readable as a fraction of type T.
383  * @return object of type T
384  **********************************************************************/
385  template<typename T> static T fract(const std::string& s) {
386  std::string::size_type delim = s.find('/');
387  return
388  !(delim != std::string::npos && delim >= 1 && delim + 2 <= s.size()) ?
389  num<T>(s) :
390  // delim in [1, size() - 2]
391  num<T>(s.substr(0, delim)) / num<T>(s.substr(delim + 1));
392  }
393 
394  /**
395  * Lookup up a character in a string.
396  *
397  * @param[in] s the string to be searched.
398  * @param[in] c the character to look for.
399  * @return the index of the first occurrence character in the string or
400  * &minus;1 is the character is not present.
401  *
402  * \e c is converted to upper case before search \e s. Therefore, it is
403  * intended that \e s should not contain any lower case letters.
404  **********************************************************************/
405  static int lookup(const std::string& s, char c) {
406  std::string::size_type r = s.find(char(toupper(c)));
407  return r == std::string::npos ? -1 : int(r);
408  }
409 
410  /**
411  * Read data of type ExtT from a binary stream to an array of type IntT.
412  * The data in the file is in (bigendp ? big : little)-endian format.
413  *
414  * @tparam ExtT the type of the objects in the binary stream (external).
415  * @tparam IntT the type of the objects in the array (internal).
416  * @tparam bigendp true if the external storage format is big-endian.
417  * @param[in] str the input stream containing the data of type ExtT
418  * (external).
419  * @param[out] array the output array of type IntT (internal).
420  * @param[in] num the size of the array.
421  * @exception GeographicErr if the data cannot be read.
422  **********************************************************************/
423  template<typename ExtT, typename IntT, bool bigendp>
424  static inline void readarray(std::istream& str,
425  IntT array[], size_t num) {
426 #if GEOGRAPHICLIB_PRECISION < 4
427  if (sizeof(IntT) == sizeof(ExtT) &&
428  std::numeric_limits<IntT>::is_integer ==
429  std::numeric_limits<ExtT>::is_integer)
430  {
431  // Data is compatible (aside from the issue of endian-ness).
432  str.read(reinterpret_cast<char*>(array), num * sizeof(ExtT));
433  if (!str.good())
434  throw GeographicErr("Failure reading data");
435  if (bigendp != Math::bigendian) { // endian mismatch -> swap bytes
436  for (size_t i = num; i--;)
437  array[i] = Math::swab<IntT>(array[i]);
438  }
439  }
440  else
441 #endif
442  {
443  const int bufsize = 1024; // read this many values at a time
444  ExtT buffer[bufsize]; // temporary buffer
445  int k = int(num); // data values left to read
446  int i = 0; // index into output array
447  while (k) {
448  int n = (std::min)(k, bufsize);
449  str.read(reinterpret_cast<char*>(buffer), n * sizeof(ExtT));
450  if (!str.good())
451  throw GeographicErr("Failure reading data");
452  for (int j = 0; j < n; ++j)
453  // fix endian-ness and cast to IntT
454  array[i++] = IntT(bigendp == Math::bigendian ? buffer[j] :
455  Math::swab<ExtT>(buffer[j]));
456  k -= n;
457  }
458  }
459  return;
460  }
461 
462  /**
463  * Read data of type ExtT from a binary stream to a vector array of type
464  * IntT. The data in the file is in (bigendp ? big : little)-endian
465  * format.
466  *
467  * @tparam ExtT the type of the objects in the binary stream (external).
468  * @tparam IntT the type of the objects in the array (internal).
469  * @tparam bigendp true if the external storage format is big-endian.
470  * @param[in] str the input stream containing the data of type ExtT
471  * (external).
472  * @param[out] array the output vector of type IntT (internal).
473  * @exception GeographicErr if the data cannot be read.
474  **********************************************************************/
475  template<typename ExtT, typename IntT, bool bigendp>
476  static inline void readarray(std::istream& str,
477  std::vector<IntT>& array) {
478  if (array.size() > 0)
479  readarray<ExtT, IntT, bigendp>(str, &array[0], array.size());
480  }
481 
482  /**
483  * Write data in an array of type IntT as type ExtT to a binary stream.
484  * The data in the file is in (bigendp ? big : little)-endian format.
485  *
486  * @tparam ExtT the type of the objects in the binary stream (external).
487  * @tparam IntT the type of the objects in the array (internal).
488  * @tparam bigendp true if the external storage format is big-endian.
489  * @param[out] str the output stream for the data of type ExtT (external).
490  * @param[in] array the input array of type IntT (internal).
491  * @param[in] num the size of the array.
492  * @exception GeographicErr if the data cannot be written.
493  **********************************************************************/
494  template<typename ExtT, typename IntT, bool bigendp>
495  static inline void writearray(std::ostream& str,
496  const IntT array[], size_t num) {
497 #if GEOGRAPHICLIB_PRECISION < 4
498  if (sizeof(IntT) == sizeof(ExtT) &&
499  std::numeric_limits<IntT>::is_integer ==
500  std::numeric_limits<ExtT>::is_integer &&
501  bigendp == Math::bigendian)
502  {
503  // Data is compatible (including endian-ness).
504  str.write(reinterpret_cast<const char*>(array), num * sizeof(ExtT));
505  if (!str.good())
506  throw GeographicErr("Failure writing data");
507  }
508  else
509 #endif
510  {
511  const int bufsize = 1024; // write this many values at a time
512  ExtT buffer[bufsize]; // temporary buffer
513  int k = int(num); // data values left to write
514  int i = 0; // index into output array
515  while (k) {
516  int n = (std::min)(k, bufsize);
517  for (int j = 0; j < n; ++j)
518  // cast to ExtT and fix endian-ness
519  buffer[j] = bigendp == Math::bigendian ? ExtT(array[i++]) :
520  Math::swab<ExtT>(ExtT(array[i++]));
521  str.write(reinterpret_cast<const char*>(buffer), n * sizeof(ExtT));
522  if (!str.good())
523  throw GeographicErr("Failure writing data");
524  k -= n;
525  }
526  }
527  return;
528  }
529 
530  /**
531  * Write data in an array of type IntT as type ExtT to a binary stream.
532  * The data in the file is in (bigendp ? big : little)-endian format.
533  *
534  * @tparam ExtT the type of the objects in the binary stream (external).
535  * @tparam IntT the type of the objects in the array (internal).
536  * @tparam bigendp true if the external storage format is big-endian.
537  * @param[out] str the output stream for the data of type ExtT (external).
538  * @param[in] array the input vector of type IntT (internal).
539  * @exception GeographicErr if the data cannot be written.
540  **********************************************************************/
541  template<typename ExtT, typename IntT, bool bigendp>
542  static inline void writearray(std::ostream& str,
543  std::vector<IntT>& array) {
544  if (array.size() > 0)
545  writearray<ExtT, IntT, bigendp>(str, &array[0], array.size());
546  }
547 
548  /**
549  * Parse a KEY VALUE line.
550  *
551  * @param[in] line the input line.
552  * @param[out] key the key.
553  * @param[out] val the value.
554  * @exception std::bad_alloc if memory for the internal strings can't be
555  * allocated.
556  * @return whether a key was found.
557  *
558  * A # character and everything after it are discarded. If the result is
559  * just white space, the routine returns false (and \e key and \e val are
560  * not set). Otherwise the first token is taken to be the key and the rest
561  * of the line (trimmed of leading and trailing white space) is the value.
562  **********************************************************************/
563  static bool ParseLine(const std::string& line,
564  std::string& key, std::string& val);
565 
566  /**
567  * Set the binary precision of a real number.
568  *
569  * @param[in] ndigits the number of bits of precision. If ndigits is 0
570  * (the default), then determine the precision from the environment
571  * variable GEOGRAPHICLIB_DIGITS. If this is undefined, use ndigits =
572  * 256 (i.e., about 77 decimal digits).
573  * @return the resulting number of bits of precision.
574  *
575  * This only has an effect when GEOGRAPHICLIB_PRECISION == 5.
576  **********************************************************************/
577  static int set_digits(int ndigits = 0);
578 
579  };
580 
581 } // namespace GeographicLib
582 
583 #if defined(_MSC_VER)
584 # pragma warning (pop)
585 #endif
586 
587 #endif // GEOGRAPHICLIB_UTILITY_HPP
static T fract(const std::string &s)
Definition: Utility.hpp:385
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:476
static void readarray(std::istream &str, IntT array[], size_t num)
Definition: Utility.hpp:424
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:614
static T fractionalyear(const std::string &s)
Definition: Utility.hpp:252
static void writearray(std::ostream &str, std::vector< IntT > &array)
Definition: Utility.hpp:542
static T nummatch(const std::string &s)
Definition: Utility.hpp:354
static void writearray(std::ostream &str, const IntT array[], size_t num)
Definition: Utility.hpp:495
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:208
static T num(const std::string &s)
Definition: Utility.hpp:324
Exception handling for GeographicLib.
Definition: Constants.hpp:382
Header for GeographicLib::Constants class.
static int lookup(const std::string &s, char c)
Definition: Utility.hpp:405
static int day(int y, int m=1, int d=1)
Definition: Utility.hpp:59