64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#ifndef STEPLOGGERWRAPPERANDROID_H
|
|
#define STEPLOGGERWRAPPERANDROID_H
|
|
|
|
#include "Scaler.h"
|
|
#include "../nav/NavControllerListener.h"
|
|
#include <Indoor/misc/Debug.h>
|
|
|
|
#ifdef ANDROID
|
|
#include <QtAndroidExtras>
|
|
#endif
|
|
|
|
/**
|
|
* sends the position-estimation-result to the step-logger service
|
|
*/
|
|
class StepLoggerWrapperAndroid : public NavControllerListener {
|
|
|
|
public:
|
|
|
|
/** convert from our position-format to ipin position-format */
|
|
IPINScaler& scaler;
|
|
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
StepLoggerWrapperAndroid(IPINScaler& scaler) : scaler(scaler) {
|
|
;
|
|
}
|
|
|
|
|
|
/**
|
|
* event fired every 500ms from the navigation controller.
|
|
* convert from our format to IPIN format
|
|
* and pass it to the logger
|
|
*/
|
|
void onNewEstimation(const Point3 pos_m) override {
|
|
|
|
// convert from our coordinate system (meter relative to (0,0,0)) to the WGS84 format
|
|
const IPIN ipin = scaler.toIPIN3(pos_m);
|
|
|
|
// inform the logger
|
|
log(ipin.lon, ipin.lat, ipin.floorNr);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
/** call java */
|
|
void log(const double x, const double y, const double z) {
|
|
|
|
#ifdef ANDROID
|
|
//Log::add("SLWA", "calling android with lon/lat/floor");
|
|
|
|
double rounded_z = std::round(z);
|
|
int res = QAndroidJniObject::callStaticMethod<int>("indoor/java/StepLoggerClient", "log", "(DDD)I", x, y, rounded_z);
|
|
//if (res != 1337) {throw Exception("invalid return code while sending the current position to StepLogger.\nService Down?");}
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // STEPLOGGERWRAPPERANDROID_H
|