added Eclipse project for nxscript
[public/netxms.git] / include / geolocation.h
CommitLineData
4899db4d 1/*
e2babedf 2** NetXMS - Network Management System
2478a40a 3** Copyright (C) 2003-2013 Victor Kirhenshtein
e2babedf
VK
4**
5** This program is free software; you can redistribute it and/or modify
68f384ea
VK
6** it under the terms of the GNU Lesser General Public License as published by
7** the Free Software Foundation; either version 3 of the License, or
e2babedf
VK
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
68f384ea 15** You should have received a copy of the GNU Lesser General Public License
e2babedf
VK
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** File: geolocation.h
20**
21**/
22
23#ifndef _geolocation_h_
24#define _geolocation_h_
25
26#include <nms_util.h>
40bd1038 27#include <nxcpapi.h>
e2babedf 28
2478a40a
VK
29/**
30 * Location types
31 */
e2babedf
VK
32#define GL_UNSET 0
33#define GL_MANUAL 1
34#define GL_GPS 2
2478a40a 35#define GL_NETWORK 3
e2babedf 36
2478a40a
VK
37/**
38 * Geo location class
39 */
e2babedf
VK
40class LIBNETXMS_EXPORTABLE GeoLocation
41{
42private:
43 int m_type;
44 double m_lat;
45 double m_lon;
46 TCHAR m_latStr[20];
47 TCHAR m_lonStr[20];
48 bool m_isValid;
2478a40a 49 int m_accuracy;
f2d5b2c4 50 time_t m_timestamp;
e2babedf
VK
51
52 void posToString(bool isLat, double pos);
53
54 static int getIntegerDegree(double pos);
55 static int getIntegerMinutes(double pos);
56 static double getDecimalSeconds(double pos);
57
58 static double parse(const TCHAR *str, bool isLat, bool *isValid);
59 bool parseLatitude(const TCHAR *lat);
60 bool parseLongitude(const TCHAR *lon);
61
62public:
63 GeoLocation();
f2d5b2c4
VK
64 GeoLocation(int type, double lat, double lon, int accuracy = 0, time_t timestamp = 0);
65 GeoLocation(int type, const TCHAR *lat, const TCHAR *lon, int accuracy = 0, time_t timestamp = 0);
0322eed7 66 GeoLocation(const GeoLocation &src);
b368969c 67 GeoLocation(NXCPMessage &msg);
e2babedf
VK
68 ~GeoLocation();
69
70 GeoLocation& operator =(const GeoLocation &src);
71
72 int getType() { return m_type; }
73 double getLatitude() { return m_lat; }
74 double getLongitude() { return m_lon; }
75 const TCHAR *getLatitudeAsString() { return m_latStr; }
76 const TCHAR *getLongitudeAsString() { return m_lonStr; }
77 bool isValid() { return m_isValid; }
2478a40a 78 int getAccuracy() { return m_accuracy; }
f2d5b2c4 79 time_t getTimestamp() { return m_timestamp; }
e8b3beef 80 bool sameLocation(double lat, double lon, int oldAccurasy);
40bd1038 81
b368969c 82 void fillMessage(NXCPMessage &msg);
e2babedf
VK
83};
84
85
86#endif