Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move argparse boilerplate code to private header #4169

Merged
merged 24 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ec6b9b6
refactor valhalla_add_elevation a bit and move the mjolnir util to baldr
nilsnolde Jun 17, 2023
1132e0c
add -j flag to all multithreaded executables
nilsnolde Jun 17, 2023
71918ab
changelog
nilsnolde Jun 17, 2023
95f299c
remove deprecated heder
nilsnolde Jun 17, 2023
918ecfa
oops
nilsnolde Jun 17, 2023
6b8f931
moved the argparse boilerplate code to a private header which all pro…
nilsnolde Jun 17, 2023
2ff4f01
cxxopts entry not needed in cmake
nilsnolde Jun 17, 2023
1c78a88
add missing midgard header
nilsnolde Jun 17, 2023
28b1d89
some fixes
nilsnolde Jun 17, 2023
c4a5e50
huch, quite a logical mistake..
nilsnolde Jun 17, 2023
a22ec55
Merge branch 'nn-concurrency2' into nn--exe-boilerplate
nilsnolde Jun 17, 2023
2e7e735
few nits
nilsnolde Jun 17, 2023
81785e4
more fixes
nilsnolde Jun 17, 2023
57a76d7
remove left-overs
nilsnolde Jun 17, 2023
30ff914
keep deduplication in the executable valhalla_add_elevation
nilsnolde Jun 21, 2023
1ca6677
merge nn-concurrency2
nilsnolde Jun 21, 2023
509e3b2
keep deduplication in the executable valhalla_add_elevation
nilsnolde Jun 21, 2023
a919eb6
Merge branch 'nn-concurrency2' into nn--exe-boilerplate
nilsnolde Jun 21, 2023
9d81545
use __FILE__ to find the executable name; overhaul src/CMakeLists.txt…
nilsnolde Jun 21, 2023
d0b33c3
Merge branch 'master' into nn--exe-boilerplate
nilsnolde Jun 23, 2023
3460c08
move get_tile_ids function into the executable
nilsnolde Jul 4, 2023
f042793
Merge branch 'master' into nn--exe-boilerplate
nilsnolde Jul 4, 2023
f4575c9
add filesystem::stem() to return the file name without extension and …
nilsnolde Jul 4, 2023
79fbea3
Merge branch 'master' into nn--exe-boilerplate
nilsnolde Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove left-overs
  • Loading branch information
nilsnolde committed Jun 17, 2023
commit 57a76d72e215fd80619735ff338d6819edf96abb
37 changes: 0 additions & 37 deletions src/mjolnir/valhalla_add_elevation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,6 @@ using namespace valhalla::mjolnir;
* - tiles - stays for the path to a tile file.
* */

std::deque<GraphId> get_tile_ids(const boost::property_tree::ptree& pt,
const std::vector<std::string>& tiles) {
if (tiles.empty())
return {};

// deduplicate
std::unordered_set<std::string> tiles_set(tiles.begin(), tiles.end());

auto tile_dir = pt.get_optional<std::string>("mjolnir.tile_dir");
if (!tile_dir || !filesystem::exists(*tile_dir)) {
LOG_WARN("Tile storage directory does not exist");
return {};
}

std::deque<GraphId> tilequeue;
GraphReader reader(pt.get_child("mjolnir"));
std::for_each(std::begin(tiles_set), std::end(tiles_set), [&](const auto& tile) {
auto tile_id = GraphTile::GetTileId(*tile_dir + tile);
GraphId local_tile_id(tile_id.tileid(), tile_id.level(), tile_id.id());
if (!reader.DoesTileExist(local_tile_id)) {
LOG_WARN("Provided tile doesn't belong to the tile directory from config file");
return;
}

tilequeue.push_back(tile_id);
});

return tilequeue;
}

bool parse_arguments(int argc, char** argv) {
}

int main(int argc, char** argv) {
const std::string program = "valhalla_add_elevation";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get this by messing around with __FILE__ then you dont have to type every single one though i guess it has to be the name of the source file (which we do adhere to)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jep, that worked, thanks! made it a function in argparse_utils.h

// args
Expand Down Expand Up @@ -114,10 +81,6 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}

if (!parse_arguments(argc, argv)) {
return EXIT_FAILURE;
};

auto tile_ids = get_tile_ids(config, tiles);
if (tile_ids.empty()) {
std::cerr << "Failed to load tiles\n\n";
Expand Down
3 changes: 0 additions & 3 deletions src/mjolnir/valhalla_build_admins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

#include "../argparse_utils.h"

bool ParseArguments(int argc, char* argv[]) {
}

int main(int argc, char** argv) {
const std::string program = "valhalla_build_admins";
// args
Expand Down
6 changes: 4 additions & 2 deletions valhalla/baldr/graph_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace valhalla {
namespace baldr {

std::deque<baldr::GraphId> get_tile_ids(const boost::property_tree::ptree& pt,
const std::unordered_set<std::string>& tiles) {
const std::vector<std::string>& tiles) {
if (tiles.empty())
return {};

Expand All @@ -26,9 +26,11 @@ std::deque<baldr::GraphId> get_tile_ids(const boost::property_tree::ptree& pt,
return {};
}

std::unordered_set<std::string> tiles_set{tiles.begin(), tiles.end()};

std::deque<baldr::GraphId> tilequeue;
baldr::GraphReader reader(pt.get_child("mjolnir"));
std::for_each(std::begin(tiles), std::end(tiles), [&](const auto& tile) {
std::for_each(std::begin(tiles_set), std::end(tiles_set), [&](const auto& tile) {
auto tile_id = baldr::GraphTile::GetTileId(*tile_dir + tile);
baldr::GraphId local_tile_id(tile_id.tileid(), tile_id.level(), tile_id.id());
if (!reader.DoesTileExist(local_tile_id)) {
Expand Down