geo: interface to get reference lat lon, option to set reference timestamp on initialization

This commit is contained in:
Thomas Gubler
2014-04-25 09:41:46 +02:00
parent 4e30784d6c
commit 9ebd6b3486
2 changed files with 21 additions and 3 deletions
+14 -2
View File
@@ -67,7 +67,7 @@ __EXPORT uint64_t map_projection_timestamp()
return mp_ref.timestamp;
}
__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
__EXPORT void map_projection_init(double lat_0, double lon_0, uint64_t timestamp) //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;
mp_ref.lon = lon_0 / 180.0 * M_PI;
@@ -75,10 +75,22 @@ __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.timestamp = timestamp;
mp_ref.init_done = true;
}
__EXPORT bool map_projection_reference(double *ref_lat, double *ref_lon)
{
if (!map_projection_initialized()) {
return false;
}
*ref_lat = mp_ref.lat;
*ref_lon = mp_ref.lon;
return true;
}
__EXPORT bool map_projection_project(double lat, double lon, float *x, float *y)
{
if (!map_projection_initialized()) {
+7 -1
View File
@@ -88,6 +88,12 @@ __EXPORT bool map_projection_initialized();
*/
__EXPORT uint64_t map_projection_timestamp();
/**
* Writes the reference values to ref_lat and ref_lon
* @return true if map_projection_init was called before, false else
*/
__EXPORT bool map_projection_reference(double *ref_lat, double *ref_lon);
/**
* Initializes the map transformation.
*
@@ -95,7 +101,7 @@ __EXPORT uint64_t map_projection_timestamp();
* @param lat in degrees (47.1234567°, not 471234567°)
* @param lon in degrees (8.1234567°, not 81234567°)
*/
__EXPORT void map_projection_init(double lat_0, double lon_0);
__EXPORT void map_projection_init(double lat_0, double lon_0, uint64_t timestamp);
/**
* Transforms a point in the geographic coordinate system to the local azimuthal equidistant plane