From f3fa22d38d3db72185aa67fb5529dc5297d4d213 Mon Sep 17 00:00:00 2001 From: eyal0 <109809+eyal0@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:46:08 -0700 Subject: [PATCH 1/2] ci: Build with multiple versions of geos --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04b96b37..10931e061 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: matrix: os: [ubuntu, macos, windows] boost: ['1_66', 'latest'] - geos: ['3.11.0', 'none'] + geos: ['3.9.0', 'main', 'none'] compiler: ['g++', 'g++-10', 'clang++'] exclude: - os: macos # Temporarily disable until fixed @@ -38,7 +38,7 @@ jobs: - os: ubuntu boost: 1_66 compiler: g++-10 - geos: '3.11.0' + geos: 'main' code_coverage: "--enable-code-coverage" #- os: windows # shell: msys2 {0} @@ -169,11 +169,11 @@ jobs: - name: Build and install geos if: matrix.os != 'macos' && matrix.geos != 'none' run: | - if ! test -d "${LOCAL_INSTALL_PATH}/include/geos" || ! test -f ${LOCAL_INSTALL_PATH}/bin/geos.version || ! grep -qx "$(git ls-remote https://github.com/libgeos/geos.git heads/main)" ${LOCAL_INSTALL_PATH}/bin/geos.version; then - git ls-remote https://github.com/libgeos/geos.git heads/main > ${LOCAL_INSTALL_PATH}/bin/geos.version + if ! test -d "${LOCAL_INSTALL_PATH}/include/geos" || ! test -f ${LOCAL_INSTALL_PATH}/bin/geos.version || ! grep -qx "$(git ls-remote https://github.com/libgeos/geos.git ${{ matrix.geos }} )" ${LOCAL_INSTALL_PATH}/bin/geos.version; then + git ls-remote https://github.com/libgeos/geos.git ${{ matrix.geos }} > ${LOCAL_INSTALL_PATH}/bin/geos.version echo "UPDATE_CACHE=true" >> $GITHUB_ENV pushd ~ - git clone --depth 1 --branch main https://github.com/libgeos/geos.git + git clone --depth 1 --branch ${{ matrix.geos }} https://github.com/libgeos/geos.git pushd geos mkdir build pushd build @@ -301,7 +301,7 @@ jobs: run: make -j ${NUM_CPUS} check-valgrind || (cat mem-test-suite.log && false) - name: Run integration tests - if: matrix.boost == '1_66' && matrix.geos == '3.11.0' + if: matrix.boost == '1_66' && matrix.geos == 'main' run: | sudo apt-get install python3-setuptools pip3 install --user wheel colour_runner unittest2 termcolor concurrencytest in_place @@ -326,8 +326,8 @@ jobs: if [[ -e ${LOCAL_INSTALL_PATH}/lib/libgerbv.so.1 ]]; then cp -L ${LOCAL_INSTALL_PATH}/lib/libgerbv.so.1 pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; fi - if [[ -e ${LOCAL_INSTALL_PATH}/lib/libgeos-3.11.0.so ]]; then - cp -L ${LOCAL_INSTALL_PATH}/lib/libgeos-3.11.0.so pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; + if ls "${LOCAL_INSTALL_PATH}/lib/libgeos*" ]]; then + cp -L "${LOCAL_INSTALL_PATH}/lib/libgeos*" pcb2gcode-$(./pcb2gcode --version | head -1)/.libs; fi cat > pcb2gcode-$(./pcb2gcode --version | head -1)/pcb2gcode.sh << EOF From a7c2ec216cb50fa4f01d61c358cb93e7a17b01d1 Mon Sep 17 00:00:00 2001 From: eyal0 <109809+eyal0@users.noreply.github.com> Date: Wed, 7 Dec 2022 22:09:53 -0700 Subject: [PATCH 2/2] fix: Don't use the CoordinateSequenceFactory. It's not used anymore in geos since geos commit https://github.com/libgeos/geos/commit/d463bcb6df8fc1f01f276b27719ee8ccfb2d788a . --- geos_helpers.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/geos_helpers.cpp b/geos_helpers.cpp index 3581de91b..7cc325b76 100644 --- a/geos_helpers.cpp +++ b/geos_helpers.cpp @@ -4,10 +4,19 @@ #include "geometry.hpp" #include #include -#include #include #include #include +#include +#include +#if ((GEOS_VERSION_MAJOR > 3) || \ + (GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR > 11)) + #define CoordinateArraySequence CoordinateSequence + #include +#else + #include +#endif + linestring_type_fp from_geos(const geos::geom::LineString* ls) { linestring_type_fp ret; @@ -86,8 +95,7 @@ multi_polygon_type_fp from_geos(const std::unique_ptr& g) std::unique_ptr to_geos( const linestring_type_fp& ls) { auto geom_factory = geos::geom::GeometryFactory::create(); - auto coord_factory = geom_factory->getCoordinateSequenceFactory(); - auto coords = coord_factory->create(ls.size(), 2 /* dimensions */); + auto coords = geos::detail::make_unique(ls.size(), 2 /* dimensions */); for (size_t i = 0; i < ls.size(); i++) { coords->setAt(geos::geom::Coordinate(ls[i].x(), ls[i].y()), i); } @@ -96,8 +104,7 @@ std::unique_ptr to_geos( std::unique_ptr to_geos(const ring_type_fp& ring) { auto geom_factory = geos::geom::GeometryFactory::create(); - auto coord_factory = geom_factory->getCoordinateSequenceFactory(); - auto coords = coord_factory->create(ring.size(), 2 /* dimensions */); + auto coords = geos::detail::make_unique(ring.size(), 2 /* dimensions */); for (size_t i = 0; i < ring.size(); i++) { // reverse rings for geos. coords->setAt(geos::geom::Coordinate(ring[i].x(), ring[i].y()), i);