OpenCPN Partial API docs
Loading...
Searching...
No Matches
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
35enum { SPEED_KTS = 0, SPEED_MPH, SPEED_KMH, SPEED_MS };
36enum { WSPEED_KTS = 0, WSPEED_MS, WSPEED_MPH, WSPEED_KMH };
37enum { DEPTH_FT = 0, DEPTH_M, DEPTH_FA };
38enum { TEMPERATURE_C = 0, TEMPERATURE_F = 1, TEMPERATURE_K = 2 };
39
40enum {
41 DISTANCE_NMI = 0,
42 DISTANCE_MI,
43 DISTANCE_KM,
44 DISTANCE_M,
45 DISTANCE_FT,
46 DISTANCE_FA,
47 DISTANCE_IN,
48 DISTANCE_CM
49};
50
52public:
53 static wxString GetUUID(void);
54 static void SeedRandom();
55
56private:
57 static int GetRandomNumber(int min, int max);
58};
59
60extern wxString toSDMM(int NEflag, double a, bool hi_precision = true);
61extern double toUsrSpeed(double kts_speed, int unit = -1);
62extern double toUsrWindSpeed(double kts_speed, int unit = -1);
63extern wxString getUsrSpeedUnit(int unit = -1);
64extern wxString getUsrWindSpeedUnit(int unit = -1);
65extern wxString getUsrTempUnit(int unit = -1);
66extern wxString FormatDistanceAdaptive(double distance);
67extern double toUsrTemp(double cel_temp, int unit = -1);
68
69extern double toUsrDistance(double nm_distance, int unit = -1);
70extern wxString getUsrDistanceUnit(int unit = -1);
71extern double fromUsrDistance(double usr_distance, int unit, int default_val);
72extern double fromUsrSpeed(double usr_speed, int unit, int default_val);
73
74extern double toUsrDepth(double cel_depth, int unit = -1);
75extern double fromUsrDepth(double usr_depth, int unit = -1);
76extern wxString getUsrDepthUnit(int unit = -1);
77
78const wxChar *ParseGPXDateTime(wxDateTime &dt, const wxChar *datetime);
79
80extern wxString formatTimeDelta(wxTimeSpan span);
81extern wxString formatTimeDelta(wxDateTime startTime, wxDateTime endTime);
82extern wxString formatTimeDelta(wxLongLong secs);
83
84extern double fromDMM(wxString sdms);
85
86extern double toMagnetic(double deg_true);
87extern double toMagnetic(double deg_true, double variation);
88#endif // _NAVUTIL_BASE__