Skip to content

Commit

Permalink
Fix for geos >= 3.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gergondet committed Jul 10, 2023
1 parent 4ef7dae commit b9a3620
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/mc_rbdyn/Contact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

#include <geos/version.h>

#include <geos/geom/CoordinateSequenceFactory.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/LinearRing.h>
#include <geos/geom/Polygon.h>

#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR < 12
# include <geos/geom/CoordinateSequenceFactory.h>
#endif

namespace mc_rbdyn
{

Expand Down Expand Up @@ -66,7 +69,11 @@ std::vector<sva::PTransformd> computePoints(const mc_rbdyn::Surface & robotSurfa
const geos::geom::GeometryFactory & factory = *factory_ptr;

// Create robot surf polygon
#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 12
auto robotPoints2dseq = std::make_unique<geos::geom::CoordinateSequence>(static_cast<size_t>(0), 0);
#else
auto robotPoints2dseq = factory.getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 0);
#endif
std::vector<geos::geom::Coordinate> points;
for(const std::pair<double, double> & p : robotPoints2d)
{
Expand All @@ -82,7 +89,11 @@ std::vector<sva::PTransformd> computePoints(const mc_rbdyn::Surface & robotSurfa
#endif

// Create env surf polygon
#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 12
auto envPoints2dseq = std::make_unique<geos::geom::CoordinateSequence>(static_cast<size_t>(0), 0);
#else
auto envPoints2dseq = factory.getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 0);
#endif
points.clear();
for(const std::pair<double, double> & p : envPoints2d)
{
Expand Down
14 changes: 13 additions & 1 deletion src/mc_rbdyn/PolygonInterpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
#include <geos/version.h>

#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/CoordinateSequenceFactory.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/LinearRing.h>
#include <geos/geom/Polygon.h>

#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR < 12
# include <geos/geom/CoordinateSequenceFactory.h>
#endif

namespace mc_rbdyn
{

Expand Down Expand Up @@ -42,7 +45,11 @@ std::shared_ptr<geos::geom::Geometry> PolygonInterpolator::fast_interpolate(doub
double perc = std::max(std::min(percent, 1.), -1.);
if(perc < 0) { perc = 1 + perc; }
std::vector<tuple_t> points;
#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 12
auto seq = std::make_unique<geos::geom::CoordinateSequence>(static_cast<size_t>(0), 0);
#else
auto seq = geom_factory.getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 0);
#endif
std::vector<geos::geom::Coordinate> seq_points;
for(const auto & p : tuple_pairs_)
{
Expand Down Expand Up @@ -77,8 +84,13 @@ std::vector<PolygonInterpolator::tuple_t> PolygonInterpolator::midpoint_derivati
std::vector<PolygonInterpolator::tuple_t> PolygonInterpolator::normal_derivative(double epsilon_derivative)
{
std::vector<tuple_t> res;
#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 12
auto seq_s = std::make_unique<geos::geom::CoordinateSequence>(static_cast<size_t>(0), 2);
auto seq_d = std::make_unique<geos::geom::CoordinateSequence>(static_cast<size_t>(0), 2);
#else
auto seq_s = geom_factory.getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 2);
auto seq_d = geom_factory.getCoordinateSequenceFactory()->create(static_cast<size_t>(0), 2);
#endif
std::vector<geos::geom::Coordinate> points_s;
std::vector<geos::geom::Coordinate> points_d;
for(const auto & p : tuple_pairs_)
Expand Down

0 comments on commit b9a3620

Please sign in to comment.