OpenCPN Partial API docs
navutil_base.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Navigation Utility Functions without GUI dependencies.
5  * Author: David Register
6  *
7  ***************************************************************************
8  * Copyright (C) 2010 by David S. Register *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
26 #ifndef _NAVUTIL_BASE__
27 #define _NAVUTIL_BASE__
28 
29 #include <wx/datetime.h>
30 #include <wx/string.h>
31 #include <wx/utils.h>
32 
33 #include "model/config_vars.h"
34 
35 
36 enum { SPEED_KTS = 0, SPEED_MPH, SPEED_KMH, SPEED_MS };
37 enum { WSPEED_KTS = 0, WSPEED_MS, WSPEED_MPH, WSPEED_KMH };
38 enum { DEPTH_FT = 0, DEPTH_M, DEPTH_FA };
39 enum { TEMPERATURE_C = 0, TEMPERATURE_F = 1, TEMPERATURE_K = 2 };
40 
41 enum {
42  DISTANCE_NMI = 0,
43  DISTANCE_MI,
44  DISTANCE_KM,
45  DISTANCE_M,
46  DISTANCE_FT,
47  DISTANCE_FA,
48  DISTANCE_IN,
49  DISTANCE_CM
50 };
51 
52 class GpxDocument {
53 public:
54  static wxString GetUUID(void);
55  static void SeedRandom();
56 
57 private:
58  static int GetRandomNumber(int min, int max);
59 };
60 
61 
62 extern wxString toSDMM(int NEflag, double a, bool hi_precision = true);
63 extern double toUsrSpeed(double kts_speed, int unit = -1);
64 extern double toUsrWindSpeed(double kts_speed, int unit = -1);
65 extern wxString getUsrSpeedUnit(int unit = -1);
66 extern wxString getUsrWindSpeedUnit(int unit = -1);
67 extern wxString getUsrTempUnit(int unit = -1);
68 extern wxString FormatDistanceAdaptive(double distance);
69 extern double toUsrTemp(double cel_temp, int unit = -1);
70 
71 extern double toUsrDistance(double nm_distance, int unit = -1);
72 extern wxString getUsrDistanceUnit(int unit = -1);
73 extern double fromUsrDistance(double usr_distance, int unit, int default_val);
74 extern double fromUsrSpeed(double usr_speed, int unit, int default_val);
75 
76 extern double toUsrDepth(double cel_depth, int unit = -1);
77 extern double fromUsrDepth(double usr_depth, int unit = -1);
78 extern wxString getUsrDepthUnit(int unit = -1);
79 
80 const wxChar *ParseGPXDateTime(wxDateTime &dt, const wxChar *datetime);
81 
82 extern wxString formatTimeDelta(wxTimeSpan span);
83 extern wxString formatTimeDelta(wxDateTime startTime, wxDateTime endTime);
84 extern wxString formatTimeDelta(wxLongLong secs);
85 
86 extern double fromDMM(wxString sdms);
87 
88 extern double toMagnetic(double deg_true);
89 extern double toMagnetic(double deg_true, double variation);
90 #endif // _NAVUTIL_BASE__