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
34enum { SPEED_KTS = 0, SPEED_MPH, SPEED_KMH, SPEED_MS };
35
36enum {
37 DISTANCE_NMI = 0,
38 DISTANCE_MI,
39 DISTANCE_KM,
40 DISTANCE_M,
41 DISTANCE_FT,
42 DISTANCE_FA,
43 DISTANCE_IN,
44 DISTANCE_CM
45};
46
48public:
49 static wxString GetUUID(void);
50 static void SeedRandom();
51
52private:
53 static int GetRandomNumber(int min, int max);
54};
55
56
57extern wxString toSDMM(int NEflag, double a, bool hi_precision = true);
58extern double toUsrSpeed(double kts_speed, int unit = -1);
59extern wxString getUsrSpeedUnit(int unit = -1);
60extern wxString FormatDistanceAdaptive(double distance);
61
62extern double toUsrDistance(double nm_distance, int unit = -1);
63extern wxString getUsrDistanceUnit(int unit = -1);
64extern double fromUsrDistance(double usr_distance, int unit, int default_val);
65extern double fromUsrSpeed(double usr_speed, int unit, int default_val);
66
67const wxChar *ParseGPXDateTime(wxDateTime &dt, const wxChar *datetime);
68
69extern wxString formatTimeDelta(wxTimeSpan span);
70extern wxString formatTimeDelta(wxDateTime startTime, wxDateTime endTime);
71extern wxString formatTimeDelta(wxLongLong secs);
72
73extern double fromDMM(wxString sdms);
74#endif // _NAVUTIL_BASE__