Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-04-21 16:24:39 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:16:11 +0300
commit3c634e71c76c31a3e8074f2d4772c1c6e1811208 (patch)
tree4834d2ce9efe07546c7c58ebff060ad2788cf13c /platform/location.hpp
parented69886a7e4c909b86c99d12f7f98280e6145703 (diff)
Added mac and ios location services implementation to platform
Diffstat (limited to 'platform/location.hpp')
-rw-r--r--platform/location.hpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/platform/location.hpp b/platform/location.hpp
new file mode 100644
index 0000000000..c9cf3d148a
--- /dev/null
+++ b/platform/location.hpp
@@ -0,0 +1,72 @@
+#pragma once
+
+#include "../std/string.hpp"
+#include "../std/vector.hpp"
+
+#include <boost/function.hpp>
+
+namespace location
+{
+ enum TLocationStatus
+ {
+ ENotSupported, //!< GpsInfo fields are not valid with this value
+ EDisabledByUser, //!< GpsInfo fields are not valid with this value
+ EAccurateMode,
+ ERoughMode //!< in this mode compass is turned off
+ };
+
+ /// @note always check m_status before using this structure
+ struct GpsInfo
+ {
+ TLocationStatus m_status;
+ double m_timestamp; //!< seconds from 01/01/1970
+ double m_latitude; //!< degrees @TODO mercator
+ double m_longitude; //!< degrees @TODO mercator
+ double m_horizontalAccuracy; //!< metres
+ double m_altitude; //!< metres
+ double m_verticalAccuracy; //!< metres
+ double m_course; //!< positive degrees from the true North
+ double m_speed; //!< metres per second
+ };
+
+ struct CompassInfo
+ {
+ double m_timestamp; //!< seconds from 01/01/1970
+ double m_magneticHeading; //!< positive degrees from the magnetic North
+ double m_trueHeading; //!< positive degrees from the true North
+ double m_accuracy; //!< offset from magnetic to true North
+ int m_x;
+ int m_y;
+ int m_z;
+ };
+
+ typedef boost::function1<void, GpsInfo const &> TGpsCallback;
+ typedef boost::function1<void, CompassInfo const &> TCompassCallback;
+
+ class LocationService
+ {
+ typedef vector<TGpsCallback> GpsObserversT;
+ GpsObserversT m_gpsObservers;
+ typedef vector<TCompassCallback> CompassObserversT;
+ CompassObserversT m_compassObservers;
+
+ protected:
+ void NotifySubscribers(GpsInfo const & info);
+ void NotifySubscribers(CompassInfo const & info);
+
+ public:
+ /// @note unsubscribe doesn't work with boost::function
+ void SubscribeToGpsUpdates(TGpsCallback observer);
+ void SubscribeToCompassUpdates(TCompassCallback observer);
+// void Unsubscribe(TGpsCallback observer);
+// void Unsubscribe(TCompassCallback observer);
+
+ /// to change active accuracy mode just call it again
+ /// @param useAccurateMode if true also enables compass if it's available
+ virtual void StartUpdate(bool useAccurateMode) = 0;
+ virtual void StopUpdate() = 0;
+ };
+
+}
+
+extern "C" location::LocationService & GetLocationService();