Skip to content

Commit c118d47

Browse files
committed
make geoconversions static
This fixes build issues that appeared in CI F F Fix
1 parent b741a2b commit c118d47

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

terrain_navigation_ros/include/terrain_navigation_ros/geo_conversions.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,33 @@
3535
#ifndef GEOCONVERSIONS_H
3636
#define GEOCONVERSIONS_H
3737

38+
#include <grid_map_geo/transform.h>
3839
#include <math.h>
3940
#include <Eigen/Dense>
4041

41-
enum class EPSG { ECEF = 4978, WGS84 = 4326, WGS84_32N = 32632, CH1903_LV03 = 21781, AT_GK_West = 31254 };
42-
43-
/**
44-
* @brief Helper function for transforming using gdal
45-
*
46-
* @param src_coord
47-
* @param tgt_coord
48-
* @param source_coordinates
49-
* @return Eigen::Vector3d
50-
*/
42+
#include <gdal/cpl_string.h>
43+
#include <gdal/gdal.h>
44+
#include <gdal/gdal_priv.h>
45+
#include <gdal/ogr_p.h>
46+
#include <gdal/ogr_spatialref.h>
5147

5248
class GeoConversions {
5349
public:
5450
GeoConversions();
5551
virtual ~GeoConversions();
5652

57-
Eigen::Vector3d transformCoordinates(EPSG src_coord, EPSG tgt_coord, const Eigen::Vector3d source_coordinates);
53+
static Eigen::Vector3d transformCoordinates(EPSG src_coord, EPSG tgt_coord, const Eigen::Vector3d source_coordinates);
5854

5955
private:
60-
Eigen::Vector3d _transformUsingGDAL(EPSG src_coord, EPSG tgt_coord, const Eigen::Vector3d source_coordinates);
56+
/**
57+
* @brief Helper function for transforming using gdal
58+
*
59+
* @param src_coord
60+
* @param tgt_coord
61+
* @param source_coordinates
62+
* @return Eigen::Vector3d
63+
*/
64+
static Eigen::Vector3d transformUsingGDAL(EPSG src_coord, EPSG tgt_coord, const Eigen::Vector3d source_coordinates);
6165

6266
/**
6367
* @brief Convert WGS84 (LLA) to LV03/CH1903

terrain_navigation_ros/src/geo_conversions.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11

22
#include <terrain_navigation_ros/geo_conversions.h>
33

4-
Eigen::Vector3d GeoConversions::transformCoordinates(EPSG src_coord, EPSG tgt_coord,
5-
const Eigen::Vector3d source_coordinates) {
6-
Eigen::Vector3d target_coordinates;
7-
if (src_coord == EPSG::WGS84 && tgt_coord == EPSG::CH1903_LV03) {
8-
GeoConversions::_forward(source_coordinates(0), source_coordinates(1), source_coordinates(2), target_coordinates(0),
9-
target_coordinates(1), target_coordinates(2));
10-
return target_coordinates;
11-
} else if (src_coord == EPSG::CH1903_LV03 && tgt_coord == EPSG::WGS84) {
12-
GeoConversions::_reverse(source_coordinates(0), source_coordinates(1), source_coordinates(2), target_coordinates(0),
13-
target_coordinates(1), target_coordinates(2));
14-
return target_coordinates;
15-
} else
16-
return GeoConversions::_transformUsingGDAL(src_coord, tgt_coord, source_coordinates);
17-
};
18-
194
Eigen::Vector3d _transformUsingGDAL(EPSG src_coord, EPSG tgt_coord, const Eigen::Vector3d source_coordinates) {
205
OGRSpatialReference source, target;
216
source.importFromEPSG(static_cast<int>(src_coord));
@@ -39,8 +24,23 @@ Eigen::Vector3d _transformUsingGDAL(EPSG src_coord, EPSG tgt_coord, const Eigen:
3924
return target_coordinates;
4025
};
4126

42-
static void GeoConversions::_forward(const double lat, const double lon, const double alt, double &y, double &x,
43-
double &h) {
27+
Eigen::Vector3d GeoConversions::transformCoordinates(EPSG src_coord, EPSG tgt_coord,
28+
const Eigen::Vector3d source_coordinates) {
29+
Eigen::Vector3d target_coordinates;
30+
if (src_coord == EPSG::WGS84 && tgt_coord == EPSG::CH1903_LV03) {
31+
_forward(source_coordinates(0), source_coordinates(1), source_coordinates(2), target_coordinates(0),
32+
target_coordinates(1), target_coordinates(2));
33+
return target_coordinates;
34+
} else if (src_coord == EPSG::CH1903_LV03 && tgt_coord == EPSG::WGS84) {
35+
_reverse(source_coordinates(0), source_coordinates(1), source_coordinates(2), target_coordinates(0),
36+
target_coordinates(1), target_coordinates(2));
37+
return target_coordinates;
38+
}
39+
// else
40+
return _transformUsingGDAL(src_coord, tgt_coord, source_coordinates);
41+
};
42+
43+
void GeoConversions::_forward(const double lat, const double lon, const double alt, double &y, double &x, double &h) {
4444
// 1. Convert the ellipsoidal latitudes φ and longitudes λ into arcseconds ["]
4545
const double lat_arc = lat * 3600.0;
4646
const double lon_arc = lon * 3600.0;
@@ -66,8 +66,7 @@ static void GeoConversions::_forward(const double lat, const double lon, const d
6666
h = alt - 49.55 + 2.73 * lon_aux + 6.94 * lat_aux;
6767
};
6868

69-
static void GeoConversions::_reverse(const double y, const double x, const double h, double &lat, double &lon,
70-
double &alt) {
69+
void GeoConversions::_reverse(const double y, const double x, const double h, double &lat, double &lon, double &alt) {
7170
// 1. Convert the projection coordinates E (easting) and N (northing) in LV95 (or y / x in LV03) into the civilian
7271
// system (Bern = 0 / 0) and express in the unit [1000 km]: E' = (E – 2600000 m)/1000000 = (y – 600000 m)/1000000
7372
// N' = (N – 1200000 m)/1000000 = (x – 200000 m)/1000000

0 commit comments

Comments
 (0)