diff options
Diffstat (limited to 'src/lib/geo')
-rw-r--r-- | src/lib/geo/geo.c | 10 | ||||
-rw-r--r-- | src/lib/geo/geo.h | 7 |
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°) |