From 3c634e71c76c31a3e8074f2d4772c1c6e1811208 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Thu, 21 Apr 2011 14:24:39 +0200 Subject: Added mac and ios location services implementation to platform --- platform/location.hpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 platform/location.hpp (limited to 'platform/location.hpp') 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 + +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 TGpsCallback; + typedef boost::function1 TCompassCallback; + + class LocationService + { + typedef vector GpsObserversT; + GpsObserversT m_gpsObservers; + typedef vector 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(); -- cgit v1.2.3