forked from ethz-asl/grid_map_geo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide GDAL from public interface, fix export (ethz-asl#59)
* Enforce export in CI * Hide implementation details of GDAL in implementation * Switch to build-scope includes * Install headers per latest ament recommendations to allow package: https://docs.ros.org/en/humble/How-To-Guides/Ament-CMake-Documentation.html#adding-targets * This is crucial before realeasing as a library * Remove unused yaml dependency * Add all missing libraries in ament_export_dependencies * Fix a few typos in comments * Add badges for all jobs but point them to the default ros2 branch rather than any branch * Fix style check not running on ros2 branch Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
- Loading branch information
Showing
14 changed files
with
133 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Style Checks | |
on: | ||
push: | ||
branches: | ||
- master | ||
- ros2 | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/**************************************************************************** | ||
* | ||
* Copyright (c) 2022 Jaeyoung Lim, ASL, ETH Zurich, Switzerland | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* 3. Neither the name terrain-navigation nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************/ | ||
|
||
#include "grid_map_geo/transform.hpp" | ||
|
||
#if __APPLE__ | ||
#include <gdal.h> | ||
#include <gdal_priv.h> | ||
#include <ogr_p.h> | ||
#include <ogr_spatialref.h> | ||
#else | ||
#include <gdal/gdal.h> | ||
#include <gdal/gdal_priv.h> | ||
#include <gdal/ogr_p.h> | ||
#include <gdal/ogr_spatialref.h> | ||
#endif | ||
|
||
Eigen::Vector3d transformCoordinates(ESPG src_coord, ESPG tgt_coord, const Eigen::Vector3d source_coordinates) { | ||
OGRSpatialReference source, target; | ||
source.importFromEPSG(static_cast<int>(src_coord)); | ||
target.importFromEPSG(static_cast<int>(tgt_coord)); | ||
|
||
OGRPoint p; | ||
p.setX(source_coordinates(0)); | ||
p.setY(source_coordinates(1)); | ||
p.setZ(source_coordinates(2)); | ||
p.assignSpatialReference(&source); | ||
|
||
p.transformTo(&target); | ||
Eigen::Vector3d target_coordinates(p.getX(), p.getY(), p.getZ()); | ||
return target_coordinates; | ||
} | ||
|
||
Eigen::Vector3d transformCoordinates(ESPG src_coord, const std::string wkt, const Eigen::Vector3d source_coordinates) { | ||
OGRSpatialReference source, target; | ||
char* wkt_string = const_cast<char*>(wkt.c_str()); | ||
source.importFromEPSG(static_cast<int>(src_coord)); | ||
target.importFromWkt(&wkt_string); | ||
|
||
OGRPoint p; | ||
p.setX(source_coordinates(0)); | ||
p.setY(source_coordinates(1)); | ||
p.setZ(source_coordinates(2)); | ||
p.assignSpatialReference(&source); | ||
|
||
p.transformTo(&target); | ||
Eigen::Vector3d target_coordinates(p.getX(), p.getY(), p.getZ()); | ||
return target_coordinates; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Add gtest based cpp test target and link libraries | ||
cmake_minimum_required(VERSION 3.14) | ||
project(grid_map_export_test) | ||
find_package(grid_map_geo REQUIRED) | ||
add_executable(main main.cpp) | ||
target_link_libraries(main PRIVATE grid_map_geo::grid_map_geo) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
|
||
#include "grid_map_geo/grid_map_geo.hpp" | ||
|
||
int main() { | ||
// Instantiate the class and call it so this doesn't get optimized out. | ||
auto gmg = GridMapGeo(); | ||
std::cout << gmg.getCoordinateName() << std::endl; | ||
return 0; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.