aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-04-24 17:04:27 +0200
committerThomas Gubler <thomasgubler@gmail.com>2014-04-24 17:04:27 +0200
commit35d15720ef79dae4d6f6202092d4869a455fc7d2 (patch)
tree03beb737ee9feac783e1e33eac4a00abb760e5b8
parentbe0824c20704bc1a47fd57611cd7fba4a535df8c (diff)
downloadpx4-firmware-35d15720ef79dae4d6f6202092d4869a455fc7d2.tar.gz
px4-firmware-35d15720ef79dae4d6f6202092d4869a455fc7d2.tar.bz2
px4-firmware-35d15720ef79dae4d6f6202092d4869a455fc7d2.zip
geo: add timestamp and function to get init state
-rw-r--r--src/lib/geo/geo.c10
-rw-r--r--src/lib/geo/geo.h7
2 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/geo/geo.c b/src/lib/geo/geo.c
index 60994940f..dbbf1f80c 100644
--- a/src/lib/geo/geo.c
+++ b/src/lib/geo/geo.c
@@ -57,6 +57,11 @@
static struct map_projection_reference_s mp_ref;
+__EXPORT bool map_projection_inited()
+{
+ return mp_ref.init_done;
+}
+
__EXPORT void map_projection_init(double lat_0, double lon_0) //lat_0, lon_0 are expected to be in correct format: -> 47.1234567 and not 471234567
{
mp_ref.lat = lat_0 / 180.0 * M_PI;
@@ -65,12 +70,13 @@ __EXPORT void map_projection_init(double lat_0, double lon_0) //lat_0, lon_0 are
mp_ref.sin_lat = sin(mp_ref.lat);
mp_ref.cos_lat = cos(mp_ref.lat);
+ mp_ref.timestamp = hrt_absolute_time();
mp_ref.init_done = true;
}
__EXPORT bool map_projection_project(double lat, double lon, float *x, float *y)
{
- if (!mp_ref.init_done) {
+ if (!map_projection_inited()) {
return false;
}
@@ -92,7 +98,7 @@ __EXPORT bool map_projection_project(double lat, double lon, float *x, float *y)
__EXPORT bool map_projection_reproject(float x, float y, double *lat, double *lon)
{
- if (!mp_ref.init_done) {
+ if (!map_projection_inited()) {
return false;
}
diff --git a/src/lib/geo/geo.h b/src/lib/geo/geo.h
index b48d26a66..b19bfe462 100644
--- a/src/lib/geo/geo.h
+++ b/src/lib/geo/geo.h
@@ -72,10 +72,17 @@ struct map_projection_reference_s {
double sin_lat;
double cos_lat;
bool init_done;
+ uint64_t timestamp;
};
/**
* Initializes the map transformation.
+ * @return true if map_projection_init was called before, false else
+ */
+__EXPORT bool map_projection_inited();
+
+/**
+ * Initializes the map transformation.
*
* Initializes the transformation between the geographic coordinate system and the azimuthal equidistant plane
* @param lat in degrees (47.1234567°, not 471234567°)