From 24eee8f4e8ea02678fc37d2d4135342b5443aad2 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 14 Nov 2019 11:34:37 +0100 Subject: [PATCH] Bump geometry.hpp dependency from 0.9.2 to 1.0.0 --- CHANGELOG.md | 1 + CMakeLists.txt | 4 +- third_party/geometry.hpp-0.9.2/.gitignore | 2 - third_party/geometry.hpp-0.9.2/.gitmodules | 3 - third_party/geometry.hpp-0.9.2/.travis.yml | 50 ---- third_party/geometry.hpp-0.9.2/Makefile | 19 -- .../include/mapbox/geometry/geometry.hpp | 58 ---- .../geometry.hpp-0.9.2/tests/collection.cpp | 5 - third_party/geometry.hpp-0.9.2/tests/test.cpp | 260 ------------------ third_party/geometry.hpp-1.0.0/.gitignore | 5 + third_party/geometry.hpp-1.0.0/.gitmodules | 0 third_party/geometry.hpp-1.0.0/.travis.yml | 81 ++++++ .../LICENSE | 0 third_party/geometry.hpp-1.0.0/Makefile | 41 +++ .../README.md | 4 +- .../include/mapbox}/feature.hpp | 56 ++-- .../include/mapbox/geometry.hpp | 1 - .../include/mapbox/geometry/box.hpp | 6 +- .../include/mapbox/geometry/empty.hpp | 18 ++ .../include/mapbox/geometry/envelope.hpp | 4 +- .../mapbox/geometry/for_each_point.hpp | 18 +- .../include/mapbox/geometry/geometry.hpp | 56 ++++ .../include/mapbox/geometry/line_string.hpp | 11 +- .../mapbox/geometry/multi_line_string.hpp | 9 +- .../include/mapbox/geometry/multi_point.hpp | 9 +- .../include/mapbox/geometry/multi_polygon.hpp | 9 +- .../include/mapbox/geometry/point.hpp | 11 +- .../mapbox/geometry/point_arithmetic.hpp | 0 .../include/mapbox/geometry/polygon.hpp | 18 +- .../include/mapbox/geometry_io.hpp | 98 +++++++ 30 files changed, 420 insertions(+), 437 deletions(-) delete mode 100644 third_party/geometry.hpp-0.9.2/.gitignore delete mode 100644 third_party/geometry.hpp-0.9.2/.gitmodules delete mode 100644 third_party/geometry.hpp-0.9.2/.travis.yml delete mode 100644 third_party/geometry.hpp-0.9.2/Makefile delete mode 100644 third_party/geometry.hpp-0.9.2/include/mapbox/geometry/geometry.hpp delete mode 100644 third_party/geometry.hpp-0.9.2/tests/collection.cpp delete mode 100644 third_party/geometry.hpp-0.9.2/tests/test.cpp create mode 100644 third_party/geometry.hpp-1.0.0/.gitignore create mode 100644 third_party/geometry.hpp-1.0.0/.gitmodules create mode 100644 third_party/geometry.hpp-1.0.0/.travis.yml rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/LICENSE (100%) create mode 100644 third_party/geometry.hpp-1.0.0/Makefile rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/README.md (92%) rename third_party/{geometry.hpp-0.9.2/include/mapbox/geometry => geometry.hpp-1.0.0/include/mapbox}/feature.hpp (61%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry.hpp (91%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/box.hpp (87%) create mode 100644 third_party/geometry.hpp-1.0.0/include/mapbox/geometry/empty.hpp rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/envelope.hpp (84%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/for_each_point.hpp (66%) create mode 100644 third_party/geometry.hpp-1.0.0/include/mapbox/geometry/geometry.hpp rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/line_string.hpp (53%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/multi_line_string.hpp (59%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/multi_point.hpp (58%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/multi_polygon.hpp (58%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/point.hpp (81%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/point_arithmetic.hpp (100%) rename third_party/{geometry.hpp-0.9.2 => geometry.hpp-1.0.0}/include/mapbox/geometry/polygon.hpp (53%) create mode 100644 third_party/geometry.hpp-1.0.0/include/mapbox/geometry_io.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 32befa035..df59ad0a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - CHANGED: default car height was reduced to 2 meters. [#5389](https://github.com/Project-OSRM/osrm-backend/pull/5389) - Misc: - CHANGED: Reduce memory usage for raster source handling. [#5572](https://github.com/Project-OSRM/osrm-backend/pull/5572) + - CHANGED: Bump geometry.hpp dependency to v1.0.0 # 5.21.0 - Changes from 5.20.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 27abf3008..de68ac3f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -425,7 +425,7 @@ include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR}) set(MICROTAR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src") include_directories(SYSTEM ${MICROTAR_INCLUDE_DIR}) -set(MBXGEOM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/geometry.hpp-0.9.2/include") +set(MBXGEOM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/geometry.hpp-1.0.0/include") include_directories(SYSTEM ${MBXGEOM_INCLUDE_DIR}) set(CHEAPRULER_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cheap-ruler-cpp-2.5.4/include") include_directories(SYSTEM ${CHEAPRULER_INCLUDE_DIR}) @@ -883,4 +883,4 @@ if (ENABLE_NODE_BINDINGS) endforeach() add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources}) set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir}) -endif() \ No newline at end of file +endif() diff --git a/third_party/geometry.hpp-0.9.2/.gitignore b/third_party/geometry.hpp-0.9.2/.gitignore deleted file mode 100644 index 204298f23..000000000 --- a/third_party/geometry.hpp-0.9.2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -mason_packages -test diff --git a/third_party/geometry.hpp-0.9.2/.gitmodules b/third_party/geometry.hpp-0.9.2/.gitmodules deleted file mode 100644 index 44fba9a2f..000000000 --- a/third_party/geometry.hpp-0.9.2/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule ".mason"] - path = .mason - url = https://github.com/mapbox/mason.git diff --git a/third_party/geometry.hpp-0.9.2/.travis.yml b/third_party/geometry.hpp-0.9.2/.travis.yml deleted file mode 100644 index a567bdc5d..000000000 --- a/third_party/geometry.hpp-0.9.2/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: generic -sudo: false - -matrix: - include: - - os: linux - env: CXX=g++-4.9 - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'g++-4.9' ] - - os: linux - env: CXX=g++-5 - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'g++-5' ] - - os: linux - env: CXX=g++-6 - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'g++-6' ] - - os: linux - env: CXX=clang++-3.8 - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'libstdc++-4.9-dev' ] - before_script: - - git submodule update --init - - .mason/mason install clang++ 3.8.1 - - export PATH=$(.mason/mason prefix clang++ 3.8.1)/bin:$PATH - - os: linux - env: CXX=clang++-3.9 - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'libstdc++-4.9-dev' ] - before_script: - - git submodule update --init - - .mason/mason install clang++ 3.9.1 - - export PATH=$(.mason/mason prefix clang++ 3.9.1)/bin:$PATH - - os: osx - osx_image: xcode7.3 - -cache: apt - -script: - - make test diff --git a/third_party/geometry.hpp-0.9.2/Makefile b/third_party/geometry.hpp-0.9.2/Makefile deleted file mode 100644 index ec95379ec..000000000 --- a/third_party/geometry.hpp-0.9.2/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CXXFLAGS += -I include -std=c++14 -DDEBUG -O0 -Wall -Wextra -Werror -MASON ?= .mason/mason - -VARIANT = 1.1.4 - -default: test - -$(MASON): - git submodule update --init - -mason_packages/headers/variant/$(VARIANT): - $(MASON) install variant $(VARIANT) - -test: tests/* include/mapbox/geometry/* mason_packages/headers/variant/$(VARIANT) Makefile - $(CXX) tests/*.cpp $(CXXFLAGS) `$(MASON) cflags variant $(VARIANT)` -o test - ./test - -clean: - rm -f test diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/geometry.hpp b/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/geometry.hpp deleted file mode 100644 index a9d072be7..000000000 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/geometry.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -#include - -// stl -#include - -namespace mapbox { -namespace geometry { - -template class Cont = std::vector> -struct geometry_collection; - -template -using geometry_base = mapbox::util::variant, - line_string, - polygon, - multi_point, - multi_line_string, - multi_polygon, - geometry_collection>; - -template -struct geometry : geometry_base -{ - using coordinate_type = T; - using geometry_base::geometry_base; - - /* - * The default constructor would create a point geometry with default-constructed coordinates; - * i.e. (0, 0). Since this is not particularly useful, and could hide bugs, it is disabled. - */ - geometry() = delete; -}; - -template class Cont> -struct geometry_collection : Cont> -{ - using coordinate_type = T; - using geometry_type = geometry; - using container_type = Cont; - - geometry_collection() = default; - geometry_collection(geometry_collection const&) = default; - geometry_collection(geometry_collection &&) = default; - geometry_collection(std::initializer_list && args) - : container_type(std::forward>(args)) {}; -}; - -} // namespace geometry -} // namespace mapbox diff --git a/third_party/geometry.hpp-0.9.2/tests/collection.cpp b/third_party/geometry.hpp-0.9.2/tests/collection.cpp deleted file mode 100644 index a3105a4e8..000000000 --- a/third_party/geometry.hpp-0.9.2/tests/collection.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -void test() { - mapbox::geometry::geometry_collection gc; -} diff --git a/third_party/geometry.hpp-0.9.2/tests/test.cpp b/third_party/geometry.hpp-0.9.2/tests/test.cpp deleted file mode 100644 index fcbde4fdc..000000000 --- a/third_party/geometry.hpp-0.9.2/tests/test.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include - -#include - -using namespace mapbox::geometry; - -static void testPoint() { - point p1; - assert(int(p1.x) == 0); - assert(int(p1.y) == 0); - - point p2(2, 3); - point p3(4, 6); - - assert((p2 + p3) == point(6, 9)); - assert((p2 + 1u) == point(3, 4)); - assert((p3 - p2) == point(2, 3)); - assert((p3 - 1u) == point(3, 5)); - assert((p3 * p2) == point(8, 18)); - assert((p2 * 2u) == point(4, 6)); - assert((p3 / p2) == point(2, 2)); - assert((p3 / 2u) == point(2, 3)); - - { point p(2, 3); assert((p += p3) == point(6, 9)); } - { point p(2, 3); assert((p += 1u) == point(3, 4)); } - { point p(4, 6); assert((p -= p2) == point(2, 3)); } - { point p(4, 6); assert((p -= 1u) == point(3, 5)); } - { point p(4, 6); assert((p *= p2) == point(8, 18)); } - { point p(2, 3); assert((p *= 2u) == point(4, 6)); } - { point p(4, 6); assert((p /= p2) == point(2, 2)); } - { point p(4, 6); assert((p /= 2u) == point(2, 3)); } -} - -static void testMultiPoint() { - multi_point mp1; - assert(mp1.size() == 0); - - multi_point mp2(10); - assert(mp2.size() == 10); - - assert(mp1 == mp1); - assert(!(mp1 != mp1)); - assert(mp1 != mp2); -} - -static void testLineString() { - line_string ls1; - assert(ls1.size() == 0); - - line_string ls2(10); - assert(ls2.size() == 10); - - assert(ls1 == ls1); - assert(!(ls1 != ls1)); - assert(ls1 != ls2); -} - -static void testMultiLineString() { - multi_line_string mls1; - assert(mls1.size() == 0); - - multi_line_string mls2(10); - assert(mls2.size() == 10); - - assert(mls1 == mls1); - assert(!(mls1 != mls1)); - assert(mls1 != mls2); -} - -static void testPolygon() { - polygon pg1; - assert(pg1.size() == 0); - - polygon pg2({{{0, 1}}}); - assert(pg2.size() == 1); - assert(pg2[0].size() == 1); - assert(pg2[0][0] == point(0, 1)); - - assert(pg1 == pg1); - assert(!(pg1 != pg1)); - assert(pg1 != pg2); -} - -static void testMultiPolygon() { - multi_polygon mpg1; - assert(mpg1.size() == 0); - - multi_polygon mpg2(10); - assert(mpg2.size() == 10); - - assert(mpg1 == mpg1); - assert(!(mpg1 != mpg1)); - assert(mpg1 != mpg2); -} - -static void testGeometry() { - geometry pg { point() }; - assert(pg.is>()); - - geometry lsg { line_string() }; - assert(lsg.is>()); - - geometry pgg { polygon() }; - assert(pgg.is>()); - - geometry mpg { multi_point() }; - assert(mpg.is>()); - - geometry mlsg { multi_line_string() }; - assert(mlsg.is>()); - - geometry mpgg { multi_polygon() }; - assert(mpgg.is>()); - - geometry gcg { geometry_collection() }; - assert(gcg.is>()); - - assert(pg == pg); - assert(!(pg != pg)); - assert(pg != lsg); -} - -static void testGeometryCollection() { - geometry_collection gc1; - assert(gc1.size() == 0); - - assert(gc1 == gc1); - assert(!(gc1 != gc1)); -} - -static void testFeature() { - feature pf { point() }; - assert(pf.geometry.is>()); - assert(pf.properties.size() == 0); - - auto &p = pf.properties; - - p["bool"] = true; - p["string"] = std::string("foo"); - p["double"] = 2.5; - p["uint"] = uint64_t(10); - p["int"] = int64_t(-10); - p["null"] = null_value; - - assert(p["bool"].is()); - assert(p["bool"] == true); - assert(p["string"].is()); - assert(p["string"] == std::string("foo")); - assert(p["double"].is()); - assert(p["double"] == 2.5); - assert(p["uint"].is()); - assert(p["uint"] == uint64_t(10)); - assert(p["int"].is()); - assert(p["int"] == int64_t(-10)); - assert(p["null"].is()); - assert(p["null"] == null_value); - - p["null"] = null_value_t{}; - assert(p["null"].is()); - assert(p["null"] == null_value); - - assert(p == p); - assert(!(p != p)); - - assert(pf == pf); - assert(!(pf != pf)); - - assert(p.size() == 6); - - feature id1 { point() }; - id1.id = { uint64_t(1) }; - - feature id2 { point() }; - id1.id = { uint64_t(2) }; - - assert(id1 == id1); - assert(id1 != id2); -} - -static void testFeatureCollection() { - feature_collection fc1; - assert(fc1.size() == 0); - - assert(fc1 == fc1); - assert(!(fc1 != fc1)); -} - -struct point_counter { - std::size_t count = 0; - template - void operator()(Point const&) { count++; }; -}; - -static void testForEachPoint() { - auto count_points = [] (auto const& g) { - point_counter counter; - for_each_point(g, counter); - return counter.count; - }; - - assert(count_points(point()) == 1); - assert(count_points(line_string({{0, 1}, {2, 3}})) == 2); - assert(count_points(geometry(polygon({{{0, 1}, {2, 3}}}))) == 2); - - auto point_negator = [] (point& p) { p *= -1.0; }; - - point p(1, 2); - for_each_point(p, point_negator); - assert(p == point(-1, -2)); - - line_string ls({{0, 1}, {2, 3}}); - for_each_point(ls, point_negator); - assert(ls == line_string({{0, -1}, {-2, -3}})); - - geometry g(polygon({{{0, 1}, {2, 3}}})); - for_each_point(g, point_negator); - assert(g == geometry(polygon({{{0, -1}, {-2, -3}}}))); - - // Custom geometry type - using my_geometry = mapbox::util::variant>; - assert(count_points(my_geometry(point())) == 1); - - // Custom point type - struct my_point { - int16_t x; - int16_t y; - }; - assert(count_points(std::vector({my_point{0, 1}})) == 1); - assert(count_points(mapbox::util::variant(my_point{0, 1})) == 1); -} - -static void testEnvelope() { - assert(envelope(point(0, 0)) == box({0, 0}, {0, 0})); - assert(envelope(line_string({{0, 1}, {2, 3}})) == box({0, 1}, {2, 3})); - assert(envelope(polygon({{{0, 1}, {2, 3}}})) == box({0, 1}, {2, 3})); - - assert(envelope(multi_point({{0, 0}})) == box({0, 0}, {0, 0})); - assert(envelope(multi_line_string({{{0, 1}, {2, 3}}})) == box({0, 1}, {2, 3})); - assert(envelope(multi_polygon({{{{0, 1}, {2, 3}}}})) == box({0, 1}, {2, 3})); - - assert(envelope(geometry(point(0, 0))) == box({0, 0}, {0, 0})); - assert(envelope(geometry_collection({point(0, 0)})) == box({0, 0}, {0, 0})); -} - -int main() { - testPoint(); - testMultiPoint(); - testLineString(); - testMultiLineString(); - testPolygon(); - testMultiPolygon(); - testGeometry(); - testGeometryCollection(); - testFeature(); - testFeatureCollection(); - - testForEachPoint(); - testEnvelope(); - return 0; -} diff --git a/third_party/geometry.hpp-1.0.0/.gitignore b/third_party/geometry.hpp-1.0.0/.gitignore new file mode 100644 index 000000000..89ebbe8be --- /dev/null +++ b/third_party/geometry.hpp-1.0.0/.gitignore @@ -0,0 +1,5 @@ +mason_packages +cmake-build +.toolchain +.mason +local.env diff --git a/third_party/geometry.hpp-1.0.0/.gitmodules b/third_party/geometry.hpp-1.0.0/.gitmodules new file mode 100644 index 000000000..e69de29bb diff --git a/third_party/geometry.hpp-1.0.0/.travis.yml b/third_party/geometry.hpp-1.0.0/.travis.yml new file mode 100644 index 000000000..b4159274c --- /dev/null +++ b/third_party/geometry.hpp-1.0.0/.travis.yml @@ -0,0 +1,81 @@ +language: generic + +matrix: + include: + # clang-tidy/format specific job + - os: linux + sudo: false + env: CLANG_FORMAT CLANG_TIDY + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'libstdc++6', 'libstdc++-5-dev' ] + script: + - make tidy + - make format + - os: linux + sudo: false + env: CXX=g++-4.9 + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-4.9' ] + - os: linux + sudo: false + env: CXX=g++-5 + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-5' ] + - os: linux + sudo: false + env: CXX=clang++ + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'libstdc++6', 'libstdc++-5-dev' ] + - os: linux + sudo: required + env: CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all" + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'libstdc++6', 'libstdc++-5-dev' ] + # coverage build + - os: linux + sudo: false + env: CXXFLAGS="--coverage" LDFLAGS="--coverage" + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'libstdc++6', 'libstdc++-5-dev' ] + script: + - make debug + - make test + # MASON_LLVM_RELEASE comes from the setup.sh script + - mason install llvm-cov ${MASON_LLVM_RELEASE} + - mason link llvm-cov ${MASON_LLVM_RELEASE} + - curl -S -f https://codecov.io/bash -o codecov + - chmod +x codecov + - ./codecov -x "llvm-cov gcov" -Z + +env: + global: + - CMAKE_VERSION="3.8.2" + +install: + # set up the environment by installing mason and clang++ + - ./scripts/setup.sh --config local.env + # put mason and clang++ on PATH + - source local.env + - mason install cmake ${CMAKE_VERSION} + - mason link cmake ${CMAKE_VERSION} + - which cmake + +script: + - make release + - make test + - make clean + - make debug + - make test + - make clean diff --git a/third_party/geometry.hpp-0.9.2/LICENSE b/third_party/geometry.hpp-1.0.0/LICENSE similarity index 100% rename from third_party/geometry.hpp-0.9.2/LICENSE rename to third_party/geometry.hpp-1.0.0/LICENSE diff --git a/third_party/geometry.hpp-1.0.0/Makefile b/third_party/geometry.hpp-1.0.0/Makefile new file mode 100644 index 000000000..dbbd5faa4 --- /dev/null +++ b/third_party/geometry.hpp-1.0.0/Makefile @@ -0,0 +1,41 @@ + +# Whether to turn compiler warnings into errors +export WERROR ?= true +export BUILD_DIR ?= cmake-build + +default: release + +release: + mkdir -p ./$(BUILD_DIR) && cd ./$(BUILD_DIR) && cmake ../ -DCMAKE_BUILD_TYPE=Release -DWERROR=$(WERROR) && VERBOSE=1 cmake --build . + +debug: + mkdir -p ./$(BUILD_DIR) && cd ./$(BUILD_DIR) && cmake ../ -DCMAKE_BUILD_TYPE=Debug -DWERROR=$(WERROR) && VERBOSE=1 cmake --build . + +test: + @if [ -f ./$(BUILD_DIR)/unit-tests ]; then ./$(BUILD_DIR)/unit-tests; else echo "Please run 'make release' or 'make debug' first" && exit 1; fi + +bench: + @if [ -f ./$(BUILD_DIR)/bench-tests ]; then ./$(BUILD_DIR)/bench-tests; else echo "Please run 'make release' or 'make debug' first" && exit 1; fi + +tidy: + ./scripts/clang-tidy.sh + +coverage: + ./scripts/coverage.sh + +clean: + rm -rf ./$(BUILD_DIR) + rm -f *.profraw + rm -f *.profdata + @echo "run 'make distclean' to also clear mason_packages, .mason, and .toolchain directories" + +distclean: clean + rm -rf mason_packages + rm -rf .mason + rm -rf .toolchain + rm -f local.env + +format: + ./scripts/format.sh + +.PHONY: test bench diff --git a/third_party/geometry.hpp-0.9.2/README.md b/third_party/geometry.hpp-1.0.0/README.md similarity index 92% rename from third_party/geometry.hpp-0.9.2/README.md rename to third_party/geometry.hpp-1.0.0/README.md index 972614a3b..07cbcfbea 100644 --- a/third_party/geometry.hpp-0.9.2/README.md +++ b/third_party/geometry.hpp-1.0.0/README.md @@ -1,5 +1,7 @@ # geometry.hpp +[![badge](https://mapbox.s3.amazonaws.com/cpp-assets/hpp-skel-badge_blue.svg)](https://github.com/mapbox/hpp-skel) + Provides header-only, generic C++ interfaces for geometry types, geometry collections, and features. - `mapbox::geometry::point` @@ -9,7 +11,7 @@ Provides header-only, generic C++ interfaces for geometry types, geometry collec - `mapbox::geometry::polygon` - `mapbox::geometry::multi_polygon` - `mapbox::geometry::geometry_collection` - - `mapbox::geometry::feature` (experimental) + - `mapbox::feature::feature` (experimental) ### Design diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/feature.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/feature.hpp similarity index 61% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/feature.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/feature.hpp index 91354442e..8d03f4674 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/feature.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/feature.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -8,17 +8,14 @@ #include #include #include -#include namespace mapbox { -namespace geometry { +namespace feature { struct value; struct null_value_t { - constexpr null_value_t() {} - constexpr null_value_t(std::nullptr_t) {} }; constexpr bool operator==(const null_value_t&, const null_value_t&) { return true; } @@ -44,7 +41,7 @@ struct value : value_base using property_map = std::unordered_map; // The same considerations and requirement for numeric types apply as for `value_base`. -using identifier = mapbox::util::variant; +using identifier = mapbox::util::variant; template struct feature @@ -53,16 +50,34 @@ struct feature using geometry_type = mapbox::geometry::geometry; // Fully qualified to avoid GCC -fpermissive error. geometry_type geometry; - property_map properties {}; - mapbox::util::optional id {}; + property_map properties; + identifier id; - // GCC 4.9 does not support C++14 aggregates with non-static data member - // initializers. - feature(geometry_type geometry_, - property_map properties_ = property_map {}, - mapbox::util::optional id_ = mapbox::util::optional {}) - : geometry(std::move(geometry_)), - properties(std::move(properties_)), + feature() + : geometry(), + properties(), + id() {} + feature(geometry_type const& geom_) + : geometry(geom_), + properties(), + id() {} + feature(geometry_type&& geom_) + : geometry(std::move(geom_)), + properties(), + id() {} + feature(geometry_type const& geom_, property_map const& prop_) + : geometry(geom_), properties(prop_), id() {} + feature(geometry_type&& geom_, property_map&& prop_) + : geometry(std::move(geom_)), + properties(std::move(prop_)), + id() {} + feature(geometry_type const& geom_, property_map const& prop_, identifier const& id_) + : geometry(geom_), + properties(prop_), + id(id_) {} + feature(geometry_type&& geom_, property_map&& prop_, identifier&& id_) + : geometry(std::move(geom_)), + properties(std::move(prop_)), id(std::move(id_)) {} }; @@ -84,8 +99,15 @@ struct feature_collection : Cont> using coordinate_type = T; using feature_type = feature; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + feature_collection(Args&&... args) : container_type(std::forward(args)...) + { + } + feature_collection(std::initializer_list args) + : container_type(std::move(args)) {} }; -} // namespace geometry +} // namespace feature } // namespace mapbox diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry.hpp similarity index 91% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry.hpp index e23245317..9caecd9a1 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/box.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/box.hpp similarity index 87% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/box.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/box.hpp index bf81b703e..bb3ea5701 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/box.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/box.hpp @@ -8,11 +8,13 @@ namespace geometry { template struct box { - using point_type = point; + using coordinate_type = T; + using point_type = point; constexpr box(point_type const& min_, point_type const& max_) : min(min_), max(max_) - {} + { + } point_type min; point_type max; diff --git a/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/empty.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/empty.hpp new file mode 100644 index 000000000..0ea446d8b --- /dev/null +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/empty.hpp @@ -0,0 +1,18 @@ +#pragma once + +namespace mapbox { +namespace geometry { + +struct empty +{ +}; // this Geometry type represents the empty point set, ∅, for the coordinate space (OGC Simple Features). + +constexpr bool operator==(empty, empty) { return true; } +constexpr bool operator!=(empty, empty) { return false; } +constexpr bool operator<(empty, empty) { return false; } +constexpr bool operator>(empty, empty) { return false; } +constexpr bool operator<=(empty, empty) { return true; } +constexpr bool operator>=(empty, empty) { return true; } + +} // namespace geometry +} // namespace mapbox diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/envelope.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/envelope.hpp similarity index 84% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/envelope.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/envelope.hpp index 860358398..e1f722fc5 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/envelope.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/envelope.hpp @@ -14,12 +14,12 @@ box envelope(G const& geometry) using limits = std::numeric_limits; T min_t = limits::has_infinity ? -limits::infinity() : limits::min(); - T max_t = limits::has_infinity ? limits::infinity() : limits::max(); + T max_t = limits::has_infinity ? limits::infinity() : limits::max(); point min(max_t, max_t); point max(min_t, min_t); - for_each_point(geometry, [&] (point const& point) { + for_each_point(geometry, [&](point const& point) { if (min.x > point.x) min.x = point.x; if (min.y > point.y) min.y = point.y; if (max.x < point.x) max.x = point.x; diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/for_each_point.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/for_each_point.hpp similarity index 66% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/for_each_point.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/for_each_point.hpp index 44d6e77bd..d31b484ff 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/for_each_point.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/for_each_point.hpp @@ -5,6 +5,11 @@ namespace mapbox { namespace geometry { +template +void for_each_point(mapbox::geometry::empty const&, F&&) +{ +} + template auto for_each_point(Point&& point, F&& f) -> decltype(point.x, point.y, void()) @@ -16,18 +21,18 @@ template auto for_each_point(Container&& container, F&& f) -> decltype(container.begin(), container.end(), void()); -template +template void for_each_point(mapbox::util::variant const& geom, F&& f) { - mapbox::util::variant::visit(geom, [&] (auto const& g) { + mapbox::util::variant::visit(geom, [&](auto const& g) { for_each_point(g, f); }); } -template -void for_each_point(mapbox::util::variant & geom, F&& f) +template +void for_each_point(mapbox::util::variant& geom, F&& f) { - mapbox::util::variant::visit(geom, [&] (auto & g) { + mapbox::util::variant::visit(geom, [&](auto& g) { for_each_point(g, f); }); } @@ -36,7 +41,8 @@ template auto for_each_point(Container&& container, F&& f) -> decltype(container.begin(), container.end(), void()) { - for (auto& e: container) { + for (auto& e : container) + { for_each_point(e, f); } } diff --git a/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/geometry.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/geometry.hpp new file mode 100644 index 000000000..fa1e7c31c --- /dev/null +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/geometry.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include + +// stl +#include + +namespace mapbox { +namespace geometry { + +template class Cont = std::vector> +struct geometry_collection; + +template class Cont = std::vector> +using geometry_base = mapbox::util::variant, + line_string, + polygon, + multi_point, + multi_line_string, + multi_polygon, + geometry_collection>; + +template class Cont = std::vector> +struct geometry : geometry_base +{ + using coordinate_type = T; + using geometry_base::geometry_base; +}; + +template class Cont> +struct geometry_collection : Cont> +{ + using coordinate_type = T; + using geometry_type = geometry; + using container_type = Cont; + using size_type = typename container_type::size_type; + + template + geometry_collection(Args&&... args) : container_type(std::forward(args)...) + { + } + geometry_collection(std::initializer_list args) + : container_type(std::move(args)) {} +}; + +} // namespace geometry +} // namespace mapbox diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/line_string.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/line_string.hpp similarity index 53% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/line_string.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/line_string.hpp index 6d811ce22..a015f71d1 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/line_string.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/line_string.hpp @@ -9,12 +9,19 @@ namespace mapbox { namespace geometry { template class Cont = std::vector> -struct line_string : Cont > +struct line_string : Cont> { using coordinate_type = T; using point_type = point; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + line_string(Args&&... args) : container_type(std::forward(args)...) + { + } + line_string(std::initializer_list args) + : container_type(std::move(args)) {} }; } // namespace geometry diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_line_string.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_line_string.hpp similarity index 59% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_line_string.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_line_string.hpp index 07a7a1d60..b528fa61b 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_line_string.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_line_string.hpp @@ -14,7 +14,14 @@ struct multi_line_string : Cont> using coordinate_type = T; using line_string_type = line_string; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + multi_line_string(Args&&... args) : container_type(std::forward(args)...) + { + } + multi_line_string(std::initializer_list args) + : container_type(std::move(args)) {} }; } // namespace geometry diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_point.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_point.hpp similarity index 58% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_point.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_point.hpp index a3c73cff9..060927bf2 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_point.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_point.hpp @@ -14,7 +14,14 @@ struct multi_point : Cont> using coordinate_type = T; using point_type = point; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + multi_point(Args&&... args) : container_type(std::forward(args)...) + { + } + multi_point(std::initializer_list args) + : container_type(std::move(args)) {} }; } // namespace geometry diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_polygon.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_polygon.hpp similarity index 58% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_polygon.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_polygon.hpp index ad230a04c..9546860ed 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/multi_polygon.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/multi_polygon.hpp @@ -14,7 +14,14 @@ struct multi_polygon : Cont> using coordinate_type = T; using polygon_type = polygon; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + multi_polygon(Args&&... args) : container_type(std::forward(args)...) + { + } + multi_polygon(std::initializer_list args) + : container_type(std::move(args)) {} }; } // namespace geometry diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/point.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/point.hpp similarity index 81% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/point.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/point.hpp index 0cba4996e..da8d67733 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/point.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/point.hpp @@ -10,21 +10,28 @@ struct point constexpr point() : x(), y() - {} + { + } constexpr point(T x_, T y_) : x(x_), y(y_) - {} + { + } T x; T y; }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" + template constexpr bool operator==(point const& lhs, point const& rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; } +#pragma GCC diagnostic pop + template constexpr bool operator!=(point const& lhs, point const& rhs) { diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/point_arithmetic.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/point_arithmetic.hpp similarity index 100% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/point_arithmetic.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/point_arithmetic.hpp diff --git a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/polygon.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/polygon.hpp similarity index 53% rename from third_party/geometry.hpp-0.9.2/include/mapbox/geometry/polygon.hpp rename to third_party/geometry.hpp-1.0.0/include/mapbox/geometry/polygon.hpp index 99a66aa12..5cad7bbf5 100644 --- a/third_party/geometry.hpp-0.9.2/include/mapbox/geometry/polygon.hpp +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry/polygon.hpp @@ -15,7 +15,14 @@ struct linear_ring : Cont> using coordinate_type = T; using point_type = point; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + linear_ring(Args&&... args) : container_type(std::forward(args)...) + { + } + linear_ring(std::initializer_list args) + : container_type(std::move(args)) {} }; template class Cont = std::vector> @@ -24,7 +31,14 @@ struct polygon : Cont> using coordinate_type = T; using linear_ring_type = linear_ring; using container_type = Cont; - using container_type::container_type; + using size_type = typename container_type::size_type; + + template + polygon(Args&&... args) : container_type(std::forward(args)...) + { + } + polygon(std::initializer_list args) + : container_type(std::move(args)) {} }; } // namespace geometry diff --git a/third_party/geometry.hpp-1.0.0/include/mapbox/geometry_io.hpp b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry_io.hpp new file mode 100644 index 000000000..4d91ccc96 --- /dev/null +++ b/third_party/geometry.hpp-1.0.0/include/mapbox/geometry_io.hpp @@ -0,0 +1,98 @@ +#pragma once + +#include +#include + +#include +#include + +namespace mapbox { +namespace geometry { + +std::ostream& operator<<(std::ostream& os, const empty&) +{ + return os << "[]"; +} + +template +std::ostream& operator<<(std::ostream& os, const point& point) +{ + return os << "[" << point.x << "," << point.y << "]"; +} + +template class C, class... Args> +std::ostream& operator<<(std::ostream& os, const C& cont) +{ + os << "["; + for (auto it = cont.cbegin();;) + { + os << *it; + if (++it == cont.cend()) + { + break; + } + os << ","; + } + return os << "]"; +} + +template +std::ostream& operator<<(std::ostream& os, const line_string& geom) +{ + return os << static_cast::container_type>(geom); +} + +template +std::ostream& operator<<(std::ostream& os, const linear_ring& geom) +{ + return os << static_cast::container_type>(geom); +} + +template +std::ostream& operator<<(std::ostream& os, const polygon& geom) +{ + return os << static_cast::container_type>(geom); +} + +template +std::ostream& operator<<(std::ostream& os, const multi_point& geom) +{ + return os << static_cast::container_type>(geom); +} + +template +std::ostream& operator<<(std::ostream& os, const multi_line_string& geom) +{ + return os << static_cast::container_type>(geom); +} + +template +std::ostream& operator<<(std::ostream& os, const multi_polygon& geom) +{ + return os << static_cast::container_type>(geom); +} + +template +std::ostream& operator<<(std::ostream& os, const geometry& geom) +{ + geometry::visit(geom, [&](const auto& g) { os << g; }); + return os; +} + +template +std::ostream& operator<<(std::ostream& os, const geometry_collection& geom) +{ + return os << static_cast::container_type>(geom); +} + +} // namespace geometry + +namespace feature { + +std::ostream& operator<<(std::ostream& os, const null_value_t&) +{ + return os << "[]"; +} + +} // namespace feature +} // namespace mapbox