From bb78bc8fe305eef39ca0a5d5e9dedc466f803dfb Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 5 Feb 2015 15:13:48 +0100 Subject: [PATCH] Squashed 'third_party/libosmium/' changes from 910f8f1..6522da5 6522da5 Merge pull request #79 from DennisOSRM/master 7c8d8dc add override keyword to close(), overridden function in include/osmium/io/detail/input_format.hpp d24841e Changes copyright dates in all files to a consistent "2013-2015". 3adc7d7 Another try to make it compile on Windows. 20dad8e Use auto instead of hard-coded types, hopefully fixes Windows build. b73ab3f Set build config in appveyor ctest call. 3e33857 Merge pull request #76 from BergWerkGIS/master c78ca6e Merge remote-tracking branch 'upstream/master' cf42013 enable test again 69e4a91 include compatibility.h 6f79b5c CMake: Remove Dart include, it seems to be superfluous. 4d40a18 Explicitly set copy constructors etc. for OutputIterator and test it. 69ee34c Run tests in build directory instead of source directory. 11c44c8 Fix typo. 675cc11 Fix formatting CMake config. 7aa3cb0 Add a benchmark counting amenity=post_box tags. 89fd942 Make it more evident that we handling constant tag lists. c72bbdf Add count() and empty() functions to Filter class. 88b9543 Disable annoying warnings from YouCompleteMe. 6cec403 Benchmarks: Only find files, not directories etc. in data dir. 09c4630 Follow redirects in benchmark download script. a8a552e Use Approx() function from Catch framework for floating point comparisons. 7db5086 Reorder data tests so fast tests run first. 24ce403 Fix #includes. ad9515c Add some comments in different config files to explain what they are. 987aa9c Some README updates. 3c18de7 Add configuration for YouCompleteMe Vim plugin. 433148e Explicit comparison against 0 to avoid warning with MSVC. e64a459 Small updates in benchmarks README. e4aff7f Add benchmark to compare static vs. dynamic index maps. f702634 Add missing include. 95a8c3b Merge branch 'master' of github.com:osmcode/libosmium 560a2ae Merge pull request #73 from osmcode/travis-fix f41e4ca remove incorrect cd f826107 Add some helper functions for working with entity_bits. 8fec1c1 Updated README: Lots of documentation is now on wiki. 6110cc8 Make cmake config work if no components are given. 8136557 Use 'Libosmium' instead of 'Osmium' as project name in doc. 10e631a Improved documenation: Dependencies to link with. 41d0ca4 Merge remote-tracking branch 'upstream/master' 6768026 SLN configuration is always 'Release' 5d985cf av: show env vars. 272ac88 don't use '%CONFIGURATION%' expands to e.g. 'Dev|x86' 59b15eb use cmake 3.1.0 again. old cmake on AppVeyor doesn't know yet about VS2014 SLN 0d0d71a try building with VS, Dev works only with VS at least locally 2fe6d02 name of geos.lib changed fc4662e test latest binary package d4a265f Add more labels to tests. 8722a3d Only check for valgrind if testing is enabled. cf7dc56 README improvements. 13a426e Fix cpack configuration. ae649c8 travis build: fix double install of make package c102040 Move cmake config for documentation into doc directory. 6064d55 Also list advanced cmake variables in travis build. c299bfa constexprt workaround for MSVC. afcf7a1 Cleanup/formatting of cmake config. a536720 Fix travis build by cloning osm-testdata in the right place. 2bdbf7f cmake: Don't clone osm-testdata repository any more. 5bdbb28 Rename test/osm-testdata to test/data-tests. 0ad0020 cmake: build data tests only by default on Dev builds 2cefa50 Add some benchmarks. 3fdb6e1 Remove outdated make_osmium_project.sh script. aca58ac Fix cmake config: overwriting of variables. 152e318 Fix compilation of examples that need wingetopt on Windows. ae17cd0 Remove superfluous warning on Windows for header test builds. f88d4c2 Switch to /W3 on Windows. 8edeba5 Remove duplicate copy constructor. cdb474e Cleanup examples cmake config ca9045a Cmake cleanup. 501eb61 Update to new version of catch unit test framework. 0646d6c Parenthesize expression to make test clearer and avoid warnings. dfdaeae Disable a warning that gdal throws on Windows. eacfe4f Explicitly test int !=0 to convert to bool. b3ba693 Cleanup of cmake config (mostly warning options Linux vs. Win) 3f5cb81 Appveyor: Also show advanced cmake variables. b544bd9 Never return valid but empty buffer from Reader.read() call. a34bb5d Declare var in a more local scope. b83e5f1 Merge pull request #66 from BergWerkGIS/master 04ef1b2 Last try for today, should solve geos test failures a749d6c hey AppVeyor: what's going on? 73131fb av: boost not found?? show directory tree 5e02886 av: should solve most "***Exception: Other" except for geos.dll related problem. should solve projection test fails. a7ae560 FlexReader now takes location handler as parameter. 6f1bd8d Disable non-existing Debian build in Makefile. 3d75178 Change warning level on MSVC. 3f0abc0 Appveyor: List cached variables from cmake. d1e1e9f Travis/Appveyor build in Dev and Release mode. Call ctest on Appveyor. 116bcc9 Fix default node location store. dedfe0e Make classes we submit to queue properly copyable. 8a432c9 Try the same ugly hack on OPLOutputBlock. 9c5b314 Try a hack to see whether it works on MSVC. 9592132 Give XMLOutputBlock a copy constructor. 991f91a Disable warning C4715: "not all control paths return a value" 340a4d7 Fix copy constructor. 7ceae00 Give OPLOutputBlock a copy constructor which basically does a move. e82951a Use rvalue as paremeter for queue submit function. 54a9cec Use explicit cast to double to silence warning. 7c5d04c Simplified use of ogr includes. 43fd388 Use appveyor supplied cmake. ce4311e cmake cleanup. 1108517 Disable warnings from MSVC in OGR headers. 2fe820c Harmonize signature of virtual member function dump_as_list(). 93c31b4 Parenthesize string in pragma message. 54ae1a0 Explicitly int to bool conversion to silence warning on MSVC. 4bde9b7 Formatting: Use spaces instead of tabs. 7224d84 cmake: Don't try to set C++ version with -std= with MSVC. 53fbcfd Remove trailing semikolon (which gcc doesn't like). 3b0c9ed Removed command that doesn't work on older cmakes. de6cc78 Merge pull request #62 from BergWerkGIS/master 9126530 Use less warning options on Windows. 6ec79fb Silence unknown pragma warning on Windows. b611589 Add static_cast to silence warning on windows. 18e54e9 remove call to build2.bat b0d9d28 try again with -DCMAKE_BUILD_TYPE=Release b495018 usage installed cmake, -DCMAKE_BUILD_TYPE=Dev 5bac95d Merge remote-tracking branch 'upstream/master' d41ea31 cmake: Do not use -Werror when using MSVC compiler 04cfe00 Provide convenience include file to include all index maps. 72fbaa7 Rename multimap indexes according to new schema. af49a27 Make registering index map types easier. 0a35701 av: remove debug echo calls 886c15f av: ditch -DCMAKE_BUILD_TYPE=Dev ad0a629 The great renaming of map index classes. 97b4d34 av: try again bf243b2 Move some hpp files into detail directory and fix include guards. 64e4841 av: try again calling cmake directly 1700789 Add way to dynamically choose node location index. da49b7f av: try again with build2.bat 4bf55f5 is appveyor working again? 5e63433 delete ws_32.lib patch. generate makefile instead of VS 1054016 Merge remote-tracking branch 'upstream/master' 8c198fc av: try even newer cmake 7cccb06 av: maybe newer cmake helps d04967a av: no existing env var was still there 80763c6 av: no build.bat, call cmake directly 3b58fc6 av: no cmds over spanning serveral lines? 33c09a0 CALL bat 34639c6 maybe double quotes? 72572de explicitly call VS2014 cmd prompt 6955e87 1st try on AppVeyor git-subtree-dir: third_party/libosmium git-subtree-split: 6522da53748e12379bbfaf70ad29ee7bd98ef02d --- .gitignore | 1 + .travis.yml | 18 +- .ycm_extra_conf.py | 44 +++ CMakeLists.txt | 309 +++++++++++------- Makefile | 10 +- README-changes-from-old-osmium | 43 --- README.md | 175 ++-------- appveyor.yml | 72 ++-- benchmarks/CMakeLists.txt | 48 +++ benchmarks/README.md | 41 +++ benchmarks/download_data.sh | 12 + benchmarks/osmium_benchmark_count.cpp | 54 +++ benchmarks/osmium_benchmark_count_tag.cpp | 55 ++++ benchmarks/osmium_benchmark_index_map.cpp | 41 +++ ...mium_benchmark_static_vs_dynamic_index.cpp | 136 ++++++++ benchmarks/run_benchmark_count.sh | 22 ++ benchmarks/run_benchmark_count_tag.sh | 22 ++ benchmarks/run_benchmark_index_map.sh | 27 ++ .../run_benchmark_static_vs_dynamic_index.sh | 21 ++ benchmarks/run_benchmarks.sh | 15 + benchmarks/setup.sh | 34 ++ cmake/FindOsmium.cmake | 46 ++- doc/CMakeLists.txt | 34 ++ doc/Doxyfile.in | 2 +- examples/CMakeLists.txt | 133 +++++--- examples/osmium_area_test.cpp | 4 +- examples/osmium_create_node_cache.cpp | 8 +- examples/osmium_index.cpp | 11 +- examples/osmium_serdump.cpp | 15 +- examples/osmium_toogr.cpp | 59 ++-- examples/osmium_toogr2.cpp | 25 +- examples/osmium_toogr2_exp.cpp | 35 +- examples/osmium_use_node_cache.cpp | 8 +- include/mmap_for_windows.hpp | 94 +++--- include/osmium/area/assembler.hpp | 2 +- .../osmium/area/detail/node_ref_segment.hpp | 2 +- include/osmium/area/detail/proto_ring.hpp | 2 +- include/osmium/area/detail/segment_list.hpp | 2 +- .../osmium/area/multipolygon_collector.hpp | 2 +- include/osmium/area/problem_reporter.hpp | 2 +- .../area/problem_reporter_exception.hpp | 2 +- include/osmium/area/problem_reporter_ogr.hpp | 44 ++- .../osmium/area/problem_reporter_stream.hpp | 2 +- include/osmium/builder/builder.hpp | 4 +- include/osmium/builder/builder_helper.hpp | 2 +- include/osmium/builder/osm_object_builder.hpp | 3 +- include/osmium/diff_handler.hpp | 2 +- include/osmium/diff_iterator.hpp | 2 +- include/osmium/diff_visitor.hpp | 2 +- include/osmium/dynamic_handler.hpp | 2 +- include/osmium/experimental/flex_reader.hpp | 27 +- include/osmium/geom/coordinates.hpp | 2 +- include/osmium/geom/factory.hpp | 2 +- include/osmium/geom/geojson.hpp | 2 +- include/osmium/geom/geos.hpp | 11 +- include/osmium/geom/haversine.hpp | 2 +- include/osmium/geom/mercator_projection.hpp | 2 +- include/osmium/geom/ogr.hpp | 46 ++- include/osmium/geom/projection.hpp | 15 +- include/osmium/geom/relations.hpp | 2 +- include/osmium/geom/util.hpp | 2 +- include/osmium/geom/wkb.hpp | 2 +- include/osmium/geom/wkt.hpp | 2 +- include/osmium/handler.hpp | 2 +- include/osmium/handler/chain.hpp | 2 +- include/osmium/handler/disk_store.hpp | 2 +- include/osmium/handler/dump.hpp | 2 +- .../handler/node_locations_for_ways.hpp | 7 +- include/osmium/handler/object_relations.hpp | 2 +- .../index/detail/create_map_with_fd.hpp | 73 +++++ .../osmium/index/detail/mmap_vector_anon.hpp | 12 +- .../osmium/index/detail/mmap_vector_base.hpp | 9 +- .../osmium/index/detail/mmap_vector_file.hpp | 8 +- include/osmium/index/detail/tmpfile.hpp | 8 +- include/osmium/index/detail/typed_mmap.hpp | 8 +- .../{map/vector.hpp => detail/vector_map.hpp} | 11 +- .../vector.hpp => detail/vector_multimap.hpp} | 11 +- include/osmium/index/index.hpp | 2 +- include/osmium/index/map.hpp | 106 +++++- include/osmium/index/map/all.hpp | 46 +++ include/osmium/index/map/dense_file_array.hpp | 67 ++++ include/osmium/index/map/dense_mem_array.hpp | 57 ++++ ...p_vector_anon.hpp => dense_mmap_array.hpp} | 17 +- include/osmium/index/map/dummy.hpp | 3 +- .../osmium/index/map/sparse_file_array.hpp | 67 ++++ .../{stl_vector.hpp => sparse_mem_array.hpp} | 17 +- .../map/{stl_map.hpp => sparse_mem_map.hpp} | 21 +- ...{sparse_table.hpp => sparse_mem_table.hpp} | 26 +- ..._vector_file.hpp => sparse_mmap_array.hpp} | 23 +- include/osmium/index/multimap.hpp | 7 +- include/osmium/index/multimap/all.hpp | 41 +++ include/osmium/index/multimap/hybrid.hpp | 17 +- ..._vector_file.hpp => sparse_file_array.hpp} | 12 +- .../{stl_vector.hpp => sparse_mem_array.hpp} | 12 +- ...l_multimap.hpp => sparse_mem_multimap.hpp} | 18 +- ..._vector_anon.hpp => sparse_mmap_array.hpp} | 12 +- include/osmium/index/node_locations_map.hpp | 70 ++++ include/osmium/io/any_compression.hpp | 11 +- include/osmium/io/any_input.hpp | 12 +- include/osmium/io/any_output.hpp | 12 +- include/osmium/io/bzip2_compression.hpp | 13 +- include/osmium/io/compression.hpp | 2 +- include/osmium/io/detail/input_format.hpp | 2 +- .../osmium/io/detail/opl_output_format.hpp | 92 +++--- include/osmium/io/detail/output_format.hpp | 2 +- include/osmium/io/detail/pbf.hpp | 2 +- include/osmium/io/detail/pbf_input_format.hpp | 2 +- .../osmium/io/detail/pbf_output_format.hpp | 2 +- include/osmium/io/detail/pbf_parser.hpp | 20 +- include/osmium/io/detail/pbf_stringtable.hpp | 2 +- include/osmium/io/detail/read_thread.hpp | 2 +- include/osmium/io/detail/read_write.hpp | 2 +- include/osmium/io/detail/write_thread.hpp | 2 +- include/osmium/io/detail/xml_input_format.hpp | 4 +- .../osmium/io/detail/xml_output_format.hpp | 151 ++++----- include/osmium/io/detail/zlib.hpp | 2 +- include/osmium/io/error.hpp | 3 +- include/osmium/io/file.hpp | 3 +- include/osmium/io/file_compression.hpp | 2 +- include/osmium/io/file_format.hpp | 2 +- include/osmium/io/gzip_compression.hpp | 11 +- include/osmium/io/header.hpp | 2 +- include/osmium/io/input_iterator.hpp | 3 +- include/osmium/io/opl_output.hpp | 2 +- include/osmium/io/output_iterator.hpp | 10 +- include/osmium/io/overwrite.hpp | 2 +- include/osmium/io/pbf_input.hpp | 12 +- include/osmium/io/pbf_output.hpp | 12 +- include/osmium/io/reader.hpp | 19 +- include/osmium/io/reader_iterator.hpp | 2 +- include/osmium/io/writer.hpp | 4 +- include/osmium/io/xml_input.hpp | 11 +- include/osmium/io/xml_output.hpp | 10 +- include/osmium/memory/buffer.hpp | 2 +- include/osmium/memory/collection.hpp | 3 +- include/osmium/memory/item.hpp | 2 +- include/osmium/memory/item_iterator.hpp | 2 +- include/osmium/object_pointer_collection.hpp | 2 +- include/osmium/osm.hpp | 2 +- include/osmium/osm/area.hpp | 2 +- include/osmium/osm/box.hpp | 4 +- include/osmium/osm/changeset.hpp | 2 +- include/osmium/osm/diff_object.hpp | 2 +- include/osmium/osm/entity.hpp | 7 +- include/osmium/osm/entity_bits.hpp | 8 +- include/osmium/osm/item_type.hpp | 2 +- include/osmium/osm/location.hpp | 2 +- include/osmium/osm/node.hpp | 2 +- include/osmium/osm/node_ref.hpp | 2 +- include/osmium/osm/node_ref_list.hpp | 2 +- include/osmium/osm/object.hpp | 2 +- include/osmium/osm/object_comparisons.hpp | 2 +- include/osmium/osm/relation.hpp | 2 +- include/osmium/osm/segment.hpp | 2 +- include/osmium/osm/tag.hpp | 2 +- include/osmium/osm/timestamp.hpp | 4 +- include/osmium/osm/types.hpp | 2 +- include/osmium/osm/undirected_segment.hpp | 2 +- include/osmium/osm/way.hpp | 2 +- include/osmium/relations/collector.hpp | 4 +- .../osmium/relations/detail/member_meta.hpp | 2 +- .../osmium/relations/detail/relation_meta.hpp | 2 +- include/osmium/tags/filter.hpp | 16 +- include/osmium/tags/regex_filter.hpp | 2 +- include/osmium/tags/taglist.hpp | 8 +- include/osmium/thread/function_wrapper.hpp | 5 +- include/osmium/thread/pool.hpp | 6 +- include/osmium/thread/queue.hpp | 3 +- include/osmium/thread/sorted_queue.hpp | 2 +- include/osmium/thread/util.hpp | 2 +- include/osmium/util/cast.hpp | 2 +- include/osmium/util/compatibility.hpp | 2 +- include/osmium/util/config.hpp | 2 +- include/osmium/util/double.hpp | 2 +- include/osmium/util/options.hpp | 2 +- include/osmium/util/verbose_output.hpp | 2 +- include/osmium/visitor.hpp | 2 +- make_osmium_project.sh | 96 ------ osmium.imp | 7 + test/CMakeLists.txt | 63 ++-- test/README | 1 + test/{osm-testdata => data-tests}/.gitignore | 0 test/data-tests/CMakeLists.txt | 121 +++++++ test/{osm-testdata => data-tests}/README.md | 0 .../include/check_basics_handler.hpp | 0 .../include/check_wkt_handler.hpp | 0 .../include/common.hpp | 7 +- .../include/testdata-testcases.hpp | 0 .../multipolygon.qgs | 0 .../run-testdata-multipolygon.bat | 0 .../run-testdata-multipolygon.sh | 0 .../testcases/test-100.cpp | 0 .../testcases/test-101.cpp | 0 .../testcases/test-110.cpp | 0 .../testdata-multipolygon.cpp | 24 +- .../testdata-overview.cpp | 25 +- .../testdata-testcases.cpp | 0 .../testdata-xml.cpp | 4 - test/include/catch.hpp | 40 ++- test/include/catch_orig.hpp | 29 +- test/include/utils.hpp | 18 + test/osm-testdata/CMakeLists.txt | 87 ----- test/t/basic/test_box.cpp | 2 +- test/t/basic/test_entity_bits.cpp | 6 + test/t/basic/test_node.cpp | 3 + test/t/basic/test_object_comparisons.cpp | 22 +- test/t/basic/test_way.cpp | 3 + test/t/geom/test_mercator.cpp | 16 +- test/t/geom/test_projection.cpp | 48 +-- test/t/index/test_id_to_location.cpp | 59 +++- test/t/index/test_typed_mmap.cpp | 2 +- test/t/io/test_bzip2.cpp | 5 +- test/t/io/test_output_iterator.cpp | 37 +++ test/t/io/test_reader.cpp | 15 +- test/valgrind.supp | 9 + 215 files changed, 2699 insertions(+), 1297 deletions(-) create mode 100644 .ycm_extra_conf.py delete mode 100644 README-changes-from-old-osmium create mode 100644 benchmarks/CMakeLists.txt create mode 100644 benchmarks/README.md create mode 100755 benchmarks/download_data.sh create mode 100644 benchmarks/osmium_benchmark_count.cpp create mode 100644 benchmarks/osmium_benchmark_count_tag.cpp create mode 100644 benchmarks/osmium_benchmark_index_map.cpp create mode 100644 benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp create mode 100755 benchmarks/run_benchmark_count.sh create mode 100755 benchmarks/run_benchmark_count_tag.sh create mode 100755 benchmarks/run_benchmark_index_map.sh create mode 100755 benchmarks/run_benchmark_static_vs_dynamic_index.sh create mode 100755 benchmarks/run_benchmarks.sh create mode 100755 benchmarks/setup.sh create mode 100644 doc/CMakeLists.txt create mode 100644 include/osmium/index/detail/create_map_with_fd.hpp rename include/osmium/index/{map/vector.hpp => detail/vector_map.hpp} (96%) rename include/osmium/index/{multimap/vector.hpp => detail/vector_multimap.hpp} (94%) create mode 100644 include/osmium/index/map/all.hpp create mode 100644 include/osmium/index/map/dense_file_array.hpp create mode 100644 include/osmium/index/map/dense_mem_array.hpp rename include/osmium/index/map/{mmap_vector_anon.hpp => dense_mmap_array.hpp} (77%) create mode 100644 include/osmium/index/map/sparse_file_array.hpp rename include/osmium/index/map/{stl_vector.hpp => sparse_mem_array.hpp} (79%) rename include/osmium/index/map/{stl_map.hpp => sparse_mem_map.hpp} (86%) rename include/osmium/index/map/{sparse_table.hpp => sparse_mem_table.hpp} (86%) rename include/osmium/index/map/{mmap_vector_file.hpp => sparse_mmap_array.hpp} (74%) create mode 100644 include/osmium/index/multimap/all.hpp rename include/osmium/index/multimap/{mmap_vector_file.hpp => sparse_file_array.hpp} (81%) rename include/osmium/index/multimap/{stl_vector.hpp => sparse_mem_array.hpp} (82%) rename include/osmium/index/multimap/{stl_multimap.hpp => sparse_mem_multimap.hpp} (90%) rename include/osmium/index/multimap/{mmap_vector_anon.hpp => sparse_mmap_array.hpp} (81%) create mode 100644 include/osmium/index/node_locations_map.hpp delete mode 100755 make_osmium_project.sh rename test/{osm-testdata => data-tests}/.gitignore (100%) create mode 100644 test/data-tests/CMakeLists.txt rename test/{osm-testdata => data-tests}/README.md (100%) rename test/{osm-testdata => data-tests}/include/check_basics_handler.hpp (100%) rename test/{osm-testdata => data-tests}/include/check_wkt_handler.hpp (100%) rename test/{osm-testdata => data-tests}/include/common.hpp (78%) rename test/{osm-testdata => data-tests}/include/testdata-testcases.hpp (100%) rename test/{osm-testdata => data-tests}/multipolygon.qgs (100%) rename test/{osm-testdata => data-tests}/run-testdata-multipolygon.bat (100%) rename test/{osm-testdata => data-tests}/run-testdata-multipolygon.sh (100%) rename test/{osm-testdata => data-tests}/testcases/test-100.cpp (100%) rename test/{osm-testdata => data-tests}/testcases/test-101.cpp (100%) rename test/{osm-testdata => data-tests}/testcases/test-110.cpp (100%) rename test/{osm-testdata => data-tests}/testdata-multipolygon.cpp (92%) rename test/{osm-testdata => data-tests}/testdata-overview.cpp (86%) rename test/{osm-testdata => data-tests}/testdata-testcases.cpp (100%) rename test/{osm-testdata => data-tests}/testdata-xml.cpp (99%) create mode 100644 test/include/utils.hpp delete mode 100644 test/osm-testdata/CMakeLists.txt create mode 100644 test/t/io/test_output_iterator.cpp diff --git a/.gitignore b/.gitignore index 608d46daf..36118e129 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ core *.swp build* +.ycm_extra_conf.pyc diff --git a/.travis.yml b/.travis.yml index 2c420728e..ea8794ecb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,19 @@ +#----------------------------------------------------------------------------- +# +# Configuration for continuous integration service at travis-ci.org +# +#----------------------------------------------------------------------------- + language: cpp compiler: - gcc - clang +env: + - CONFIGURATION=Dev + - CONFIGURATION=Release + before_install: # we need at least g++-4.8 for c++11 features - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test @@ -16,8 +26,8 @@ install: - sudo rm /usr/bin/cpp - sudo ln -s /usr/bin/cpp-4.8 /usr/bin/cpp # upgrade libosmium dependencies - - sudo apt-get install --yes make libboost-dev libboost-program-options-dev libsparsehash-dev libprotobuf-dev protobuf-compiler libgeos++-dev libproj-dev - - sudo apt-get install --yes make libgdal1h libgdal-dev + - sudo apt-get install --yes make libboost-dev libboost-program-options-dev libsparsehash-dev libprotobuf-dev protobuf-compiler libgeos++-dev libproj-dev libgdal1h libgdal-dev + - git clone https://github.com/osmcode/osm-testdata.git # OSMPBF is too old, install from git #- sudo apt-get install --yes libosmpbf-dev - git clone https://github.com/scrosby/OSM-binary.git @@ -26,8 +36,6 @@ install: - sudo make install - cd ../.. -#env: - before_script: - true @@ -35,7 +43,7 @@ script: - if [ "${CXX}" = 'g++' ]; then export CXX=g++-4.8; fi; - mkdir build - cd build - - cmake -L -DCMAKE_BUILD_TYPE=Dev .. + - cmake -LA -DCMAKE_BUILD_TYPE=${CONFIGURATION} .. - make VERBOSE=1 # Disable multipolygon test because it needs ruby and the 'json' gem, but the # travis ruby installation doesn't find the gem it did install itself. diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py new file mode 100644 index 000000000..b0f9d3eaf --- /dev/null +++ b/.ycm_extra_conf.py @@ -0,0 +1,44 @@ +#----------------------------------------------------------------------------- +# +# Configuration for YouCompleteMe Vim plugin +# +# http://valloric.github.io/YouCompleteMe/ +# +#----------------------------------------------------------------------------- + +# some default flags +# for more information install clang-3.2-doc package and +# check UsersManual.html +flags = [ +'-Werror', +'-Wall', +'-Wextra', +'-pedantic', +'-Wno-return-type', +'-Wno-unused-parameter', +'-Wno-unused-variable', + +'-std=c++11', + +# '-x' and 'c++' also required +# use 'c' for C projects +'-x', +'c++', + +# libosmium include dirs +'-Iinclude', +'-Itest/include', +'-Itest/data-test/include', + +# include third party libraries +'-I/usr/include/gdal', +] + +# youcompleteme is calling this function to get flags +# You can also set database for flags. Check: JSONCompilationDatabase.html in +# clang-3.2-doc package +def FlagsForFile( filename ): + return { + 'flags': flags, + 'do_cache': True + } diff --git a/CMakeLists.txt b/CMakeLists.txt index 19b88cfc2..373bf8eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,20 @@ -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # -# Libosmium CMakeLists.txt +# CMake Config # -#---------------------------------------------------------------------- +# Libosmium +# +#----------------------------------------------------------------------------- cmake_minimum_required(VERSION 2.8 FATAL_ERROR) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # # Project version # -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- project(libosmium) @@ -20,85 +22,103 @@ set(LIBOSMIUM_VERSION_MAJOR 0) set(LIBOSMIUM_VERSION_MINOR 0) set(LIBOSMIUM_VERSION_PATCH 1) -set(LIBOSMIUM_VERSION ${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}) +set(LIBOSMIUM_VERSION + ${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}) -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # # Build options # # (Change with -DOPTION=VALUE on cmake command line.) # -#---------------------------------------------------------------------- - -option(BUILD_EXAMPLES "compile example programs" ON) -option(BUILD_UNIT_TESTS "compile unit tests, please run them with ctest" ON) -option(BUILD_DATA_TESTS "compile data tests, please run them with ctest" ON) +#----------------------------------------------------------------------------- if(CMAKE_BUILD_TYPE STREQUAL "Dev") - option(BUILD_HEADERS "compile every header file on its own" ON) + set(dev_build ON) else() - option(BUILD_HEADERS "compile every header file on its own" OFF) + set(dev_build OFF) endif() +option(BUILD_EXAMPLES "compile example programs" ON) +option(BUILD_TESTING "compile unit tests, please run them with ctest" ON) -#---------------------------------------------------------------------- +option(BUILD_HEADERS "compile every header file on its own" ${dev_build}) +option(BUILD_BENCHMARKS "compile benchmark programs" ${dev_build}) +option(BUILD_DATA_TESTS "compile data tests, please run them with ctest" ${dev_build}) + + +#----------------------------------------------------------------------------- # # Find external dependencies # -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- -# check that the essential libraries were found -if(BUILD_EXAMPLES OR BUILD_TESTING OR BUILD_UNIT_TESTS OR BUILD_DATA_TESTS OR BUILD_HEADERS) +find_package(Boost 1.38) +mark_as_advanced(CLEAR BOOST_ROOT) - find_package(Boost 1.38) - mark_as_advanced(CLEAR BOOST_ROOT) - - if(Boost_FOUND) - include_directories(${Boost_INCLUDE_DIRS}) - else() - set(BOOST_ROOT "NOT FOUND: please choose" CACHE PATH "") - message(FATAL_ERROR "PLEASE, specify the directory where the Boost library is installed in BOOST_ROOT") - endif() - - set(OSMIUM_INCLUDE_DIR include) - find_package(Osmium COMPONENTS io gdal geos proj sparsehash) - include_directories(${OSMIUM_INCLUDE_DIRS}) - - if(MSVC) - find_path(GETOPT_INCLUDE_DIR getopt.h) - find_library(GETOPT_LIBRARY NAMES wingetopt) - if(GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY) - include_directories(${GETOPT_INCLUDE_DIR}) - list(APPEND OSMIUM_LIBRARIES ${GETOPT_LIBRARY}) - else() - set(GETOPT_MISSING 1) - endif() - endif() - - include_directories(include) +if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) +else() + set(BOOST_ROOT "NOT FOUND: please choose" CACHE PATH "") + message(FATAL_ERROR "PLEASE, specify the directory where the Boost library is installed in BOOST_ROOT") endif() -#---------------------------------------------------------------------- +set(OSMIUM_INCLUDE_DIR include) +find_package(Osmium COMPONENTS io gdal geos proj sparsehash) +include_directories(${OSMIUM_INCLUDE_DIRS}) + +if(MSVC) + find_path(GETOPT_INCLUDE_DIR getopt.h) + find_library(GETOPT_LIBRARY NAMES wingetopt) + if(GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY) + include_directories(${GETOPT_INCLUDE_DIR}) + list(APPEND OSMIUM_LIBRARIES ${GETOPT_LIBRARY}) + else() + set(GETOPT_MISSING 1) + endif() +endif() + +include_directories(include) + + +#----------------------------------------------------------------------------- # # Decide which C++ version to use (Minimum/default: C++11). # -#---------------------------------------------------------------------- - -if(NOT USE_CPP_VERSION) - set(USE_CPP_VERSION c++11) +#----------------------------------------------------------------------------- +if(NOT MSVC) + if(NOT USE_CPP_VERSION) + set(USE_CPP_VERSION c++11) + endif() + message(STATUS "Use C++ version: ${USE_CPP_VERSION}") + # following only available from cmake 2.8.12: + # add_compile_options(-std=${USE_CPP_VERSION}) + # so using this instead: + add_definitions(-std=${USE_CPP_VERSION}) endif() -message(STATUS "Use C++ version: ${USE_CPP_VERSION}") -# following only available from cmake 2.8.12: -# add_compile_options(-std=${USE_CPP_VERSION}) -# so using this instead: -add_definitions(-std=${USE_CPP_VERSION}) -#---------------------------------------------------------------------- -set(CMAKE_CXX_FLAGS_DEV "-O3 -g" +#----------------------------------------------------------------------------- +# +# Compiler and Linker flags +# +#----------------------------------------------------------------------------- +if(MSVC) + set(USUAL_COMPILE_OPTIONS "/Ox") +else() + set(USUAL_COMPILE_OPTIONS "-O3 -g") +endif() + +if(WIN32) + add_definitions(-DWIN32 -D_WIN32 -DMSWIN32 -DBGDWIN32 + -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0600) +endif() + +set(CMAKE_CXX_FLAGS_DEV "${USUAL_COMPILE_OPTIONS}" CACHE STRING "Flags used by the compiler during developer builds." FORCE) + set(CMAKE_EXE_LINKER_FLAGS_DEV "" CACHE STRING "Flags used by the linker during developer builds." FORCE) @@ -107,61 +127,76 @@ mark_as_advanced( CMAKE_EXE_LINKER_FLAGS_DEV ) -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g" +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${USUAL_COMPILE_OPTIONS}" CACHE STRING "Flags used by the compiler during RELWITHDEBINFO builds." FORCE) + +#----------------------------------------------------------------------------- +# +# Build Type +# +#----------------------------------------------------------------------------- set(CMAKE_CONFIGURATION_TYPES "Debug Release RelWithDebInfo MinSizeRel Dev") +# In 'Dev' mode: compile with very strict warnings and turn them into errors. +if(CMAKE_BUILD_TYPE STREQUAL "Dev") + if(NOT MSVC) + add_definitions(-Werror) + endif() + add_definitions(${OSMIUM_WARNING_OPTIONS}) +endif() + # Force RelWithDebInfo build type if none was given -if (CMAKE_BUILD_TYPE STREQUAL "") - set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE) +if(CMAKE_BUILD_TYPE) + set(build_type ${CMAKE_BUILD_TYPE}) else() - set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE) + set(build_type "RelWithDebInfo") endif() - -#---------------------------------------------------------------------- - -if(WIN32) - add_definitions(-DWIN32 -D_WIN32 -DMSWIN32 -DBGDWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0600) - set(CPACK_GENERATOR ZIP) -else() - set(CPACK_GENERATOR TGZ) -endif() +set(CMAKE_BUILD_TYPE ${build_type} + CACHE STRING + "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." + FORCE) -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # -# Set up testing +# Unit and data tests # -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- enable_testing() -find_program(MEMORYCHECK_COMMAND valgrind) -set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full --show-reachable=yes --error-exitcode=1") -set(MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.supp") +if(BUILD_TESTING OR BUILD_DATA_TESTS) + find_program(MEMORYCHECK_COMMAND valgrind) -if(BUILD_UNIT_TESTS OR BUILD_TESTING) + set(MEMORYCHECK_COMMAND_OPTIONS + "--trace-children=yes --leak-check=full --show-reachable=yes --error-exitcode=1") + + set(MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.supp") +endif() + +if(BUILD_TESTING) add_subdirectory(test) endif() -if(BUILD_DATA_TESTS OR BUILD_TESTING) - add_subdirectory(test/osm-testdata) +if(BUILD_DATA_TESTS) + add_subdirectory(test/data-tests) endif() -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # # Optional "cppcheck" target that checks C++ code # -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- message(STATUS "Looking for cppcheck") find_program(CPPCHECK cppcheck) if(CPPCHECK) message(STATUS "Looking for cppcheck - found") - set(CPPCHECK_OPTIONS --enable=warning,style,performance,portability,information,missingInclude) + set(CPPCHECK_OPTIONS + --enable=warning,style,performance,portability,information,missingInclude) # cpp doesn't find system includes for some reason, suppress that report set(CPPCHECK_OPTIONS ${CPPCHECK_OPTIONS} --suppress=missingIncludeSystem) @@ -169,7 +204,7 @@ if(CPPCHECK) file(GLOB_RECURSE ALL_INCLUDES include/osmium/*.hpp) file(GLOB ALL_EXAMPLES examples/*.cpp) file(GLOB ALL_UNIT_TESTS test/t/*/test_*.cpp) - file(GLOB ALL_DATA_TESTS test/osm-testdata/*.cpp) + file(GLOB ALL_DATA_TESTS test/data-tests/*.cpp) if(Osmium_DEBUG) message(STATUS "Checking includes : ${ALL_INCLUDES}") @@ -178,7 +213,11 @@ if(CPPCHECK) message(STATUS "Checking data test code: ${ALL_DATA_TESTS}") endif() - set(CPPCHECK_FILES ${ALL_INCLUDES} ${ALL_EXAMPLES} ${ALL_UNIT_TESTS} ${ALL_DATA_TESTS}) + set(CPPCHECK_FILES + ${ALL_INCLUDES} + ${ALL_EXAMPLES} + ${ALL_UNIT_TESTS} + ${ALL_DATA_TESTS}) add_custom_target(cppcheck ${CPPCHECK} @@ -188,48 +227,42 @@ if(CPPCHECK) ) else() message(STATUS "Looking for cppcheck - not found") - message(STATUS " Make target cppcheck not available") + message(STATUS " Build target 'cppcheck' will not be available.") endif(CPPCHECK) -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # -# Doxygen-based documentation +# Examples, benchmarks and documentation # -#---------------------------------------------------------------------- -find_package(Doxygen) -if(DOXYGEN_FOUND) - configure_file(doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) - add_custom_target(doc - ${DOXYGEN_EXECUTABLE} - ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" VERBATIM - ) - install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html" DESTINATION "share/doc/libosmium-dev") -else() - message(STATUS "Doxygen not found, so 'doc' target will not be available.") -endif() - - -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- if(BUILD_EXAMPLES) add_subdirectory(examples) endif() -#---------------------------------------------------------------------- -# This will try to compile include files on their own to detect missing -# include directives and other dependency-related problems. Note that if this -# work, it is not enough to be sure it will compile in production code. -# But if it reports an error we know we are missing something. -if(BUILD_HEADERS) - file(GLOB_RECURSE ALL_HPPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include" include/osmium/*.hpp) +if(BUILD_BENCHMARKS) + add_subdirectory(benchmarks) +endif() - # In 'Dev' mode: compile with very strict warnings and turn them into errors. - if(CMAKE_BUILD_TYPE STREQUAL "Dev") - add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS}) - endif() +add_subdirectory(doc) + + +#----------------------------------------------------------------------------- +# +# Headers +# +# This will try to compile include files on their own to detect missing +# include directives and other dependency-related problems. Note that if this +# work, it is not enough to be sure it will compile in production code. +# But if it reports an error we know we are missing something. +# +#----------------------------------------------------------------------------- +if(BUILD_HEADERS) + file(GLOB_RECURSE + ALL_HPPS + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include" + include/osmium/*.hpp) file(MAKE_DIRECTORY header_check) @@ -244,7 +277,19 @@ if(BUILD_HEADERS) # There is no way in CMake to just compile but not link a C++ file, # so we pretend to build a library here. - add_library(${libname} OBJECT ${DUMMYCPP} include/${hpp}) + add_library(${libname} STATIC ${DUMMYCPP} include/${hpp}) + + if(MSVC) + # Remove warning LNK4221: "This object file does not define any + # previously undefined public symbols, so it will not be used by + # any link operation that consumes this library". This is a dummy + # library anyways. + target_link_libraries(${libname} /wd4221) + endif() + + #### this is better but only supported from cmake 3.0: + ###add_library(${libname} OBJECT ${DUMMYCPP} include/${hpp}) + endforeach() endif() @@ -254,6 +299,38 @@ install(DIRECTORY include/osmium DESTINATION include) # don't have it. We probably don't want to install it. #install(FILES include/boost_unicode_iterator.hpp DESTINATION include) -#---------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# +# Packaging +# +#----------------------------------------------------------------------------- + +set(CPACK_PACKAGE_VERSION_MAJOR ${LIBOSMIUM_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${LIBOSMIUM_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${LIBOSMIUM_VERSION_PATCH}) + +if(WIN32) + set(CPACK_GENERATOR ZIP) +else() + set(CPACK_GENERATOR TGZ) +endif() + include(CPack) + +#----------------------------------------------------------------------------- +# +# Print warnings at the end +# +#----------------------------------------------------------------------------- +if(BUILD_DATA_TESTS AND OSM_TESTDATA STREQUAL "OSM_TESTDATA-NOTFOUND") + message("\n========================== WARNING ==========================") + message("osm-testdata directory not found, data tests were disabled!\n") + message("You can get it from https://github.com/osmcode/osm-testdata") + message("Clone it into the same directory libosmium is in") + message("or set the OSM_TESTDATA cmake variable to its path.") + message("=============================================================\n") +endif() + +#----------------------------------------------------------------------------- diff --git a/Makefile b/Makefile index b445e8e82..7b2b83d7b 100644 --- a/Makefile +++ b/Makefile @@ -11,11 +11,11 @@ clean: distclean: rm -fr build -deb: - debuild -I -us -uc - -deb-clean: - debuild clean +#deb: +# debuild -I -us -uc +# +#deb-clean: +# debuild clean indent: astyle --style=java --indent-namespaces --indent-switches --pad-header --lineend=linux --suffix=none --recursive include/\*.hpp examples/\*.cpp test/\*.cpp diff --git a/README-changes-from-old-osmium b/README-changes-from-old-osmium deleted file mode 100644 index 3e94500ea..000000000 --- a/README-changes-from-old-osmium +++ /dev/null @@ -1,43 +0,0 @@ - -Changes from old versions of Osmium -=================================== - -This version has some substantial changes and users of Osmium will have to -rewrite their code. Use the examples provided in the "example" directory -or in the osmium-contrib repository to get an idea what needs changing. -These examples are often similar to the examples provided with the old -Osmium so they should give you an idea how your code has to change. - -Here are some of the more important changes: - -* Osmium now needs C++11. It will not work with older compilers. You need - at least GCC 4.7.3 or clang (LLVM) 3.2. - -* Namespaces are now all lower case. Everything is in the "osmium" namespace - or sub-namespaces of it. Many classes and functions have been moved to - different, more logical or shorter namespaces. - -* You can't just instantiate OSM objects such as Nodes, Ways, or Relations. - You need a Buffer first to hold them and use the Builder classes to - create them. This is a bit more cumbersome, but greatly reduces the need - for memory management and makes Osmium faster and easier to parallelize. - -* Usually you don't act on single OSM objects any more, but on groups of - them in a Buffer. - -* Reading and writing of OSM data is much simpler. Use the Reader and Writer - classes as they hide much of the detail and have much nicer interfaces - than the old Input/Output classes. - -* The class Osmium::OSM::Position was renamed to osmium::Location. This - better reflects that it is a location on the planet we are talking about. - The word "position" has many meanings and is, for instance, often used - to denote a position in a file or buffer or so. - -* The dependency on boost has been greatly reduced. C++11 offers many - features that used to be only available with boost, such as shared_ptr. - Osmium now uses the C++11 versions of these. - -* Osmium now makes use of the new C++11 threading support when reading and - writing OSM files. - diff --git a/README.md b/README.md index 8c7957f3b..503440e8e 100644 --- a/README.md +++ b/README.md @@ -1,112 +1,47 @@ -# Osmium Library +# Libosmium http://osmcode.org/libosmium A fast and flexible C++ library for working with OpenStreetMap data. -NOTE: This is a beta version of the next-generation Osmium. For production -use, see the Osmium version at https://github.com/joto/osmium . - -There are a few applications that use the Osmium library in the examples -directory. See the [osmium-contrib](http://github.com/osmcode/osmium-contrib) -repository for more example code. - [![Build Status](https://secure.travis-ci.org/osmcode/libosmium.png)](http://travis-ci.org/osmcode/libosmium) [![Build status](https://ci.appveyor.com/api/projects/status/mkbg6e6stdgq7c1b?svg=true)](https://ci.appveyor.com/project/Mapbox/libosmium) Libosmium is developed on Linux, but also works on OSX and Windows (with some limitations). +There are a few applications that use the Osmium library in the examples +directory. See the [osmium-contrib](http://github.com/osmcode/osmium-contrib) +repository for more example code. + ## Prerequisites -Because Osmium uses many C++11 features you need a modern compiler and standard -C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.2. (Some parts may -work with older versions.) +Because Libosmium uses many C++11 features you need a modern compiler and +standard C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.4. +(Some parts may work with older versions.) -Different parts of Osmium (and the applications built on top of it) need +Different parts of Libosmium (and the applications built on top of it) need different libraries. You DO NOT NEED to install all of them, just install those -you need for the programs you need. +you need for your programs. - boost-iterator, boost-regex - http://www.boost.org/ - Debian/Ubuntu: libboost-dev - openSUSE: boost-devel - Homebrew: boost - - boost-program-options (for parsing command line options in some examples) - http://www.boost.org/doc/libs/1_54_0/doc/html/program_options.html - Debian/Ubuntu: libboost-program-options-dev - - Google protocol buffers (for PBF support) - http://code.google.com/p/protobuf/ (at least version 2.3.0 needed) - Debian/Ubuntu: libprotobuf-dev protobuf-compiler - openSUSE: protobuf-devel - Homebrew: protobuf - Also see http://wiki.openstreetmap.org/wiki/PBF_Format - - OSMPBF (for PBF support) - https://github.com/scrosby/OSM-binary - Debian/Ubuntu: libosmpbf-dev - (The package in Ubuntu 14.04 and older is too old, install from source - in these cases.) - Homebrew: osm-pbf - - Expat (for parsing XML files) - http://expat.sourceforge.net/ - Debian/Ubuntu: libexpat1-dev - openSUSE: libexpat-devel - Homebrew: expat - - zlib (for PBF and for gzip support when reading/writing XML) - http://www.zlib.net/ - Debian/Ubuntu: zlib1g-dev - openSUSE: zlib-devel - - bz2lib (for bzip2 support when reading/writing XML) - http://www.bzip.org/ - Debian/Ubuntu: libbz2-dev - - Google sparsehash - http://code.google.com/p/google-sparsehash/ - Debian/Ubuntu: libsparsehash-dev - openSUSE: sparsehash - Homebrew: google-sparsehash - - GDAL (for OGR support) - http://gdal.org/ - Debian/Ubuntu: libgdal1-dev - openSUSE: libgdal-devel - Homebrew: gdal - - GEOS (for GEOS support) - http://trac.osgeo.org/geos/ - Debian/Ubuntu: libgeos++-dev - openSUSE: libgeos-devel - Homebrew: geos - - libproj (for projection support) - http://trac.osgeo.org/proj/ - Debian/Ubuntu: libproj-dev - - Doxygen (to build API documentation) and tools - http://www.stack.nl/~dimitri/doxygen/ - Debian/Ubuntu: doxygen graphviz xmlstarlet - Homebrew: doxygen - -You need to either install the packages for your distribution or install those -libraries from source. Most libraries should be available in all distributions. +For details see the +[list of dependencies](https://github.com/osmcode/libosmium/wiki/Libosmium-dependencies). ## Directories -* include: C/C++ include files. All of Osmium is in those header files which - are needed for building Osmium applications. +* benchmarks: Some benchmarks checking different parts of Libosmium. + +* cmake: CMake configuration scripts. + +* doc: Config for documentation. * examples: Osmium example applications. -* test: Tests (see below). +* include: C/C++ include files. All of Libosmium is in those header files + which are needed for building Osmium applications. -* doc: Config for documentation. +* test: Tests (see below). ## Building @@ -124,61 +59,15 @@ cmake: This will build the examples and tests. Call `ctest` to run the tests. -To build the documentation you need Doxygen. If cmake can find it it will -enable the `doc` target so you can build the documentation like this: - - make doc - -If the 'cppcheck' binary is found, cmake will add another target to the -Makfile which allows you to call cppheck on all `*.cpp` and `*.hpp` files: - - make cppcheck - -For Mac users: If you have clang 3.2 or newer, use the system compiler. -If not you have to build the compiler yourself. See the instructions -on http://clang.llvm.org/ . - -Preliminary support for cmake is provided. You can use this instead of "make": +For more see the +[Libosmium Wiki](https://github.com/osmcode/libosmium/wiki/Building-Libosmium). ## Testing -### Unit Tests - -There are a few unit tests using the Catch unit test framework in the "test" -directory. Many more tests are needed, any help appreciated. - -For [Catch](https://github.com/philsquared/Catch/) only one header file is -needed which is included (`test/include/catch.hpp`). - -To compile these unit tests make sure `BUILD_UNIT_TESTS` is set in the cmake -config, then build the project and call - - ctest - -You can run tests matching a pattern by calling - - ctest -R test_name - -for instance: - - ctest basic_test_node - -will run the `basic_test_node` and `basic_test_node_ref` tests. - -### Data Tests - -In addition there are some test based on the OSM Test Data Repository at -http://osmcode.org/osm-testdata/ . Make sure `BUILD_DATA_TESTS` is set in the -cmake config, then build the project and call `ctest`. - -Some of these tests need Ruby and then 'json' gem installed. - -### Valgrind - -Running tests with valgrind: - - ctest -D ExperimentalMemCheck +See the +[Libosmium Wiki](https://github.com/osmcode/libosmium/wiki/Testing-Libosmium) +for instructions. ## Osmium on 32bit Machines @@ -198,20 +87,18 @@ Please report any issues you have and we might be able to solve them. ## Switching from the old Osmium -See `README-changes-from-old-osmium`. +If you have been using the old version of Osmium at +https://github.com/joto/osmium you might want to read about the +[changes needed](https://github.com/osmcode/libosmium/wiki/Changes-from-old-versions-of-Osmium). ## License -The Osmium Library is available under the Boost Software License. See -LICENSE.txt. +Libosmium is available under the Boost Software License. See LICENSE.txt. ## Authors -The Osmium Library was mainly written and is maintained by Jochen Topf -(jochen@topf.org). - -Other authors: -* Peter Körner (github@mazdermind.de) (PBF writer, ...) +Libosmium was mainly written and is maintained by Jochen Topf +(jochen@topf.org). See the git commit log for other authors. diff --git a/appveyor.yml b/appveyor.yml index d084b7dad..c112d4f77 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,13 @@ +#----------------------------------------------------------------------------- # -# Configuration for appveyor.com +# Configuration for continuous integration service at appveyor.com # +#----------------------------------------------------------------------------- environment: matrix: - - configuration: Dev -# - configuration: Release + - config: Dev + - config: Release # branches to build branches: @@ -14,7 +16,7 @@ branches: - master # Operating system (build VM template) -os: Windows Server 2012 R2 +os: Visual Studio 2014 CTP4 # scripts that are called at very beginning, before repo cloning init: @@ -25,31 +27,51 @@ clone_folder: c:\projects\libosmium platform: x64 install: - # by default, all script lines are interpreted as batch + # show all availble env vars + - SET + - ECHO cmake on AppVeyor + - cmake -version + - CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 + - SET PATH=c:\projects\libosmium\cmake-3.1.0-win32-x86\bin;%PATH% + - SET LODEPSDIR=c:\projects\libosmium\libosmium-deps + - SET PROJ_LIB=%LODEPSDIR%\proj\share + - set GDAL_DATA=%LODEPSDIR%\gdal\data + #geos.dll + - SET PATH=%LODEPSDIR%\geos\lib;%PATH% + #gdal.dll + - SET PATH=%LODEPSDIR%\gdal\lib;%PATH% + #libexpat.dll + - SET PATH=%LODEPSDIR%\expat\lib;%PATH% + #libtiff.dll + - SET PATH=%LODEPSDIR%\libtiff\lib;%PATH% + #zlibwapi.dll + - SET PATH=%LODEPSDIR%\zlib\lib;%PATH% + #convert backslashes in bzip2 path to forward slashes + #cmake cannot find it otherwise + - SET LIBBZIP2=%LODEPSDIR%\bzip2\lib\libbz2.lib + - SET LIBBZIP2=%LIBBZIP2:\=/% + - ps: Start-FileDownload https://mapnik.s3.amazonaws.com/deps/cmake-3.1.0-win32-x86.7z -FileName cm.7z + - ps: Start-FileDownload https://mapnik.s3.amazonaws.com/dist/dev/libosmium-deps-win-14.0-x64.7z -FileName lodeps.7z + - 7z x cm.7z > null + - 7z x lodeps.7z > nul + - echo %LODEPSDIR% + - dir %LODEPSDIR% + - ECHO our own cmake + - cmake -version - cd c:\projects - - nuget install boost - - nuget install bzip2 - - nuget install zlib - - nuget install GDAL - - nuget install expat - - nuget install protobuf - - dir /S c:\projects - - git clone https://github.com/scrosby/OSM-binary - - cd OSM-binary - - mkdir build - - cd build - - call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 - - cmake .. -G "Visual Studio 12 Win64" -DSEARCH_PREFIX=c:\projects -T CTP_Nov2013 - - msbuild /clp:Verbosity=minimal /nologo OSM-binary.sln + - git clone https://github.com/osmcode/osm-testdata.git build_script: - cd c:\projects\libosmium - mkdir build - cd build - - call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 - - SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% - - SET P=c:/projects/libosmium - - cmake .. -G "Visual Studio 12 Win64" -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_PREFIX_PATH=c:\projects -DBoost_USE_STATIC_LIBS=ON -T CTP_Nov2013 - - msbuild /clp:Verbosity=minimal /nologo libosmium.sln - - msbuild /clp:Verbosity=minimal /nologo tests.vcxproj + - echo %config% + - cmake .. -LA -G "Visual Studio 14 Win64" -DOsmium_DEBUG=TRUE -DCMAKE_BUILD_TYPE=%config% -DBOOST_ROOT=%LODEPSDIR%\boost -DBoost_PROGRAM_OPTIONS_LIBRARY=%LODEPSDIR%\boost\lib\libboost_program_options-vc140-mt-1_57.lib -DOSMPBF_LIBRARY=%LODEPSDIR%\osmpbf\lib\osmpbf.lib -DOSMPBF_INCLUDE_DIR=%LODEPSDIR%\osmpbf\include -DPROTOBUF_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf.lib -DPROTOBUF_LITE_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf-lite.lib -DPROTOBUF_INCLUDE_DIR=%LODEPSDIR%\protobuf\include -DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib -DZLIB_INCLUDE_DIR=%LODEPSDIR%\zlib\include -DEXPAT_LIBRARY=%LODEPSDIR%\expat\lib\libexpat.lib -DEXPAT_INCLUDE_DIR=%LODEPSDIR%\expat\include -DBZIP2_LIBRARIES=%LIBBZIP2% -DBZIP2_INCLUDE_DIR=%LODEPSDIR%\bzip2\include -DGDAL_LIBRARY=%LODEPSDIR%\gdal\lib\gdal_i.lib -DGDAL_INCLUDE_DIR=%LODEPSDIR%\gdal\include -DGEOS_LIBRARY=%LODEPSDIR%\geos\lib\geos.lib -DGEOS_INCLUDE_DIR=%LODEPSDIR%\geos\include -DPROJ_LIBRARY=%LODEPSDIR%\proj\lib\proj.lib -DPROJ_INCLUDE_DIR=%LODEPSDIR%\proj\include -DSPARSEHASH_INCLUDE_DIR=%LODEPSDIR%\sparsehash\include -DGETOPT_LIBRARY=%LODEPSDIR%\wingetopt\lib\wingetopt.lib -DGETOPT_INCLUDE_DIR=%LODEPSDIR%\wingetopt\include + - msbuild libosmium.sln /p:Configuration=Release /toolsversion:14.0 /p:Platform=x64 /p:PlatformToolset=v140 + #- cmake .. -LA -G "NMake Makefiles" -DOsmium_DEBUG=TRUE -DCMAKE_BUILD_TYPE=%config% -DBOOST_ROOT=%LODEPSDIR%\boost -DBoost_PROGRAM_OPTIONS_LIBRARY=%LODEPSDIR%\boost\lib\libboost_program_options-vc140-mt-1_57.lib -DOSMPBF_LIBRARY=%LODEPSDIR%\osmpbf\lib\osmpbf.lib -DOSMPBF_INCLUDE_DIR=%LODEPSDIR%\osmpbf\include -DPROTOBUF_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf.lib -DPROTOBUF_LITE_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf-lite.lib -DPROTOBUF_INCLUDE_DIR=%LODEPSDIR%\protobuf\include -DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib -DZLIB_INCLUDE_DIR=%LODEPSDIR%\zlib\include -DEXPAT_LIBRARY=%LODEPSDIR%\expat\lib\libexpat.lib -DEXPAT_INCLUDE_DIR=%LODEPSDIR%\expat\include -DBZIP2_LIBRARIES=%LIBBZIP2% -DBZIP2_INCLUDE_DIR=%LODEPSDIR%\bzip2\include -DGDAL_LIBRARY=%LODEPSDIR%\gdal\lib\gdal_i.lib -DGDAL_INCLUDE_DIR=%LODEPSDIR%\gdal\include -DGEOS_LIBRARY=%LODEPSDIR%\geos\lib\geos.lib -DGEOS_INCLUDE_DIR=%LODEPSDIR%\geos\include -DPROJ_LIBRARY=%LODEPSDIR%\proj\lib\proj.lib -DPROJ_INCLUDE_DIR=%LODEPSDIR%\proj\include -DSPARSEHASH_INCLUDE_DIR=%LODEPSDIR%\sparsehash\include -DGETOPT_LIBRARY=%LODEPSDIR%\wingetopt\lib\wingetopt.lib -DGETOPT_INCLUDE_DIR=%LODEPSDIR%\wingetopt\include + #- nmake + +test_script: + # Disable multipolygon test because it needs ruby and the 'json' gem + - ctest -V -C %config% -E testdata-multipolygon diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt new file mode 100644 index 000000000..6a4ca162d --- /dev/null +++ b/benchmarks/CMakeLists.txt @@ -0,0 +1,48 @@ +#----------------------------------------------------------------------------- +# +# CMake Config +# +# Libosmium benchmarks +# +#----------------------------------------------------------------------------- + +message(STATUS "Configuring benchmarks") + +set(BENCHMARKS + count + count_tag + index_map + static_vs_dynamic_index + CACHE STRING "Benchmark programs" +) + + +#----------------------------------------------------------------------------- +# +# Configure benchmarks +# +#----------------------------------------------------------------------------- + +message(STATUS "Configuring benchmarks - Building these benchmarks:") +foreach(benchmark ${BENCHMARKS}) + message(STATUS " - osmium_benchmark_${benchmark}") + add_executable(osmium_benchmark_${benchmark} + "osmium_benchmark_${benchmark}.cpp") + target_link_libraries(osmium_benchmark_${benchmark} + ${OSMIUM_IO_LIBRARIES} + ${BENCHMARK_LIBS_${benchmark}}) + configure_file(run_benchmark_${benchmark}.sh + ${CMAKE_CURRENT_BINARY_DIR}/run_benchmark_${benchmark}.sh + @ONLY) +endforeach() + +foreach(file setup run_benchmarks) + configure_file(${file}.sh ${CMAKE_CURRENT_BINARY_DIR}/${file}.sh @ONLY) +endforeach() + + +#----------------------------------------------------------------------------- +message(STATUS "Configuring benchmarks - done") + + +#----------------------------------------------------------------------------- diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 000000000..f10045ca0 --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,41 @@ + +# Benchmarks + +Benchmarks check the performance of different parts of Libosmium. + +## Preparations + +To run the benchmarks first make a directory for the data files somewhere +(outside the repository) and set the `DATA_DIR` environment variable: + + export DATA_DIR=benchmark_data + mkdir $DATA_DIR + +Then copy the OSM files you want to do the benchmarks with into this directory. +You can use the `download_data.sh` script to download a selection of OSM files +in different sizes, but you can use a different selection, too. The benchmarks +will use whatever files you have in the `DATA_DIR` directory. + +The download script will start the data files names with a number in order of +the size of the file from smallest to largest. You can use the same convention +or use a different one. Benchmarks will be run on the files in alphabetical +order. + +The files don't have to be in that directory, you can add soft links from that +directory to the real file locations if that suits you. + +## Compiling the benchmarks + +To build the benchmarks set the `BUILD_BENCHMARKS` option when configuring with +CMake and run the compilation by calling `make` (or whatever build tool you +are using). + +## Running the benchmarks + +Go to the build directory and run `benchmarks/run_benchmarks.sh`. You can also +run each benchmark on its own by calling the respective script in the +`benchmarks` directory. + +Results of the benchmarks will be printed to stdout, you might want to redirect +them into a file. + diff --git a/benchmarks/download_data.sh b/benchmarks/download_data.sh new file mode 100755 index 000000000..8a6a8ff50 --- /dev/null +++ b/benchmarks/download_data.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# download_data.sh +# + +cd $DATA_DIR +curl --location --output 1_liechtenstein.osm.pbf http://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf # about 1 MB +curl --location --output 2_bremen.osm.pbf http://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf # about 13 MB +curl --location --output 3_sachsen.osm.pbf http://download.geofabrik.de/europe/germany/sachsen-latest.osm.pbf # about 120 MB +curl --location --output 4_germany.osm.pbf http://download.geofabrik.de/europe/germany-latest.osm.pbf # about 2 GB +curl --location --output 5_planet.osm.pbf http://planet.osm.org/pbf/planet-latest.osm.pbf # about 26 GB + diff --git a/benchmarks/osmium_benchmark_count.cpp b/benchmarks/osmium_benchmark_count.cpp new file mode 100644 index 000000000..701d6faec --- /dev/null +++ b/benchmarks/osmium_benchmark_count.cpp @@ -0,0 +1,54 @@ +/* + + The code in this file is released into the Public Domain. + +*/ + +#include + +#include +#include +#include + +struct CountHandler : public osmium::handler::Handler { + + int nodes = 0; + int ways = 0; + int relations = 0; + + void node(osmium::Node&) { + ++nodes; + } + + void way(osmium::Way&) { + ++ways; + } + + void relation(osmium::Relation&) { + ++relations; + } + +}; + + +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; + exit(1); + } + + std::string input_filename = argv[1]; + + osmium::io::Reader reader(input_filename); + + CountHandler handler; + osmium::apply(reader, handler); + reader.close(); + + std::cout << "Nodes: " << handler.nodes << "\n"; + std::cout << "Ways: " << handler.ways << "\n"; + std::cout << "Relations: " << handler.relations << "\n"; + + google::protobuf::ShutdownProtobufLibrary(); +} + diff --git a/benchmarks/osmium_benchmark_count_tag.cpp b/benchmarks/osmium_benchmark_count_tag.cpp new file mode 100644 index 000000000..4a77c3452 --- /dev/null +++ b/benchmarks/osmium_benchmark_count_tag.cpp @@ -0,0 +1,55 @@ +/* + + The code in this file is released into the Public Domain. + +*/ + +#include + +#include +#include +#include + +struct CountHandler : public osmium::handler::Handler { + + int counter = 0; + int all = 0; + + void node(osmium::Node& node) { + ++all; + const char* amenity = node.tags().get_value_by_key("amenity"); + if (amenity && !strcmp(amenity, "post_box")) { + ++counter; + } + } + + void way(osmium::Way&) { + ++all; + } + + void relation(osmium::Relation&) { + ++all; + } + +}; + + +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; + exit(1); + } + + std::string input_filename = argv[1]; + + osmium::io::Reader reader(input_filename); + + CountHandler handler; + osmium::apply(reader, handler); + reader.close(); + + std::cout << "r_all=" << handler.all << " r_counter=" << handler.counter << "\n"; + + google::protobuf::ShutdownProtobufLibrary(); +} + diff --git a/benchmarks/osmium_benchmark_index_map.cpp b/benchmarks/osmium_benchmark_index_map.cpp new file mode 100644 index 000000000..fa75fb2b8 --- /dev/null +++ b/benchmarks/osmium_benchmark_index_map.cpp @@ -0,0 +1,41 @@ +/* + + The code in this file is released into the Public Domain. + +*/ + +#include + +#include +#include +#include + +#include +#include + +typedef osmium::index::map::Map index_type; + +typedef osmium::handler::NodeLocationsForWays location_handler_type; + +int main(int argc, char* argv[]) { + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << " OSMFILE FORMAT\n"; + exit(1); + } + + std::string input_filename = argv[1]; + std::string location_store = argv[2]; + + osmium::io::Reader reader(input_filename); + + const auto& map_factory = osmium::index::MapFactory::instance(); + std::unique_ptr index = map_factory.create_map(location_store); + location_handler_type location_handler(*index); + location_handler.ignore_errors(); + + osmium::apply(reader, location_handler); + reader.close(); + + google::protobuf::ShutdownProtobufLibrary(); +} + diff --git a/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp b/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp new file mode 100644 index 000000000..9c47c8449 --- /dev/null +++ b/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp @@ -0,0 +1,136 @@ +/* + + This benchmarks compares the run time for statically vs. dynamically + configured index maps. You can configure index maps at compile-time using + typedefs or at run-time using polymorphism. + + This will read the input file into a buffer and then run the + NodeLocationForWays handler multiple times over the complete data. The + number of runs depends on the size of the input, but is never smaller + than 10. + + Do not run this with very large input files! It will need about 10 times + as much RAM as the file size of the input file. + + The code in this file is released into the Public Domain. + +*/ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +typedef osmium::index::map::SparseMemArray static_index_type; +const std::string location_store="sparse_mem_array"; + +typedef osmium::index::map::Map dynamic_index_type; + +typedef osmium::handler::NodeLocationsForWays static_location_handler_type; +typedef osmium::handler::NodeLocationsForWays dynamic_location_handler_type; + +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; + exit(1); + } + + std::string input_filename = argv[1]; + + osmium::memory::Buffer buffer = osmium::io::read_file(input_filename); + google::protobuf::ShutdownProtobufLibrary(); + + const auto& map_factory = osmium::index::MapFactory::instance(); + + const auto buffer_size = buffer.committed() / (1024*1024); // buffer size in MBytes + const int runs = std::max(10, static_cast(5000ull / buffer_size)); + + std::cout << "input: filename=" << input_filename << " buffer_size=" << buffer_size << "MBytes\n"; + std::cout << "runs: " << runs << "\n"; + + double static_min = std::numeric_limits::max(); + double static_sum = 0; + double static_max = 0; + + double dynamic_min = std::numeric_limits::max(); + double dynamic_sum = 0; + double dynamic_max = 0; + + for (int i = 0; i < runs; ++i) { + + { + // static index + osmium::memory::Buffer tmp_buffer(buffer.committed()); + for (const auto& item : buffer) { + tmp_buffer.add_item(item); + tmp_buffer.commit(); + } + + static_index_type static_index; + static_location_handler_type static_location_handler(static_index); + + auto start = std::chrono::steady_clock::now(); + osmium::apply(tmp_buffer, static_location_handler); + auto end = std::chrono::steady_clock::now(); + + double duration = std::chrono::duration(end-start).count(); + + if (duration < static_min) static_min = duration; + if (duration > static_max) static_max = duration; + static_sum += duration; + } + + { + // dynamic index + osmium::memory::Buffer tmp_buffer(buffer.committed()); + for (const auto& item : buffer) { + tmp_buffer.add_item(item); + tmp_buffer.commit(); + } + + std::unique_ptr index = map_factory.create_map(location_store); + dynamic_location_handler_type dynamic_location_handler(*index); + dynamic_location_handler.ignore_errors(); + + auto start = std::chrono::steady_clock::now(); + osmium::apply(tmp_buffer, dynamic_location_handler); + auto end = std::chrono::steady_clock::now(); + + double duration = std::chrono::duration(end-start).count(); + + if (duration < dynamic_min) dynamic_min = duration; + if (duration > dynamic_max) dynamic_max = duration; + dynamic_sum += duration; + } + } + + double static_avg = static_sum/runs; + double dynamic_avg = dynamic_sum/runs; + + std::cout << "static min=" << static_min << "ms avg=" << static_avg << "ms max=" << static_max << "ms\n"; + std::cout << "dynamic min=" << dynamic_min << "ms avg=" << dynamic_avg << "ms max=" << dynamic_max << "ms\n"; + + double rfactor = 100.0; + double diff_min = std::round((dynamic_min - static_min) * rfactor) / rfactor; + double diff_avg = std::round((dynamic_avg - static_avg) * rfactor) / rfactor; + double diff_max = std::round((dynamic_max - static_max) * rfactor) / rfactor; + + double prfactor = 10.0; + double percent_min = std::round((100.0 * diff_min / static_min) * prfactor) / prfactor; + double percent_avg = std::round((100.0 * diff_avg / static_avg) * prfactor) / prfactor; + double percent_max = std::round((100.0 * diff_max / static_max) * prfactor) / prfactor; + + std::cout << "difference:"; + std::cout << " min=" << diff_min << "ms (" << percent_min << "%)"; + std::cout << " avg=" << diff_avg << "ms (" << percent_avg << "%)"; + std::cout << " max=" << diff_max << "ms (" << percent_max << "%)\n"; +} + diff --git a/benchmarks/run_benchmark_count.sh b/benchmarks/run_benchmark_count.sh new file mode 100755 index 000000000..d71508f76 --- /dev/null +++ b/benchmarks/run_benchmark_count.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# run_benchmark_count.sh +# + +set -e + +BENCHMARK_NAME=count + +. @CMAKE_BINARY_DIR@/benchmarks/setup.sh + +CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME + +echo "# file size num mem time cpu_kernel cpu_user cpu_percent cmd options" +for data in $OB_DATA_FILES; do + filename=`basename $data` + filesize=`stat --format="%s" --dereference $data` + for n in $OB_SEQ; do + $OB_TIME_CMD -f "$filename $filesize $n $OB_TIME_FORMAT" $CMD $data 2>&1 >/dev/null | sed -e "s%$DATA_DIR/%%" | sed -e "s%$OB_DIR/%%" + done +done + diff --git a/benchmarks/run_benchmark_count_tag.sh b/benchmarks/run_benchmark_count_tag.sh new file mode 100755 index 000000000..4fa6a1068 --- /dev/null +++ b/benchmarks/run_benchmark_count_tag.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# run_benchmark_count_tag.sh +# + +set -e + +BENCHMARK_NAME=count_tag + +. @CMAKE_BINARY_DIR@/benchmarks/setup.sh + +CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME + +echo "# file size num mem time cpu_kernel cpu_user cpu_percent cmd options" +for data in $OB_DATA_FILES; do + filename=`basename $data` + filesize=`stat --format="%s" --dereference $data` + for n in $OB_SEQ; do + $OB_TIME_CMD -f "$filename $filesize $n $OB_TIME_FORMAT" $CMD $data 2>&1 >/dev/null | sed -e "s%$DATA_DIR/%%" | sed -e "s%$OB_DIR/%%" + done +done + diff --git a/benchmarks/run_benchmark_index_map.sh b/benchmarks/run_benchmark_index_map.sh new file mode 100755 index 000000000..30984d460 --- /dev/null +++ b/benchmarks/run_benchmark_index_map.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# run_benchmark_index_map.sh +# + +set -e + +BENCHMARK_NAME=index_map + +. @CMAKE_BINARY_DIR@/benchmarks/setup.sh + +CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME + +#MAPS="sparse_mem_map sparse_mem_table sparse_mem_array sparse_mmap_array sparse_file_array dense_mem_array dense_mmap_array dense_file_array" +MAPS="sparse_mem_map sparse_mem_table sparse_mem_array sparse_mmap_array sparse_file_array" + +echo "# file size num mem time cpu_kernel cpu_user cpu_percent cmd options" +for data in $OB_DATA_FILES; do + filename=`basename $data` + filesize=`stat --format="%s" --dereference $data` + for map in $MAPS; do + for n in $OB_SEQ; do + $OB_TIME_CMD -f "$filename $filesize $n $OB_TIME_FORMAT" $CMD $data $map 2>&1 >/dev/null | sed -e "s%$DATA_DIR/%%" | sed -e "s%$OB_DIR/%%" + done + done +done + diff --git a/benchmarks/run_benchmark_static_vs_dynamic_index.sh b/benchmarks/run_benchmark_static_vs_dynamic_index.sh new file mode 100755 index 000000000..05e32f126 --- /dev/null +++ b/benchmarks/run_benchmark_static_vs_dynamic_index.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# run_benchmark_static_vs_dynamic_index.sh +# + +set -e + +BENCHMARK_NAME=static_vs_dynamic_index + +. @CMAKE_BINARY_DIR@/benchmarks/setup.sh + +CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME + +for data in $OB_DATA_FILES; do + filesize=`stat --format="%s" --dereference $data` + if [ $filesize -lt 500000000 ]; then + echo "========================" + $CMD $data + fi +done + diff --git a/benchmarks/run_benchmarks.sh b/benchmarks/run_benchmarks.sh new file mode 100755 index 000000000..6a20c0214 --- /dev/null +++ b/benchmarks/run_benchmarks.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# run_benchmarks.sh +# +# Run all benchmarks. +# + +set -e + +for benchmark in @CMAKE_BINARY_DIR@/benchmarks/run_benchmark_*.sh; do + name=`basename $benchmark` + echo "Running $name..." + $benchmark +done + diff --git a/benchmarks/setup.sh b/benchmarks/setup.sh new file mode 100755 index 000000000..9733bfe1b --- /dev/null +++ b/benchmarks/setup.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# setup.sh +# + +if [ -z $DATA_DIR ]; then + echo "Please set DATA_DIR environment variable before running benchmark" + exit 1 +fi + +OB_DIR=@CMAKE_BINARY_DIR@/benchmarks + +OB_RUNS=3 +OB_SEQ=`seq -s' ' 1 $OB_RUNS` + +OB_TIME_CMD=/usr/bin/time +OB_TIME_FORMAT="%M %e %S %U %P %C" + +OB_DATA_FILES=`find -L $DATA_DIR -mindepth 1 -maxdepth 1 -type f | sort` + +echo "BENCHMARK: $BENCHMARK_NAME" +echo "---------------------" +echo "CPU:" +grep '^model name' /proc/cpuinfo | tail -1 +grep '^cpu MHz' /proc/cpuinfo | tail -1 +grep '^cpu cores' /proc/cpuinfo | tail -1 +grep '^siblings' /proc/cpuinfo | tail -1 + +echo "---------------------" +echo "MEMORY:" +free +echo "---------------------" +echo "RESULTS:" + diff --git a/cmake/FindOsmium.cmake b/cmake/FindOsmium.cmake index 085983149..15b1e013f 100644 --- a/cmake/FindOsmium.cmake +++ b/cmake/FindOsmium.cmake @@ -9,16 +9,15 @@ # # Usage: # -# Copy this file (and OsmiumOptions.cmake) somewhere into your project -# directory, where cmake can find it. Usually this will be a directory -# called "cmake" which you can add to your module search path with the -# following line in your CMakeLists.txt: +# Copy this file somewhere into your project directory, where cmake can +# find it. Usually this will be a directory called "cmake" which you can +# add to the CMake module search path with the following line in your +# CMakeLists.txt: # # list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") # # Then add the following in your CMakeLists.txt: # -# include(OsmiumOptions) # find_package(Osmium REQUIRED COMPONENTS ) # include_directories(${OSMIUM_INCLUDE_DIRS}) # @@ -75,6 +74,8 @@ find_package_handle_standard_args(OSMIUM REQUIRED_VARS OSMIUM_INCLUDE_DIR) # Copy the results to the output variables. if(OSMIUM_FOUND) set(OSMIUM_INCLUDE_DIRS ${OSMIUM_INCLUDE_DIR}) +else() + set(OSMIUM_INCLUDE_DIRS "") endif() if(Osmium_FIND_REQUIRED AND NOT OSMIUM_FOUND) @@ -234,10 +235,22 @@ endif() #---------------------------------------------------------------------- list(REMOVE_DUPLICATES OSMIUM_INCLUDE_DIRS) -list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES) -list(REMOVE_DUPLICATES OSMIUM_PBF_LIBRARIES) -list(REMOVE_DUPLICATES OSMIUM_IO_LIBRARIES) -list(REMOVE_DUPLICATES OSMIUM_LIBRARIES) + +if(OSMIUM_XML_LIBRARIES) + list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES) +endif() + +if(OSMIUM_PBF_LIBRARIES) + list(REMOVE_DUPLICATES OSMIUM_PBF_LIBRARIES) +endif() + +if(OSMIUM_IO_LIBRARIES) + list(REMOVE_DUPLICATES OSMIUM_IO_LIBRARIES) +endif() + +if(OSMIUM_LIBRARIES) + list(REMOVE_DUPLICATES OSMIUM_LIBRARIES) +endif() #---------------------------------------------------------------------- # @@ -256,7 +269,14 @@ endif() add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64) if(MSVC) - add_definitions(-wd4996 -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS) + add_definitions(-wd4996) + add_definitions(-wd4068) + + # Disable warning C4715: "not all control paths return a value" because + # it generates too many false positives. + add_definitions(-wd4715) + + add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS) endif() if(APPLE) @@ -271,7 +291,11 @@ endif() # This is a set of recommended warning options that can be added when compiling # libosmium code. -set(OSMIUM_WARNING_OPTIONS "-Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast -Wno-return-type" CACHE STRING "Recommended warning options for libosmium") +if(MSVC) + set(OSMIUM_WARNING_OPTIONS "/W3 /wd4514" CACHE STRING "Recommended warning options for libosmium") +else() + set(OSMIUM_WARNING_OPTIONS "-Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast -Wno-return-type" CACHE STRING "Recommended warning options for libosmium") +endif() set(OSMIUM_DRACONIC_CLANG_OPTIONS "-Wdocumentation -Wunused-exception-parameter -Wmissing-declarations -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-exit-time-destructors -Wno-global-constructors -Wno-padded -Wno-switch-enum -Wno-missing-prototypes -Wno-weak-vtables -Wno-cast-align -Wno-float-equal") diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 000000000..903aad12e --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,34 @@ +#----------------------------------------------------------------------------- +# +# CMake Config +# +# Libosmium documentation +# +#----------------------------------------------------------------------------- + +message(STATUS "Configuring documentation") + +message(STATUS "Looking for doxygen") +find_package(Doxygen) + +if(DOXYGEN_FOUND) + message(STATUS "Looking for doxygen - found") + configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) + add_custom_target(doc + ${DOXYGEN_EXECUTABLE} + ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" VERBATIM + ) +# install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html" +# DESTINATION "share/doc/libosmium-dev") +else() + message(STATUS "Looking for doxygen - not found") + message(STATUS " Disabled making of documentation.") +endif() + +#----------------------------------------------------------------------------- +message(STATUS "Configuring documentation - done") + + +#----------------------------------------------------------------------------- diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index e48d2da7e..5ce78ab59 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "Osmium" +PROJECT_NAME = "Libosmium" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1f8a10573..c9f59603d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,64 +1,115 @@ -message(STATUS "Configuring examples...") +#----------------------------------------------------------------------------- +# +# CMake Config +# +# Libosmium examples +# +#----------------------------------------------------------------------------- -if(GETOPT_MISSING) - message(FATAL_ERROR "On Visual Studio the wingetopt library is needed to compile examples") -endif() +message(STATUS "Configuring examples") -set(SIMPLE_EXAMPLES - osmium_convert - osmium_count - osmium_create_node_cache - osmium_debug - osmium_read - osmium_serdump - osmium_use_node_cache +set(EXAMPLES + area_test + convert + count + create_node_cache + debug + index + read + serdump + toogr + toogr2 + toogr2_exp + use_node_cache + CACHE STRING "Example programs" ) -if(SPARSEHASH_FOUND) - list(APPEND SIMPLE_EXAMPLES osmium_area_test) + +#----------------------------------------------------------------------------- +# +# Examples depending on wingetopt +# +#----------------------------------------------------------------------------- +set(GETOPT_EXAMPLES area_test convert serdump toogr toogr2 toogr2_exp) +if(NOT GETOPT_MISSING) + foreach(example ${GETOPT_EXAMPLES}) + list(APPEND EXAMPLE_LIBS_${example} ${GETOPT_LIBRARY}) + endforeach() else() - message("Skipped osmium_area_test example - needed Google SparseHash") + message(STATUS "Configuring examples - Skipping examples because on Visual Studio the wingetopt library is needed and was not found:") + foreach(example ${GETOPT_EXAMPLES}) + message(STATUS " - osmium_${example}") + list(REMOVE_ITEM EXAMPLES ${example}) + endforeach() endif() -# In 'Dev' mode: compile with very strict warnings and turn them into errors. -if(CMAKE_BUILD_TYPE STREQUAL "Dev") - add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS}) + +#----------------------------------------------------------------------------- +# +# Examples depending on SparseHash +# +#----------------------------------------------------------------------------- +if(NOT SPARSEHASH_FOUND) + list(REMOVE_ITEM EXAMPLES area_test) + message(STATUS "Configuring examples - Skipping examples because Google SparseHash not found:") + message(STATUS " - osmium_area_test") endif() -foreach(example ${SIMPLE_EXAMPLES}) - message(STATUS "Configuring example ${example}...") - add_executable(${example} "${example}.cpp") - target_link_libraries(${example} ${OSMIUM_LIBRARIES}) -endforeach(example) +#----------------------------------------------------------------------------- +# +# Examples depending on Boost Program Options +# +#----------------------------------------------------------------------------- unset(Boost_LIBRARIES) unset(Boost_FOUND) find_package(Boost 1.38 COMPONENTS program_options) if(Boost_PROGRAM_OPTIONS_FOUND) - set(example - osmium_index - ) - message(STATUS "Configuring example ${example}...") - add_executable(${example} "${example}.cpp") - target_link_libraries(${example} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OSMIUM_LIBRARIES}) + list(APPEND EXAMPLE_LIBS_index ${Boost_PROGRAM_OPTIONS_LIBRARY}) else() - message("Can not build osmium_index example without Boost program_options") + list(REMOVE_ITEM EXAMPLES index) + message(STATUS "Configuring examples - Skipping examples because Boost program_options not found:") + message(STATUS " - osmium_index") endif() -set(OGR_EXAMPLES - osmium_toogr - osmium_toogr2 - osmium_toogr2_exp -) -if(GDAL_FOUND AND GEOS_FOUND AND SPARSEHASH_FOUND) +#----------------------------------------------------------------------------- +# +# Examples depending on GDAL/PROJ.4/SparseHash +# +#----------------------------------------------------------------------------- +set(OGR_EXAMPLES toogr toogr2 toogr2_exp) + +if(GDAL_FOUND AND PROJ_FOUND AND SPARSEHASH_FOUND) foreach(example ${OGR_EXAMPLES}) - message(STATUS "Configuring example ${example}...") - add_executable(${example} "${example}.cpp") - target_link_libraries(${example} ${OSMIUM_LIBRARIES}) - endforeach(example) + list(APPEND EXAMPLE_LIBS_${example} ${GDAL_LIBRARIES}) + list(APPEND EXAMPLE_LIBS_${example} ${PROJ_LIBRARIES}) + endforeach() else() - message("GDAL+GEOS+SparseHash not found, skipping OGR examples") + message(STATUS "Configuring examples - Skipping examples because GDAL and/or Proj.4 and/or SparseHash not found:") + foreach(example ${OGR_EXAMPLES}) + message(STATUS " - osmium_${example}") + list(REMOVE_ITEM EXAMPLES ${example}) + endforeach() endif() + +#----------------------------------------------------------------------------- +# +# Configure examples +# +#----------------------------------------------------------------------------- +message(STATUS "Configuring examples - Building these examples:") +foreach(example ${EXAMPLES}) + message(STATUS " - osmium_${example}") + add_executable(osmium_${example} "osmium_${example}.cpp") + target_link_libraries(osmium_${example} ${OSMIUM_IO_LIBRARIES} ${EXAMPLE_LIBS_${example}}) +endforeach() + + +#----------------------------------------------------------------------------- +message(STATUS "Configuring examples - done") + + +#----------------------------------------------------------------------------- diff --git a/examples/osmium_area_test.cpp b/examples/osmium_area_test.cpp index 92d4933f7..b3030a354 100644 --- a/examples/osmium_area_test.cpp +++ b/examples/osmium_area_test.cpp @@ -18,12 +18,12 @@ #include #include #include -#include +#include #include #include typedef osmium::index::map::Dummy index_neg_type; -typedef osmium::index::map::SparseTable index_pos_type; +typedef osmium::index::map::SparseMemTable index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; class WKTDump : public osmium::handler::Handler { diff --git a/examples/osmium_create_node_cache.cpp b/examples/osmium_create_node_cache.cpp index 948d23021..74f7596fe 100644 --- a/examples/osmium_create_node_cache.cpp +++ b/examples/osmium_create_node_cache.cpp @@ -16,15 +16,15 @@ #include #include -#include -#include +#include +#include #include #include typedef osmium::index::map::Dummy index_neg_type; -//typedef osmium::index::map::DenseMapMmap index_pos_type; -typedef osmium::index::map::DenseMapFile index_pos_type; +//typedef osmium::index::map::DenseMmapArray index_pos_type; +typedef osmium::index::map::DenseFileArray index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; diff --git a/examples/osmium_index.cpp b/examples/osmium_index.cpp index 2f7e512a5..b61214097 100644 --- a/examples/osmium_index.cpp +++ b/examples/osmium_index.cpp @@ -14,15 +14,16 @@ #include -#include +#include +#include #include #include template class IndexSearch { - typedef typename osmium::index::map::DenseMapFile dense_index_type; - typedef typename osmium::index::map::SparseMapFile sparse_index_type; + typedef typename osmium::index::map::DenseFileArray dense_index_type; + typedef typename osmium::index::map::SparseFileArray sparse_index_type; int m_fd; bool m_dense_format; @@ -186,11 +187,11 @@ public: } bool dense_format() const { - return vm.count("array"); + return vm.count("array") != 0; } bool do_dump() const { - return vm.count("dump"); + return vm.count("dump") != 0; } std::vector search_keys() const { diff --git a/examples/osmium_serdump.cpp b/examples/osmium_serdump.cpp index 0ce8c3894..a774a8dbd 100644 --- a/examples/osmium_serdump.cpp +++ b/examples/osmium_serdump.cpp @@ -24,27 +24,26 @@ #include #include -#include -#include -#include +#include +#include +#include #include // ============================================================================== // Choose the following depending on the size of the input OSM files: // ============================================================================== // for smaller OSM files (extracts) -typedef osmium::index::map::SparseMapMem offset_index_type; +typedef osmium::index::map::SparseMemArray offset_index_type; //typedef osmium::index::map::SparseMapMmap offset_index_type; //typedef osmium::index::map::SparseMapFile offset_index_type; -typedef osmium::index::multimap::SparseMultimapMem map_type; -//typedef osmium::index::multimap::StlMultimap map_type; +typedef osmium::index::multimap::SparseMemArray map_type; +//typedef osmium::index::multimap::SparseMemMultimap map_type; //typedef osmium::index::multimap::Hybrid map_type; // ============================================================================== // for very large OSM files (planet) -//typedef osmium::index::map::DenseMapMmap offset_index_type; -//typedef osmium::index::map::DenseMapMem map_type; +//typedef osmium::index::map::DenseMmapArray offset_index_type; // ============================================================================== void print_help() { diff --git a/examples/osmium_toogr.cpp b/examples/osmium_toogr.cpp index 3230eb956..6d8ab8d94 100644 --- a/examples/osmium_toogr.cpp +++ b/examples/osmium_toogr.cpp @@ -10,25 +10,7 @@ #include #include -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" -#endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#pragma GCC diagnostic ignored "-Wpadded" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -# include -# include -#pragma GCC diagnostic pop - -// usually you only need one or two of these -#include -#include -#include -#include - +#include #include #include @@ -37,10 +19,7 @@ #include typedef osmium::index::map::Dummy index_neg_type; - -//typedef osmium::index::map::StlMap index_pos_type; -//typedef osmium::index::map::SparseMapMmap index_pos_type; -typedef osmium::index::map::SparseTable index_pos_type; +typedef osmium::index::map::Map index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; @@ -181,21 +160,28 @@ void print_help() { << "If INFILE is not given stdin is assumed.\n" \ << "If OUTFILE is not given 'ogr_out' is used.\n" \ << "\nOptions:\n" \ - << " -h, --help This help message\n" \ - << " -f, --format=FORMAT Output OGR format (Default: 'SQLite')\n"; + << " -h, --help This help message\n" \ + << " -l, --location_store=TYPE Set location store\n" \ + << " -f, --format=FORMAT Output OGR format (Default: 'SQLite')\n" \ + << " -L See available location stores\n"; } int main(int argc, char* argv[]) { + const auto& map_factory = osmium::index::MapFactory::instance(); + static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"format", required_argument, 0, 'f'}, + {"help", no_argument, 0, 'h'}, + {"format", required_argument, 0, 'f'}, + {"location_store", required_argument, 0, 'l'}, + {"list_location_stores", no_argument, 0, 'L'}, {0, 0, 0, 0} }; - std::string output_format("SQLite"); + std::string output_format { "SQLite" }; + std::string location_store { "sparse_mem_array" }; while (true) { - int c = getopt_long(argc, argv, "hf:", long_options, 0); + int c = getopt_long(argc, argv, "hf:l:L", long_options, 0); if (c == -1) { break; } @@ -207,6 +193,15 @@ int main(int argc, char* argv[]) { case 'f': output_format = optarg; break; + case 'l': + location_store = optarg; + break; + case 'L': + std::cout << "Available map types:\n"; + for (const auto& map_type : map_factory.map_types()) { + std::cout << " " << map_type << "\n"; + } + exit(0); default: exit(1); } @@ -229,9 +224,9 @@ int main(int argc, char* argv[]) { osmium::io::Reader reader(input_filename); - index_pos_type index_pos; + std::unique_ptr index_pos = map_factory.create_map(location_store); index_neg_type index_neg; - location_handler_type location_handler(index_pos, index_neg); + location_handler_type location_handler(*index_pos, index_neg); location_handler.ignore_errors(); MyOGRHandler ogr_handler(output_format, output_filename); @@ -245,7 +240,7 @@ int main(int argc, char* argv[]) { if (locations_fd < 0) { throw std::system_error(errno, std::system_category(), "Open failed"); } - index_pos.dump_as_list(locations_fd); + index_pos->dump_as_list(locations_fd); close(locations_fd); } diff --git a/examples/osmium_toogr2.cpp b/examples/osmium_toogr2.cpp index d2f46eb91..dc5c77325 100644 --- a/examples/osmium_toogr2.cpp +++ b/examples/osmium_toogr2.cpp @@ -13,24 +13,11 @@ #include #include -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" -#endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#pragma GCC diagnostic ignored "-Wpadded" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -# include -# include -#pragma GCC diagnostic pop - // usually you only need one or two of these #include -#include -#include -#include +#include +#include +#include #include #include @@ -45,9 +32,9 @@ typedef osmium::index::map::Dummy index_neg_type; -//typedef osmium::index::map::StlMap index_pos_type; -//typedef osmium::index::map::SparseMapMmap index_pos_type; -typedef osmium::index::map::SparseTable index_pos_type; +//typedef osmium::index::map::SparseMemArray index_pos_type; +//typedef osmium::index::map::SparseMmapArray index_pos_type; +typedef osmium::index::map::SparseMemTable index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; diff --git a/examples/osmium_toogr2_exp.cpp b/examples/osmium_toogr2_exp.cpp index 424fe05d2..474da96d0 100644 --- a/examples/osmium_toogr2_exp.cpp +++ b/examples/osmium_toogr2_exp.cpp @@ -15,24 +15,7 @@ #include #include -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" -#endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#pragma GCC diagnostic ignored "-Wpadded" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -# include -# include -#pragma GCC diagnostic pop - -// usually you only need one or two of these -#include -#include -#include -#include +#include #include @@ -43,13 +26,8 @@ #include #include -typedef osmium::index::map::Dummy index_neg_type; - -//typedef osmium::index::map::StlMap index_pos_type; -//typedef osmium::index::map::SparseMapMmap index_pos_type; -typedef osmium::index::map::SparseTable index_pos_type; - -typedef osmium::handler::NodeLocationsForWays location_handler_type; +typedef osmium::index::map::SparseMemArray index_type; +typedef osmium::handler::NodeLocationsForWays location_handler_type; class MyOGRHandler : public osmium::handler::Handler { @@ -303,10 +281,9 @@ int main(int argc, char* argv[]) { input_filename = "-"; } - index_pos_type index_pos; - index_neg_type index_neg; - location_handler_type location_handler(index_pos, index_neg); - osmium::experimental::FlexReader exr(input_filename, osmium::osm_entity_bits::object); + index_type index_pos; + location_handler_type location_handler(index_pos); + osmium::experimental::FlexReader exr(input_filename, location_handler, osmium::osm_entity_bits::object); MyOGRHandler ogr_handler(output_format, output_filename); diff --git a/examples/osmium_use_node_cache.cpp b/examples/osmium_use_node_cache.cpp index b7ac80770..6b8f964ab 100644 --- a/examples/osmium_use_node_cache.cpp +++ b/examples/osmium_use_node_cache.cpp @@ -16,15 +16,15 @@ #include #include -#include -#include +#include +#include #include #include typedef osmium::index::map::Dummy index_neg_type; -//typedef osmium::index::map::DenseMapMmap index_pos_type; -typedef osmium::index::map::DenseMapFile index_pos_type; +//typedef osmium::index::map::DenseMmapArray index_pos_type; +typedef osmium::index::map::DenseFileArray index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; diff --git a/include/mmap_for_windows.hpp b/include/mmap_for_windows.hpp index ed568a1b2..d14c81148 100644 --- a/include/mmap_for_windows.hpp +++ b/include/mmap_for_windows.hpp @@ -44,60 +44,60 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { - if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) - return MAP_FAILED; - if (fd == -1) { - if (!(flags & MAP_ANON) || offset) - return MAP_FAILED; - } else if (flags & MAP_ANON) - return MAP_FAILED; + if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) + return MAP_FAILED; + if (fd == -1) { + if (!(flags & MAP_ANON) || offset) + return MAP_FAILED; + } else if (flags & MAP_ANON) + return MAP_FAILED; - DWORD flProtect; - if (prot & PROT_WRITE) { - if (prot & PROT_EXEC) - flProtect = PAGE_EXECUTE_READWRITE; - else - flProtect = PAGE_READWRITE; - } else if (prot & PROT_EXEC) { - if (prot & PROT_READ) - flProtect = PAGE_EXECUTE_READ; - else if (prot & PROT_EXEC) - flProtect = PAGE_EXECUTE; - } else - flProtect = PAGE_READONLY; + DWORD flProtect; + if (prot & PROT_WRITE) { + if (prot & PROT_EXEC) + flProtect = PAGE_EXECUTE_READWRITE; + else + flProtect = PAGE_READWRITE; + } else if (prot & PROT_EXEC) { + if (prot & PROT_READ) + flProtect = PAGE_EXECUTE_READ; + else if (prot & PROT_EXEC) + flProtect = PAGE_EXECUTE; + } else + flProtect = PAGE_READONLY; - off_t end = length + offset; - HANDLE mmap_fd, h; - if (fd == -1) - mmap_fd = INVALID_HANDLE_VALUE; - else - mmap_fd = (HANDLE)_get_osfhandle(fd); - h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL); - if (h == NULL) - return MAP_FAILED; + off_t end = length + offset; + HANDLE mmap_fd, h; + if (fd == -1) + mmap_fd = INVALID_HANDLE_VALUE; + else + mmap_fd = (HANDLE)_get_osfhandle(fd); + h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL); + if (h == NULL) + return MAP_FAILED; - DWORD dwDesiredAccess; - if (prot & PROT_WRITE) - dwDesiredAccess = FILE_MAP_WRITE; - else - dwDesiredAccess = FILE_MAP_READ; - if (prot & PROT_EXEC) - dwDesiredAccess |= FILE_MAP_EXECUTE; - if (flags & MAP_PRIVATE) - dwDesiredAccess |= FILE_MAP_COPY; - void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); - if (ret == NULL) { - CloseHandle(h); - ret = MAP_FAILED; - } - return ret; + DWORD dwDesiredAccess; + if (prot & PROT_WRITE) + dwDesiredAccess = FILE_MAP_WRITE; + else + dwDesiredAccess = FILE_MAP_READ; + if (prot & PROT_EXEC) + dwDesiredAccess |= FILE_MAP_EXECUTE; + if (flags & MAP_PRIVATE) + dwDesiredAccess |= FILE_MAP_COPY; + void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); + if (ret == NULL) { + CloseHandle(h); + ret = MAP_FAILED; + } + return ret; } static int munmap(void *addr, size_t length) { - UnmapViewOfFile(addr); - return 0; - /* ruh-ro, we leaked handle from CreateFileMapping() ... */ + UnmapViewOfFile(addr); + return 0; + /* ruh-ro, we leaked handle from CreateFileMapping() ... */ } #undef DWORD_HI diff --git a/include/osmium/area/assembler.hpp b/include/osmium/area/assembler.hpp index 155fa24c2..db769ddf8 100644 --- a/include/osmium/area/assembler.hpp +++ b/include/osmium/area/assembler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/detail/node_ref_segment.hpp b/include/osmium/area/detail/node_ref_segment.hpp index 5b251bb5b..43569a865 100644 --- a/include/osmium/area/detail/node_ref_segment.hpp +++ b/include/osmium/area/detail/node_ref_segment.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/detail/proto_ring.hpp b/include/osmium/area/detail/proto_ring.hpp index 759b2dc05..c0f545c98 100644 --- a/include/osmium/area/detail/proto_ring.hpp +++ b/include/osmium/area/detail/proto_ring.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/detail/segment_list.hpp b/include/osmium/area/detail/segment_list.hpp index a14f792e4..12ec97fa9 100644 --- a/include/osmium/area/detail/segment_list.hpp +++ b/include/osmium/area/detail/segment_list.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/multipolygon_collector.hpp b/include/osmium/area/multipolygon_collector.hpp index af48176d4..0bd10f78b 100644 --- a/include/osmium/area/multipolygon_collector.hpp +++ b/include/osmium/area/multipolygon_collector.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/problem_reporter.hpp b/include/osmium/area/problem_reporter.hpp index 5e255db50..4ae4bb23d 100644 --- a/include/osmium/area/problem_reporter.hpp +++ b/include/osmium/area/problem_reporter.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/problem_reporter_exception.hpp b/include/osmium/area/problem_reporter_exception.hpp index 29c7ad429..5e743c6d8 100644 --- a/include/osmium/area/problem_reporter_exception.hpp +++ b/include/osmium/area/problem_reporter_exception.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/area/problem_reporter_ogr.hpp b/include/osmium/area/problem_reporter_ogr.hpp index a567057ce..c437a3f57 100644 --- a/include/osmium/area/problem_reporter_ogr.hpp +++ b/include/osmium/area/problem_reporter_ogr.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,18 +33,38 @@ DEALINGS IN THE SOFTWARE. */ -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" +/** + * @file + * + * This file contains code for reporting problems through OGR when + * assembling multipolygons. + * + * @attention If you include this file, you'll need to link with `libgdal`. + */ + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4458) +#else +# pragma GCC diagnostic push +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" +# endif +# pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wold-style-cast" +# pragma GCC diagnostic ignored "-Wpadded" +# pragma GCC diagnostic ignored "-Wredundant-decls" +# pragma GCC diagnostic ignored "-Wshadow" +#endif + +#include +#include + +#ifdef _MSC_VER +# pragma warning(pop) +#else +# pragma GCC diagnostic pop #endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#pragma GCC diagnostic ignored "-Wpadded" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -# include -# include -#pragma GCC diagnostic pop #include #include diff --git a/include/osmium/area/problem_reporter_stream.hpp b/include/osmium/area/problem_reporter_stream.hpp index 6bee56816..ddcb343e8 100644 --- a/include/osmium/area/problem_reporter_stream.hpp +++ b/include/osmium/area/problem_reporter_stream.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/builder/builder.hpp b/include/osmium/builder/builder.hpp index 30c180c0d..bf9cdccfc 100644 --- a/include/osmium/builder/builder.hpp +++ b/include/osmium/builder/builder.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -37,7 +37,9 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include #include +#include #include #include diff --git a/include/osmium/builder/builder_helper.hpp b/include/osmium/builder/builder_helper.hpp index 3e00f81c4..eebdf338c 100644 --- a/include/osmium/builder/builder_helper.hpp +++ b/include/osmium/builder/builder_helper.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/builder/osm_object_builder.hpp b/include/osmium/builder/osm_object_builder.hpp index 851eb85f8..b88765e2a 100644 --- a/include/osmium/builder/osm_object_builder.hpp +++ b/include/osmium/builder/osm_object_builder.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -36,6 +36,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include diff --git a/include/osmium/diff_handler.hpp b/include/osmium/diff_handler.hpp index 9864df5a1..4f9b3a1a0 100644 --- a/include/osmium/diff_handler.hpp +++ b/include/osmium/diff_handler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/diff_iterator.hpp b/include/osmium/diff_iterator.hpp index 576834c4d..0ddf7ff7a 100644 --- a/include/osmium/diff_iterator.hpp +++ b/include/osmium/diff_iterator.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/diff_visitor.hpp b/include/osmium/diff_visitor.hpp index b8db6970b..5e72a7bb7 100644 --- a/include/osmium/diff_visitor.hpp +++ b/include/osmium/diff_visitor.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/dynamic_handler.hpp b/include/osmium/dynamic_handler.hpp index bc593131c..9d0bd66f5 100644 --- a/include/osmium/dynamic_handler.hpp +++ b/include/osmium/dynamic_handler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/experimental/flex_reader.hpp b/include/osmium/experimental/flex_reader.hpp index 1ce4312fc..f00a5ecaf 100644 --- a/include/osmium/experimental/flex_reader.hpp +++ b/include/osmium/experimental/flex_reader.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -41,7 +41,7 @@ DEALINGS IN THE SOFTWARE. namespace osmium { /** - * @short Experimental code that is not "officially" supported. + * @brief Experimental code that is not "officially" supported. */ namespace experimental { @@ -51,9 +51,7 @@ namespace osmium { bool m_with_areas; osmium::osm_entity_bits::type m_entities; - typename TLocationHandler::index_pos_type m_index_pos; - typename TLocationHandler::index_neg_type m_index_neg; - TLocationHandler m_location_handler; + TLocationHandler& m_location_handler; osmium::io::Reader m_reader; osmium::area::Assembler::config_type m_assembler_config; @@ -61,12 +59,10 @@ namespace osmium { public: - explicit FlexReader(const osmium::io::File& file, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : - m_with_areas(entities & osmium::osm_entity_bits::area), + explicit FlexReader(const osmium::io::File& file, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : + m_with_areas((entities & osmium::osm_entity_bits::area) != 0), m_entities((entities & ~osmium::osm_entity_bits::area) | (m_with_areas ? osmium::osm_entity_bits::node | osmium::osm_entity_bits::way : osmium::osm_entity_bits::nothing)), - m_index_pos(), - m_index_neg(), - m_location_handler(m_index_pos, m_index_neg), + m_location_handler(location_handler), m_reader(file, m_entities), m_assembler_config(), m_collector(m_assembler_config) @@ -79,21 +75,20 @@ namespace osmium { } } - explicit FlexReader(const std::string& filename, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : - FlexReader(osmium::io::File(filename), entities) { + explicit FlexReader(const std::string& filename, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : + FlexReader(osmium::io::File(filename), location_handler, entities) { } - explicit FlexReader(const char* filename, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : - FlexReader(osmium::io::File(filename), entities) { + explicit FlexReader(const char* filename, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : + FlexReader(osmium::io::File(filename), location_handler, entities) { } osmium::memory::Buffer read() { - std::vector area_buffers; - osmium::memory::Buffer buffer = m_reader.read(); if (buffer) { if (m_with_areas) { + std::vector area_buffers; osmium::apply(buffer, m_location_handler, m_collector.handler([&area_buffers](osmium::memory::Buffer&& area_buffer) { area_buffers.push_back(std::move(area_buffer)); })); diff --git a/include/osmium/geom/coordinates.hpp b/include/osmium/geom/coordinates.hpp index 1ff27fea4..2bad57e0d 100644 --- a/include/osmium/geom/coordinates.hpp +++ b/include/osmium/geom/coordinates.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/factory.hpp b/include/osmium/geom/factory.hpp index 4097b5dac..a0a208075 100644 --- a/include/osmium/geom/factory.hpp +++ b/include/osmium/geom/factory.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/geojson.hpp b/include/osmium/geom/geojson.hpp index b8bc5fde0..7d5953535 100644 --- a/include/osmium/geom/geojson.hpp +++ b/include/osmium/geom/geojson.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/geos.hpp b/include/osmium/geom/geos.hpp index fffe20d3a..3c73637be 100644 --- a/include/osmium/geom/geos.hpp +++ b/include/osmium/geom/geos.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * This file contains code for conversion of OSM geometries into GDAL + * geometries. + * + * @attention If you include this file, you'll need to link with `libgeos`. + */ + #include #include diff --git a/include/osmium/geom/haversine.hpp b/include/osmium/geom/haversine.hpp index b8d013492..14e18c59a 100644 --- a/include/osmium/geom/haversine.hpp +++ b/include/osmium/geom/haversine.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/mercator_projection.hpp b/include/osmium/geom/mercator_projection.hpp index d17001717..a6d1d5742 100644 --- a/include/osmium/geom/mercator_projection.hpp +++ b/include/osmium/geom/mercator_projection.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/ogr.hpp b/include/osmium/geom/ogr.hpp index 3770c503a..f33971c7d 100644 --- a/include/osmium/geom/ogr.hpp +++ b/include/osmium/geom/ogr.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,19 +33,49 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * This file contains code for conversion of OSM geometries into OGR + * geometries. + * + * @attention If you include this file, you'll need to link with `libgdal`. + */ + #include #include #include #include -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4458) +# pragma warning(disable : 4251) +#else +# pragma GCC diagnostic push +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" +# endif +# pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wold-style-cast" +# pragma GCC diagnostic ignored "-Wpadded" +# pragma GCC diagnostic ignored "-Wredundant-decls" +# pragma GCC diagnostic ignored "-Wshadow" +#endif + +/* Strictly speaking the following include would be enough here, + but everybody using this file will very likely need the other includes, + so we are adding them here, so that not everybody will need all those + pragmas to disable warnings. */ +//#include +#include +#include + +#ifdef _MSC_VER +# pragma warning(pop) +#else +# pragma GCC diagnostic pop #endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wpadded" -# include -#pragma GCC diagnostic pop #include #include diff --git a/include/osmium/geom/projection.hpp b/include/osmium/geom/projection.hpp index 55f4eebf7..6419101f8 100644 --- a/include/osmium/geom/projection.hpp +++ b/include/osmium/geom/projection.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * This file contains code for projecting OSM locations to arbitrary + * coordinate reference systems. It is based on the Proj.4 library. + * + * @attention If you include this file, you'll need to link with `libproj`. + */ + #include #include @@ -77,11 +86,11 @@ namespace osmium { } bool is_latlong() const { - return pj_is_latlong(m_crs.get()); + return pj_is_latlong(m_crs.get()) != 0; } bool is_geocent() const { - return pj_is_geocent(m_crs.get()); + return pj_is_geocent(m_crs.get()) != 0; } /** diff --git a/include/osmium/geom/relations.hpp b/include/osmium/geom/relations.hpp index e57e2f4c9..e9e2aa420 100644 --- a/include/osmium/geom/relations.hpp +++ b/include/osmium/geom/relations.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/util.hpp b/include/osmium/geom/util.hpp index 1f1a50dc8..5e9f8228c 100644 --- a/include/osmium/geom/util.hpp +++ b/include/osmium/geom/util.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/wkb.hpp b/include/osmium/geom/wkb.hpp index df4e25549..31fce71f9 100644 --- a/include/osmium/geom/wkb.hpp +++ b/include/osmium/geom/wkb.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/geom/wkt.hpp b/include/osmium/geom/wkt.hpp index 86ea7c039..4fea96baa 100644 --- a/include/osmium/geom/wkt.hpp +++ b/include/osmium/geom/wkt.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/handler.hpp b/include/osmium/handler.hpp index 62e59f80a..34d878511 100644 --- a/include/osmium/handler.hpp +++ b/include/osmium/handler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/handler/chain.hpp b/include/osmium/handler/chain.hpp index 868632d7e..1af3962fd 100644 --- a/include/osmium/handler/chain.hpp +++ b/include/osmium/handler/chain.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/handler/disk_store.hpp b/include/osmium/handler/disk_store.hpp index 2b7ffcff6..ccae5962a 100644 --- a/include/osmium/handler/disk_store.hpp +++ b/include/osmium/handler/disk_store.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/handler/dump.hpp b/include/osmium/handler/dump.hpp index e62c4b071..564035c56 100644 --- a/include/osmium/handler/dump.hpp +++ b/include/osmium/handler/dump.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/handler/node_locations_for_ways.hpp b/include/osmium/handler/node_locations_for_ways.hpp index a273082b0..d1224a0d5 100644 --- a/include/osmium/handler/node_locations_for_ways.hpp +++ b/include/osmium/handler/node_locations_for_ways.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -44,6 +44,8 @@ DEALINGS IN THE SOFTWARE. #include #include +#include + namespace osmium { namespace handler { @@ -102,6 +104,9 @@ namespace osmium { NodeLocationsForWays(const NodeLocationsForWays&) = delete; NodeLocationsForWays& operator=(const NodeLocationsForWays&) = delete; + NodeLocationsForWays(NodeLocationsForWays&&) = default; + NodeLocationsForWays& operator=(NodeLocationsForWays&&) = default; + ~NodeLocationsForWays() noexcept = default; void ignore_errors() { diff --git a/include/osmium/handler/object_relations.hpp b/include/osmium/handler/object_relations.hpp index e73ce87fc..dc4aa45d8 100644 --- a/include/osmium/handler/object_relations.hpp +++ b/include/osmium/handler/object_relations.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/index/detail/create_map_with_fd.hpp b/include/osmium/index/detail/create_map_with_fd.hpp new file mode 100644 index 000000000..29dc1dc67 --- /dev/null +++ b/include/osmium/index/detail/create_map_with_fd.hpp @@ -0,0 +1,73 @@ +#ifndef OSMIUM_INDEX_DETAIL_CREATE_MAP_WITH_FD_HPP +#define OSMIUM_INDEX_DETAIL_CREATE_MAP_WITH_FD_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace osmium { + + namespace index { + + namespace detail { + + template + inline T* create_map_with_fd(const std::vector& config) { + if (config.size() == 1) { + return new T(); + } else { + assert(config.size() > 1); + const std::string& filename = config[1]; + int fd = ::open(filename.c_str(), O_CREAT | O_RDWR, 0644); + if (fd == -1) { + throw std::runtime_error(std::string("can't open file '") + filename + "': " + strerror(errno)); + } + return new T(fd); + } + } + + } // namespace detail + + } // namespace index + +} // namespace osmium + +#endif // OSMIUM_INDEX_DETAIL_CREATE_MAP_WITH_FD_HPP diff --git a/include/osmium/index/detail/mmap_vector_anon.hpp b/include/osmium/index/detail/mmap_vector_anon.hpp index f06696150..0ea4f9db6 100644 --- a/include/osmium/index/detail/mmap_vector_anon.hpp +++ b/include/osmium/index/detail/mmap_vector_anon.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP -#define OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP +#ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP +#define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -45,8 +45,8 @@ namespace osmium { namespace detail { /** - * This class looks and behaves like STL vector, but uses mmap internally. - */ + * This class looks and behaves like STL vector, but uses mmap internally. + */ template class mmap_vector_anon : public mmap_vector_base { @@ -75,4 +75,4 @@ namespace osmium { #endif // __linux__ -#endif // OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP +#endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP diff --git a/include/osmium/index/detail/mmap_vector_base.hpp b/include/osmium/index/detail/mmap_vector_base.hpp index fc96b271a..3aff26d41 100644 --- a/include/osmium/index/detail/mmap_vector_base.hpp +++ b/include/osmium/index/detail/mmap_vector_base.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP -#define OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP +#ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP +#define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE. #include #include +#include namespace osmium { @@ -180,4 +181,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP +#endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP diff --git a/include/osmium/index/detail/mmap_vector_file.hpp b/include/osmium/index/detail/mmap_vector_file.hpp index 421b97769..55077d18d 100644 --- a/include/osmium/index/detail/mmap_vector_file.hpp +++ b/include/osmium/index/detail/mmap_vector_file.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP -#define OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP +#ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP +#define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -82,4 +82,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP +#endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP diff --git a/include/osmium/index/detail/tmpfile.hpp b/include/osmium/index/detail/tmpfile.hpp index 3d00c5017..06cab6544 100644 --- a/include/osmium/index/detail/tmpfile.hpp +++ b/include/osmium/index/detail/tmpfile.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_DETAIL_TMPFILE_HPP -#define OSMIUM_DETAIL_TMPFILE_HPP +#ifndef OSMIUM_INDEX_DETAIL_TMPFILE_HPP +#define OSMIUM_INDEX_DETAIL_TMPFILE_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -59,4 +59,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_DETAIL_TMPFILE +#endif // OSMIUM_INDEX_DETAIL_TMPFILE_HPP diff --git a/include/osmium/index/detail/typed_mmap.hpp b/include/osmium/index/detail/typed_mmap.hpp index 8a952a4e0..77b065e8e 100644 --- a/include/osmium/index/detail/typed_mmap.hpp +++ b/include/osmium/index/detail/typed_mmap.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_DETAIL_TYPED_MMAP_HPP -#define OSMIUM_DETAIL_TYPED_MMAP_HPP +#ifndef OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP +#define OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -226,4 +226,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_DETAIL_TYPED_MMAP_HPP +#endif // OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP diff --git a/include/osmium/index/map/vector.hpp b/include/osmium/index/detail/vector_map.hpp similarity index 96% rename from include/osmium/index/map/vector.hpp rename to include/osmium/index/detail/vector_map.hpp index 1ac16cab2..73c5a37a5 100644 --- a/include/osmium/index/map/vector.hpp +++ b/include/osmium/index/detail/vector_map.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MAP_VECTOR_HPP -#define OSMIUM_INDEX_MAP_VECTOR_HPP +#ifndef OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP +#define OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE. #include #include +#include #include #include @@ -198,7 +199,7 @@ namespace osmium { std::sort(m_vector.begin(), m_vector.end()); } - void dump_as_list(int fd) const override final { + void dump_as_list(const int fd) override final { osmium::io::detail::reliable_write(fd, reinterpret_cast(m_vector.data()), byte_size()); } @@ -234,4 +235,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MAP_VECTOR_HPP +#endif // OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP diff --git a/include/osmium/index/multimap/vector.hpp b/include/osmium/index/detail/vector_multimap.hpp similarity index 94% rename from include/osmium/index/multimap/vector.hpp rename to include/osmium/index/detail/vector_multimap.hpp index b9dae43e5..c2b2e1f29 100644 --- a/include/osmium/index/multimap/vector.hpp +++ b/include/osmium/index/detail/vector_multimap.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MULTIMAP_VECTOR_HPP -#define OSMIUM_INDEX_MULTIMAP_VECTOR_HPP +#ifndef OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP +#define OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -37,6 +37,7 @@ DEALINGS IN THE SOFTWARE. #include #include +#include #include #include @@ -136,7 +137,7 @@ namespace osmium { ); } - void dump_as_list(int fd) const override final { + void dump_as_list(const int fd) override final { osmium::io::detail::reliable_write(fd, reinterpret_cast(m_vector.data()), byte_size()); } @@ -148,4 +149,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MULTIMAP_VECTOR_HPP +#endif // OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP diff --git a/include/osmium/index/index.hpp b/include/osmium/index/index.hpp index ece8ec444..b73b319e8 100644 --- a/include/osmium/index/index.hpp +++ b/include/osmium/index/index.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/index/map.hpp b/include/osmium/index/map.hpp index 92b880f47..a9fe0c3bd 100644 --- a/include/osmium/index/map.hpp +++ b/include/osmium/index/map.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,10 +33,18 @@ DEALINGS IN THE SOFTWARE. */ +#include #include +#include +#include +#include +#include +#include #include +#include -#include // IWYU pragma: export +#include +#include namespace osmium { @@ -140,7 +148,7 @@ namespace osmium { // default implementation is empty } - virtual void dump_as_list(int /*fd*/) const { + virtual void dump_as_list(const int /*fd*/) { std::runtime_error("can't dump as list"); } @@ -148,6 +156,98 @@ namespace osmium { } // namespace map + template + class MapFactory { + + public: + + typedef TId id_type; + typedef TValue value_type; + typedef osmium::index::map::Map map_type; + typedef std::function&)> create_map_func; + + private: + + std::map m_callbacks; + + MapFactory() = default; + + MapFactory(const MapFactory&) = delete; + MapFactory& operator=(const MapFactory&) = delete; + + MapFactory(MapFactory&&) = delete; + MapFactory& operator=(MapFactory&&) = delete; + + OSMIUM_NORETURN static void error(const std::string& map_type_name) { + std::string error_message {"Support for map type '"}; + error_message += map_type_name; + error_message += "' not compiled into this binary."; + throw std::runtime_error(error_message); + } + + public: + + static MapFactory& instance() { + static MapFactory factory; + return factory; + } + + bool register_map(const std::string& map_type_name, create_map_func func) { + return m_callbacks.emplace(map_type_name, func).second; + } + + std::vector map_types() const { + std::vector result; + + for (const auto& cb : m_callbacks) { + result.push_back(cb.first); + } + + std::sort(result.begin(), result.end()); + + return result; + } + + std::unique_ptr create_map(const std::string& config_string) const { + std::vector config = osmium::split_string(config_string, ','); + + if (config.empty()) { + throw std::runtime_error("Need non-empty map type name."); + } + + auto it = m_callbacks.find(config[0]); + if (it != m_callbacks.end()) { + return std::unique_ptr((it->second)(config)); + } + + error(config[0]); + } + + }; // class MapFactory + + namespace map { + + template class TMap> + struct create_map { + TMap* operator()(const std::vector&) { + return new TMap(); + } + }; + + } // namespace map + + template class TMap> + inline bool register_map(const std::string& name) { + return osmium::index::MapFactory::instance().register_map(name, [](const std::vector& config) { + return map::create_map()(config); + }); + } + +#define REGISTER_MAP(id, value, klass, name) \ +namespace { \ + const bool registered_index_map_##name = osmium::index::register_map(#name); \ +} + } // namespace index } // namespace osmium diff --git a/include/osmium/index/map/all.hpp b/include/osmium/index/map/all.hpp new file mode 100644 index 000000000..9ffadc0de --- /dev/null +++ b/include/osmium/index/map/all.hpp @@ -0,0 +1,46 @@ +#ifndef OSMIUM_INDEX_MAP_ALL_HPP +#define OSMIUM_INDEX_MAP_ALL_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep + +#endif // OSMIUM_INDEX_MAP_ALL_HPP diff --git a/include/osmium/index/map/dense_file_array.hpp b/include/osmium/index/map/dense_file_array.hpp new file mode 100644 index 000000000..d209a875c --- /dev/null +++ b/include/osmium/index/map/dense_file_array.hpp @@ -0,0 +1,67 @@ +#ifndef OSMIUM_INDEX_MAP_DENSE_FILE_ARRAY_HPP +#define OSMIUM_INDEX_MAP_DENSE_FILE_ARRAY_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include + +#include +#include +#include + +#define OSMIUM_HAS_INDEX_MAP_DENSE_FILE_ARRAY + +namespace osmium { + + namespace index { + + namespace map { + + template + using DenseFileArray = VectorBasedDenseMap, TId, TValue>; + + template + struct create_map { + DenseFileArray* operator()(const std::vector& config) { + return osmium::index::detail::create_map_with_fd>(config); + } + }; + + } // namespace map + + } // namespace index + +} // namespace osmium + +#endif // OSMIUM_INDEX_MAP_DENSE_FILE_ARRAY_HPP diff --git a/include/osmium/index/map/dense_mem_array.hpp b/include/osmium/index/map/dense_mem_array.hpp new file mode 100644 index 000000000..b45eec458 --- /dev/null +++ b/include/osmium/index/map/dense_mem_array.hpp @@ -0,0 +1,57 @@ +#ifndef OSMIUM_INDEX_MAP_DENSE_MEM_ARRAY_HPP +#define OSMIUM_INDEX_MAP_DENSE_MEM_ARRAY_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include + +#include + +#define OSMIUM_HAS_INDEX_MAP_DENSE_MEM_ARRAY + +namespace osmium { + + namespace index { + + namespace map { + + template + using DenseMemArray = VectorBasedDenseMap, TId, TValue>; + + } // namespace map + + } // namespace index + +} // namespace osmium + +#endif // OSMIUM_INDEX_MAP_DENSE_MEM_ARRAY_HPP diff --git a/include/osmium/index/map/mmap_vector_anon.hpp b/include/osmium/index/map/dense_mmap_array.hpp similarity index 77% rename from include/osmium/index/map/mmap_vector_anon.hpp rename to include/osmium/index/map/dense_mmap_array.hpp index a62e99aa6..fc60a1ef2 100644 --- a/include/osmium/index/map/mmap_vector_anon.hpp +++ b/include/osmium/index/map/dense_mmap_array.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP -#define OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP +#ifndef OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP +#define OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -35,8 +35,10 @@ DEALINGS IN THE SOFTWARE. #ifdef __linux__ -#include #include +#include + +#define OSMIUM_HAS_INDEX_MAP_DENSE_MMAP_ARRAY namespace osmium { @@ -45,10 +47,7 @@ namespace osmium { namespace map { template - using DenseMapMmap = VectorBasedDenseMap, TId, TValue>; - - template - using SparseMapMmap = VectorBasedSparseMap; + using DenseMmapArray = VectorBasedDenseMap, TId, TValue>; } // namespace map @@ -58,4 +57,4 @@ namespace osmium { #endif // __linux__ -#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP +#endif // OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP diff --git a/include/osmium/index/map/dummy.hpp b/include/osmium/index/map/dummy.hpp index bafb81008..de05d1d69 100644 --- a/include/osmium/index/map/dummy.hpp +++ b/include/osmium/index/map/dummy.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -35,6 +35,7 @@ DEALINGS IN THE SOFTWARE. #include +#include #include namespace osmium { diff --git a/include/osmium/index/map/sparse_file_array.hpp b/include/osmium/index/map/sparse_file_array.hpp new file mode 100644 index 000000000..2ba9315dd --- /dev/null +++ b/include/osmium/index/map/sparse_file_array.hpp @@ -0,0 +1,67 @@ +#ifndef OSMIUM_INDEX_MAP_SPARSE_FILE_ARRAY_HPP +#define OSMIUM_INDEX_MAP_SPARSE_FILE_ARRAY_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include + +#include +#include +#include + +#define OSMIUM_HAS_INDEX_MAP_SPARSE_FILE_ARRAY + +namespace osmium { + + namespace index { + + namespace map { + + template + using SparseFileArray = VectorBasedSparseMap; + + template + struct create_map { + SparseFileArray* operator()(const std::vector& config) { + return osmium::index::detail::create_map_with_fd>(config); + } + }; + + } // namespace map + + } // namespace index + +} // namespace osmium + +#endif // OSMIUM_INDEX_MAP_SPARSE_FILE_ARRAY_HPP diff --git a/include/osmium/index/map/stl_vector.hpp b/include/osmium/index/map/sparse_mem_array.hpp similarity index 79% rename from include/osmium/index/map/stl_vector.hpp rename to include/osmium/index/map/sparse_mem_array.hpp index 238e9afa9..9adf41f0a 100644 --- a/include/osmium/index/map/stl_vector.hpp +++ b/include/osmium/index/map/sparse_mem_array.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MAP_STL_VECTOR_HPP -#define OSMIUM_INDEX_MAP_STL_VECTOR_HPP +#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP +#define OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -35,7 +35,9 @@ DEALINGS IN THE SOFTWARE. #include -#include +#include + +#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_ARRAY namespace osmium { @@ -43,14 +45,11 @@ namespace osmium { namespace map { - template - using DenseMapMem = VectorBasedDenseMap, TId, TValue>; - template using StdVectorWrap = std::vector; template - using SparseMapMem = VectorBasedSparseMap; + using SparseMemArray = VectorBasedSparseMap; } // namespace map @@ -58,4 +57,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MAP_STL_VECTOR_HPP +#endif // OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP diff --git a/include/osmium/index/map/stl_map.hpp b/include/osmium/index/map/sparse_mem_map.hpp similarity index 86% rename from include/osmium/index/map/stl_map.hpp rename to include/osmium/index/map/sparse_mem_map.hpp index d2781a7e1..d053155f0 100644 --- a/include/osmium/index/map/stl_map.hpp +++ b/include/osmium/index/map/sparse_mem_map.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MAP_STL_MAP_HPP -#define OSMIUM_INDEX_MAP_STL_MAP_HPP +#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP +#define OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -41,8 +41,11 @@ DEALINGS IN THE SOFTWARE. #include #include +#include #include +#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_MAP + namespace osmium { namespace index { @@ -54,7 +57,7 @@ namespace osmium { * lot of memory, but might make sense for small maps. */ template - class StlMap : public osmium::index::map::Map { + class SparseMemMap : public osmium::index::map::Map { // This is a rough estimate for the memory needed for each // element in the map (id + value + pointers to left, right, @@ -66,9 +69,9 @@ namespace osmium { public: - StlMap() = default; + SparseMemMap() = default; - ~StlMap() override final = default; + ~SparseMemMap() override final = default; void set(const TId id, const TValue value) override final { m_elements[id] = value; @@ -94,14 +97,14 @@ namespace osmium { m_elements.clear(); } - void dump_as_list(const int fd) const override final { + void dump_as_list(const int fd) override final { typedef typename std::map::value_type t; std::vector v; std::copy(m_elements.begin(), m_elements.end(), std::back_inserter(v)); osmium::io::detail::reliable_write(fd, reinterpret_cast(v.data()), sizeof(t) * v.size()); } - }; // class StlMap + }; // class SparseMemMap } // namespace map @@ -109,4 +112,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MAP_STL_MAP_HPP +#endif // OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP diff --git a/include/osmium/index/map/sparse_table.hpp b/include/osmium/index/map/sparse_mem_table.hpp similarity index 86% rename from include/osmium/index/map/sparse_table.hpp rename to include/osmium/index/map/sparse_mem_table.hpp index 704e33e21..27b8f3963 100644 --- a/include/osmium/index/map/sparse_table.hpp +++ b/include/osmium/index/map/sparse_mem_table.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP -#define OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP +#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP +#define OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -34,15 +34,17 @@ DEALINGS IN THE SOFTWARE. */ #include -#include #include #include #include +#include #include #include +#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE + namespace osmium { namespace index { @@ -50,9 +52,9 @@ namespace osmium { namespace map { /** - * The SparseTable index stores elements in a Google sparsetable, + * The SparseMemTable index stores elements in a Google sparsetable, * a data structure that can hold sparsly filled tables in a - * very space efficient way. It will resize automatically. + * space efficient way. It will resize automatically. * * Use this index if the ID space is only sparsly * populated, such as when working with smaller OSM files (like @@ -61,7 +63,7 @@ namespace osmium { * This will only work on 64 bit machines. */ template - class SparseTable : public osmium::index::map::Map { + class SparseMemTable : public osmium::index::map::Map { TId m_grow_size; @@ -79,12 +81,12 @@ namespace osmium { * The storage will grow by at least this size * every time it runs out of space. */ - explicit SparseTable(const TId grow_size=10000) : + explicit SparseMemTable(const TId grow_size=10000) : m_grow_size(grow_size), m_elements(grow_size) { } - ~SparseTable() override final = default; + ~SparseMemTable() override final = default; void set(const TId id, const TValue value) override final { if (id >= m_elements.size()) { @@ -117,7 +119,7 @@ namespace osmium { m_elements.clear(); } - void dump_as_list(const int fd) const override final { + void dump_as_list(const int fd) override final { std::vector> v; int n=0; for (const TValue value : m_elements) { @@ -129,7 +131,7 @@ namespace osmium { osmium::io::detail::reliable_write(fd, reinterpret_cast(v.data()), sizeof(std::pair) * v.size()); } - }; // class SparseTable + }; // class SparseMemTable } // namespace map @@ -137,4 +139,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_BYID_SPARSE_TABLE_HPP +#endif // OSMIUM_INDEX_BYID_SPARSE_MEM_TABLE_HPP diff --git a/include/osmium/index/map/mmap_vector_file.hpp b/include/osmium/index/map/sparse_mmap_array.hpp similarity index 74% rename from include/osmium/index/map/mmap_vector_file.hpp rename to include/osmium/index/map/sparse_mmap_array.hpp index 7ea76fa6b..c85e2c938 100644 --- a/include/osmium/index/map/mmap_vector_file.hpp +++ b/include/osmium/index/map/sparse_mmap_array.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP -#define OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP +#ifndef OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP +#define OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,8 +33,12 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include +#ifdef __linux__ + +#include +#include + +#define OSMIUM_HAS_INDEX_MAP_SPARSE_MMAP_ARRAY namespace osmium { @@ -43,10 +47,7 @@ namespace osmium { namespace map { template - using DenseMapFile = VectorBasedDenseMap, TId, TValue>; - - template - using SparseMapFile = VectorBasedSparseMap; + using SparseMmapArray = VectorBasedSparseMap; } // namespace map @@ -54,4 +55,6 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP +#endif // __linux__ + +#endif // OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP diff --git a/include/osmium/index/multimap.hpp b/include/osmium/index/multimap.hpp index f76c65ddb..e5c6b4f4e 100644 --- a/include/osmium/index/multimap.hpp +++ b/include/osmium/index/multimap.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -34,11 +34,10 @@ DEALINGS IN THE SOFTWARE. */ #include +#include #include #include -#include // IWYU pragma: export - namespace osmium { namespace index { @@ -114,7 +113,7 @@ namespace osmium { // default implementation is empty } - virtual void dump_as_list(int /*fd*/) const { + virtual void dump_as_list(const int /*fd*/) { std::runtime_error("can't dump as list"); } diff --git a/include/osmium/index/multimap/all.hpp b/include/osmium/index/multimap/all.hpp new file mode 100644 index 000000000..8b0ae99f9 --- /dev/null +++ b/include/osmium/index/multimap/all.hpp @@ -0,0 +1,41 @@ +#ifndef OSMIUM_INDEX_MULTIMAP_ALL_HPP +#define OSMIUM_INDEX_MULTIMAP_ALL_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep + +#endif // OSMIUM_INDEX_MULTIMAP_ALL_HPP diff --git a/include/osmium/index/multimap/hybrid.hpp b/include/osmium/index/multimap/hybrid.hpp index abaf31e95..ac2d96452 100644 --- a/include/osmium/index/multimap/hybrid.hpp +++ b/include/osmium/index/multimap/hybrid.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -36,9 +36,10 @@ DEALINGS IN THE SOFTWARE. #include #include +#include #include -#include -#include +#include +#include namespace osmium { @@ -49,8 +50,8 @@ namespace osmium { template class HybridIterator { - typedef SparseMultimapMem main_map_type; - typedef StlMultimap extra_map_type; + typedef SparseMemArray main_map_type; + typedef SparseMemMultimap extra_map_type; typedef typename std::pair element_type; @@ -117,8 +118,8 @@ namespace osmium { template class Hybrid : public Multimap { - typedef SparseMultimapMem main_map_type; - typedef StlMultimap extra_map_type; + typedef SparseMemArray main_map_type; + typedef SparseMemMultimap extra_map_type; main_map_type m_main; extra_map_type m_extra; @@ -174,7 +175,7 @@ namespace osmium { m_main.sort(); } - void dump_as_list(int fd) override final { + void dump_as_list(const int fd) override final { consolidate(); m_main.dump_as_list(fd); } diff --git a/include/osmium/index/multimap/mmap_vector_file.hpp b/include/osmium/index/multimap/sparse_file_array.hpp similarity index 81% rename from include/osmium/index/multimap/mmap_vector_file.hpp rename to include/osmium/index/multimap/sparse_file_array.hpp index 0a925b4ef..0b9ae92c5 100644 --- a/include/osmium/index/multimap/mmap_vector_file.hpp +++ b/include/osmium/index/multimap/sparse_file_array.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP -#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP +#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP +#define OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,8 +33,8 @@ DEALINGS IN THE SOFTWARE. */ -#include #include +#include namespace osmium { @@ -43,7 +43,7 @@ namespace osmium { namespace multimap { template - using SparseMultimapFile = VectorBasedSparseMultimap; + using SparseFileArray = VectorBasedSparseMultimap; } // namespace multimap @@ -51,4 +51,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP +#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP diff --git a/include/osmium/index/multimap/stl_vector.hpp b/include/osmium/index/multimap/sparse_mem_array.hpp similarity index 82% rename from include/osmium/index/multimap/stl_vector.hpp rename to include/osmium/index/multimap/sparse_mem_array.hpp index 2102824d5..c4140cba0 100644 --- a/include/osmium/index/multimap/stl_vector.hpp +++ b/include/osmium/index/multimap/sparse_mem_array.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP -#define OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP +#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP +#define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE. #include -#include +#include namespace osmium { @@ -47,7 +47,7 @@ namespace osmium { using StdVectorWrap = std::vector; template - using SparseMultimapMem = VectorBasedSparseMultimap; + using SparseMemArray = VectorBasedSparseMultimap; } // namespace multimap @@ -55,4 +55,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP +#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP diff --git a/include/osmium/index/multimap/stl_multimap.hpp b/include/osmium/index/multimap/sparse_mem_multimap.hpp similarity index 90% rename from include/osmium/index/multimap/stl_multimap.hpp rename to include/osmium/index/multimap/sparse_mem_multimap.hpp index 3df07abff..5b4715279 100644 --- a/include/osmium/index/multimap/stl_multimap.hpp +++ b/include/osmium/index/multimap/sparse_mem_multimap.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP -#define OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP +#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP +#define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -53,7 +53,7 @@ namespace osmium { * lot of memory, but might make sense for small maps. */ template - class StlMultimap : public osmium::index::multimap::Multimap { + class SparseMemMultimap : public osmium::index::multimap::Multimap { // This is a rough estimate for the memory needed for each // element in the map (id + value + pointers to left, right, @@ -76,9 +76,9 @@ namespace osmium { public: - StlMultimap() = default; + SparseMemMultimap() = default; - ~StlMultimap() noexcept override final = default; + ~SparseMemMultimap() noexcept override final = default; void unsorted_set(const TId id, const TValue value) { m_elements.emplace(id, value); @@ -130,7 +130,7 @@ namespace osmium { // intentionally left blank } - void dump_as_list(const int fd) const override final { + void dump_as_list(const int fd) override final { std::vector v; for (const auto& element : m_elements) { v.emplace_back(element.first, element.second); @@ -140,7 +140,7 @@ namespace osmium { osmium::io::detail::reliable_write(fd, reinterpret_cast(v.data()), sizeof(element_type) * v.size()); } - }; // class StlMultimap + }; // class SparseMemMultimap } // namespace multimap @@ -148,4 +148,4 @@ namespace osmium { } // namespace osmium -#endif // OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP +#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP diff --git a/include/osmium/index/multimap/mmap_vector_anon.hpp b/include/osmium/index/multimap/sparse_mmap_array.hpp similarity index 81% rename from include/osmium/index/multimap/mmap_vector_anon.hpp rename to include/osmium/index/multimap/sparse_mmap_array.hpp index b9de34a34..9f92555f6 100644 --- a/include/osmium/index/multimap/mmap_vector_anon.hpp +++ b/include/osmium/index/multimap/sparse_mmap_array.hpp @@ -1,11 +1,11 @@ -#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP -#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP +#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP +#define OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP /* This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE. #ifdef __linux__ -#include #include +#include namespace osmium { @@ -45,7 +45,7 @@ namespace osmium { namespace multimap { template - using SparseMultimapMmap = VectorBasedSparseMultimap; + using SparseMmapArray = VectorBasedSparseMultimap; } // namespace multimap @@ -55,4 +55,4 @@ namespace osmium { #endif // __linux__ -#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP +#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP diff --git a/include/osmium/index/node_locations_map.hpp b/include/osmium/index/node_locations_map.hpp new file mode 100644 index 000000000..ca4b1361e --- /dev/null +++ b/include/osmium/index/node_locations_map.hpp @@ -0,0 +1,70 @@ +#ifndef OSMIUM_INDEX_NODE_LOCATIONS_MAP_HPP +#define OSMIUM_INDEX_NODE_LOCATIONS_MAP_HPP + +/* + +This file is part of Osmium (http://osmcode.org/libosmium). + +Copyright 2013-2015 Jochen Topf and others (see README). + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include // IWYU pragma: keep + +#ifdef OSMIUM_HAS_INDEX_MAP_DENSE_FILE_ARRAY + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::DenseFileArray, dense_file_array) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_DENSE_MEM_ARRAY + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::DenseMemArray, dense_mem_array) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_DENSE_MMAP_ARRAY + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::DenseMmapArray, dense_mmap_array) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_FILE_ARRAY + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseFileArray, sparse_file_array) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_ARRAY + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemArray, sparse_mem_array) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_MAP + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemMap, sparse_mem_map) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemTable, sparse_mem_table) +#endif + +#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MMAP_ARRAY + REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMmapArray, sparse_mmap_array) +#endif + +#endif // OSMIUM_INDEX_NODE_LOCATIONS_MAP_HPP diff --git a/include/osmium/io/any_compression.hpp b/include/osmium/io/any_compression.hpp index 03ad5ce2b..00e8ee2be 100644 --- a/include/osmium/io/any_compression.hpp +++ b/include/osmium/io/any_compression.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to read or write compressed OSM XML files. + * + * @attention If you include this file, you'll need to link with `libz` + * and `libbz2`. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/io/any_input.hpp b/include/osmium/io/any_input.hpp index f60ff1455..633fab313 100644 --- a/include/osmium/io/any_input.hpp +++ b/include/osmium/io/any_input.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,16 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to read all kinds of OSM files. + * + * @attention If you include this file, you'll need to link with + * `libprotobuf-lite`, `libosmpbf`, `ws2_32` (Windows only), + * `libexpat`, `libz`, `libbz2`, and enable multithreading. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/io/any_output.hpp b/include/osmium/io/any_output.hpp index 9d97d7d93..63de3ff2e 100644 --- a/include/osmium/io/any_output.hpp +++ b/include/osmium/io/any_output.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,16 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to write all kinds of OSM files. + * + * @attention If you include this file, you'll need to link with + * `libprotobuf-lite`, `libosmpbf`, `ws2_32` (Windows only), + * `libz`, `libbz2`, and enable multithreading. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/io/bzip2_compression.hpp b/include/osmium/io/bzip2_compression.hpp index 90e5784c1..de1364c69 100644 --- a/include/osmium/io/bzip2_compression.hpp +++ b/include/osmium/io/bzip2_compression.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,17 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to read or write bzip2-compressed OSM XML + * files. + * + * @attention If you include this file, you'll need to link with `libbz2`. + */ + +#include +#include #include #include #include diff --git a/include/osmium/io/compression.hpp b/include/osmium/io/compression.hpp index e83e5ba77..f5308eacb 100644 --- a/include/osmium/io/compression.hpp +++ b/include/osmium/io/compression.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/input_format.hpp b/include/osmium/io/detail/input_format.hpp index 5a0e4e9ae..03e1190c3 100644 --- a/include/osmium/io/detail/input_format.hpp +++ b/include/osmium/io/detail/input_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/opl_output_format.hpp b/include/osmium/io/detail/opl_output_format.hpp index b4f069e0d..cf92e1382 100644 --- a/include/osmium/io/detail/opl_output_format.hpp +++ b/include/osmium/io/detail/opl_output_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -97,9 +97,9 @@ namespace osmium { static constexpr size_t tmp_buffer_size = 100; - osmium::memory::Buffer m_input_buffer; + std::shared_ptr m_input_buffer; - std::string m_out; + std::shared_ptr m_out; char m_tmp_buffer[tmp_buffer_size+1]; @@ -114,13 +114,13 @@ namespace osmium { _snprintf(m_tmp_buffer, tmp_buffer_size, format, std::forward(args)...); #endif assert(len > 0 && static_cast(len) < tmp_buffer_size); - m_out += m_tmp_buffer; + *m_out += m_tmp_buffer; } void append_encoded_string(const std::string& data) { boost::u8_to_u32_iterator it(data.cbegin(), data.cbegin(), data.cend()); boost::u8_to_u32_iterator end(data.cend(), data.cend(), data.cend()); - boost::utf8_output_iterator> oit(std::back_inserter(m_out)); + boost::utf8_output_iterator> oit(std::back_inserter(*m_out)); for (; it != end; ++it) { uint32_t c = *it; @@ -140,7 +140,7 @@ namespace osmium { (0x00ae <= c && c <= 0x05ff)) { *oit = c; } else { - m_out += '%'; + *m_out += '%'; output_formatted("%04x", c); } } @@ -148,21 +148,21 @@ namespace osmium { void write_meta(const osmium::OSMObject& object) { output_formatted("%" PRId64 " v%d d", object.id(), object.version()); - m_out += (object.visible() ? 'V' : 'D'); + *m_out += (object.visible() ? 'V' : 'D'); output_formatted(" c%d t", object.changeset()); - m_out += object.timestamp().to_iso(); + *m_out += object.timestamp().to_iso(); output_formatted(" i%d u", object.uid()); append_encoded_string(object.user()); - m_out += " T"; + *m_out += " T"; bool first = true; for (const auto& tag : object.tags()) { if (first) { first = false; } else { - m_out += ','; + *m_out += ','; } append_encoded_string(tag.key()); - m_out += '='; + *m_out += '='; append_encoded_string(tag.value()); } } @@ -171,109 +171,103 @@ namespace osmium { if (location) { output_formatted(" %c%.7f %c%.7f", x, location.lon_without_check(), y, location.lat_without_check()); } else { - m_out += ' '; - m_out += x; - m_out += ' '; - m_out += y; + *m_out += ' '; + *m_out += x; + *m_out += ' '; + *m_out += y; } } public: explicit OPLOutputBlock(osmium::memory::Buffer&& buffer) : - m_input_buffer(std::move(buffer)), - m_out(), + m_input_buffer(std::make_shared(std::move(buffer))), + m_out(std::make_shared()), m_tmp_buffer() { } - OPLOutputBlock(const OPLOutputBlock&) = delete; - OPLOutputBlock& operator=(const OPLOutputBlock&) = delete; + OPLOutputBlock(const OPLOutputBlock&) = default; + OPLOutputBlock& operator=(const OPLOutputBlock&) = default; - OPLOutputBlock(OPLOutputBlock&& other) : - m_input_buffer(std::move(other.m_input_buffer)), - m_out(), - m_tmp_buffer() { - } + OPLOutputBlock(OPLOutputBlock&&) = default; + OPLOutputBlock& operator=(OPLOutputBlock&&) = default; - OPLOutputBlock& operator=(OPLOutputBlock&& other) { - m_input_buffer = std::move(other.m_input_buffer); - return *this; - } + ~OPLOutputBlock() = default; std::string operator()() { - osmium::apply(m_input_buffer.cbegin(), m_input_buffer.cend(), *this); + osmium::apply(m_input_buffer->cbegin(), m_input_buffer->cend(), *this); std::string out; - std::swap(out, m_out); + std::swap(out, *m_out); return out; } void node(const osmium::Node& node) { - m_out += 'n'; + *m_out += 'n'; write_meta(node); write_location(node.location(), 'x', 'y'); - m_out += '\n'; + *m_out += '\n'; } void way(const osmium::Way& way) { - m_out += 'w'; + *m_out += 'w'; write_meta(way); - m_out += " N"; + *m_out += " N"; bool first = true; for (const auto& node_ref : way.nodes()) { if (first) { first = false; } else { - m_out += ','; + *m_out += ','; } output_formatted("n%" PRId64, node_ref.ref()); } - m_out += '\n'; + *m_out += '\n'; } void relation(const osmium::Relation& relation) { - m_out += 'r'; + *m_out += 'r'; write_meta(relation); - m_out += " M"; + *m_out += " M"; bool first = true; for (const auto& member : relation.members()) { if (first) { first = false; } else { - m_out += ','; + *m_out += ','; } - m_out += item_type_to_char(member.type()); + *m_out += item_type_to_char(member.type()); output_formatted("%" PRId64 "@", member.ref()); - m_out += member.role(); + *m_out += member.role(); } - m_out += '\n'; + *m_out += '\n'; } void changeset(const osmium::Changeset& changeset) { output_formatted("c%d k%d s", changeset.id(), changeset.num_changes()); - m_out += changeset.created_at().to_iso(); - m_out += " e"; - m_out += changeset.closed_at().to_iso(); + *m_out += changeset.created_at().to_iso(); + *m_out += " e"; + *m_out += changeset.closed_at().to_iso(); output_formatted(" i%d u", changeset.uid()); append_encoded_string(changeset.user()); write_location(changeset.bounds().bottom_left(), 'x', 'y'); write_location(changeset.bounds().top_right(), 'X', 'Y'); - m_out += " T"; + *m_out += " T"; bool first = true; for (const auto& tag : changeset.tags()) { if (first) { first = false; } else { - m_out += ','; + *m_out += ','; } append_encoded_string(tag.key()); - m_out += '='; + *m_out += '='; append_encoded_string(tag.value()); } - m_out += '\n'; + *m_out += '\n'; } }; // OPLOutputBlock diff --git a/include/osmium/io/detail/output_format.hpp b/include/osmium/io/detail/output_format.hpp index ad9e70204..529a1890f 100644 --- a/include/osmium/io/detail/output_format.hpp +++ b/include/osmium/io/detail/output_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/pbf.hpp b/include/osmium/io/detail/pbf.hpp index c1e59ee7f..e64e51a57 100644 --- a/include/osmium/io/detail/pbf.hpp +++ b/include/osmium/io/detail/pbf.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/pbf_input_format.hpp b/include/osmium/io/detail/pbf_input_format.hpp index 2d85d9ff0..dc161ebab 100644 --- a/include/osmium/io/detail/pbf_input_format.hpp +++ b/include/osmium/io/detail/pbf_input_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/pbf_output_format.hpp b/include/osmium/io/detail/pbf_output_format.hpp index 44f8ffb5e..73bc61673 100644 --- a/include/osmium/io/detail/pbf_output_format.hpp +++ b/include/osmium/io/detail/pbf_output_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/pbf_parser.hpp b/include/osmium/io/detail/pbf_parser.hpp index e89d0196c..d99819d3d 100644 --- a/include/osmium/io/detail/pbf_parser.hpp +++ b/include/osmium/io/detail/pbf_parser.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -412,28 +412,34 @@ namespace osmium { class DataBlobParser { - std::string m_input_buffer; + std::shared_ptr m_input_buffer; osmium::osm_entity_bits::type m_read_types; public: DataBlobParser(std::string&& input_buffer, osmium::osm_entity_bits::type read_types) : - m_input_buffer(std::move(input_buffer)), + m_input_buffer(std::make_shared(std::move(input_buffer))), m_read_types(read_types) { if (input_buffer.size() > OSMPBF::max_uncompressed_blob_size) { throw osmium::pbf_error(std::string("invalid blob size: " + std::to_string(input_buffer.size()))); } } - +/* DataBlobParser(const DataBlobParser& other) : m_input_buffer(std::move(other.m_input_buffer)), m_read_types(other.m_read_types) { - } + }*/ - DataBlobParser& operator=(const DataBlobParser&) = delete; + DataBlobParser(const DataBlobParser&) = default; + DataBlobParser& operator=(const DataBlobParser&) = default; + + DataBlobParser(DataBlobParser&&) = default; + DataBlobParser& operator=(DataBlobParser&&) = default; + + ~DataBlobParser() = default; osmium::memory::Buffer operator()() { - const std::unique_ptr data = unpack_blob(m_input_buffer); + const std::unique_ptr data = unpack_blob(*m_input_buffer); PBFPrimitiveBlockParser parser(*data, m_read_types); return parser(); } diff --git a/include/osmium/io/detail/pbf_stringtable.hpp b/include/osmium/io/detail/pbf_stringtable.hpp index 6f6c54c89..c56d549de 100644 --- a/include/osmium/io/detail/pbf_stringtable.hpp +++ b/include/osmium/io/detail/pbf_stringtable.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/read_thread.hpp b/include/osmium/io/detail/read_thread.hpp index 7c371396c..bce4f5507 100644 --- a/include/osmium/io/detail/read_thread.hpp +++ b/include/osmium/io/detail/read_thread.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/read_write.hpp b/include/osmium/io/detail/read_write.hpp index a949296f2..564d72147 100644 --- a/include/osmium/io/detail/read_write.hpp +++ b/include/osmium/io/detail/read_write.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/write_thread.hpp b/include/osmium/io/detail/write_thread.hpp index 49b7b5dda..fad22ed69 100644 --- a/include/osmium/io/detail/write_thread.hpp +++ b/include/osmium/io/detail/write_thread.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/detail/xml_input_format.hpp b/include/osmium/io/detail/xml_input_format.hpp index c42f61983..96003d874 100644 --- a/include/osmium/io/detail/xml_input_format.hpp +++ b/include/osmium/io/detail/xml_input_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -699,7 +699,7 @@ namespace osmium { return buffer; } - void close() { + void close() override { m_done = true; osmium::thread::wait_until_done(m_parser_future); } diff --git a/include/osmium/io/detail/xml_output_format.hpp b/include/osmium/io/detail/xml_output_format.hpp index c8c7a385e..73a7263ce 100644 --- a/include/osmium/io/detail/xml_output_format.hpp +++ b/include/osmium/io/detail/xml_output_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -120,9 +120,9 @@ namespace osmium { op_delete = 3 }; // enum class operation - osmium::memory::Buffer m_input_buffer; + std::shared_ptr m_input_buffer; - std::string m_out; + std::shared_ptr m_out; operation m_last_op {operation::op_none}; @@ -131,7 +131,7 @@ namespace osmium { void write_spaces(int num) { for (; num!=0; --num) { - m_out += ' '; + *m_out += ' '; } } @@ -144,33 +144,33 @@ namespace osmium { } void write_meta(const osmium::OSMObject& object) { - oprintf(m_out, " id=\"%" PRId64 "\"", object.id()); + oprintf(*m_out, " id=\"%" PRId64 "\"", object.id()); if (object.version()) { - oprintf(m_out, " version=\"%d\"", object.version()); + oprintf(*m_out, " version=\"%d\"", object.version()); } if (object.timestamp()) { - m_out += " timestamp=\""; - m_out += object.timestamp().to_iso(); - m_out += "\""; + *m_out += " timestamp=\""; + *m_out += object.timestamp().to_iso(); + *m_out += "\""; } if (!object.user_is_anonymous()) { - oprintf(m_out, " uid=\"%d\" user=\"", object.uid()); - xml_string(m_out, object.user()); - m_out += "\""; + oprintf(*m_out, " uid=\"%d\" user=\"", object.uid()); + xml_string(*m_out, object.user()); + *m_out += "\""; } if (object.changeset()) { - oprintf(m_out, " changeset=\"%d\"", object.changeset()); + oprintf(*m_out, " changeset=\"%d\"", object.changeset()); } if (m_write_visible_flag) { if (object.visible()) { - m_out += " visible=\"true\""; + *m_out += " visible=\"true\""; } else { - m_out += " visible=\"false\""; + *m_out += " visible=\"false\""; } } } @@ -178,11 +178,11 @@ namespace osmium { void write_tags(const osmium::TagList& tags) { for (const auto& tag : tags) { write_prefix(); - m_out += " \n"; + *m_out += " \n"; } } @@ -195,13 +195,13 @@ namespace osmium { case operation::op_none: break; case operation::op_create: - m_out += " \n"; + *m_out += " \n"; break; case operation::op_modify: - m_out += " \n"; + *m_out += " \n"; break; case operation::op_delete: - m_out += " \n"; + *m_out += " \n"; break; } @@ -209,13 +209,13 @@ namespace osmium { case operation::op_none: break; case operation::op_create: - m_out += " \n"; + *m_out += " \n"; break; case operation::op_modify: - m_out += " \n"; + *m_out += " \n"; break; case operation::op_delete: - m_out += " \n"; + *m_out += " \n"; break; } @@ -225,26 +225,29 @@ namespace osmium { public: explicit XMLOutputBlock(osmium::memory::Buffer&& buffer, bool write_visible_flag, bool write_change_ops) : - m_input_buffer(std::move(buffer)), + m_input_buffer(std::make_shared(std::move(buffer))), + m_out(std::make_shared()), m_write_visible_flag(write_visible_flag && !write_change_ops), m_write_change_ops(write_change_ops) { } - XMLOutputBlock(const XMLOutputBlock&) = delete; - XMLOutputBlock& operator=(const XMLOutputBlock&) = delete; + XMLOutputBlock(const XMLOutputBlock&) = default; + XMLOutputBlock& operator=(const XMLOutputBlock&) = default; XMLOutputBlock(XMLOutputBlock&&) = default; XMLOutputBlock& operator=(XMLOutputBlock&&) = default; + ~XMLOutputBlock() = default; + std::string operator()() { - osmium::apply(m_input_buffer.cbegin(), m_input_buffer.cend(), *this); + osmium::apply(m_input_buffer->cbegin(), m_input_buffer->cend(), *this); if (m_write_change_ops) { open_close_op_tag(); } std::string out; - std::swap(out, m_out); + std::swap(out, *m_out); return out; } @@ -254,29 +257,29 @@ namespace osmium { } write_prefix(); - m_out += "\n", node_ref.ref()); + oprintf(*m_out, " \n", node_ref.ref()); } write_tags(way.tags()); write_prefix(); - m_out += "\n"; + *m_out += "\n"; } void relation(const osmium::Relation& relation) { @@ -312,77 +315,77 @@ namespace osmium { } write_prefix(); - m_out += "\n"; + *m_out += " \n"; } write_tags(relation.tags()); write_prefix(); - m_out += "\n"; + *m_out += "\n"; } void changeset(const osmium::Changeset& changeset) { write_prefix(); - m_out += " and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/error.hpp b/include/osmium/io/error.hpp index 8fb9f05f6..07652bc59 100644 --- a/include/osmium/io/error.hpp +++ b/include/osmium/io/error.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -34,6 +34,7 @@ DEALINGS IN THE SOFTWARE. */ #include +#include namespace osmium { diff --git a/include/osmium/io/file.hpp b/include/osmium/io/file.hpp index 21469b865..5b6c02f13 100644 --- a/include/osmium/io/file.hpp +++ b/include/osmium/io/file.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -42,6 +42,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include namespace osmium { diff --git a/include/osmium/io/file_compression.hpp b/include/osmium/io/file_compression.hpp index c71871553..292ddcfca 100644 --- a/include/osmium/io/file_compression.hpp +++ b/include/osmium/io/file_compression.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/file_format.hpp b/include/osmium/io/file_format.hpp index 5a4aa5c01..1a63a5e49 100644 --- a/include/osmium/io/file_format.hpp +++ b/include/osmium/io/file_format.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/gzip_compression.hpp b/include/osmium/io/gzip_compression.hpp index c1f8888ba..8bc1e5a50 100644 --- a/include/osmium/io/gzip_compression.hpp +++ b/include/osmium/io/gzip_compression.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to read or write gzip-compressed OSM XML + * files. + * + * @attention If you include this file, you'll need to link with `libz`. + */ + #include #include diff --git a/include/osmium/io/header.hpp b/include/osmium/io/header.hpp index 0fdbf77fc..4b0830a62 100644 --- a/include/osmium/io/header.hpp +++ b/include/osmium/io/header.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/input_iterator.hpp b/include/osmium/io/input_iterator.hpp index a2e3b83b3..f6197299d 100644 --- a/include/osmium/io/input_iterator.hpp +++ b/include/osmium/io/input_iterator.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -41,6 +41,7 @@ DEALINGS IN THE SOFTWARE. #include #include +#include namespace osmium { diff --git a/include/osmium/io/opl_output.hpp b/include/osmium/io/opl_output.hpp index 46a12240b..04385d968 100644 --- a/include/osmium/io/opl_output.hpp +++ b/include/osmium/io/opl_output.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/output_iterator.hpp b/include/osmium/io/output_iterator.hpp index e6a9cc096..608852fa9 100644 --- a/include/osmium/io/output_iterator.hpp +++ b/include/osmium/io/output_iterator.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -75,6 +75,14 @@ namespace osmium { m_buffer_wrapper(std::make_shared(buffer_size)) { } + OutputIterator(const OutputIterator&) = default; + OutputIterator(OutputIterator&&) = default; + + OutputIterator& operator=(const OutputIterator&) = default; + OutputIterator& operator=(OutputIterator&&) = default; + + ~OutputIterator() = default; + void flush() { osmium::memory::Buffer buffer(m_buffer_wrapper->buffer.capacity(), osmium::memory::Buffer::auto_grow::no); std::swap(m_buffer_wrapper->buffer, buffer); diff --git a/include/osmium/io/overwrite.hpp b/include/osmium/io/overwrite.hpp index f29a93228..e33894bd8 100644 --- a/include/osmium/io/overwrite.hpp +++ b/include/osmium/io/overwrite.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/pbf_input.hpp b/include/osmium/io/pbf_input.hpp index 8426f6cf6..766153ede 100644 --- a/include/osmium/io/pbf_input.hpp +++ b/include/osmium/io/pbf_input.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,16 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to read OSM PBF files. + * + * @attention If you include this file, you'll need to link with + * `libprotobuf-lite`, `libosmpbf`, `ws2_32` (Windows only), + * `libz`, and enable multithreading. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/io/pbf_output.hpp b/include/osmium/io/pbf_output.hpp index 9fd039654..5f46ede2b 100644 --- a/include/osmium/io/pbf_output.hpp +++ b/include/osmium/io/pbf_output.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,16 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to write OSM PBF files. + * + * @attention If you include this file, you'll need to link with + * `libprotobuf-lite`, `libosmpbf`, `ws2_32` (Windows only), + * `libz`, and enable multithreading. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/io/reader.hpp b/include/osmium/io/reader.hpp index a9b8b954d..0bb4f1cb8 100644 --- a/include/osmium/io/reader.hpp +++ b/include/osmium/io/reader.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -258,11 +258,20 @@ namespace osmium { return osmium::memory::Buffer(); } - osmium::memory::Buffer buffer = m_input->read(); - if (!buffer) { - m_input_done = true; + // m_input->read() can return an invalid buffer to signal EOF, + // or a valid buffer with or without data. A valid buffer + // without data is not an error, it just means we have to get + // keep getting the next buffer until there is one with data. + while (true) { + osmium::memory::Buffer buffer = m_input->read(); + if (!buffer) { + m_input_done = true; + return buffer; + } + if (buffer.committed() > 0) { + return buffer; + } } - return buffer; } /** diff --git a/include/osmium/io/reader_iterator.hpp b/include/osmium/io/reader_iterator.hpp index 8d71418e0..862078935 100644 --- a/include/osmium/io/reader_iterator.hpp +++ b/include/osmium/io/reader_iterator.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/io/writer.hpp b/include/osmium/io/writer.hpp index 7e9bd1383..64afe2066 100644 --- a/include/osmium/io/writer.hpp +++ b/include/osmium/io/writer.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -80,7 +80,7 @@ namespace osmium { * defaults will be used. See the default constructor * of osmium::io::Header for details. * @param allow_overwrite Allow overwriting of existing file? Can be - * osmium::io::overwrite::allow or osmium::io::overwrite::no+ + * osmium::io::overwrite::allow or osmium::io::overwrite::no * (default). * * @throws std::runtime_error If the file could not be opened. diff --git a/include/osmium/io/xml_input.hpp b/include/osmium/io/xml_input.hpp index f33d37ee2..dfcd0a9fc 100644 --- a/include/osmium/io/xml_input.hpp +++ b/include/osmium/io/xml_input.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to read OSM XML files. + * + * @attention If you include this file, you'll need to link with + * `libexpat`, and enable multithreading. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/io/xml_output.hpp b/include/osmium/io/xml_output.hpp index d5b839f60..18a13869d 100644 --- a/include/osmium/io/xml_output.hpp +++ b/include/osmium/io/xml_output.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,14 @@ DEALINGS IN THE SOFTWARE. */ +/** + * @file + * + * Include this file if you want to write OSM XML files. + * + * @attention If you include this file, you'll need to enable multithreading. + */ + #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/osmium/memory/buffer.hpp b/include/osmium/memory/buffer.hpp index 8c05ced21..85a3a46d4 100644 --- a/include/osmium/memory/buffer.hpp +++ b/include/osmium/memory/buffer.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/memory/collection.hpp b/include/osmium/memory/collection.hpp index b25dd64ec..7deb88b45 100644 --- a/include/osmium/memory/collection.hpp +++ b/include/osmium/memory/collection.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE. #include #include +#include namespace osmium { diff --git a/include/osmium/memory/item.hpp b/include/osmium/memory/item.hpp index 2d22f948e..df15d0133 100644 --- a/include/osmium/memory/item.hpp +++ b/include/osmium/memory/item.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/memory/item_iterator.hpp b/include/osmium/memory/item_iterator.hpp index 34ed60083..3e5b5fa8b 100644 --- a/include/osmium/memory/item_iterator.hpp +++ b/include/osmium/memory/item_iterator.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/object_pointer_collection.hpp b/include/osmium/object_pointer_collection.hpp index 22029a149..752470305 100644 --- a/include/osmium/object_pointer_collection.hpp +++ b/include/osmium/object_pointer_collection.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm.hpp b/include/osmium/osm.hpp index bf21c19dc..e92d9b8ef 100644 --- a/include/osmium/osm.hpp +++ b/include/osmium/osm.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/area.hpp b/include/osmium/osm/area.hpp index a388de2e9..afd127ee6 100644 --- a/include/osmium/osm/area.hpp +++ b/include/osmium/osm/area.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/box.hpp b/include/osmium/osm/box.hpp index 2b761fefc..37baf7e33 100644 --- a/include/osmium/osm/box.hpp +++ b/include/osmium/osm/box.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -123,7 +123,7 @@ namespace osmium { * Box are valid, ie. defined and inside usual bounds * (-180<=lon<=180, -90<=lat<=90). */ - constexpr bool valid() const noexcept { + OSMIUM_CONSTEXPR bool valid() const noexcept { return bottom_left().valid() && top_right().valid(); } diff --git a/include/osmium/osm/changeset.hpp b/include/osmium/osm/changeset.hpp index 2b79fb5cf..cc1c52d4a 100644 --- a/include/osmium/osm/changeset.hpp +++ b/include/osmium/osm/changeset.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/diff_object.hpp b/include/osmium/osm/diff_object.hpp index a8f91ecd5..55a5cef68 100644 --- a/include/osmium/osm/diff_object.hpp +++ b/include/osmium/osm/diff_object.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/entity.hpp b/include/osmium/osm/entity.hpp index e37ed4c94..14861a2d5 100644 --- a/include/osmium/osm/entity.hpp +++ b/include/osmium/osm/entity.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -34,6 +34,7 @@ DEALINGS IN THE SOFTWARE. */ #include +#include namespace osmium { @@ -67,6 +68,10 @@ namespace osmium { Item(size, type) { } + bool type_is_in(osmium::osm_entity_bits::type entity_bits) const { + return (osm_entity_bits::from_item_type(type()) & entity_bits) != 0; + } + }; // class OSMEntity } // namespace osmium diff --git a/include/osmium/osm/entity_bits.hpp b/include/osmium/osm/entity_bits.hpp index 2a4d96416..1c1cb8027 100644 --- a/include/osmium/osm/entity_bits.hpp +++ b/include/osmium/osm/entity_bits.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + namespace osmium { /** @@ -92,6 +94,10 @@ namespace osmium { return lhs; } + inline type from_item_type(osmium::item_type item_type) noexcept { + return static_cast(0x1 << (static_cast(item_type) - 1)); + } + } // namespace osm_entity_bits } // namespace osmium diff --git a/include/osmium/osm/item_type.hpp b/include/osmium/osm/item_type.hpp index d277e06c8..c2187a36a 100644 --- a/include/osmium/osm/item_type.hpp +++ b/include/osmium/osm/item_type.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/location.hpp b/include/osmium/osm/location.hpp index cabecd50f..0d4fdc13d 100644 --- a/include/osmium/osm/location.hpp +++ b/include/osmium/osm/location.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/node.hpp b/include/osmium/osm/node.hpp index 50146c568..123bfc4fa 100644 --- a/include/osmium/osm/node.hpp +++ b/include/osmium/osm/node.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/node_ref.hpp b/include/osmium/osm/node_ref.hpp index ed50b9e66..1a66607a1 100644 --- a/include/osmium/osm/node_ref.hpp +++ b/include/osmium/osm/node_ref.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/node_ref_list.hpp b/include/osmium/osm/node_ref_list.hpp index 321c952f4..f45bf6b59 100644 --- a/include/osmium/osm/node_ref_list.hpp +++ b/include/osmium/osm/node_ref_list.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/object.hpp b/include/osmium/osm/object.hpp index 9c4d60341..d5ae48aab 100644 --- a/include/osmium/osm/object.hpp +++ b/include/osmium/osm/object.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/object_comparisons.hpp b/include/osmium/osm/object_comparisons.hpp index db11b0d4c..bdf99e11c 100644 --- a/include/osmium/osm/object_comparisons.hpp +++ b/include/osmium/osm/object_comparisons.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/relation.hpp b/include/osmium/osm/relation.hpp index f5d040100..6c0381539 100644 --- a/include/osmium/osm/relation.hpp +++ b/include/osmium/osm/relation.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/segment.hpp b/include/osmium/osm/segment.hpp index 205036ec6..f3a82c97f 100644 --- a/include/osmium/osm/segment.hpp +++ b/include/osmium/osm/segment.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/tag.hpp b/include/osmium/osm/tag.hpp index fe80de34f..2e93ede24 100644 --- a/include/osmium/osm/tag.hpp +++ b/include/osmium/osm/tag.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/timestamp.hpp b/include/osmium/osm/timestamp.hpp index 23f0ec8af..f36ea36a1 100644 --- a/include/osmium/osm/timestamp.hpp +++ b/include/osmium/osm/timestamp.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -101,7 +101,7 @@ namespace osmium { tm.tm_wday = 0; tm.tm_yday = 0; tm.tm_isdst = 0; - m_timestamp = _mkgmtime(&tm); + m_timestamp = static_cast(_mkgmtime(&tm)); #endif } diff --git a/include/osmium/osm/types.hpp b/include/osmium/osm/types.hpp index 532b5497c..aea61bd37 100644 --- a/include/osmium/osm/types.hpp +++ b/include/osmium/osm/types.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/undirected_segment.hpp b/include/osmium/osm/undirected_segment.hpp index 487e7bf32..654ef7d9a 100644 --- a/include/osmium/osm/undirected_segment.hpp +++ b/include/osmium/osm/undirected_segment.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/osm/way.hpp b/include/osmium/osm/way.hpp index a30cf911f..6d3e2dea0 100644 --- a/include/osmium/osm/way.hpp +++ b/include/osmium/osm/way.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/relations/collector.hpp b/include/osmium/relations/collector.hpp index 60864d308..d4af916b7 100644 --- a/include/osmium/relations/collector.hpp +++ b/include/osmium/relations/collector.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -509,7 +509,7 @@ namespace osmium { const size_t size_before = m_members_buffer.committed(); m_members_buffer.purge_removed(this); const size_t size_after = m_members_buffer.committed(); - double percent = size_before - size_after; + double percent = static_cast(size_before - size_after); percent /= size_before; percent *= 100; std::cerr << "PURGE (size before=" << size_before << " after=" << size_after << " purged=" << (size_before - size_after) << " / " << static_cast(percent) << "%)\n"; diff --git a/include/osmium/relations/detail/member_meta.hpp b/include/osmium/relations/detail/member_meta.hpp index 5463a1cb8..a45088eab 100644 --- a/include/osmium/relations/detail/member_meta.hpp +++ b/include/osmium/relations/detail/member_meta.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/relations/detail/relation_meta.hpp b/include/osmium/relations/detail/relation_meta.hpp index 77ca0c130..a48c50acc 100644 --- a/include/osmium/relations/detail/relation_meta.hpp +++ b/include/osmium/relations/detail/relation_meta.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/tags/filter.hpp b/include/osmium/tags/filter.hpp index 0a0fd3b56..3c1946c54 100644 --- a/include/osmium/tags/filter.hpp +++ b/include/osmium/tags/filter.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -135,6 +135,20 @@ namespace osmium { return m_default_result; } + /** + * Return the number of rules in this filter. + */ + size_t count() const { + return m_rules.count(); + } + + /** + * Is this filter empty, ie are there no rules defined? + */ + bool empty() const { + return m_rules.empty(); + } + }; // class Filter typedef Filter KeyValueFilter; diff --git a/include/osmium/tags/regex_filter.hpp b/include/osmium/tags/regex_filter.hpp index ae2703a30..725c42376 100644 --- a/include/osmium/tags/regex_filter.hpp +++ b/include/osmium/tags/regex_filter.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/tags/taglist.hpp b/include/osmium/tags/taglist.hpp index 41ef993a0..d7c78dc79 100644 --- a/include/osmium/tags/taglist.hpp +++ b/include/osmium/tags/taglist.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -47,17 +47,17 @@ namespace osmium { template inline bool match_any_of(const osmium::TagList& tag_list, TFilter&& filter) { - return std::any_of(tag_list.begin(), tag_list.end(), std::forward(filter)); + return std::any_of(tag_list.cbegin(), tag_list.cend(), std::forward(filter)); } template inline bool match_all_of(const osmium::TagList& tag_list, TFilter&& filter) { - return std::all_of(tag_list.begin(), tag_list.end(), std::forward(filter)); + return std::all_of(tag_list.cbegin(), tag_list.cend(), std::forward(filter)); } template inline bool match_none_of(const osmium::TagList& tag_list, TFilter&& filter) { - return std::none_of(tag_list.begin(), tag_list.end(), std::forward(filter)); + return std::none_of(tag_list.cbegin(), tag_list.cend(), std::forward(filter)); } } // namespace tags diff --git a/include/osmium/thread/function_wrapper.hpp b/include/osmium/thread/function_wrapper.hpp index dbb47ff87..fe0a49257 100644 --- a/include/osmium/thread/function_wrapper.hpp +++ b/include/osmium/thread/function_wrapper.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -94,9 +94,10 @@ namespace osmium { } function_wrapper(const function_wrapper&) = delete; - function_wrapper(function_wrapper&) = delete; function_wrapper& operator=(const function_wrapper&) = delete; + ~function_wrapper() = default; + explicit operator bool() const { return static_cast(impl); } diff --git a/include/osmium/thread/pool.hpp b/include/osmium/thread/pool.hpp index 702be66e0..bc1e9a82b 100644 --- a/include/osmium/thread/pool.hpp +++ b/include/osmium/thread/pool.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -160,11 +160,11 @@ namespace osmium { } template - std::future::type> submit(TFunction f) { + std::future::type> submit(TFunction&& func) { typedef typename std::result_of::type result_type; - std::packaged_task task(std::move(f)); + std::packaged_task task(std::forward(func)); std::future future_result(task.get_future()); m_work_queue.push(std::move(task)); diff --git a/include/osmium/thread/queue.hpp b/include/osmium/thread/queue.hpp index b01dd39bf..5c5f8e768 100644 --- a/include/osmium/thread/queue.hpp +++ b/include/osmium/thread/queue.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -39,6 +39,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include diff --git a/include/osmium/thread/sorted_queue.hpp b/include/osmium/thread/sorted_queue.hpp index e33dfe696..e0181eb61 100644 --- a/include/osmium/thread/sorted_queue.hpp +++ b/include/osmium/thread/sorted_queue.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/thread/util.hpp b/include/osmium/thread/util.hpp index 286ea5e06..62bb82ab5 100644 --- a/include/osmium/thread/util.hpp +++ b/include/osmium/thread/util.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/util/cast.hpp b/include/osmium/util/cast.hpp index 750326706..13e6e3a9c 100644 --- a/include/osmium/util/cast.hpp +++ b/include/osmium/util/cast.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/util/compatibility.hpp b/include/osmium/util/compatibility.hpp index 48a6db017..90d85c502 100644 --- a/include/osmium/util/compatibility.hpp +++ b/include/osmium/util/compatibility.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/util/config.hpp b/include/osmium/util/config.hpp index 4fc8f2860..3285eedbb 100644 --- a/include/osmium/util/config.hpp +++ b/include/osmium/util/config.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/util/double.hpp b/include/osmium/util/double.hpp index 67e997d9f..85a250807 100644 --- a/include/osmium/util/double.hpp +++ b/include/osmium/util/double.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/util/options.hpp b/include/osmium/util/options.hpp index fc74980d1..fea075230 100644 --- a/include/osmium/util/options.hpp +++ b/include/osmium/util/options.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/util/verbose_output.hpp b/include/osmium/util/verbose_output.hpp index 8709441af..178781e23 100644 --- a/include/osmium/util/verbose_output.hpp +++ b/include/osmium/util/verbose_output.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/include/osmium/visitor.hpp b/include/osmium/visitor.hpp index d71a2e01c..0250f11d4 100644 --- a/include/osmium/visitor.hpp +++ b/include/osmium/visitor.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013,2014 Jochen Topf and others (see README). +Copyright 2013-2015 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/make_osmium_project.sh b/make_osmium_project.sh deleted file mode 100755 index ba844b85b..000000000 --- a/make_osmium_project.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh -# -# make_osmium_project.sh PROJECTNAME -# -# Creates a subdirectory named as the project in the current directory and -# adds a skeleton of files needed to begin a new project using the Osmium -# library. -# - -if [ "x$1" = "x" ]; then - echo "Usage: $0 PROJECTNAME" - exit 1 -fi - -if [ -e "$1" ]; then - echo "Directory '$1' exists" - exit 1 -fi - -mkdir $1 -cd $1 - -sed -e "s/__PROJECTNAME__/$1/g" >Makefile <<'__EOF__' -CXXFLAGS += -O3 -#CXXFLAGS += -g -CXXFLAGS += -std=c++11 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -CXXFLAGS += -I../include - -OS:=$(shell uname -s) -ifeq ($(OS),Darwin) - CXXFLAGS += -stdlib=libc++ - LDFLAGS += -stdlib=libc++ -endif - -CXXFLAGS_WARNINGS := -Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast - -LIB_EXPAT := -lexpat -LIB_PBF := -pthread -lz -lprotobuf-lite -losmpbf -LIB_GZIP := -lz -LIB_BZIP2 := -lbz2 - -LIB_IO := $(LIB_EXPAT) $(LIB_PBF) $(LIB_GZIP) $(LIB_BZIP2) - -PROGRAMS := __PROJECTNAME__ - -.PHONY: all clean - -all: $(PROGRAMS) - -__PROJECTNAME__: main.cpp - $(CXX) $(CXXFLAGS) $(CXXFLAGS_WARNINGS) -o $@ $< $(LDFLAGS) $(LIB_IO) - -clean: - rm -f *.o core $(PROGRAMS) - -__EOF__ - -cat >main.cpp <<'__EOF__' - -#include -#include -#include - -class MyHandler : public osmium::handler::Handler { - -public: - - MyHandler() : - osmium::handler::Handler() { - } - - void node(const osmium::Node& node) { - } - - void way(const osmium::Way& way) { - } - - void relation(const osmium::Relation& relation) { - } - -}; // class MyHandler - -int main(int argc, char* argv[]) { - - if (argc != 2) { - std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; - exit(1); - } - - MyHandler handler; - osmium::io::Reader reader(argv[1]); - osmium::apply(reader, handler); -} - -__EOF__ - diff --git a/osmium.imp b/osmium.imp index 1f0963f11..c45794d08 100644 --- a/osmium.imp +++ b/osmium.imp @@ -1,3 +1,10 @@ +#----------------------------------------------------------------------------- +# +# Configuration for Include-What-You-Use tool +# +# https://code.google.com/p/include-what-you-use/ +# +#----------------------------------------------------------------------------- [ { "include": ["", "private", "", "public"] }, { "include": ["", "public", "", "public"] } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ebea16c11..9e27b120c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,25 +1,31 @@ -message(STATUS "Configuring unit tests...") +#----------------------------------------------------------------------------- +# +# CMake Config +# +# Libosmium unit tests +# +#----------------------------------------------------------------------------- + +message(STATUS "Configuring unit tests") -set(DART_TESTING_TIMEOUT 60) -include(Dart) include_directories(include) -# In 'Dev' mode: compile with very strict warnings and turn them into errors. -if(CMAKE_BUILD_TYPE STREQUAL "Dev") - add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS} -Wno-unused-variable) -endif() - add_library(testlib STATIC test_main.cpp) -#---------------------------------------------------------------------- - set(ALL_TESTS "") -# call with parameters: -# TGROUP - test group (directory) -# TNAME - name of test -# ARGV2 - flag to enable test (optional) -# ARGV3 - libraries to add (optional) + +#----------------------------------------------------------------------------- +# +# Define function for adding tests +# +# Call with parameters: +# TGROUP - test group (directory) +# TNAME - name of test +# ARGV2 - flag to enable test (optional) +# ARGV3 - libraries to add (optional) +# +#----------------------------------------------------------------------------- function(add_unit_test TGROUP TNAME) set(ALL_TESTS "${ALL_TESTS};${TGROUP}/${TNAME}" PARENT_SCOPE) if((${ARGC} EQUAL 2) OR (${ARGV2})) @@ -36,10 +42,13 @@ function(add_unit_test TGROUP TNAME) target_link_libraries(${TESTNAME} ${ARGV3}) endif() add_test(NAME ${TESTNAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTNAME} ) - set_tests_properties(${TESTNAME} PROPERTIES LABELS "unit;${TGROUP}") + set_tests_properties(${TESTNAME} PROPERTIES + LABELS "unit;fast;${TGROUP}" + ENVIRONMENT "OSMIUM_TEST_DATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}" + ) else() message("Skipped test ${TGROUP}/${TNAME} because a dependency was not found") set(OSMIUM_SKIPPED_TESTS @@ -48,12 +57,11 @@ function(add_unit_test TGROUP TNAME) endif() endfunction() -#---------------------------------------------------------------------- +#----------------------------------------------------------------------------- # # Add all tests. # -#---------------------------------------------------------------------- - +#----------------------------------------------------------------------------- add_unit_test(area test_area_id) add_unit_test(area test_node_ref_segment) @@ -71,7 +79,7 @@ add_unit_test(basic test_way) add_unit_test(buffer test_buffer_node) add_unit_test(buffer test_buffer_purge) -if (GEOS_FOUND AND PROJ_FOUND) +if(GEOS_FOUND AND PROJ_FOUND) set(GEOS_AND_PROJ_FOUND TRUE) else() set(GEOS_AND_PROJ_FOUND FALSE) @@ -95,6 +103,7 @@ add_unit_test(index test_typed_mmap) add_unit_test(io test_bzip2 ${BZIP2_FOUND} ${BZIP2_LIBRARIES}) add_unit_test(io test_file_formats) add_unit_test(io test_reader TRUE "${OSMIUM_XML_LIBRARIES}") +add_unit_test(io test_output_iterator ${Threads_FOUND} ${CMAKE_THREAD_LIBS_INIT}) add_unit_test(tags test_filter) add_unit_test(tags test_operators) @@ -104,12 +113,12 @@ add_unit_test(util test_double) add_unit_test(util test_options) add_unit_test(util test_string) -#---------------------------------------------------------------------- + +#----------------------------------------------------------------------------- # # Check that all tests available in test/t/*/test_*.cpp are run. # -#---------------------------------------------------------------------- - +#----------------------------------------------------------------------------- file(GLOB TESTS_IN_DIR RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/t" t/*/test_*.cpp) foreach(file ${TESTS_IN_DIR}) @@ -121,3 +130,9 @@ foreach(file ${TESTS_IN_DIR}) endif() endforeach() + +#----------------------------------------------------------------------------- +message(STATUS "Configuring unit tests - done") + + +#----------------------------------------------------------------------------- diff --git a/test/README b/test/README index dc5e51222..8195824b4 100644 --- a/test/README +++ b/test/README @@ -7,6 +7,7 @@ Osmium needs a few changes to catch.hpp, they were patched in. To be able to compare with the original version, it is stored in include/catch_orig.hpp. Changes are: +* Disable more warnings in GCC * CATCH_CONFIG_CPP11_NULLPTR must be set for MSVC * Problem with test running in loop: https://github.com/philsquared/Catch/issues/271 diff --git a/test/osm-testdata/.gitignore b/test/data-tests/.gitignore similarity index 100% rename from test/osm-testdata/.gitignore rename to test/data-tests/.gitignore diff --git a/test/data-tests/CMakeLists.txt b/test/data-tests/CMakeLists.txt new file mode 100644 index 000000000..a2938e519 --- /dev/null +++ b/test/data-tests/CMakeLists.txt @@ -0,0 +1,121 @@ +#----------------------------------------------------------------------------- +# +# CMake Config +# +# Libosmium data tests +# +#----------------------------------------------------------------------------- + +message(STATUS "Configuring data tests") + +if(NOT GDAL_FOUND OR NOT EXPAT_FOUND) + message(STATUS "Sorry, building data tests needs GDAL and Expat") + message(STATUS "Configuring data tests - failed") + return() +endif() + +message(STATUS "Looking for osm-testdata") +find_path(OSM_TESTDATA grid/data/all.osm HINT ../../../osm-testdata) +if(OSM_TESTDATA STREQUAL "OSM_TESTDATA-NOTFOUND") + message(STATUS "Looking for osm-testdata - not found (data tests disabled)") + message(STATUS "Configuring data tests - failed") + return() +endif() +message(STATUS "Looking for osm-testdata - found") + + +#----------------------------------------------------------------------------- + +include_directories("include") +include_directories("../include") + + +#----------------------------------------------------------------------------- +# +# testcases +# +#----------------------------------------------------------------------------- +file(GLOB TESTCASE_CPPS testcases/*.cpp) +add_executable(testdata-testcases testdata-testcases.cpp ${TESTCASE_CPPS}) +target_link_libraries(testdata-testcases + ${OSMIUM_XML_LIBRARIES} +) +add_test(NAME testdata-testcases + COMMAND testdata-testcases +) +set_tests_properties(testdata-testcases PROPERTIES + ENVIRONMENT "TESTCASES_DIR=${OSM_TESTDATA}/grid/data" + LABELS "data;fast") + + +#----------------------------------------------------------------------------- +# +# xml +# +#----------------------------------------------------------------------------- +add_executable(testdata-xml testdata-xml.cpp) +target_link_libraries(testdata-xml + ${OSMIUM_XML_LIBRARIES} +) +add_test(NAME testdata-xml + COMMAND testdata-xml +) +set_tests_properties(testdata-xml PROPERTIES + ENVIRONMENT "TESTDIR=${OSM_TESTDATA}/xml/data" + LABELS "data;fast") + + +#----------------------------------------------------------------------------- +# +# overview +# +#----------------------------------------------------------------------------- +add_executable(testdata-overview testdata-overview.cpp) +target_link_libraries(testdata-overview + ${OSMIUM_XML_LIBRARIES} + ${GDAL_LIBRARIES} +) +add_test(NAME testdata-overview + COMMAND testdata-overview ${OSM_TESTDATA}/grid/data/all.osm +) +set_tests_properties(testdata-overview PROPERTIES + LABELS "data;slow") + + +#----------------------------------------------------------------------------- +# +# multipolygon +# +#----------------------------------------------------------------------------- +add_executable(testdata-multipolygon testdata-multipolygon.cpp) +target_link_libraries(testdata-multipolygon + ${OSMIUM_XML_LIBRARIES} + ${GDAL_LIBRARIES} +) + +if(WIN32) + set(MULTIPOLYGON_TEST_SCRIPT "run-testdata-multipolygon.bat") +else() + set(MULTIPOLYGON_TEST_SCRIPT "run-testdata-multipolygon.sh") +endif() + +if(MSVC) + set(EXE_DIR ${CMAKE_BUILD_TYPE}) +else() + set(EXE_DIR .) +endif() + +add_test(NAME testdata-multipolygon + COMMAND ${CMAKE_SOURCE_DIR}/test/data-tests/${MULTIPOLYGON_TEST_SCRIPT} + ${OSM_TESTDATA} + ${EXE_DIR} +) +set_tests_properties(testdata-multipolygon PROPERTIES + LABELS "data;slow") + + +#----------------------------------------------------------------------------- +message(STATUS "Configuring data tests - done") + + +#----------------------------------------------------------------------------- diff --git a/test/osm-testdata/README.md b/test/data-tests/README.md similarity index 100% rename from test/osm-testdata/README.md rename to test/data-tests/README.md diff --git a/test/osm-testdata/include/check_basics_handler.hpp b/test/data-tests/include/check_basics_handler.hpp similarity index 100% rename from test/osm-testdata/include/check_basics_handler.hpp rename to test/data-tests/include/check_basics_handler.hpp diff --git a/test/osm-testdata/include/check_wkt_handler.hpp b/test/data-tests/include/check_wkt_handler.hpp similarity index 100% rename from test/osm-testdata/include/check_wkt_handler.hpp rename to test/data-tests/include/check_wkt_handler.hpp diff --git a/test/osm-testdata/include/common.hpp b/test/data-tests/include/common.hpp similarity index 78% rename from test/osm-testdata/include/common.hpp rename to test/data-tests/include/common.hpp index 0f6957056..a6fd3df61 100644 --- a/test/osm-testdata/include/common.hpp +++ b/test/data-tests/include/common.hpp @@ -1,16 +1,17 @@ #ifndef COMMON_HPP #define COMMON_HPP +#include +#include + #include #include #include -#include -#include #include #include typedef osmium::index::map::Dummy index_neg_type; -typedef osmium::index::map::SparseMapMem index_pos_type; +typedef osmium::index::map::SparseMemArray index_pos_type; typedef osmium::handler::NodeLocationsForWays location_handler_type; #include "check_basics_handler.hpp" diff --git a/test/osm-testdata/include/testdata-testcases.hpp b/test/data-tests/include/testdata-testcases.hpp similarity index 100% rename from test/osm-testdata/include/testdata-testcases.hpp rename to test/data-tests/include/testdata-testcases.hpp diff --git a/test/osm-testdata/multipolygon.qgs b/test/data-tests/multipolygon.qgs similarity index 100% rename from test/osm-testdata/multipolygon.qgs rename to test/data-tests/multipolygon.qgs diff --git a/test/osm-testdata/run-testdata-multipolygon.bat b/test/data-tests/run-testdata-multipolygon.bat similarity index 100% rename from test/osm-testdata/run-testdata-multipolygon.bat rename to test/data-tests/run-testdata-multipolygon.bat diff --git a/test/osm-testdata/run-testdata-multipolygon.sh b/test/data-tests/run-testdata-multipolygon.sh similarity index 100% rename from test/osm-testdata/run-testdata-multipolygon.sh rename to test/data-tests/run-testdata-multipolygon.sh diff --git a/test/osm-testdata/testcases/test-100.cpp b/test/data-tests/testcases/test-100.cpp similarity index 100% rename from test/osm-testdata/testcases/test-100.cpp rename to test/data-tests/testcases/test-100.cpp diff --git a/test/osm-testdata/testcases/test-101.cpp b/test/data-tests/testcases/test-101.cpp similarity index 100% rename from test/osm-testdata/testcases/test-101.cpp rename to test/data-tests/testcases/test-101.cpp diff --git a/test/osm-testdata/testcases/test-110.cpp b/test/data-tests/testcases/test-110.cpp similarity index 100% rename from test/osm-testdata/testcases/test-110.cpp rename to test/data-tests/testcases/test-110.cpp diff --git a/test/osm-testdata/testdata-multipolygon.cpp b/test/data-tests/testdata-multipolygon.cpp similarity index 92% rename from test/osm-testdata/testdata-multipolygon.cpp rename to test/data-tests/testdata-multipolygon.cpp index d732566c4..0fd0d9849 100644 --- a/test/osm-testdata/testdata-multipolygon.cpp +++ b/test/data-tests/testdata-multipolygon.cpp @@ -3,18 +3,7 @@ #include #include -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" -#endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#pragma GCC diagnostic ignored "-Wpadded" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -# include -# include -#pragma GCC diagnostic pop +#include #include #include @@ -23,14 +12,12 @@ #include #include #include -#include -#include #include #include -typedef osmium::index::map::SparseMapMem index_type; +typedef osmium::index::map::SparseMemArray index_type; -typedef osmium::handler::NodeLocationsForWays location_handler_type; +typedef osmium::handler::NodeLocationsForWays location_handler_type; struct less_charptr { @@ -284,9 +271,8 @@ int main(int argc, char* argv[]) { reader1.close(); std::cerr << "Pass 1 done\n"; - index_type index_pos; - index_type index_neg; - location_handler_type location_handler(index_pos, index_neg); + index_type index; + location_handler_type location_handler(index); location_handler.ignore_errors(); TestHandler test_handler(data_source); diff --git a/test/osm-testdata/testdata-overview.cpp b/test/data-tests/testdata-overview.cpp similarity index 86% rename from test/osm-testdata/testdata-overview.cpp rename to test/data-tests/testdata-overview.cpp index b56781268..2d63dc684 100644 --- a/test/osm-testdata/testdata-overview.cpp +++ b/test/data-tests/testdata-overview.cpp @@ -2,30 +2,16 @@ #include -#pragma GCC diagnostic push -#ifdef __clang__ -# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" -#endif -#pragma GCC diagnostic ignored "-Wfloat-equal" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#pragma GCC diagnostic ignored "-Wpadded" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -# include -# include -#pragma GCC diagnostic pop +#include #include #include #include -#include -#include #include #include -typedef osmium::index::map::Dummy index_neg_type; -typedef osmium::index::map::SparseMapMem index_pos_type; -typedef osmium::handler::NodeLocationsForWays location_handler_type; +typedef osmium::index::map::SparseMemArray index_type; +typedef osmium::handler::NodeLocationsForWays location_handler_type; class TestOverviewHandler : public osmium::handler::Handler { @@ -199,9 +185,8 @@ int main(int argc, char* argv[]) { osmium::io::Reader reader(input_filename); - index_pos_type index_pos; - index_neg_type index_neg; - location_handler_type location_handler(index_pos, index_neg); + index_type index; + location_handler_type location_handler(index); location_handler.ignore_errors(); TestOverviewHandler handler(output_format, output_filename); diff --git a/test/osm-testdata/testdata-testcases.cpp b/test/data-tests/testdata-testcases.cpp similarity index 100% rename from test/osm-testdata/testdata-testcases.cpp rename to test/data-tests/testdata-testcases.cpp diff --git a/test/osm-testdata/testdata-xml.cpp b/test/data-tests/testdata-xml.cpp similarity index 99% rename from test/osm-testdata/testdata-xml.cpp rename to test/data-tests/testdata-xml.cpp index e4c1716d4..16133a92a 100644 --- a/test/osm-testdata/testdata-xml.cpp +++ b/test/data-tests/testdata-xml.cpp @@ -1,11 +1,7 @@ /* The code in this file is released into the Public Domain. */ #define CATCH_CONFIG_MAIN - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "catch.hpp" -#pragma GCC diagnostic pop #include #include diff --git a/test/include/catch.hpp b/test/include/catch.hpp index f35378fea..bb87af296 100644 --- a/test/include/catch.hpp +++ b/test/include/catch.hpp @@ -3,8 +3,8 @@ #define CATCH_CONFIG_CPP11_NULLPTR /* - * CATCH v1.0 build 52 (master branch) - * Generated: 2014-07-10 09:17:43.994453 + * CATCH v1.0 build 53 (master branch) + * Generated: 2014-08-20 08:08:19.533804 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -30,15 +30,13 @@ #pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wc++98-compat" #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#pragma clang diagnostic ignored "-Wfloat-equal" -#endif - -#ifndef __clang__ -# pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wreturn-type" -# pragma GCC diagnostic ignored "-Wsign-promo" -# pragma GCC diagnostic ignored "-Wparentheses" +#elif defined __GNUC__ +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpadded" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" +#pragma GCC diagnostic ignored "-Wsign-promo" #endif #ifdef CATCH_CONFIG_MAIN @@ -1175,6 +1173,8 @@ std::string toString( std::string const& value ); std::string toString( std::wstring const& value ); std::string toString( const char* const value ); std::string toString( char* const value ); +std::string toString( const wchar_t* const value ); +std::string toString( wchar_t* const value ); std::string toString( int value ); std::string toString( unsigned long value ); std::string toString( unsigned int value ); @@ -6423,7 +6423,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 52, "master" ); + Version libraryVersion( 1, 0, 53, "master" ); } // #included from: catch_message.hpp @@ -6909,6 +6909,16 @@ std::string toString( char* const value ) { return Catch::toString( static_cast( value ) ); } +std::string toString( const wchar_t* const value ) +{ + return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); +} + +std::string toString( wchar_t* const value ) +{ + return Catch::toString( static_cast( value ) ); +} + std::string toString( int value ) { std::ostringstream oss; oss << value; @@ -8897,8 +8907,10 @@ int main (int argc, char * const argv[]) { // "BDD-style" convenience wrappers #ifdef CATCH_CONFIG_VARIADIC_MACROS #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) #else #define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) +#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) #endif #define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" ) #define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" ) @@ -8964,8 +8976,10 @@ int main (int argc, char * const argv[]) { // "BDD-style" convenience wrappers #ifdef CATCH_CONFIG_VARIADIC_MACROS #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) #else #define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) +#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) #endif #define GIVEN( desc ) SECTION( " Given: " desc, "" ) #define WHEN( desc ) SECTION( " When: " desc, "" ) @@ -8981,6 +8995,8 @@ using Catch::Detail::Approx; #ifdef __clang__ #pragma clang diagnostic pop +#elif defined __GNUC__ +#pragma GCC diagnostic pop #endif #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED diff --git a/test/include/catch_orig.hpp b/test/include/catch_orig.hpp index 1fba6a34e..6b8dfb5eb 100644 --- a/test/include/catch_orig.hpp +++ b/test/include/catch_orig.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 52 (master branch) - * Generated: 2014-07-10 09:17:43.994453 + * CATCH v1.0 build 53 (master branch) + * Generated: 2014-08-20 08:08:19.533804 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -26,6 +26,11 @@ #pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wc++98-compat" #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#elif defined __GNUC__ +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpadded" #endif #ifdef CATCH_CONFIG_MAIN @@ -1162,6 +1167,8 @@ std::string toString( std::string const& value ); std::string toString( std::wstring const& value ); std::string toString( const char* const value ); std::string toString( char* const value ); +std::string toString( const wchar_t* const value ); +std::string toString( wchar_t* const value ); std::string toString( int value ); std::string toString( unsigned long value ); std::string toString( unsigned int value ); @@ -6410,7 +6417,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 52, "master" ); + Version libraryVersion( 1, 0, 53, "master" ); } // #included from: catch_message.hpp @@ -6896,6 +6903,16 @@ std::string toString( char* const value ) { return Catch::toString( static_cast( value ) ); } +std::string toString( const wchar_t* const value ) +{ + return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); +} + +std::string toString( wchar_t* const value ) +{ + return Catch::toString( static_cast( value ) ); +} + std::string toString( int value ) { std::ostringstream oss; oss << value; @@ -8884,8 +8901,10 @@ int main (int argc, char * const argv[]) { // "BDD-style" convenience wrappers #ifdef CATCH_CONFIG_VARIADIC_MACROS #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) #else #define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) +#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) #endif #define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" ) #define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" ) @@ -8951,8 +8970,10 @@ int main (int argc, char * const argv[]) { // "BDD-style" convenience wrappers #ifdef CATCH_CONFIG_VARIADIC_MACROS #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) #else #define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) +#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) #endif #define GIVEN( desc ) SECTION( " Given: " desc, "" ) #define WHEN( desc ) SECTION( " When: " desc, "" ) @@ -8968,6 +8989,8 @@ using Catch::Detail::Approx; #ifdef __clang__ #pragma clang diagnostic pop +#elif defined __GNUC__ +#pragma GCC diagnostic pop #endif #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED diff --git a/test/include/utils.hpp b/test/include/utils.hpp new file mode 100644 index 000000000..662155abf --- /dev/null +++ b/test/include/utils.hpp @@ -0,0 +1,18 @@ + +#include +#include + +inline std::string with_data_dir(const char* filename) { + const char* data_dir = getenv("OSMIUM_TEST_DATA_DIR"); + + std::string result; + if (data_dir) { + result = data_dir; + result += '/'; + } + + result += filename; + + return result; +} + diff --git a/test/osm-testdata/CMakeLists.txt b/test/osm-testdata/CMakeLists.txt deleted file mode 100644 index b29510ce4..000000000 --- a/test/osm-testdata/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -message(STATUS "Configuring osm-testdata tests...") - -if(NOT GDAL_FOUND OR - NOT EXPAT_FOUND) - message("Sorry, building osm-testdata tests needs GDAL and Expat") - return() -endif() - -set(DART_TESTING_TIMEOUT 300) -include(Dart) - -include_directories("include") -include_directories("../include") - -# In 'Dev' mode: compile with very strict warnings and turn them into errors. -if(CMAKE_BUILD_TYPE STREQUAL "Dev") - add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS} -Wno-unused-variable) -endif() - -get_filename_component(TESTDATA_DIR ../../../osm-testdata ABSOLUTE) -if(NOT EXISTS ${TESTDATA_DIR}) - execute_process(COMMAND git clone https://github.com/osmcode/osm-testdata.git ${TESTDATA_DIR}) -endif() - -#---------------------------------------------------------------------- - -file(GLOB TESTCASE_CPPS testcases/*.cpp) -add_executable(testdata-testcases testdata-testcases.cpp ${TESTCASE_CPPS}) -target_link_libraries(testdata-testcases - ${OSMIUM_XML_LIBRARIES} -) -add_test(NAME testdata-testcases - COMMAND testdata-testcases -) -set_tests_properties(testdata-testcases - PROPERTIES ENVIRONMENT "TESTCASES_DIR=${TESTDATA_DIR}/grid/data") - -#---------------------------------------------------------------------- - -add_executable(testdata-overview testdata-overview.cpp) -target_link_libraries(testdata-overview - ${OSMIUM_XML_LIBRARIES} - ${GDAL_LIBRARIES} -) -add_test(NAME testdata-overview - COMMAND testdata-overview ${TESTDATA_DIR}/grid/data/all.osm -) - -#---------------------------------------------------------------------- - -add_executable(testdata-xml testdata-xml.cpp) -target_link_libraries(testdata-xml - ${OSMIUM_XML_LIBRARIES} -) -add_test(NAME testdata-xml - COMMAND testdata-xml -) -set_tests_properties(testdata-xml - PROPERTIES ENVIRONMENT "TESTDIR=${TESTDATA_DIR}/xml/data") - -#---------------------------------------------------------------------- - -add_executable(testdata-multipolygon testdata-multipolygon.cpp) -target_link_libraries(testdata-multipolygon - ${OSMIUM_XML_LIBRARIES} - ${GDAL_LIBRARIES} -) - -if(WIN32) - set(MULTIPOLYGON_TEST_SCRIPT "run-testdata-multipolygon.bat") -else() - set(MULTIPOLYGON_TEST_SCRIPT "run-testdata-multipolygon.sh") -endif() - -if(MSVC) - set(EXE_DIR ${CMAKE_BUILD_TYPE}) -else() - set(EXE_DIR .) -endif() - -add_test(NAME testdata-multipolygon - COMMAND ${CMAKE_SOURCE_DIR}/test/osm-testdata/${MULTIPOLYGON_TEST_SCRIPT} - ${TESTDATA_DIR} - ${EXE_DIR} -) - -#---------------------------------------------------------------------- diff --git a/test/t/basic/test_box.cpp b/test/t/basic/test_box.cpp index 34789e815..73a45f4e2 100644 --- a/test/t/basic/test_box.cpp +++ b/test/t/basic/test_box.cpp @@ -47,7 +47,7 @@ SECTION("output_defined") { std::stringstream out; out << b; REQUIRE(out.str() == "(1.2,3.4,5.6,7.8)"); - REQUIRE((19.36 - b.size()) < 0.000001); + REQUIRE(b.size() == Approx(19.36).epsilon(0.000001)); } SECTION("output_undefined") { diff --git a/test/t/basic/test_entity_bits.cpp b/test/t/basic/test_entity_bits.cpp index b3f3e66af..a200f480b 100644 --- a/test/t/basic/test_entity_bits.cpp +++ b/test/t/basic/test_entity_bits.cpp @@ -20,6 +20,12 @@ SECTION("can_be_set_and_checked") { REQUIRE((entities & osmium::osm_entity_bits::node)); REQUIRE(! (entities & osmium::osm_entity_bits::way)); REQUIRE(entities == osmium::osm_entity_bits::node); + + REQUIRE(osmium::osm_entity_bits::node == osmium::osm_entity_bits::from_item_type(osmium::item_type::node)); + REQUIRE(osmium::osm_entity_bits::way == osmium::osm_entity_bits::from_item_type(osmium::item_type::way)); + REQUIRE(osmium::osm_entity_bits::relation == osmium::osm_entity_bits::from_item_type(osmium::item_type::relation)); + REQUIRE(osmium::osm_entity_bits::changeset == osmium::osm_entity_bits::from_item_type(osmium::item_type::changeset)); + REQUIRE(osmium::osm_entity_bits::area == osmium::osm_entity_bits::from_item_type(osmium::item_type::area)); } } diff --git a/test/t/basic/test_node.cpp b/test/t/basic/test_node.cpp index d5351d96f..6c2c899bd 100644 --- a/test/t/basic/test_node.cpp +++ b/test/t/basic/test_node.cpp @@ -21,6 +21,9 @@ SECTION("node_builder") { .set_uid(21) .set_timestamp(123); + REQUIRE(osmium::item_type::node == node.type()); + REQUIRE(node.type_is_in(osmium::osm_entity_bits::node)); + REQUIRE(node.type_is_in(osmium::osm_entity_bits::nwr)); REQUIRE(17l == node.id()); REQUIRE(17ul == node.positive_id()); REQUIRE(3 == node.version()); diff --git a/test/t/basic/test_object_comparisons.cpp b/test/t/basic/test_object_comparisons.cpp index 49733ce30..ffffbccb3 100644 --- a/test/t/basic/test_object_comparisons.cpp +++ b/test/t/basic/test_object_comparisons.cpp @@ -31,20 +31,20 @@ SECTION("order") { node1.set_version(1); node2.set_id(15); node2.set_version(2); - REQUIRE(true == node1 < node2); - REQUIRE(false == node1 > node2); + REQUIRE(true == (node1 < node2)); + REQUIRE(false == (node1 > node2)); node1.set_id(20); node1.set_version(1); node2.set_id(20); node2.set_version(2); - REQUIRE(true == node1 < node2); - REQUIRE(false == node1 > node2); + REQUIRE(true == (node1 < node2)); + REQUIRE(false == (node1 > node2)); node1.set_id(-10); node1.set_version(2); node2.set_id(-15); node2.set_version(1); - REQUIRE(true == node1 < node2); - REQUIRE(false == node1 > node2); + REQUIRE(true == (node1 < node2)); + REQUIRE(false == (node1 > node2)); } SECTION("order_types") { @@ -122,11 +122,11 @@ SECTION("order_types") { const osmium::Way& way = static_cast(*(++it)); const osmium::Relation& relation = static_cast(*(++it)); - REQUIRE(true == node1 < node2); - REQUIRE(true == node2 < way); - REQUIRE(false == node2 > way); - REQUIRE(true == way < relation); - REQUIRE(true == node1 < relation); + REQUIRE(true == (node1 < node2)); + REQUIRE(true == (node2 < way)); + REQUIRE(false == (node2 > way)); + REQUIRE(true == (way < relation)); + REQUIRE(true == (node1 < relation)); REQUIRE(true == osmium::object_order_type_id_version()(node1, node2)); REQUIRE(true == osmium::object_order_type_id_reverse_version()(node2, node1)); diff --git a/test/t/basic/test_way.cpp b/test/t/basic/test_way.cpp index 6d510ab3e..9d2ba0691 100644 --- a/test/t/basic/test_way.cpp +++ b/test/t/basic/test_way.cpp @@ -22,6 +22,9 @@ SECTION("way_builder") { .set_uid(21) .set_timestamp(123); + REQUIRE(osmium::item_type::way == way.type()); + REQUIRE(way.type_is_in(osmium::osm_entity_bits::way)); + REQUIRE(way.type_is_in(osmium::osm_entity_bits::node | osmium::osm_entity_bits::way)); REQUIRE(17 == way.id()); REQUIRE(3 == way.version()); REQUIRE(true == way.visible()); diff --git a/test/t/geom/test_mercator.cpp b/test/t/geom/test_mercator.cpp index c5c663700..a6ce2ee4a 100644 --- a/test/t/geom/test_mercator.cpp +++ b/test/t/geom/test_mercator.cpp @@ -13,25 +13,25 @@ SECTION("mercator_projection") { SECTION("low_level_mercator_functions") { osmium::geom::Coordinates c1(17.839, -3.249); osmium::geom::Coordinates r1 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c1)); - REQUIRE(std::abs(c1.x - r1.x) < 0.000001); - REQUIRE(std::abs(c1.y - r1.y) < 0.000001); + REQUIRE(r1.x == Approx(c1.x).epsilon(0.000001)); + REQUIRE(r1.y == Approx(c1.y).epsilon(0.000001)); osmium::geom::Coordinates c2(-89.2, 15.915); osmium::geom::Coordinates r2 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c2)); - REQUIRE(std::abs(c2.x - r2.x) < 0.000001); - REQUIRE(std::abs(c2.y - r2.y) < 0.000001); + REQUIRE(r2.x == Approx(c2.x).epsilon(0.000001)); + REQUIRE(r2.y == Approx(c2.y).epsilon(0.000001)); osmium::geom::Coordinates c3(180.0, 85.0); osmium::geom::Coordinates r3 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c3)); - REQUIRE(std::abs(c3.x - r3.x) < 0.000001); - REQUIRE(std::abs(c3.y - r3.y) < 0.000001); + REQUIRE(r3.x == Approx(c3.x).epsilon(0.000001)); + REQUIRE(r3.y == Approx(c3.y).epsilon(0.000001)); } SECTION("mercator_bounds") { osmium::Location mmax(180.0, osmium::geom::MERCATOR_MAX_LAT); osmium::geom::Coordinates c = osmium::geom::lonlat_to_mercator(mmax); - REQUIRE((c.x - c.y) < 0.001); - REQUIRE((osmium::geom::MERCATOR_MAX_LAT - osmium::geom::detail::y_to_lat(osmium::geom::detail::lon_to_x(180.0))) < 0.0000001); + REQUIRE(c.x == Approx(c.y).epsilon(0.001)); + REQUIRE(osmium::geom::detail::y_to_lat(osmium::geom::detail::lon_to_x(180.0)) == Approx(osmium::geom::MERCATOR_MAX_LAT).epsilon(0.0000001)); } } diff --git a/test/t/geom/test_projection.cpp b/test/t/geom/test_projection.cpp index 8d14ec598..2257d7f06 100644 --- a/test/t/geom/test_projection.cpp +++ b/test/t/geom/test_projection.cpp @@ -48,26 +48,26 @@ SECTION("project_location_3857") { { const osmium::Location loc(0.0, 0.0); const osmium::geom::Coordinates c {0.0, 0.0}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } { const osmium::Location loc(180.0, 0.0); const osmium::geom::Coordinates c {20037508.34, 0.0}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } { const osmium::Location loc(180.0, 0.0); const osmium::geom::Coordinates c {20037508.34, 0.0}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } { const osmium::Location loc(0.0, 85.0511288); const osmium::geom::Coordinates c {0.0, 20037508.34}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } } @@ -77,26 +77,26 @@ SECTION("project_location_mercator") { { const osmium::Location loc(0.0, 0.0); const osmium::geom::Coordinates c {0.0, 0.0}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } { const osmium::Location loc(180.0, 0.0); const osmium::geom::Coordinates c {20037508.34, 0.0}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } { const osmium::Location loc(180.0, 0.0); const osmium::geom::Coordinates c {20037508.34, 0.0}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } { const osmium::Location loc(0.0, 85.0511288); const osmium::geom::Coordinates c {0.0, 20037508.34}; - REQUIRE(std::abs(projection(loc).x - c.x) < 0.1); - REQUIRE(std::abs(projection(loc).y - c.y) < 0.1); + REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1)); + REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1)); } } @@ -108,23 +108,23 @@ SECTION("compare_mercators") { { const osmium::Location loc(4.2, 27.3); - REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1); - REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1); + REQUIRE(projection_merc(loc).x == Approx(projection_3857(loc).x).epsilon(0.1)); + REQUIRE(projection_merc(loc).y == Approx(projection_3857(loc).y).epsilon(0.1)); } { const osmium::Location loc(160.789, -42.42); - REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1); - REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1); + REQUIRE(projection_merc(loc).x == Approx(projection_3857(loc).x).epsilon(0.1)); + REQUIRE(projection_merc(loc).y == Approx(projection_3857(loc).y).epsilon(0.1)); } { const osmium::Location loc(-0.001, 0.001); - REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1); - REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1); + REQUIRE(projection_merc(loc).x == Approx(projection_3857(loc).x).epsilon(0.1)); + REQUIRE(projection_merc(loc).y == Approx(projection_3857(loc).y).epsilon(0.1)); } { const osmium::Location loc(-85.2, -85.2); - REQUIRE(std::abs(projection_merc(loc).x - projection_3857(loc).x) < 0.1); - REQUIRE(std::abs(projection_merc(loc).y - projection_3857(loc).y) < 0.1); + REQUIRE(projection_merc(loc).x == Approx(projection_3857(loc).x).epsilon(0.1)); + REQUIRE(projection_merc(loc).y == Approx(projection_3857(loc).y).epsilon(0.1)); } } diff --git a/test/t/index/test_id_to_location.cpp b/test/t/index/test_id_to_location.cpp index 4f873e1a0..bc2ec446a 100644 --- a/test/t/index/test_id_to_location.cpp +++ b/test/t/index/test_id_to_location.cpp @@ -3,12 +3,17 @@ #include #include +#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include template void test_func_all(TIndex& index) { @@ -67,8 +72,8 @@ SECTION("Dummy") { REQUIRE(0 == index1.used_memory()); } -SECTION("DenseMapMem") { - typedef osmium::index::map::DenseMapMem index_type; +SECTION("DenseMemArray") { + typedef osmium::index::map::DenseMemArray index_type; index_type index1; index1.reserve(1000); @@ -80,8 +85,8 @@ SECTION("DenseMapMem") { } #ifdef __linux__ -SECTION("DenseMapMmap") { - typedef osmium::index::map::DenseMapMmap index_type; +SECTION("DenseMmapArray") { + typedef osmium::index::map::DenseMmapArray index_type; index_type index1; test_func_all(index1); @@ -90,11 +95,11 @@ SECTION("DenseMapMmap") { test_func_real(index2); } #else -# pragma message "not running 'DenseMapMmap' test case on this machine" +# pragma message("not running 'DenseMapMmap' test case on this machine") #endif -SECTION("DenseMapFile") { - typedef osmium::index::map::DenseMapFile index_type; +SECTION("DenseFileArray") { + typedef osmium::index::map::DenseFileArray index_type; index_type index1; test_func_all(index1); @@ -103,8 +108,8 @@ SECTION("DenseMapFile") { test_func_real(index2); } -SECTION("SparseTable") { - typedef osmium::index::map::SparseTable index_type; +SECTION("SparseMemTable") { + typedef osmium::index::map::SparseMemTable index_type; index_type index1; test_func_all(index1); @@ -113,8 +118,8 @@ SECTION("SparseTable") { test_func_real(index2); } -SECTION("StlMap") { - typedef osmium::index::map::StlMap index_type; +SECTION("SparseMemMap") { + typedef osmium::index::map::SparseMemMap index_type; index_type index1; test_func_all(index1); @@ -123,8 +128,8 @@ SECTION("StlMap") { test_func_real(index2); } -SECTION("SparseMapMem") { - typedef osmium::index::map::SparseMapMem index_type; +SECTION("SparseMemArray") { + typedef osmium::index::map::SparseMemArray index_type; index_type index1; @@ -139,5 +144,23 @@ SECTION("SparseMapMem") { test_func_real(index2); } +SECTION("Dynamic map choice") { + typedef osmium::index::map::Map map_type; + const auto& map_factory = osmium::index::MapFactory::instance(); + + std::vector map_type_names = map_factory.map_types(); + REQUIRE(map_type_names.size() >= 5); + + for (const auto& map_type_name : map_type_names) { + std::unique_ptr index1 = map_factory.create_map(map_type_name); + index1->reserve(1000); + test_func_all(*index1); + + std::unique_ptr index2 = map_factory.create_map(map_type_name); + index2->reserve(1000); + test_func_real(*index2); + } +} + } diff --git a/test/t/index/test_typed_mmap.cpp b/test/t/index/test_typed_mmap.cpp index 90f8f6242..745535d95 100644 --- a/test/t/index/test_typed_mmap.cpp +++ b/test/t/index/test_typed_mmap.cpp @@ -48,7 +48,7 @@ SECTION("Remap") { REQUIRE(25ul == new_data[9]); } #else -# pragma message "not running 'Remap' test case on this machine" +# pragma message("not running 'Remap' test case on this machine") #endif SECTION("FileSize") { diff --git a/test/t/io/test_bzip2.cpp b/test/t/io/test_bzip2.cpp index 143f70d36..e6342e11d 100644 --- a/test/t/io/test_bzip2.cpp +++ b/test/t/io/test_bzip2.cpp @@ -1,4 +1,5 @@ #include "catch.hpp" +#include "utils.hpp" #include #include @@ -9,7 +10,9 @@ TEST_CASE("Bzip2") { SECTION("read_compressed_file") { - int fd = ::open("t/io/data_bzip2.txt.bz2", O_RDONLY); + std::string input_file = with_data_dir("t/io/data_bzip2.txt.bz2"); + + int fd = ::open(input_file.c_str(), O_RDONLY); REQUIRE(fd > 0); size_t size = 0; diff --git a/test/t/io/test_output_iterator.cpp b/test/t/io/test_output_iterator.cpp new file mode 100644 index 000000000..7a1f57027 --- /dev/null +++ b/test/t/io/test_output_iterator.cpp @@ -0,0 +1,37 @@ +#include "catch.hpp" + +#include +#include +#include + +TEST_CASE("output iterator") { + + SECTION("should be copy constructable") { + osmium::io::Header header; + osmium::io::Writer writer("test.osm", header, osmium::io::overwrite::allow); + osmium::io::OutputIterator out1(writer); + + osmium::io::OutputIterator out2(out1); + } + + SECTION("should be copy assignable") { + osmium::io::Header header; + osmium::io::Writer writer1("test1.osm", header, osmium::io::overwrite::allow); + osmium::io::Writer writer2("test2.osm", header, osmium::io::overwrite::allow); + + osmium::io::OutputIterator out1(writer1); + osmium::io::OutputIterator out2(writer2); + + out2 = out1; + } + + SECTION("should be incrementable") { + osmium::io::Header header; + osmium::io::Writer writer("test.osm", header, osmium::io::overwrite::allow); + osmium::io::OutputIterator out(writer); + + ++out; + } + +} + diff --git a/test/t/io/test_reader.cpp b/test/t/io/test_reader.cpp index 3be842b86..22f1aa24b 100644 --- a/test/t/io/test_reader.cpp +++ b/test/t/io/test_reader.cpp @@ -1,4 +1,5 @@ #include "catch.hpp" +#include "utils.hpp" #include #include @@ -19,7 +20,7 @@ struct CountHandler : public osmium::handler::Handler { TEST_CASE("Reader") { SECTION("reader can be initialized with file") { - osmium::io::File file("t/io/data.osm"); + osmium::io::File file(with_data_dir("t/io/data.osm")); osmium::io::Reader reader(file); osmium::handler::Handler handler; @@ -27,14 +28,14 @@ TEST_CASE("Reader") { } SECTION("reader can be initialized with string") { - osmium::io::Reader reader("t/io/data.osm"); + osmium::io::Reader reader(with_data_dir("t/io/data.osm")); osmium::handler::Handler handler; osmium::apply(reader, handler); } SECTION("should return invalid buffer after eof") { - osmium::io::File file("t/io/data.osm"); + osmium::io::File file(with_data_dir("t/io/data.osm")); osmium::io::Reader reader(file); REQUIRE(!reader.eof()); @@ -50,7 +51,7 @@ TEST_CASE("Reader") { } SECTION("should not hang when apply() is called twice on reader") { - osmium::io::File file("t/io/data.osm"); + osmium::io::File file(with_data_dir("t/io/data.osm")); osmium::io::Reader reader(file); osmium::handler::Handler handler; @@ -59,7 +60,7 @@ TEST_CASE("Reader") { } SECTION("should work with a buffer with uncompressed data") { - int fd = osmium::io::detail::open_for_reading("t/io/data.osm"); + int fd = osmium::io::detail::open_for_reading(with_data_dir("t/io/data.osm")); REQUIRE(fd >= 0); const size_t buffer_size = 1000; @@ -77,7 +78,7 @@ TEST_CASE("Reader") { } SECTION("should work with a buffer with gzip-compressed data") { - int fd = osmium::io::detail::open_for_reading("t/io/data.osm.gz"); + int fd = osmium::io::detail::open_for_reading(with_data_dir("t/io/data.osm.gz")); REQUIRE(fd >= 0); const size_t buffer_size = 1000; @@ -95,7 +96,7 @@ TEST_CASE("Reader") { } SECTION("should work with a buffer with bzip2-compressed data") { - int fd = osmium::io::detail::open_for_reading("t/io/data.osm.bz2"); + int fd = osmium::io::detail::open_for_reading(with_data_dir("t/io/data.osm.bz2")); REQUIRE(fd >= 0); const size_t buffer_size = 1000; diff --git a/test/valgrind.supp b/test/valgrind.supp index aa5024a82..f6ef1f65a 100644 --- a/test/valgrind.supp +++ b/test/valgrind.supp @@ -1,3 +1,12 @@ +#----------------------------------------------------------------------------- +# +# This file describes messages that Valgrind should suppress, because they +# are about problems outside Libosmium that we can't fix anyway. +# +# See http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress +# +#----------------------------------------------------------------------------- + { dl_error1 Memcheck:Cond