Merge commit 'bb78bc8fe305eef39ca0a5d5e9dedc466f803dfb' into develop

This commit is contained in:
Dennis Luxen
2015-02-05 15:13:48 +01:00
215 changed files with 2699 additions and 1297 deletions
+92 -41
View File
@@ -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")
#-----------------------------------------------------------------------------
+2 -2
View File
@@ -18,12 +18,12 @@
#include <osmium/handler/dump.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/sparse_table.hpp>
#include <osmium/index/map/sparse_mem_table.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/visitor.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
class WKTDump : public osmium::handler::Handler {
@@ -16,15 +16,15 @@
#include <osmium/io/xml_input.hpp>
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp>
#include <osmium/index/map/mmap_vector_file.hpp>
#include <osmium/index/map/dense_mmap_array.hpp>
#include <osmium/index/map/dense_file_array.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
//typedef osmium::index::map::DenseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::DenseMapFile<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
+6 -5
View File
@@ -14,15 +14,16 @@
#include <boost/program_options.hpp>
#include <osmium/index/map/mmap_vector_file.hpp>
#include <osmium/index/map/dense_file_array.hpp>
#include <osmium/index/map/sparse_file_array.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/types.hpp>
template <typename TKey, typename TValue>
class IndexSearch {
typedef typename osmium::index::map::DenseMapFile<TKey, TValue> dense_index_type;
typedef typename osmium::index::map::SparseMapFile<TKey, TValue> sparse_index_type;
typedef typename osmium::index::map::DenseFileArray<TKey, TValue> dense_index_type;
typedef typename osmium::index::map::SparseFileArray<TKey, TValue> 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<osmium::unsigned_object_id_type> search_keys() const {
+7 -8
View File
@@ -24,27 +24,26 @@
#include <osmium/handler/disk_store.hpp>
#include <osmium/handler/object_relations.hpp>
#include <osmium/index/map/stl_vector.hpp>
#include <osmium/index/multimap/stl_multimap.hpp>
#include <osmium/index/multimap/stl_vector.hpp>
#include <osmium/index/map/sparse_mem_array.hpp>
#include <osmium/index/multimap/sparse_mem_multimap.hpp>
#include <osmium/index/multimap/sparse_mem_array.hpp>
#include <osmium/index/multimap/hybrid.hpp>
// ==============================================================================
// Choose the following depending on the size of the input OSM files:
// ==============================================================================
// for smaller OSM files (extracts)
typedef osmium::index::map::SparseMapMem<osmium::unsigned_object_id_type, size_t> offset_index_type;
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, size_t> offset_index_type;
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, size_t> offset_index_type;
//typedef osmium::index::map::SparseMapFile<osmium::unsigned_object_id_type, size_t> offset_index_type;
typedef osmium::index::multimap::SparseMultimapMem<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
//typedef osmium::index::multimap::StlMultimap<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
typedef osmium::index::multimap::SparseMemArray<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
//typedef osmium::index::multimap::SparseMemMultimap<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
//typedef osmium::index::multimap::Hybrid<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
// ==============================================================================
// for very large OSM files (planet)
//typedef osmium::index::map::DenseMapMmap<osmium::unsigned_object_id_type, size_t> offset_index_type;
//typedef osmium::index::map::DenseMapMem map_type;
//typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, size_t> offset_index_type;
// ==============================================================================
void print_help() {
+27 -32
View File
@@ -10,25 +10,7 @@
#include <iostream>
#include <getopt.h>
#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 <ogr_api.h>
# include <ogrsf_frmts.h>
#pragma GCC diagnostic pop
// usually you only need one or two of these
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/sparse_table.hpp>
#include <osmium/index/map/stl_map.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp>
#include <osmium/index/map/all.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp>
@@ -37,10 +19,7 @@
#include <osmium/handler.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
//typedef osmium::index::map::StlMap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> 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<osmium::unsigned_object_id_type, osmium::Location>::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_type> 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);
}
+6 -19
View File
@@ -13,24 +13,11 @@
#include <iostream>
#include <getopt.h>
#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 <ogr_api.h>
# include <ogrsf_frmts.h>
#pragma GCC diagnostic pop
// usually you only need one or two of these
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/sparse_table.hpp>
#include <osmium/index/map/stl_map.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp>
#include <osmium/index/map/sparse_mem_table.hpp>
#include <osmium/index/map/sparse_mem_map.hpp>
#include <osmium/index/map/sparse_mmap_array.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp>
@@ -45,9 +32,9 @@
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
//typedef osmium::index::map::StlMap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::SparseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
+6 -29
View File
@@ -15,24 +15,7 @@
#include <iostream>
#include <getopt.h>
#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 <ogr_api.h>
# include <ogrsf_frmts.h>
#pragma GCC diagnostic pop
// usually you only need one or two of these
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/sparse_table.hpp>
#include <osmium/index/map/stl_map.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp>
#include <osmium/index/map/sparse_mem_array.hpp>
#include <osmium/visitor.hpp>
@@ -43,13 +26,8 @@
#include <osmium/handler.hpp>
#include <osmium/experimental/flex_reader.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
//typedef osmium::index::map::StlMap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
typedef osmium::handler::NodeLocationsForWays<index_type> 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<location_handler_type> exr(input_filename, osmium::osm_entity_bits::object);
index_type index_pos;
location_handler_type location_handler(index_pos);
osmium::experimental::FlexReader<location_handler_type> exr(input_filename, location_handler, osmium::osm_entity_bits::object);
MyOGRHandler ogr_handler(output_format, output_filename);
+4 -4
View File
@@ -16,15 +16,15 @@
#include <osmium/io/xml_input.hpp>
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp>
#include <osmium/index/map/mmap_vector_file.hpp>
#include <osmium/index/map/dense_file_array.hpp>
#include <osmium/index/map/dense_mmap_array.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
//typedef osmium::index::map::DenseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::DenseMapFile<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
//typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;