2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003-2013 Victor Kirhenshtein
5 ** This program is free software; you can redistribute it and/or modify
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
8 ** (at your option) any later version.
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.
15 ** You should have received a copy of the GNU Lesser 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.
19 ** File: geolocation.h
23 #ifndef _geolocation_h_
24 #define _geolocation_h_
40 class LIBNETXMS_EXPORTABLE GeoLocation
52 void posToString(bool isLat
, double pos
);
54 static int getIntegerDegree(double pos
);
55 static int getIntegerMinutes(double pos
);
56 static double getDecimalSeconds(double pos
);
58 static double parse(const TCHAR
*str
, bool isLat
, bool *isValid
);
59 bool parseLatitude(const TCHAR
*lat
);
60 bool parseLongitude(const TCHAR
*lon
);
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);
66 GeoLocation(const GeoLocation
&src
);
67 GeoLocation(NXCPMessage
&msg
);
70 GeoLocation
& operator =(const GeoLocation
&src
);
72 int getType() const { return m_type
; }
73 double getLatitude() const { return m_lat
; }
74 double getLongitude() const { return m_lon
; }
75 const TCHAR
*getLatitudeAsString() const { return m_latStr
; }
76 const TCHAR
*getLongitudeAsString() const { return m_lonStr
; }
77 bool isValid() const { return m_isValid
; }
78 bool isManual() const { return m_type
== GL_MANUAL
; }
79 int getAccuracy() const { return m_accuracy
; }
80 time_t getTimestamp() const { return m_timestamp
; }
81 bool sameLocation(double lat
, double lon
, int oldAccurasy
) const;
82 int calculateDistance(GeoLocation
&location
) const;
84 void fillMessage(NXCPMessage
&msg
) const;
86 json_t
*toJson() const;
88 static GeoLocation
parseAgentData(const TCHAR
*data
);