Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geospatial component for heightmap & DEMs #267

Merged
merged 16 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ libavdevice-dev
libavformat-dev
libavutil-dev
libfreeimage-dev
libgdal-dev
libgts-dev
libignition-cmake2-dev
libignition-math7-dev
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======")

#--------------------------------------
# Find ignition-math
ign_find_package(ignition-math7 REQUIRED_BY graphics events)
ign_find_package(ignition-math7 REQUIRED_BY geospatial graphics events)
set(IGN_MATH_VER ${ignition-math7_VERSION_MAJOR})

#--------------------------------------
Expand Down Expand Up @@ -94,6 +94,13 @@ ign_find_package(
REQUIRED_BY graphics
PRIVATE_FOR graphics)

#------------------------------------
# Find GDAL
ign_find_package(GDAL VERSION 3.0
PKGCONFIG gdal
PRIVATE_FOR geospatial
REQUIRED_BY geospatial)

#------------------------------------
# Find libswscale
ign_find_package(SWSCALE REQUIRED_BY av PRETTY libswscale)
Expand Down Expand Up @@ -125,7 +132,7 @@ configure_file("${PROJECT_SOURCE_DIR}/cppcheck.suppress.in"
${PROJECT_BINARY_DIR}/cppcheck.suppress)

ign_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS av events graphics profiler)
COMPONENTS av events geospatial graphics profiler)

#============================================================================
# Create package information
Expand Down
15 changes: 14 additions & 1 deletion Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ Deprecated code produces compile-time warnings. These warning serve as
notification to users that their code should be upgraded. The next major
release will remove the deprecated code.

## Ignition Common 4.X to 5.X

### Additions

1. **geospatial** component that loads heightmap images and DEMs
+ Depends on the ign-common's `graphics` component and the `gdal` library

### Modifications

1. `HeightmapData.hh` and `ImageHeightmap.hh` have been moved out of the
`graphics` component and into the new `geospatial` component
+ To use the heightmap features, users must add the `geospatial` component
to the `find_package` call

## Ignition Common 3.X to 4.X

### Modifications
Expand Down Expand Up @@ -72,4 +86,3 @@ release will remove the deprecated code.
1. **ignition-cmake**
+ Ignition-math now has a build dependency on ignition-cmake, which
allows cmake scripts to be shared across all the ignition packages.

2 changes: 2 additions & 0 deletions geospatial/include/ignition/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

ign_install_all_headers(COMPONENT geospatial)
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
#define IGNITION_COMMON_DEM_HH_

#include <memory>
#include <string>
#include <vector>

#include <ignition/math/Vector3.hh>
#include <ignition/math/Angle.hh>

#include <ignition/common/HeightmapData.hh>
#include <ignition/common/graphics/Export.hh>

#include <ignition/utils/ImplPtr.hh>

#ifdef HAVE_GDAL
# include <string>
# include <vector>

# include <ignition/common/HeightmapData.hh>

namespace ignition
{
Expand All @@ -53,7 +52,8 @@ namespace ignition
/// \brief Get the elevation of a terrain's point in meters.
/// \param[in] _x X coordinate of the terrain.
/// \param[in] _y Y coordinate of the terrain.
/// \return Terrain's elevation at (x,y) in meters.
/// \return Terrain's elevation at (x,y) in meters or infinity if illegal
/// coordinates were provided.
public: double Elevation(double _x, double _y);

/// \brief Get the terrain's minimum elevation in meters.
Expand All @@ -68,7 +68,8 @@ namespace ignition
/// origin in WGS84.
/// \param[out] _latitude Georeferenced latitude.
/// \param[out] _longitude Georeferenced longitude.
public: void GeoReferenceOrigin(ignition::math::Angle &_latitude,
/// \return True if able to retrieve origin coordinates. False otherwise.
public: bool GeoReferenceOrigin(ignition::math::Angle &_latitude,
ignition::math::Angle &_longitude) const;

/// \brief Get the terrain's height. Due to the Ogre constrains, this
Expand Down Expand Up @@ -120,7 +121,8 @@ namespace ignition
/// \param[in] _y Y coordinate of the terrain.
/// \param[out] _latitude Georeferenced latitude.
/// \param[out] _longitude Georeferenced longitude.
private: void GeoReference(double _x, double _y,
/// \return True if able to retrieve coordinates. False otherwise.
private: bool GeoReference(double _x, double _y,
ignition::math::Angle &_latitude,
ignition::math::Angle &_longitude) const;

Expand All @@ -130,11 +132,13 @@ namespace ignition
/// \return 0 when the operation succeeds to open a file.
private: int LoadData();

// Documentation inherited.
public: std::string Filename() const;

/// internal
/// \brief Pointer to the private data.
IGN_UTILS_IMPL_PTR(dataPtr)
};
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_COMMON_HEIGHTMAPDATA_HH_
#define IGNITION_COMMON_HEIGHTMAPDATA_HH_

#include <string>
#include <vector>
#include <ignition/math/Vector3.hh>
#include <ignition/common/graphics/Export.hh>
Expand Down Expand Up @@ -57,6 +58,17 @@ namespace ignition
/// \brief Get the maximum terrain's elevation.
/// \return The maximum terrain's elevation.
public: virtual float MaxElevation() const = 0;

/// \brief Get the min terrain's elevation.
/// \return The min terrain's elevation.
public: virtual float MinElevation() const
{
return 0.0f;
}

/// \brief Get the full filename of loaded heightmap image/dem
/// \return The filename used to load the heightmap image/dem
public: virtual std::string Filename() const = 0;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ namespace ignition
const ignition::math::Vector3d &_scale, bool _flipY,
std::vector<float> &_heights);

/// \brief Get the full filename of the image
/// \return The filename used to load the image
// Documentation inherited.
public: std::string Filename() const;

// Documentation inherited.
Expand Down
22 changes: 22 additions & 0 deletions geospatial/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

ign_get_libsources_and_unittests(sources gtest_sources)

ign_add_component(geospatial
SOURCES ${sources}
DEPENDS_ON_COMPONENTS graphics
GET_TARGET_NAME geospatial_target)

target_link_libraries(${geospatial_target}
PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}-graphics
ignition-math${IGN_MATH_VER}::ignition-math${IGN_MATH_VER}
ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER}
PRIVATE
${GDAL_LIBRARY})

target_include_directories(${geospatial_target}
PRIVATE
${GDAL_INCLUDE_DIR})

ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS ${geospatial_target})
Loading