Skip to content

Commit

Permalink
Merge branch 'planet-on-32gb' into protozero
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow committed Dec 26, 2023
2 parents 181c3c7 + 657da1a commit 576fd37
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions include/options_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ namespace OptionsParser {
bool uncompressedNodes = false;
bool uncompressedWays = false;
bool materializeGeometries = false;
// lazyGeometries is the inverse of materializeGeometries. It can be passed
// to override an implicit materializeGeometries, as in the non-store case.
bool lazyGeometries = false;
bool shardStores = false;
};

Expand Down
13 changes: 9 additions & 4 deletions src/options_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ po::options_description getParser(OptionsParser::Options& options) {
("compact",po::bool_switch(&options.osm.compact), "use faster data structure for node lookups\nNOTE: This requires the input to be renumbered (osmium renumber)")
("no-compress-nodes", po::bool_switch(&options.osm.uncompressedNodes), "store nodes uncompressed")
("no-compress-ways", po::bool_switch(&options.osm.uncompressedWays), "store ways uncompressed")
("materialize-geometries", po::bool_switch(&options.osm.materializeGeometries), "materialize geometries")
("lazy-geometries", po::bool_switch(&options.osm.lazyGeometries), "generate geometries from the OSM stores; uses less memory")
("materialize-geometries", po::bool_switch(&options.osm.materializeGeometries), "materialize geometries; uses more memory")
("shard-stores", po::bool_switch(&options.osm.shardStores), "use an alternate reading/writing strategy for low-memory machines")
("threads",po::value<uint32_t>(&options.threadNum)->default_value(0), "number of threads (automatically detected if 0)")
;
Expand Down Expand Up @@ -68,12 +69,16 @@ OptionsParser::Options OptionsParser::parse(const int argc, const char* argv[])
if (options.osm.storeFile.empty()) {
options.osm.materializeGeometries = true;
} else {
if (options.osm.fast) {
options.osm.materializeGeometries = true;
} else {
if (!options.osm.fast) {
options.osm.shardStores = true;
}
}

// You can pass --lazy-geometries to override the default of materialized geometries for
// the non-store case.
if (options.osm.lazyGeometries)
options.osm.materializeGeometries = false;


if (vm.count("help")) {
options.showHelp = true;
Expand Down
15 changes: 14 additions & 1 deletion test/options_parser.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ MU_TEST(test_options_parser) {
mu_check(!opts.osm.shardStores);
}

// --lazy-geometries overrides default
{
std::vector<std::string> args = {"--output", "foo.mbtiles", "--input", "ontario.pbf", "--lazy-geometries"};
auto opts = parse(args);
mu_check(opts.inputFiles.size() == 1);
mu_check(opts.inputFiles[0] == "ontario.pbf");
mu_check(opts.outputFile == "foo.mbtiles");
mu_check(opts.outputMode == OutputMode::MBTiles);
mu_check(!opts.osm.materializeGeometries);
mu_check(opts.osm.lazyGeometries);
mu_check(!opts.osm.shardStores);
}

// --store should optimize for reduced memory
{
std::vector<std::string> args = {"--output", "foo.mbtiles", "--input", "ontario.pbf", "--store", "/tmp/store"};
Expand All @@ -75,7 +88,7 @@ MU_TEST(test_options_parser) {
mu_check(opts.outputFile == "foo.pmtiles");
mu_check(opts.outputMode == OutputMode::PMTiles);
mu_check(opts.osm.storeFile == "/tmp/store");
mu_check(opts.osm.materializeGeometries);
mu_check(!opts.osm.materializeGeometries);
mu_check(!opts.osm.shardStores);
}

Expand Down

0 comments on commit 576fd37

Please sign in to comment.