├── .github └── workflows │ └── build.yml ├── .gitignore ├── CMakeLists.txt ├── README.md ├── conanfile.txt ├── include └── GeosCli │ ├── AreaCommand.hpp │ ├── BoundaryCommand.hpp │ ├── BufferCommand.hpp │ ├── CentroidCommand.hpp │ ├── Command.hpp │ ├── Commands.hpp │ ├── ConcaveHullCommand.hpp │ ├── ContainsCommand.hpp │ ├── ConvexHullCommand.hpp │ ├── CoordinatesCommand.hpp │ ├── CountCommand.hpp │ ├── CountPointsCommand.hpp │ ├── CoveredByCommand.hpp │ ├── CoversCommand.hpp │ ├── CrossesCommand.hpp │ ├── DelaunayTriangulationCommand.hpp │ ├── DifferenceCommand.hpp │ ├── DimensionCommand.hpp │ ├── DisjointCommand.hpp │ ├── DistanceCommand.hpp │ ├── EnvelopeCommand.hpp │ ├── GeosCli.hpp │ ├── GetCommand.hpp │ ├── InteriorPointCommand.hpp │ ├── IntersectionCommand.hpp │ ├── IntersectsCommand.hpp │ ├── IsEmptyCommand.hpp │ ├── IsRectCommand.hpp │ ├── IsSimpleCommand.hpp │ ├── IsValidCommand.hpp │ ├── IsWithinDistanceCommand.hpp │ ├── LengthCommand.hpp │ ├── ListCommand.hpp │ ├── MakeValidCommand.hpp │ ├── OffsetCurveCommand.hpp │ ├── OverlapsCommand.hpp │ ├── RelateCommand.hpp │ ├── SymDifferenceCommand.hpp │ ├── TouchesCommand.hpp │ ├── TypeCommand.hpp │ ├── UnionCommand.hpp │ ├── VoronoiDiagramCommand.hpp │ └── WithinCommand.hpp ├── src ├── App.cpp ├── AreaCommand.cpp ├── BoundaryCommand.cpp ├── BufferCommand.cpp ├── CentroidCommand.cpp ├── Command.cpp ├── Commands.cpp ├── ConcaveHullCommand.cpp ├── ContainsCommand.cpp ├── ConvexHullCommand.cpp ├── CoordinatesCommand.cpp ├── CountCommand.cpp ├── CountPointsCommand.cpp ├── CoveredByCommand.cpp ├── CoversCommand.cpp ├── CrossesCommand.cpp ├── DelaunayTriangulationCommand.cpp ├── DifferenceCommand.cpp ├── DimensionCommand.cpp ├── DisjointCommand.cpp ├── DistanceCommand.cpp ├── EnvelopeCommand.cpp ├── GetCommand.cpp ├── InteriorPointCommand.cpp ├── IntersectionCommand.cpp ├── IntersectsCommand.cpp ├── IsEmptyCommand.cpp ├── IsRectCommand.cpp ├── IsSimpleCommand.cpp ├── IsValidCommand.cpp ├── IsWithinDistanceCommand.cpp ├── LengthCommand.cpp ├── ListCommand.cpp ├── MakeValidCommand.cpp ├── OffsetCurveCommand.cpp ├── OverlapsCommand.cpp ├── RelateCommand.cpp ├── SymDifferenceCommand.cpp ├── TouchesCommand.cpp ├── TypeCommand.cpp ├── UnionCommand.cpp ├── VoronoiDiagramCommand.cpp └── WithinCommand.cpp └── test ├── AreaCommandTest.cpp ├── BoundaryCommandTest.cpp ├── BufferCommandTest.cpp ├── CMakeLists.txt ├── CentroidCommandTest.cpp ├── ConcaveHullCommandTest.cpp ├── ContainsCommandTest.cpp ├── ConvexHullCommandTest.cpp ├── CoordinatesCommandTest.cpp ├── CountCommandTest.cpp ├── CountPointsCommandTest.cpp ├── CoveredByCommandTest.cpp ├── CoversCommandTest.cpp ├── CrossesCommandTest.cpp ├── DelaunayTriangulationCommandTest.cpp ├── DifferenceCommandTest.cpp ├── DimensionCommandTest.cpp ├── DisjointCommandTest.cpp ├── DistanceCommandTest.cpp ├── EnvelopeCommandTest.cpp ├── GetCommandTest.cpp ├── InteriorPointCommandTest.cpp ├── IntersectionCommandTest.cpp ├── IntersectsCommandTest.cpp ├── IsEmptyCommandTest.cpp ├── IsRectCommandTest.cpp ├── IsSimpleCommandTest.cpp ├── IsValidCommandTest.cpp ├── IsWithinDistanceCommandTest.cpp ├── LengthCommandTest.cpp ├── ListCommandTest.cpp ├── MakeValidCommandTest.cpp ├── OffsetCurveCommandTest.cpp ├── OverlapsCommandTest.cpp ├── RelateCommandTest.cpp ├── SymDifferenceCommandTest.cpp ├── TouchesCommandTest.cpp ├── TypeCommandTest.cpp ├── UnionCommandTest.cpp ├── VoronoiDiagramCommandTest.cpp └── WithinCommandTest.cpp /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | 3 | on: [push] 4 | 5 | env: 6 | BUILD_TYPE: RelWithDebInfo 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest] 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: Create Build Environment 20 | run: cmake -E make_directory ${{runner.workspace}}/build 21 | 22 | - name: Install conan 23 | shell: bash 24 | run: | 25 | python3 -m pip install --upgrade pip setuptools 26 | python3 -m pip install conan 27 | source ~/.profile 28 | - name: Install conan libraries 29 | shell: bash 30 | working-directory: ${{runner.workspace}}/build 31 | run: | 32 | source ~/.profile 33 | conan profile new default --detect 34 | conan profile update settings.compiler.libcxx=libstdc++11 default 35 | conan install $GITHUB_WORKSPACE 36 | - name: Configure CMake 37 | shell: bash 38 | working-directory: ${{runner.workspace}}/build 39 | run: | 40 | source ~/.profile 41 | cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE 42 | - name: Build 43 | working-directory: ${{runner.workspace}}/build 44 | shell: bash 45 | run: cmake --build . --config $BUILD_TYPE 46 | 47 | - name: Test 48 | working-directory: ${{runner.workspace}}/build 49 | shell: bash 50 | run: ctest --verbose -C $BUILD_TYPE 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | .DS_Store 4 | build 5 | TODO.md -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.4 FATAL_ERROR) 2 | project(geos-cli VERSION 0.0.1 LANGUAGES CXX) 3 | 4 | # Conan 5 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) 6 | find_package(geos REQUIRED) 7 | find_package(GTest REQUIRED) 8 | find_package(CLI11 REQUIRED) 9 | 10 | # Library 11 | add_library(geos-cmds STATIC 12 | src/Commands.cpp 13 | src/Command.cpp 14 | src/AreaCommand.cpp 15 | src/BoundaryCommand.cpp 16 | src/BufferCommand.cpp 17 | src/CentroidCommand.cpp 18 | src/ContainsCommand.cpp 19 | src/ConcaveHullCommand.cpp 20 | src/ConvexHullCommand.cpp 21 | src/CoordinatesCommand.cpp 22 | src/CountCommand.cpp 23 | src/CountPointsCommand.cpp 24 | src/CoveredByCommand.cpp 25 | src/CoversCommand.cpp 26 | src/CrossesCommand.cpp 27 | src/DelaunayTriangulationCommand.cpp 28 | src/DifferenceCommand.cpp 29 | src/DimensionCommand.cpp 30 | src/DisjointCommand.cpp 31 | src/DistanceCommand.cpp 32 | src/EnvelopeCommand.cpp 33 | src/GetCommand.cpp 34 | src/InteriorPointCommand.cpp 35 | src/IntersectionCommand.cpp 36 | src/IntersectsCommand.cpp 37 | src/IsEmptyCommand.cpp 38 | src/IsRectCommand.cpp 39 | src/IsSimpleCommand.cpp 40 | src/IsValidCommand.cpp 41 | src/IsWithinDistanceCommand.cpp 42 | src/LengthCommand.cpp 43 | src/ListCommand.cpp 44 | src/MakeValidCommand.cpp 45 | src/OffsetCurveCommand.cpp 46 | src/OverlapsCommand.cpp 47 | src/RelateCommand.cpp 48 | src/SymDifferenceCommand.cpp 49 | src/TouchesCommand.cpp 50 | src/TypeCommand.cpp 51 | src/UnionCommand.cpp 52 | src/VoronoiDiagramCommand.cpp 53 | src/WithinCommand.cpp 54 | ) 55 | add_library(GeosCli::geos-cmds ALIAS geos-cmds) 56 | target_include_directories(geos-cmds PUBLIC "${PROJECT_SOURCE_DIR}/include") 57 | target_compile_features(geos-cmds PUBLIC cxx_std_11) 58 | target_link_libraries(geos-cmds PRIVATE GEOS::GEOS CLI11::CLI11) 59 | 60 | # Application 61 | add_executable(geos-cli src/App.cpp) 62 | target_link_libraries(geos-cli PRIVATE geos-cmds GEOS::GEOS CLI11::CLI11) 63 | 64 | # Tests 65 | enable_testing() 66 | add_subdirectory(test) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Github Action](https://github.com/jericks/geos-cli/workflows/CMake/badge.svg)](https://github.com/jericks/geos-cli/actions) 2 | 3 | geos-cli 4 | ======== 5 | 6 | A Command line interface for [GEOS - Geometry Engine Open Source](https://github.com/libgeos/geos). 7 | 8 | Each command does one thing well (buffer, centroid, envelope) by reading in a geometry, processing the geometry, and writing the geometry out as WKT. Individual commands can be connected with unix pipes. 9 | 10 | ```bash 11 | geos-cli buffer -g "POINT (1 1)" -d 10 | geos-cli centroid 12 | ``` 13 | 14 | geos-cli is written in C++ using [CLI11](https://github.com/CLIUtils/CLI11) and [GEOS](https://github.com/libgeos/geos). The [Google Test](https://github.com/google/googletest) library is used to write unit tests. The project is built with [CMake](https://cmake.org/) and dependencies are managed with [conan](https://conan.io/). 15 | 16 | Build 17 | ----- 18 | 19 | ```bash 20 | mkdir build 21 | cd build 22 | conan install .. 23 | cmake -g "Unix Makefiles" . 24 | cmake --build . 25 | ctest --verbose 26 | ``` 27 | 28 | Use 29 | --- 30 | 31 | List all commands 32 | 33 | ```bash 34 | % geos-cli list 35 | area 36 | boundary 37 | buffer 38 | centroid 39 | contains 40 | convexhull 41 | coordinates 42 | count 43 | countpoints 44 | ``` 45 | 46 | Get help for a command 47 | 48 | ```bash 49 | % geos-cli buffer --help 50 | Buffer a geometry 51 | Usage: geos-cli buffer [OPTIONS] 52 | 53 | Options: 54 | -h,--help Print this help message and exit 55 | -g TEXT Geometry 56 | -d FLOAT REQUIRED Distance 57 | ``` 58 | 59 | Use a command 60 | 61 | ```bash 62 | % geos-cli get -g "MULTIPOINT (1 1, 5 5, 10 10)" -i 1 63 | POINT (1.0000000000000000 1.0000000000000000) 64 | ``` 65 | 66 | Combine commands 67 | 68 | ```bash 69 | % geos-cli buffer -g "POINT (1 1)" -d 10 | geos-cli centroid 70 | POINT (0.9999999999999994 0.9999999999999997) 71 | ``` 72 | 73 | -------------------------------------------------------------------------------- /conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | geos/3.11.0 3 | cli11/2.2.0 4 | gtest/cci.20210126 5 | 6 | [generators] 7 | cmake_find_package -------------------------------------------------------------------------------- /include/GeosCli/AreaCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class AreaOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class AreaCommand : public Command { 17 | 18 | public: 19 | 20 | AreaCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | AreaOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/BoundaryCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class BoundaryOptions { 12 | public: 13 | std::string geometry; 14 | double distance; 15 | }; 16 | 17 | class BoundaryCommand : public Command { 18 | 19 | public: 20 | 21 | BoundaryCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | BoundaryOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/BufferCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class BufferOptions { 12 | public: 13 | std::string geometry; 14 | double distance; 15 | }; 16 | 17 | class BufferCommand : public Command { 18 | 19 | public: 20 | 21 | BufferCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | BufferOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/CentroidCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class CentroidOptions { 13 | public: 14 | std::string geometry; 15 | double distance; 16 | }; 17 | 18 | class CentroidCommand : public Command { 19 | 20 | public: 21 | 22 | CentroidCommand(CLI::App* app); 23 | 24 | void execute(std::istream& istream, std::ostream& ostream); 25 | 26 | private: 27 | 28 | CentroidOptions options; 29 | 30 | }; -------------------------------------------------------------------------------- /include/GeosCli/Command.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Command { 7 | 8 | public: 9 | 10 | Command(std::string name, std::string description); 11 | 12 | std::string getName() const; 13 | 14 | std::string getDescription() const; 15 | 16 | virtual void execute(std::istream& istream, std::ostream& ostream) = 0; 17 | 18 | private: 19 | 20 | std::string name; 21 | 22 | std::string description; 23 | 24 | }; -------------------------------------------------------------------------------- /include/GeosCli/Commands.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "GeosCli/Command.hpp" 5 | 6 | class Commands { 7 | 8 | private: 9 | 10 | std::vector commands; 11 | 12 | public: 13 | 14 | void add(Command* cmd); 15 | 16 | std::vector get(); 17 | 18 | }; 19 | -------------------------------------------------------------------------------- /include/GeosCli/ConcaveHullCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class ConcaveHullOptions { 13 | public: 14 | std::string geometry; 15 | double length; 16 | }; 17 | 18 | class ConcaveHullCommand : public Command { 19 | 20 | public: 21 | 22 | ConcaveHullCommand(CLI::App* app); 23 | 24 | void execute(std::istream& istream, std::ostream& ostream); 25 | 26 | private: 27 | 28 | ConcaveHullOptions options; 29 | 30 | }; -------------------------------------------------------------------------------- /include/GeosCli/ContainsCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class ContainsOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class ContainsCommand : public Command { 17 | 18 | public: 19 | 20 | ContainsCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | ContainsOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/ConvexHullCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class ConvexHullOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class ConvexHullCommand : public Command { 17 | 18 | public: 19 | 20 | ConvexHullCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | ConvexHullOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/CoordinatesCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class CoordinatesOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class CoordinatesCommand : public Command { 17 | 18 | public: 19 | 20 | CoordinatesCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | CoordinatesOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/CountCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class CountOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class CountCommand : public Command { 17 | 18 | public: 19 | 20 | CountCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | CountOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/CountPointsCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class CountPointsOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class CountPointsCommand : public Command { 17 | 18 | public: 19 | 20 | CountPointsCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | CountPointsOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/CoveredByCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class CoveredByOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class CoveredByCommand : public Command { 17 | 18 | public: 19 | 20 | CoveredByCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | CoveredByOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/CoversCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class CoversOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class CoversCommand : public Command { 17 | 18 | public: 19 | 20 | CoversCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | CoversOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/CrossesCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class CrossesOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class CrossesCommand : public Command { 17 | 18 | public: 19 | 20 | CrossesCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | CrossesOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/DelaunayTriangulationCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class DelaunayTriangulationOptions { 14 | public: 15 | std::string geometry; 16 | }; 17 | 18 | class DelaunayTriangulationCommand : public Command { 19 | 20 | public: 21 | 22 | DelaunayTriangulationCommand(CLI::App* app); 23 | 24 | void execute(std::istream& istream, std::ostream& ostream); 25 | 26 | private: 27 | 28 | DelaunayTriangulationOptions options; 29 | 30 | }; -------------------------------------------------------------------------------- /include/GeosCli/DifferenceCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class DifferenceOptions { 12 | public: 13 | std::string geometry; 14 | std::string otherGeometry; 15 | }; 16 | 17 | class DifferenceCommand : public Command { 18 | 19 | public: 20 | 21 | DifferenceCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | DifferenceOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/DimensionCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class DimensionOptions { 11 | public: 12 | std::string geometry; 13 | }; 14 | 15 | class DimensionCommand : public Command { 16 | 17 | public: 18 | 19 | DimensionCommand(CLI::App* app); 20 | 21 | void execute(std::istream& istream, std::ostream& ostream); 22 | 23 | private: 24 | 25 | DimensionOptions options; 26 | 27 | }; -------------------------------------------------------------------------------- /include/GeosCli/DisjointCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class DisjointOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class DisjointCommand : public Command { 17 | 18 | public: 19 | 20 | DisjointCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | DisjointOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/DistanceCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class DistanceOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class DistanceCommand : public Command { 17 | 18 | public: 19 | 20 | DistanceCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | DistanceOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/EnvelopeCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class EnvelopeOptions { 12 | public: 13 | std::string geometry; 14 | double distance; 15 | }; 16 | 17 | class EnvelopeCommand : public Command { 18 | 19 | public: 20 | 21 | EnvelopeCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | EnvelopeOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/GeosCli.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GeosCli/Commands.hpp" 4 | #include "GeosCli/Command.hpp" 5 | 6 | #include "GeosCli/AreaCommand.hpp" 7 | #include "GeosCli/BoundaryCommand.hpp" 8 | #include "GeosCli/BufferCommand.hpp" 9 | #include "GeosCli/CentroidCommand.hpp" 10 | #include "GeosCli/ContainsCommand.hpp" 11 | #include "GeosCli/ConcaveHullCommand.hpp" 12 | #include "GeosCli/ConvexHullCommand.hpp" 13 | #include "GeosCli/CoordinatesCommand.hpp" 14 | #include "GeosCli/CountCommand.hpp" 15 | #include "GeosCli/CountPointsCommand.hpp" 16 | #include "GeosCli/CoveredByCommand.hpp" 17 | #include "GeosCli/CoversCommand.hpp" 18 | #include "GeosCli/CrossesCommand.hpp" 19 | #include "GeosCli/DelaunayTriangulationCommand.hpp" 20 | #include "GeosCli/DifferenceCommand.hpp" 21 | #include "GeosCli/DimensionCommand.hpp" 22 | #include "GeosCli/DisjointCommand.hpp" 23 | #include "GeosCli/DistanceCommand.hpp" 24 | #include "GeosCli/EnvelopeCommand.hpp" 25 | #include "GeosCli/GetCommand.hpp" 26 | #include "GeosCli/InteriorPointCommand.hpp" 27 | #include "GeosCli/IntersectionCommand.hpp" 28 | #include "GeosCli/IntersectsCommand.hpp" 29 | #include "GeosCli/IsEmptyCommand.hpp" 30 | #include "GeosCli/IsRectCommand.hpp" 31 | #include "GeosCli/IsSimpleCommand.hpp" 32 | #include "GeosCli/IsValidCommand.hpp" 33 | #include "GeosCli/IsWithinDistanceCommand.hpp" 34 | #include "GeosCli/LengthCommand.hpp" 35 | #include "GeosCli/ListCommand.hpp" 36 | #include "GeosCli/MakeValidCommand.hpp" 37 | #include "GeosCli/OffsetCurveCommand.hpp" 38 | #include "GeosCli/OverlapsCommand.hpp" 39 | #include "GeosCli/RelateCommand.hpp" 40 | #include "GeosCli/SymDifferenceCommand.hpp" 41 | #include "GeosCli/TouchesCommand.hpp" 42 | #include "GeosCli/TypeCommand.hpp" 43 | #include "GeosCli/UnionCommand.hpp" 44 | #include "GeosCli/VoronoiDiagramCommand.hpp" 45 | #include "GeosCli/WithinCommand.hpp" -------------------------------------------------------------------------------- /include/GeosCli/GetCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class GetOptions { 12 | public: 13 | std::string geometry; 14 | int index; 15 | }; 16 | 17 | class GetCommand : public Command { 18 | 19 | public: 20 | 21 | GetCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | GetOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/InteriorPointCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class InteriorPointOptions { 13 | public: 14 | std::string geometry; 15 | double distance; 16 | }; 17 | 18 | class InteriorPointCommand : public Command { 19 | 20 | public: 21 | 22 | InteriorPointCommand(CLI::App* app); 23 | 24 | void execute(std::istream& istream, std::ostream& ostream); 25 | 26 | private: 27 | 28 | InteriorPointOptions options; 29 | 30 | }; -------------------------------------------------------------------------------- /include/GeosCli/IntersectionCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class IntersectionOptions { 12 | public: 13 | std::string geometry; 14 | std::string otherGeometry; 15 | }; 16 | 17 | class IntersectionCommand : public Command { 18 | 19 | public: 20 | 21 | IntersectionCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | IntersectionOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/IntersectsCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class IntersectsOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class IntersectsCommand : public Command { 17 | 18 | public: 19 | 20 | IntersectsCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | IntersectsOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/IsEmptyCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class IsEmptyOptions { 11 | public: 12 | std::string geometry; 13 | }; 14 | 15 | class IsEmptyCommand : public Command { 16 | 17 | public: 18 | 19 | IsEmptyCommand(CLI::App* app); 20 | 21 | void execute(std::istream& istream, std::ostream& ostream); 22 | 23 | private: 24 | 25 | IsEmptyOptions options; 26 | 27 | }; -------------------------------------------------------------------------------- /include/GeosCli/IsRectCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class IsRectOptions { 11 | public: 12 | std::string geometry; 13 | }; 14 | 15 | class IsRectCommand : public Command { 16 | 17 | public: 18 | 19 | IsRectCommand(CLI::App* app); 20 | 21 | void execute(std::istream& istream, std::ostream& ostream); 22 | 23 | private: 24 | 25 | IsRectOptions options; 26 | 27 | }; -------------------------------------------------------------------------------- /include/GeosCli/IsSimpleCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class IsSimpleOptions { 11 | public: 12 | std::string geometry; 13 | }; 14 | 15 | class IsSimpleCommand : public Command { 16 | 17 | public: 18 | 19 | IsSimpleCommand(CLI::App* app); 20 | 21 | void execute(std::istream& istream, std::ostream& ostream); 22 | 23 | private: 24 | 25 | IsSimpleOptions options; 26 | 27 | }; -------------------------------------------------------------------------------- /include/GeosCli/IsValidCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class IsValidOptions { 11 | public: 12 | std::string geometry; 13 | }; 14 | 15 | class IsValidCommand : public Command { 16 | 17 | public: 18 | 19 | IsValidCommand(CLI::App* app); 20 | 21 | void execute(std::istream& istream, std::ostream& ostream); 22 | 23 | private: 24 | 25 | IsValidOptions options; 26 | 27 | }; -------------------------------------------------------------------------------- /include/GeosCli/IsWithinDistanceCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class IsWithinDistanceOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | double distance; 15 | }; 16 | 17 | class IsWithinDistanceCommand : public Command { 18 | 19 | public: 20 | 21 | IsWithinDistanceCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | IsWithinDistanceOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/LengthCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class LengthOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class LengthCommand : public Command { 17 | 18 | public: 19 | 20 | LengthCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | LengthOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/ListCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CLI/CLI.hpp" 4 | #include "GeosCli/Command.hpp" 5 | #include "GeosCli/Commands.hpp" 6 | 7 | class ListOptions { 8 | public: 9 | bool showDescription = false; 10 | }; 11 | 12 | class ListCommand : public Command { 13 | 14 | public: 15 | 16 | ListCommand(CLI::App* app, Commands* commands); 17 | 18 | void execute(std::istream& istream, std::ostream& ostream); 19 | 20 | private: 21 | 22 | ListOptions options; 23 | 24 | Commands* commands; 25 | }; -------------------------------------------------------------------------------- /include/GeosCli/MakeValidCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef USE_UNSTABLE_GEOS_CPP_API 4 | #define USE_UNSTABLE_GEOS_CPP_API 5 | #endif 6 | 7 | #include "CLI/CLI.hpp" 8 | #include "GeosCli/Command.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | class MakeValidOptions { 16 | public: 17 | std::string geometry; 18 | }; 19 | 20 | class MakeValidCommand : public Command { 21 | 22 | public: 23 | 24 | MakeValidCommand(CLI::App* app); 25 | 26 | void execute(std::istream& istream, std::ostream& ostream); 27 | 28 | private: 29 | 30 | MakeValidOptions options; 31 | 32 | }; -------------------------------------------------------------------------------- /include/GeosCli/OffsetCurveCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class OffsetCurveOptions { 14 | public: 15 | std::string geometry; 16 | double distance; 17 | }; 18 | 19 | class OffsetCurveCommand : public Command { 20 | 21 | public: 22 | 23 | OffsetCurveCommand(CLI::App* app); 24 | 25 | void execute(std::istream& istream, std::ostream& ostream); 26 | 27 | private: 28 | 29 | OffsetCurveOptions options; 30 | 31 | }; -------------------------------------------------------------------------------- /include/GeosCli/OverlapsCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class OverlapsOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class OverlapsCommand : public Command { 17 | 18 | public: 19 | 20 | OverlapsCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | OverlapsOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/RelateCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class RelateOptions { 12 | public: 13 | std::string geometry; 14 | std::string otherGeometry; 15 | std::string intersectionMatrix; 16 | }; 17 | 18 | class RelateCommand : public Command { 19 | 20 | public: 21 | 22 | RelateCommand(CLI::App* app); 23 | 24 | void execute(std::istream& istream, std::ostream& ostream); 25 | 26 | private: 27 | 28 | RelateOptions options; 29 | 30 | }; -------------------------------------------------------------------------------- /include/GeosCli/SymDifferenceCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class SymDifferenceOptions { 12 | public: 13 | std::string geometry; 14 | std::string otherGeometry; 15 | }; 16 | 17 | class SymDifferenceCommand : public Command { 18 | 19 | public: 20 | 21 | SymDifferenceCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | SymDifferenceOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/TouchesCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class TouchesOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class TouchesCommand : public Command { 17 | 18 | public: 19 | 20 | TouchesCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | TouchesOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/TypeCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class TypeOptions { 12 | public: 13 | std::string geometry; 14 | }; 15 | 16 | class TypeCommand : public Command { 17 | 18 | public: 19 | 20 | TypeCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | TypeOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /include/GeosCli/UnionCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class UnionOptions { 12 | public: 13 | std::string geometry; 14 | std::string otherGeometry; 15 | }; 16 | 17 | class UnionCommand : public Command { 18 | 19 | public: 20 | 21 | UnionCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | UnionOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/VoronoiDiagramCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class VoronoiDiagramOptions { 13 | public: 14 | std::string geometry; 15 | }; 16 | 17 | class VoronoiDiagramCommand : public Command { 18 | 19 | public: 20 | 21 | VoronoiDiagramCommand(CLI::App* app); 22 | 23 | void execute(std::istream& istream, std::ostream& ostream); 24 | 25 | private: 26 | 27 | VoronoiDiagramOptions options; 28 | 29 | }; -------------------------------------------------------------------------------- /include/GeosCli/WithinCommand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define USE_UNSTABLE_GEOS_CPP_API 4 | 5 | #include "CLI/CLI.hpp" 6 | #include "GeosCli/Command.hpp" 7 | #include 8 | #include 9 | 10 | class WithinOptions { 11 | public: 12 | std::string geometry; 13 | std::string otherGeometry; 14 | }; 15 | 16 | class WithinCommand : public Command { 17 | 18 | public: 19 | 20 | WithinCommand(CLI::App* app); 21 | 22 | void execute(std::istream& istream, std::ostream& ostream); 23 | 24 | private: 25 | 26 | WithinOptions options; 27 | 28 | }; -------------------------------------------------------------------------------- /src/App.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GeosCli/GeosCli.hpp" 3 | #include "CLI/CLI.hpp" 4 | 5 | int main(int argc, char const *argv[]) { 6 | 7 | CLI::App app{"GEOS CLI"}; 8 | app.require_subcommand(1); 9 | 10 | Commands commands; 11 | AreaCommand areaCommand(&app); 12 | commands.add(&areaCommand); 13 | BoundaryCommand boundaryCommand(&app); 14 | commands.add(&boundaryCommand); 15 | BufferCommand bufferCommand(&app); 16 | commands.add(&bufferCommand); 17 | CentroidCommand centroidCommand(&app); 18 | commands.add(¢roidCommand); 19 | ContainsCommand containsCommand(&app); 20 | commands.add(&containsCommand); 21 | ConcaveHullCommand concaveHullCommand(&app); 22 | commands.add(&concaveHullCommand); 23 | ConvexHullCommand convexHullCommand(&app); 24 | commands.add(&convexHullCommand); 25 | CoordinatesCommand coordinatesCommand(&app); 26 | commands.add(&coordinatesCommand); 27 | CountCommand countCommand(&app); 28 | commands.add(&countCommand); 29 | CountPointsCommand countPointsCommand(&app); 30 | commands.add(&countPointsCommand); 31 | CoversCommand coversCommand(&app); 32 | commands.add(&coversCommand); 33 | CoveredByCommand coveredByCommand(&app); 34 | commands.add(&coveredByCommand); 35 | CrossesCommand crossesCommand(&app); 36 | commands.add(&crossesCommand); 37 | DelaunayTriangulationCommand delaunayTriangulationCommand(&app); 38 | commands.add(&delaunayTriangulationCommand); 39 | DifferenceCommand differenceCommand(&app); 40 | commands.add(&differenceCommand); 41 | DimensionCommand dimensionCommand(&app); 42 | commands.add(&dimensionCommand); 43 | DisjointCommand disjointCommand(&app); 44 | commands.add(&disjointCommand); 45 | DistanceCommand distanceCommand(&app); 46 | commands.add(&distanceCommand); 47 | EnvelopeCommand envelopeCommand(&app); 48 | commands.add(&envelopeCommand); 49 | GetCommand getCommand(&app); 50 | commands.add(&getCommand); 51 | InteriorPointCommand interiorPointCommand(&app); 52 | commands.add(&interiorPointCommand); 53 | IntersectionCommand intersectionCommand(&app); 54 | commands.add(&intersectionCommand); 55 | IntersectsCommand intersectsCommand(&app); 56 | commands.add(&intersectsCommand); 57 | IsEmptyCommand isEmptyCommand(&app); 58 | commands.add(&isEmptyCommand); 59 | IsRectCommand isRectCommand(&app); 60 | commands.add(&isRectCommand); 61 | IsSimpleCommand isSimpleCommand(&app); 62 | commands.add(&isSimpleCommand); 63 | IsValidCommand isValidCommand(&app); 64 | commands.add(&isValidCommand); 65 | IsWithinDistanceCommand isWithinDistanceCommand(&app); 66 | commands.add(&isWithinDistanceCommand); 67 | LengthCommand lengthCommand(&app); 68 | commands.add(&lengthCommand); 69 | ListCommand listCommand(&app, &commands); 70 | commands.add(&listCommand); 71 | MakeValidCommand makeValidCommand(&app); 72 | commands.add(&makeValidCommand); 73 | OffsetCurveCommand offsetCurveCommand(&app); 74 | commands.add(&offsetCurveCommand); 75 | OverlapsCommand overlapsCommand(&app); 76 | commands.add(&overlapsCommand); 77 | RelateCommand relateCommand(&app); 78 | commands.add(&relateCommand); 79 | SymDifferenceCommand symDifferenceCommand(&app); 80 | commands.add(&symDifferenceCommand); 81 | TouchesCommand touchesCommand(&app); 82 | commands.add(&touchesCommand); 83 | TypeCommand typeCommand(&app); 84 | commands.add(&typeCommand); 85 | UnionCommand unionCommand(&app); 86 | commands.add(&unionCommand); 87 | VoronoiDiagramCommand voronoiDiagramCommand(&app); 88 | commands.add(&voronoiDiagramCommand); 89 | WithinCommand withinCommand(&app); 90 | commands.add(&withinCommand); 91 | 92 | CLI11_PARSE(app, argc, argv); 93 | 94 | for(Command* cmd : commands.get()) { 95 | if (app.got_subcommand(cmd->getName())) { 96 | cmd->execute(std::cin, std::cout); 97 | break; 98 | } 99 | } 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /src/AreaCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/AreaCommand.hpp" 2 | 3 | AreaCommand::AreaCommand(CLI::App* app): Command ("area", "Get the area a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void AreaCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto area = geometry->getArea(); 16 | ostream << area << std::endl; 17 | } -------------------------------------------------------------------------------- /src/BoundaryCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/BoundaryCommand.hpp" 2 | 3 | BoundaryCommand::BoundaryCommand(CLI::App* app): Command ("boundary", "Get the bounds of a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Input Geometry"); 6 | } 7 | 8 | void BoundaryCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto envelope = geometry->getBoundary(); 16 | auto wkt = writer.write(envelope.get()); 17 | ostream << wkt << std::endl; 18 | } -------------------------------------------------------------------------------- /src/BufferCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/BufferCommand.hpp" 2 | 3 | BufferCommand::BufferCommand(CLI::App* app): Command ("buffer", "Buffer a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-d", options.distance, "Distance")->required(); 7 | } 8 | 9 | void BufferCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | geos::io::WKTWriter writer; 16 | auto buffer = geometry->buffer(options.distance, 10); 17 | auto wkt = writer.write(buffer.get()); 18 | ostream << wkt << std::endl; 19 | } -------------------------------------------------------------------------------- /src/CentroidCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CentroidCommand.hpp" 2 | 3 | CentroidCommand::CentroidCommand(CLI::App* app): Command ("centroid", "Get the centroid from a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void CentroidCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto centroid = geometry->getCentroid(); 16 | auto wkt = writer.write(centroid.get()); 17 | ostream << wkt << std::endl; 18 | } -------------------------------------------------------------------------------- /src/Command.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/Command.hpp" 2 | 3 | Command::Command(std::string commandName, std::string commandDescription) { 4 | name = commandName; 5 | description = commandDescription; 6 | }; 7 | 8 | std::string Command::getName() const { 9 | return name; 10 | }; 11 | 12 | std::string Command::getDescription() const { 13 | return description; 14 | }; -------------------------------------------------------------------------------- /src/Commands.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/Commands.hpp" 2 | 3 | void Commands::add(Command* cmd) { 4 | commands.push_back(cmd); 5 | } 6 | 7 | std::vector Commands::get() { 8 | return commands; 9 | } -------------------------------------------------------------------------------- /src/ConcaveHullCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/ConcaveHullCommand.hpp" 2 | 3 | ConcaveHullCommand::ConcaveHullCommand(CLI::App* app): Command ("concavehull", "Get the concavehull of a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-l", options.length, "Length"); 7 | } 8 | 9 | void ConcaveHullCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | geos::io::WKTWriter writer; 16 | auto convexHull = geos::algorithm::hull::ConcaveHull::concaveHullByLength(geometry.get(), options.length, true); 17 | auto wkt = writer.write(convexHull.get()); 18 | ostream << wkt << std::endl; 19 | } -------------------------------------------------------------------------------- /src/ContainsCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/ContainsCommand.hpp" 2 | 3 | ContainsCommand::ContainsCommand(CLI::App* app): Command ("contains", "Determine if one geometry contains another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void ContainsCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool contains = geometry.get()->contains(otherGeometry.get()); 17 | ostream << (contains ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/ConvexHullCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/ConvexHullCommand.hpp" 2 | 3 | ConvexHullCommand::ConvexHullCommand(CLI::App* app): Command ("convexhull", "Get the convexhull of a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void ConvexHullCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto convexHull = geometry->convexHull(); 16 | auto wkt = writer.write(convexHull.get()); 17 | ostream << wkt << std::endl; 18 | } -------------------------------------------------------------------------------- /src/CoordinatesCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CoordinatesCommand.hpp" 2 | 3 | CoordinatesCommand::CoordinatesCommand(CLI::App* app): Command ("coordinates", "Get the coordinates of a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void CoordinatesCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto factory = geometry->getFactory(); 16 | auto coordinateSequence = geometry->getCoordinates(); 17 | std::vector coordinates; 18 | coordinateSequence->toVector(coordinates); 19 | auto multiPoint = factory->createMultiPoint(coordinates); 20 | auto wkt = writer.write(multiPoint); 21 | ostream << wkt << std::endl; 22 | } -------------------------------------------------------------------------------- /src/CountCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CountCommand.hpp" 2 | 3 | CountCommand::CountCommand(CLI::App* app): Command ("count", "Get the number of geometries") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void CountCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto count = geometry->getNumGeometries(); 16 | ostream << count << std::endl; 17 | } -------------------------------------------------------------------------------- /src/CountPointsCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CountPointsCommand.hpp" 2 | 3 | CountPointsCommand::CountPointsCommand(CLI::App* app): Command ("countpoints", "Get the number of points") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void CountPointsCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto numberOfPoints = geometry->getNumPoints(); 16 | ostream << numberOfPoints << std::endl; 17 | } -------------------------------------------------------------------------------- /src/CoveredByCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CoveredByCommand.hpp" 2 | 3 | CoveredByCommand::CoveredByCommand(CLI::App* app): Command ("coveredby", "Determine if one geometry is coveredby another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void CoveredByCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool coveredby = geometry.get()->coveredBy(otherGeometry.get()); 17 | ostream << (coveredby ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/CoversCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CoversCommand.hpp" 2 | 3 | CoversCommand::CoversCommand(CLI::App* app): Command ("covers", "Determine if one geometry covers another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void CoversCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool covers = geometry.get()->covers(otherGeometry.get()); 17 | ostream << (covers ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/CrossesCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/CrossesCommand.hpp" 2 | 3 | CrossesCommand::CrossesCommand(CLI::App* app): Command ("crosses", "Determine if one geometry is crosses another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void CrossesCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool crosses = geometry.get()->crosses(otherGeometry.get()); 17 | ostream << (crosses ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/DelaunayTriangulationCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/DelaunayTriangulationCommand.hpp" 2 | 3 | DelaunayTriangulationCommand::DelaunayTriangulationCommand(CLI::App* app): Command ("delaunaytriangulation", "Create delaunay triangles") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Input Geometry"); 6 | } 7 | 8 | void DelaunayTriangulationCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | geos::triangulate::DelaunayTriangulationBuilder delaunayTriangulationBuilder; 16 | delaunayTriangulationBuilder.setSites(*geometry); 17 | auto triangles = delaunayTriangulationBuilder.getTriangles(*geometry->getFactory()); 18 | auto wkt = writer.write(triangles.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/DifferenceCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/DifferenceCommand.hpp" 2 | 3 | DifferenceCommand::DifferenceCommand(CLI::App* app): Command ("difference", "Calculate the difference between two geometries") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void DifferenceCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | geos::io::WKTWriter writer; 17 | auto difference = geometry->difference(otherGeometry.get()); 18 | auto wkt = writer.write(difference.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/DimensionCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/DimensionCommand.hpp" 2 | 3 | DimensionCommand::DimensionCommand(CLI::App* app): Command ("dimension", "Get the dimension of the geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void DimensionCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | auto dimensionType = geometry.get()->getDimension(); 15 | ostream << dimensionType << std::endl; 16 | } -------------------------------------------------------------------------------- /src/DisjointCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/DisjointCommand.hpp" 2 | 3 | DisjointCommand::DisjointCommand(CLI::App* app): Command ("disjoint", "Determine whether a geometry is disjoint from another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void DisjointCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | auto disjoint = geometry->disjoint(otherGeometry.get()); 17 | ostream << (disjoint ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/DistanceCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/DistanceCommand.hpp" 2 | 3 | DistanceCommand::DistanceCommand(CLI::App* app): Command ("distance", "Determine the distance between two geometries") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void DistanceCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | double distance = geometry.get()->distance(otherGeometry.get()); 17 | ostream << distance << std::endl; 18 | } -------------------------------------------------------------------------------- /src/EnvelopeCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/EnvelopeCommand.hpp" 2 | 3 | EnvelopeCommand::EnvelopeCommand(CLI::App* app): Command ("envelope", "Get the envelope from a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Input Geometry"); 6 | } 7 | 8 | void EnvelopeCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto envelope = geometry->getEnvelope(); 16 | auto wkt = writer.write(envelope.get()); 17 | ostream << wkt << std::endl; 18 | } -------------------------------------------------------------------------------- /src/GetCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/GetCommand.hpp" 2 | 3 | GetCommand::GetCommand(CLI::App* app): Command ("get", "Get a sub geometry from a geometry collection by index") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Input Geometry"); 6 | cmd->add_option("-i", options.index, "The index number of the Geometry")->required(); 7 | } 8 | 9 | void GetCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | size_t numberOfGeometries = geometry->getNumGeometries(); 16 | if (options.index >= 1 && options.index <= numberOfGeometries) { 17 | geos::io::WKTWriter writer; 18 | auto subGeometry = geometry->getGeometryN(options.index - 1); 19 | auto wkt = writer.write(subGeometry); 20 | ostream << wkt << std::endl; 21 | } 22 | } -------------------------------------------------------------------------------- /src/InteriorPointCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/InteriorPointCommand.hpp" 2 | 3 | InteriorPointCommand::InteriorPointCommand(CLI::App* app): Command ("interiorpoint", "Get the interior point from a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void InteriorPointCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto point = geometry->getInteriorPoint(); 16 | auto wkt = writer.write(point.get()); 17 | ostream << wkt << std::endl; 18 | } -------------------------------------------------------------------------------- /src/IntersectionCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IntersectionCommand.hpp" 2 | 3 | IntersectionCommand::IntersectionCommand(CLI::App* app): Command ("intersection", "Calculate the intersection between two geometries") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void IntersectionCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | geos::io::WKTWriter writer; 17 | auto intersection = geometry->intersection(otherGeometry.get()); 18 | auto wkt = writer.write(intersection.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/IntersectsCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IntersectsCommand.hpp" 2 | 3 | IntersectsCommand::IntersectsCommand(CLI::App* app): Command ("intersects", "Determine if one geometry intersects another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void IntersectsCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool intersects = geometry.get()->intersects(otherGeometry.get()); 17 | ostream << (intersects ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/IsEmptyCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IsEmptyCommand.hpp" 2 | 3 | IsEmptyCommand::IsEmptyCommand(CLI::App* app): Command ("isempty", "Determine if a geometry is empty") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void IsEmptyCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | bool isEmpty = geometry.get()->isEmpty(); 15 | ostream << (isEmpty ? "true" : "false") << std::endl; 16 | } -------------------------------------------------------------------------------- /src/IsRectCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IsRectCommand.hpp" 2 | 3 | IsRectCommand::IsRectCommand(CLI::App* app): Command ("isrect", "Determine if a geometry is a rectangle") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void IsRectCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | bool isRect = geometry.get()->isRectangle(); 15 | ostream << (isRect ? "true" : "false") << std::endl; 16 | } -------------------------------------------------------------------------------- /src/IsSimpleCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IsSimpleCommand.hpp" 2 | 3 | IsSimpleCommand::IsSimpleCommand(CLI::App* app): Command ("issimple", "Determine if a geometry is simple") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void IsSimpleCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | bool isSimple = geometry.get()->isSimple(); 15 | ostream << (isSimple ? "true" : "false") << std::endl; 16 | } -------------------------------------------------------------------------------- /src/IsValidCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IsValidCommand.hpp" 2 | 3 | IsValidCommand::IsValidCommand(CLI::App* app): Command ("isvalid", "Determine if a geometry is valid") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void IsValidCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | bool isValid = geometry.get()->isValid(); 15 | ostream << (isValid ? "true" : "false") << std::endl; 16 | } -------------------------------------------------------------------------------- /src/IsWithinDistanceCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/IsWithinDistanceCommand.hpp" 2 | 3 | IsWithinDistanceCommand::IsWithinDistanceCommand(CLI::App* app): Command ("iswithindistance", "Determine if a geometry is within the given distance of another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | cmd->add_option("-d", options.distance, "Distance")->required(); 8 | } 9 | 10 | void IsWithinDistanceCommand::execute(std::istream& istream, std::ostream& ostream) { 11 | if (options.geometry.empty()) { 12 | std::getline(istream, options.geometry); 13 | } 14 | geos::io::WKTReader reader; 15 | auto geometry = reader.read(options.geometry); 16 | auto otherGeometry = reader.read(options.otherGeometry); 17 | bool isWithinDistance = geometry.get()->isWithinDistance(otherGeometry.get(), options.distance); 18 | ostream << (isWithinDistance ? "true" : "false") << std::endl; 19 | } -------------------------------------------------------------------------------- /src/LengthCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/LengthCommand.hpp" 2 | 3 | LengthCommand::LengthCommand(CLI::App* app): Command ("length", "Get the length of a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void LengthCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto area = geometry->getLength(); 16 | ostream << area << std::endl; 17 | } -------------------------------------------------------------------------------- /src/ListCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/ListCommand.hpp" 2 | 3 | ListCommand::ListCommand(CLI::App* app, Commands* cmds): Command ("list", "List all commands") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_flag("-d", options.showDescription, "Show Description"); 6 | commands = cmds; 7 | } 8 | 9 | void ListCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | for(auto cmd : commands->get()) { 11 | ostream << cmd->getName(); 12 | if (options.showDescription == true) { 13 | ostream << " = " << cmd->getDescription(); 14 | } 15 | ostream << std::endl; 16 | } 17 | } -------------------------------------------------------------------------------- /src/MakeValidCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/MakeValidCommand.hpp" 2 | 3 | MakeValidCommand::MakeValidCommand(CLI::App* app): Command ("makevalid", "Make a geometry valid") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void MakeValidCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto validGeometry = geos::operation::valid::MakeValid().build(geometry.get()); 16 | auto wkt = writer.write(validGeometry.get()); 17 | ostream << wkt << std::endl; 18 | } -------------------------------------------------------------------------------- /src/OffsetCurveCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/OffsetCurveCommand.hpp" 2 | 3 | OffsetCurveCommand::OffsetCurveCommand(CLI::App* app): Command ("offsetcurve", "Get the offset curve a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-d", options.distance, "Distance")->required(); 7 | } 8 | 9 | void OffsetCurveCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | geos::io::WKTWriter writer; 16 | geos::operation::buffer::OffsetCurve offsetCurve {*geometry.get(), options.distance}; 17 | auto curve = offsetCurve.getCurve(); 18 | auto wkt = writer.write(curve.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/OverlapsCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/OverlapsCommand.hpp" 2 | 3 | OverlapsCommand::OverlapsCommand(CLI::App* app): Command ("overlaps", "Determine if one geometry overlaps another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void OverlapsCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool overlaps = geometry.get()->overlaps(otherGeometry.get()); 17 | ostream << (overlaps ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/RelateCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/RelateCommand.hpp" 2 | 3 | RelateCommand::RelateCommand(CLI::App* app): Command ("relate", "Determine if the input Geometry and the other Geometry are related according to the DE-9IM intersection matrix or calculate the DE-9IM.") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | cmd->add_option("-m", options.intersectionMatrix, "DE-9IM intesection matrix"); 8 | } 9 | 10 | void RelateCommand::execute(std::istream& istream, std::ostream& ostream) { 11 | if (options.geometry.empty()) { 12 | std::getline(istream, options.geometry); 13 | } 14 | geos::io::WKTReader reader; 15 | auto geometry = reader.read(options.geometry); 16 | auto otherGeometry = reader.read(options.otherGeometry); 17 | if (!options.intersectionMatrix.empty()) { 18 | bool related = geometry.get()->relate(otherGeometry.get(), options.intersectionMatrix); 19 | ostream << (related ? "true" : "false") << std::endl; 20 | } else { 21 | std::string matrix = geometry.get()->relate(otherGeometry.get())->toString(); 22 | ostream << matrix << std::endl; 23 | } 24 | } -------------------------------------------------------------------------------- /src/SymDifferenceCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/SymDifferenceCommand.hpp" 2 | 3 | SymDifferenceCommand::SymDifferenceCommand(CLI::App* app): Command ("symdifference", "Calculate the symdifference between two geometries") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void SymDifferenceCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | geos::io::WKTWriter writer; 17 | auto symdifference = geometry->symDifference(otherGeometry.get()); 18 | auto wkt = writer.write(symdifference.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/TouchesCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/TouchesCommand.hpp" 2 | 3 | TouchesCommand::TouchesCommand(CLI::App* app): Command ("touches", "Determine if one geometry is touches another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void TouchesCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool touches = geometry.get()->touches(otherGeometry.get()); 17 | ostream << (touches ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /src/TypeCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/TypeCommand.hpp" 2 | 3 | TypeCommand::TypeCommand(CLI::App* app): Command ("type", "Get the geometry type a geometry") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | } 7 | 8 | void TypeCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | auto type = geometry->getGeometryType(); 16 | ostream << type << std::endl; 17 | } -------------------------------------------------------------------------------- /src/UnionCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/UnionCommand.hpp" 2 | 3 | UnionCommand::UnionCommand(CLI::App* app): Command ("union", "Calculate the union between two geometries") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void UnionCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | geos::io::WKTWriter writer; 17 | auto result = geometry->Union(otherGeometry.get()); 18 | auto wkt = writer.write(result.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/VoronoiDiagramCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/VoronoiDiagramCommand.hpp" 2 | 3 | VoronoiDiagramCommand::VoronoiDiagramCommand(CLI::App* app): Command ("voronoidiagram", "Create a voronoi diagram") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Input Geometry"); 6 | } 7 | 8 | void VoronoiDiagramCommand::execute(std::istream& istream, std::ostream& ostream) { 9 | if (options.geometry.empty()) { 10 | std::getline(istream, options.geometry); 11 | } 12 | geos::io::WKTReader reader; 13 | auto geometry = reader.read(options.geometry); 14 | geos::io::WKTWriter writer; 15 | geos::triangulate::VoronoiDiagramBuilder voronoiDiagramBuilder; 16 | voronoiDiagramBuilder.setSites(*geometry); 17 | auto diagram = voronoiDiagramBuilder.getDiagram(*geometry->getFactory()); 18 | auto wkt = writer.write(diagram.get()); 19 | ostream << wkt << std::endl; 20 | } -------------------------------------------------------------------------------- /src/WithinCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "GeosCli/WithinCommand.hpp" 2 | 3 | WithinCommand::WithinCommand(CLI::App* app): Command ("within", "Determine if one geometry is within another") { 4 | CLI::App* cmd = app->add_subcommand(this->getName(), this->getDescription()); 5 | cmd->add_option("-g", options.geometry, "Geometry"); 6 | cmd->add_option("-o", options.otherGeometry, "Other Geometry")->required(); 7 | } 8 | 9 | void WithinCommand::execute(std::istream& istream, std::ostream& ostream) { 10 | if (options.geometry.empty()) { 11 | std::getline(istream, options.geometry); 12 | } 13 | geos::io::WKTReader reader; 14 | auto geometry = reader.read(options.geometry); 15 | auto otherGeometry = reader.read(options.otherGeometry); 16 | bool contains = geometry.get()->within(otherGeometry.get()); 17 | ostream << (contains ? "true" : "false") << std::endl; 18 | } -------------------------------------------------------------------------------- /test/AreaCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, area_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | AreaCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "area", "-g", "POLYGON((1 1, 1 10, 10 10, 10 1, 1 1))"}; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("81\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/BoundaryCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, boundary_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | BoundaryCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | 14 | char const *argv[4] = { "geos-cli", "boundary", "-g", "POLYGON((1 1, 1 10, 10 10, 10 1, 1 1))" }; 15 | 16 | app.parse(argc, argv); 17 | 18 | std::istringstream instream; 19 | std::ostringstream outstream; 20 | 21 | cmd.execute(instream, outstream); 22 | 23 | ASSERT_EQ(0, outstream.str().rfind("LINESTRING", 0)); 24 | 25 | } -------------------------------------------------------------------------------- /test/BufferCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, buffer_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | BufferCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "buffer", "-g", "POINT(1 1)", "-d", "2" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_EXECUTABLE(tests 2 | AreaCommandTest.cpp 3 | BoundaryCommandTest.cpp 4 | BufferCommandTest.cpp 5 | CentroidCommandTest.cpp 6 | ContainsCommandTest.cpp 7 | ConcaveHullCommandTest.cpp 8 | ConvexHullCommandTest.cpp 9 | CoordinatesCommandTest.cpp 10 | CountCommandTest.cpp 11 | CountPointsCommandTest.cpp 12 | CoveredByCommandTest.cpp 13 | CoversCommandTest.cpp 14 | CrossesCommandTest.cpp 15 | DelaunayTriangulationCommandTest.cpp 16 | DifferenceCommandTest.cpp 17 | DimensionCommandTest.cpp 18 | DisjointCommandTest.cpp 19 | DistanceCommandTest.cpp 20 | EnvelopeCommandTest.cpp 21 | GetCommandTest.cpp 22 | InteriorPointCommandTest.cpp 23 | IntersectionCommandTest.cpp 24 | IntersectsCommandTest.cpp 25 | IsEmptyCommandTest.cpp 26 | IsRectCommandTest.cpp 27 | IsSimpleCommandTest.cpp 28 | IsValidCommandTest.cpp 29 | IsWithinDistanceCommandTest.cpp 30 | LengthCommandTest.cpp 31 | ListCommandTest.cpp 32 | MakeValidCommandTest.cpp 33 | OffsetCurveCommandTest.cpp 34 | OverlapsCommandTest.cpp 35 | RelateCommandTest.cpp 36 | SymDifferenceCommandTest.cpp 37 | TouchesCommandTest.cpp 38 | TypeCommandTest.cpp 39 | UnionCommandTest.cpp 40 | VoronoiDiagramCommandTest.cpp 41 | WithinCommandTest.cpp 42 | ) 43 | target_link_libraries(tests 44 | geos-cmds 45 | GEOS::GEOS 46 | CLI11::CLI11 47 | GTest::GTest 48 | ) 49 | 50 | ADD_TEST(NAME "GeosCliTests" COMMAND "tests") 51 | -------------------------------------------------------------------------------- /test/CentroidCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, centroid_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CentroidCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = { "geos-cli", "centroid", "-g", "POINT(1 1)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("POINT", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/ConcaveHullCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, concavehull_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | ConcaveHullCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | 14 | char const *argv[6] = { "geos-cli", "concavehull", "-g", "MULTIPOINT ((12.27256417862947 12.73833434783841), (13.737894633461437 7.658802439672621), (6.857126638942733 8.821305316892328), (9.260874914207697 13.087320259444919), (8.017822881853032 7.492806794533148))", "-l", "1.1" }; 15 | 16 | app.parse(argc, argv); 17 | 18 | std::istringstream instream; 19 | std::ostringstream outstream; 20 | 21 | cmd.execute(instream, outstream); 22 | 23 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 24 | 25 | } -------------------------------------------------------------------------------- /test/ContainsCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, contains_true_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | ContainsCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "contains", "-g", "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))", "-o", "POINT (2 2)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, contains_false_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | ContainsCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "contains", "-g", "POINT (2 2)", "-o", "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("false\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/ConvexHullCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, convexhull_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | ConvexHullCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | 14 | char const *argv[4] = { "geos-cli", "convexhull", "-g", "MULTIPOINT ((12.27256417862947 12.73833434783841), (13.737894633461437 7.658802439672621), (6.857126638942733 8.821305316892328), (9.260874914207697 13.087320259444919), (8.017822881853032 7.492806794533148))" }; 15 | 16 | app.parse(argc, argv); 17 | 18 | std::istringstream instream; 19 | std::ostringstream outstream; 20 | 21 | cmd.execute(instream, outstream); 22 | 23 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 24 | 25 | } -------------------------------------------------------------------------------- /test/CoordinatesCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, coordinates_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CoordinatesCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | 14 | char const *argv[4] = { "geos-cli", "coordinates", "-g", "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))" }; 15 | 16 | app.parse(argc, argv); 17 | 18 | std::istringstream instream; 19 | std::ostringstream outstream; 20 | 21 | cmd.execute(instream, outstream); 22 | 23 | ASSERT_EQ("MULTIPOINT (1.0000000000000000 1.0000000000000000, 1.0000000000000000 10.0000000000000000, 10.0000000000000000 10.0000000000000000, 10.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000)\n", outstream.str()); 24 | 25 | } -------------------------------------------------------------------------------- /test/CountCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, count_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CountCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "count", "-g", "MULTIPOINT(1 1, 1 10, 10 10, 10 1, 1 1)"}; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("5\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/CountPointsCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, countpoints_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CountPointsCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "countpoints", "-g", "MULTIPOINT(1 1, 1 10, 10 10, 10 1, 1 1)"}; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("5\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/CoveredByCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, coveredby_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CoveredByCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "coveredby", "-g", "POINT(20 20)", "-o", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, coveredby_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | CoveredByCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "coveredby", "-g", "POINT (5 5)", "-o", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/CoversCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, covers_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CoversCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "covers", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POINT(20 20)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, covers_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | CoversCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "covers", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POINT (5 5)" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/CrossesCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, crosses_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | CrossesCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "crosses", "-g", "LINESTRING (1 10, 10 1)", "-o", "LINESTRING (20 30, 20 14)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, crosses_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | CrossesCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "crosses", "-g", "LINESTRING (1 1, 10 10)", "-o", "LINESTRING (1 10, 10 1)" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/DelaunayTriangulationCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, delaunay_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | DelaunayTriangulationCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = { "geos-cli", "delaunaytriangulation", "-g", "MULTIPOINT ((-53.979858979818516 -70.33735880193296), (63.835508810294016 35.31802926793449), (48.5389085690133 -23.614423069809703), (67.25245886702766 -44.07914094501147), (-45.446181860439914 11.257960381463633))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("GEOMETRYCOLLECTION", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/DifferenceCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, difference_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | DifferenceCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "difference", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((5 5, 5 15, 15 15, 15 5, 5 5))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/DimensionCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, dimension_point_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | DimensionCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "dimension", "-g", "POINT (1 1)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("0\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, dimension_polygon_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | DimensionCommand cmd{&app}; 30 | 31 | int argc = 4; 32 | char const *argv[4] = {"geos-cli", "dimension", "-g", "POLYGON ((17.06298828125 49.7998046875, 14.25048828125 44.04296875, 18.24951171875 44.04296875, 13.45947265625 48.1298828125, 17.06298828125 49.7998046875))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("2\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/DisjointCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, disjoint_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | DisjointCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "disjoint", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "LINESTRING (15 15, 20 20)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/DistanceCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, distance_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | DistanceCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "distance", "-g", "POINT(5 5)", "-o", "POINT (2 2)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("4.24264\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/EnvelopeCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, envelope_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | EnvelopeCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | 14 | char const *argv[4] = { "geos-cli", "envelope", "-g", "MULTIPOINT ((12.27256417862947 12.73833434783841), (13.737894633461437 7.658802439672621), (6.857126638942733 8.821305316892328), (9.260874914207697 13.087320259444919), (8.017822881853032 7.492806794533148))" }; 15 | 16 | app.parse(argc, argv); 17 | 18 | std::istringstream instream; 19 | std::ostringstream outstream; 20 | 21 | cmd.execute(instream, outstream); 22 | 23 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 24 | 25 | } -------------------------------------------------------------------------------- /test/GetCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, get_test_1) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | GetCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = { "geos-cli", "get", "-g", "MULTIPOINT (1 1, 5 5, 10 10)", "-i", "1"}; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("POINT (1.0000000000000000 1.0000000000000000)\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, get_test_2) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | GetCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = { "geos-cli", "get", "-g", "MULTIPOINT (1 1, 5 5, 10 10)", "-i", "2"}; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("POINT (5.0000000000000000 5.0000000000000000)\n", outstream.str()); 42 | 43 | } 44 | 45 | TEST(geos_tests, get_test_3) { 46 | 47 | CLI::App app{"GEOS CLI"}; 48 | GetCommand cmd{&app}; 49 | 50 | int argc = 6; 51 | char const *argv[6] = { "geos-cli", "get", "-g", "MULTIPOINT (1 1, 5 5, 10 10)", "-i", "3"}; 52 | 53 | app.parse(argc, argv); 54 | 55 | std::istringstream instream; 56 | std::ostringstream outstream; 57 | 58 | cmd.execute(instream, outstream); 59 | 60 | ASSERT_EQ("POINT (10.0000000000000000 10.0000000000000000)\n", outstream.str()); 61 | 62 | } 63 | 64 | TEST(geos_tests, get_test_0) { 65 | 66 | CLI::App app{"GEOS CLI"}; 67 | GetCommand cmd{&app}; 68 | 69 | int argc = 6; 70 | char const *argv[6] = { "geos-cli", "get", "-g", "MULTIPOINT (1 1, 5 5, 10 10)", "-i", "0"}; 71 | 72 | app.parse(argc, argv); 73 | 74 | std::istringstream instream; 75 | std::ostringstream outstream; 76 | 77 | cmd.execute(instream, outstream); 78 | 79 | ASSERT_EQ("", outstream.str()); 80 | 81 | } 82 | 83 | TEST(geos_tests, get_test_4) { 84 | 85 | CLI::App app{"GEOS CLI"}; 86 | GetCommand cmd{&app}; 87 | 88 | int argc = 6; 89 | char const *argv[6] = { "geos-cli", "get", "-g", "MULTIPOINT (1 1, 5 5, 10 10)", "-i", "4"}; 90 | 91 | app.parse(argc, argv); 92 | 93 | std::istringstream instream; 94 | std::ostringstream outstream; 95 | 96 | cmd.execute(instream, outstream); 97 | 98 | ASSERT_EQ("", outstream.str()); 99 | 100 | } -------------------------------------------------------------------------------- /test/InteriorPointCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, interiorpoint_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | InteriorPointCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = { "geos-cli", "interiorpoint", "-g", "POLYGON ((-122.39662170410156 47.584168193691696, -122.39542007446289 47.57826273896928, -122.38065719604491 47.58173661653957, -122.37825393676758 47.57166173655188, -122.3938751220703 47.568766297532925, -122.39044189453124 47.56343827149225, -122.36469268798828 47.57050358015324, -122.37258911132812 47.594703722902004, -122.39662170410156 47.584168193691696))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("POINT", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/IntersectionCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, intersection_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IntersectionCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "intersection", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((5 5, 5 15, 15 15, 15 5, 5 5))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/IntersectsCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, intersects_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IntersectsCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "intersects", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((20 20, 20 30, 30 30, 30 20, 20 20))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, intersects_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | IntersectsCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "intersects", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((5 5, 5 15, 15 15, 15 5, 5 5))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/IsEmptyCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, isempty_true_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IsEmptyCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "isempty", "-g", "POINT EMPTY" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, isempty_false_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | IsEmptyCommand cmd{&app}; 30 | 31 | int argc = 4; 32 | char const *argv[4] = {"geos-cli", "isempty", "-g", "POLYGON ((17.06298828125 49.7998046875, 14.25048828125 44.04296875, 18.24951171875 44.04296875, 13.45947265625 48.1298828125, 17.06298828125 49.7998046875))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("false\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/IsRectCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, isrect_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IsRectCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "isrect", "-g", "POINT (1 1)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, isrect_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | IsRectCommand cmd{&app}; 30 | 31 | int argc = 4; 32 | char const *argv[4] = {"geos-cli", "isrect", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/IsSimpleCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, issimple_true_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IsSimpleCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "issimple", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, issimple_false_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | IsSimpleCommand cmd{&app}; 30 | 31 | int argc = 4; 32 | char const *argv[4] = {"geos-cli", "issimple", "-g", "LINESTRING (8.14208984375 48.0419921875, 10.60302734375 51.6015625, 11.56982421875 47.91015625, 8.36181640625 50.72265625)" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("false\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/IsValidCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, isvalid_true_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IsValidCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "isvalid", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, isvalid_false_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | IsValidCommand cmd{&app}; 30 | 31 | int argc = 4; 32 | char const *argv[4] = {"geos-cli", "isvalid", "-g", "POLYGON ((17.06298828125 49.7998046875, 14.25048828125 44.04296875, 18.24951171875 44.04296875, 13.45947265625 48.1298828125, 17.06298828125 49.7998046875))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("false\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/IsWithinDistanceCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, iswithindistance_true_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | IsWithinDistanceCommand cmd{&app}; 11 | 12 | int argc = 8; 13 | char const *argv[8] = {"geos-cli", "iswithindistance", "-g", "POINT(5 5)", "-o", "POINT (2 2)", "-d", "5" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, iswithindistance_false_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | IsWithinDistanceCommand cmd{&app}; 30 | 31 | int argc = 8; 32 | char const *argv[8] = {"geos-cli", "iswithindistance", "-g", "POINT(5 5)", "-o", "POINT (2 2)", "-d", "1" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("false\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/LengthCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, length_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | LengthCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "length", "-g", "LINESTRING(1 1, 10 10)"}; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("12.7279\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/ListCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, list_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | 11 | Commands commands; 12 | BufferCommand bufferCommand{&app}; 13 | commands.add(&bufferCommand); 14 | ListCommand listCommand{&app, &commands}; 15 | commands.add(&listCommand); 16 | 17 | int argc = 2; 18 | char const *argv[2] = {"geos-cli", "list"}; 19 | 20 | app.parse(argc, argv); 21 | 22 | std::istringstream instream; 23 | std::ostringstream outstream; 24 | 25 | listCommand.execute(instream, outstream); 26 | 27 | std::string result = outstream.str(); 28 | ASSERT_NE(std::string::npos, result.find("list")); 29 | ASSERT_NE(std::string::npos, result.find("buffer")); 30 | ASSERT_EQ(std::string::npos, result.find("notacommand")); 31 | } 32 | 33 | TEST(geos_tests, list_description_test) { 34 | 35 | CLI::App app{"GEOS CLI"}; 36 | 37 | Commands commands; 38 | BufferCommand bufferCommand{&app}; 39 | commands.add(&bufferCommand); 40 | ListCommand listCommand{&app, &commands}; 41 | commands.add(&listCommand); 42 | 43 | int argc = 3; 44 | char const *argv[3] = {"geos-cli", "list", "-d"}; 45 | 46 | app.parse(argc, argv); 47 | 48 | std::istringstream instream; 49 | std::ostringstream outstream; 50 | 51 | listCommand.execute(instream, outstream); 52 | 53 | std::string result = outstream.str(); 54 | ASSERT_NE(std::string::npos, result.find("list = List all commands")); 55 | ASSERT_NE(std::string::npos, result.find("buffer = Buffer a geometry")); 56 | ASSERT_EQ(std::string::npos, result.find("notacommand")); 57 | } -------------------------------------------------------------------------------- /test/MakeValidCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, makevalid_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | MakeValidCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = { "geos-cli", "makevalid", "-g", "MULTIPOLYGON(((91 50,79 22,51 10,23 22,11 50,23 78,51 90,79 78,91 50)),((91 100,79 72,51 60,23 72,11 100,23 128,51 140,79 128,91 100)),((91 150,79 122,51 110,23 122,11 150,23 178,51 190,79 178,91 150)),((141 50,129 22,101 10,73 22,61 50,73 78,101 90,129 78,141 50)),((141 100,129 72,101 60,73 72,61 100,73 128,101 140,129 128,141 100)),((141 150,129 122,101 110,73 122,61 150,73 178,101 190,129 178,141 150)))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("MULTIPOLYGON", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/OffsetCurveCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, offsetcurve_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | OffsetCurveCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "offsetcurve", "-g", "LINESTRING(1 2, 10 30)", "-d", "2" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("LINESTRING", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/OverlapsCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, overlaps_true_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | OverlapsCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "overlaps", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((2 2, 2 14, 14 14, 14 2, 2 2))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("true\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, overlaps_false_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | OverlapsCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "overlaps", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POINT (15 15)" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("false\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/RelateCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, relate_matrix_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | RelateCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "relate", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POINT(5 5)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("0F2FF1FF2\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, relate_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | RelateCommand cmd{&app}; 30 | 31 | int argc = 8; 32 | char const *argv[8] = {"geos-cli", "relate", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POINT(5 5)", "-m", "0F2FF1FF2" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/SymDifferenceCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, symdifference_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | SymDifferenceCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "symdifference", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((5 5, 5 20, 20 20, 20 5, 5 5))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("MULTIPOLYGON", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/TouchesCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, touches_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | TouchesCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "touches", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((20 20, 20 30, 30 30, 30 20, 20 20))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, touches_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | TouchesCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "touches", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((10 10, 10 14, 14 14, 14 10, 10 10))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } -------------------------------------------------------------------------------- /test/TypeCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, type_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | TypeCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = {"geos-cli", "type", "-g", "POLYGON((1 1, 1 10, 10 10, 10 1, 1 1))"}; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("Polygon\n", outstream.str()); 23 | 24 | } -------------------------------------------------------------------------------- /test/UnionCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, union_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | UnionCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "union", "-g", "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", "-o", "POLYGON ((5 5, 5 15, 15 15, 15 5, 5 5))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("POLYGON", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/VoronoiDiagramCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, voronoi_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | VoronoiDiagramCommand cmd{&app}; 11 | 12 | int argc = 4; 13 | char const *argv[4] = { "geos-cli", "voronoidiagram", "-g", "MULTIPOINT ((-53.979858979818516 -70.33735880193296), (63.835508810294016 35.31802926793449), (48.5389085690133 -23.614423069809703), (67.25245886702766 -44.07914094501147), (-45.446181860439914 11.257960381463633))" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ(0, outstream.str().rfind("GEOMETRYCOLLECTION", 0)); 23 | 24 | } -------------------------------------------------------------------------------- /test/WithinCommandTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GeosCli/GeosCli.hpp" 4 | #include "CLI/CLI.hpp" 5 | #include "gtest/gtest.h" 6 | 7 | TEST(geos_tests, within_false_test) { 8 | 9 | CLI::App app{"GEOS CLI"}; 10 | WithinCommand cmd{&app}; 11 | 12 | int argc = 6; 13 | char const *argv[6] = {"geos-cli", "within", "-g", "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))", "-o", "POINT (2 2)" }; 14 | 15 | app.parse(argc, argv); 16 | 17 | std::istringstream instream; 18 | std::ostringstream outstream; 19 | 20 | cmd.execute(instream, outstream); 21 | 22 | ASSERT_EQ("false\n", outstream.str()); 23 | 24 | } 25 | 26 | TEST(geos_tests, within_true_test) { 27 | 28 | CLI::App app{"GEOS CLI"}; 29 | WithinCommand cmd{&app}; 30 | 31 | int argc = 6; 32 | char const *argv[6] = {"geos-cli", "within", "-g", "POINT (2 2)", "-o", "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))" }; 33 | 34 | app.parse(argc, argv); 35 | 36 | std::istringstream instream; 37 | std::ostringstream outstream; 38 | 39 | cmd.execute(instream, outstream); 40 | 41 | ASSERT_EQ("true\n", outstream.str()); 42 | 43 | } --------------------------------------------------------------------------------