added geolocation attribute to objects; # escaping removed for table object_propertie...
[public/netxms.git] / include / geolocation.h
CommitLineData
e2babedf
VK
1/*
2** NetXMS - Network Management System
3** Copyright (C) 2003-2009 Victor Kirhenshtein
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
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**
15** You should have received a copy of the GNU General Public License
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>
27
28
29//
30// Location types
31//
32
33#define GL_UNSET 0
34#define GL_MANUAL 1
35#define GL_GPS 2
36
37
38//
39// Geo location class
40//
41
42class LIBNETXMS_EXPORTABLE GeoLocation
43{
44private:
45 int m_type;
46 double m_lat;
47 double m_lon;
48 TCHAR m_latStr[20];
49 TCHAR m_lonStr[20];
50 bool m_isValid;
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();
64 GeoLocation(int type, double lat, double lon);
65 GeoLocation(int type, const TCHAR *lat, const TCHAR *lon);
66 GeoLocation(GeoLocation &src);
67 ~GeoLocation();
68
69 GeoLocation& operator =(const GeoLocation &src);
70
71 int getType() { return m_type; }
72 double getLatitude() { return m_lat; }
73 double getLongitude() { return m_lon; }
74 const TCHAR *getLatitudeAsString() { return m_latStr; }
75 const TCHAR *getLongitudeAsString() { return m_lonStr; }
76 bool isValid() { return m_isValid; }
77};
78
79
80#endif