geo: Moved the map_projection_* functions and state into a self-contained C++ class

This commit is contained in:
Thomas Debrunner
2021-12-06 14:30:14 +01:00
committed by Matthias Grob
parent fe23718e2c
commit 8db7a6225b
38 changed files with 324 additions and 329 deletions
+4 -4
View File
@@ -75,13 +75,13 @@ void OutputBase::publish()
float OutputBase::_calculate_pitch(double lon, double lat, float altitude,
const vehicle_global_position_s &global_position)
{
if (!map_projection_initialized(&_projection_reference)) {
map_projection_init(&_projection_reference, global_position.lat, global_position.lon);
if (!_projection_reference.isInitialized()) {
_projection_reference.initReference(global_position.lat, global_position.lon);
}
float x1, y1, x2, y2;
map_projection_project(&_projection_reference, lat, lon, &x1, &y1);
map_projection_project(&_projection_reference, global_position.lat, global_position.lon, &x2, &y2);
_projection_reference.project(lat, lon, x1, y1);
_projection_reference.project(global_position.lat, global_position.lon, x2, y2);
float dx = x1 - x2, dy = y1 - y2;
float target_distance = sqrtf(dx * dx + dy * dy);
float z = altitude - global_position.alt;
+1 -1
View File
@@ -101,7 +101,7 @@ protected:
float _calculate_pitch(double lon, double lat, float altitude,
const vehicle_global_position_s &global_position);
map_projection_reference_s _projection_reference = {}; ///< reference to convert (lon, lat) to local [m]
MapProjection _projection_reference = {}; ///< reference to convert (lon, lat) to local [m]
const OutputConfig &_config;