Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Thumbs.db
#######################
/_build*
/build/
/test/data/monaco.osrm*
/test/data/monaco*.osrm*
/test/data/ch
/test/data/mld
/cmake/postinst
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- FIXED: Work around compilation error due to a false-positive of array-bounds check in sol2 [#7317](https://github.com/Project-OSRM/osrm-backend/pull/7317)
- FIXED: Fix compilation with gcc >14 in release with LTO. [#7268](https://github.com/Project-OSRM/osrm-backend/issues/7268)
- Misc:
- ADDED: `--output` / `-o` option to osrm-extract for specifying custom output base path [#4930](https://github.com/Project-OSRM/osrm-backend/issues/4930)
- ADDED: `--max-header-size` to override the (automatically) configured maximum header size for osrm-routed [#7336](https://github.com/Project-OSRM/osrm-backend/pull/7336)
- CHANGED: Use boost::beast instead of own HTTP code for osrm-routed [#7328](https://github.com/Project-OSRM/osrm-backend/pull/7328)
- ADDED: `SHM_LOCK_DIR` environment variable for shared memory lock file directory [#7312](https://github.com/Project-OSRM/osrm-backend/pull/7312)
Expand Down
12 changes: 12 additions & 0 deletions docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ When running OSRM preprocessing commands you specify the profile with the --prof

`osrm-extract --profile ../profiles/car.lua planet-latest.osm.pbf`

### Using Multiple Profiles with the Same Input

You can extract the same OSM file with different profiles by specifying an output path:

```bash
osrm-extract --profile profiles/car.lua planet.osm.pbf --output /data/car
osrm-extract --profile profiles/bicycle.lua planet.osm.pbf --output /data/bicycle
osrm-extract --profile profiles/foot.lua planet.osm.pbf --output /data/foot
```

This avoids the need to create symbolic links to the input file.

## Processing flow
It's important to understand that profiles are used when preprocessing the OSM data, NOT at query time when routes are computed.

Expand Down
1 change: 1 addition & 0 deletions include/extractor/extractor_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct ExtractorConfig final : storage::IOConfig
std::filesystem::path input_path;
std::filesystem::path profile_path;
std::vector<std::filesystem::path> location_dependent_data_paths;
std::filesystem::path output_path;
std::string data_version;

unsigned requested_num_threads = 0;
Expand Down
14 changes: 12 additions & 2 deletions src/tools/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ return_code parseArguments(int argc,
boost::program_options::bool_switch(&extractor_config.dump_nbg_graph)
->implicit_value(true)
->default_value(false),
"Dump raw node-based graph to *.osrm file for debug purposes.");
"Dump raw node-based graph to *.osrm file for debug purposes.")(
"output,o",
boost::program_options::value<std::filesystem::path>(&extractor_config.output_path),
"Output base path for generated files (default: derived from input file name)");

bool dummy;
// hidden options, will be allowed on command line, but will not be
Expand Down Expand Up @@ -166,7 +169,14 @@ try

util::LogPolicy::GetInstance().SetLevel(verbosity);

extractor_config.UseDefaultOutputNames(extractor_config.input_path);
if (!extractor_config.output_path.empty())
{
extractor_config.UseDefaultOutputNames(extractor_config.output_path);
}
else
{
extractor_config.UseDefaultOutputNames(extractor_config.input_path);
}

if (1 > extractor_config.requested_num_threads)
{
Expand Down
16 changes: 16 additions & 0 deletions unit_tests/library/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "osrm/extractor_config.hpp"

#include <boost/algorithm/string.hpp>
#include <filesystem>
#include <thread>

// utility class to redirect stderr so we can test it
Expand Down Expand Up @@ -48,6 +49,21 @@ BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
BOOST_CHECK_NO_THROW(osrm::extract(config));
}

BOOST_AUTO_TEST_CASE(test_extract_with_custom_output_path)
{
osrm::ExtractorConfig config;
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
// Use custom output path instead of deriving from input
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco-custom-output");
config.profile_path = OSRM_TEST_DATA_DIR "/../../profiles/car.lua";
config.small_component_size = 1000;
config.requested_num_threads = std::thread::hardware_concurrency();
BOOST_CHECK_NO_THROW(osrm::extract(config));

// Verify output files exist at custom path
BOOST_CHECK(std::filesystem::exists(OSRM_TEST_DATA_DIR "/monaco-custom-output.osrm.names"));
}

BOOST_AUTO_TEST_CASE(test_setup_runtime_error)
{
osrm::ExtractorConfig config;
Expand Down
Loading