Merges node-osrm into repository

Build with

    cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=On -DENABLE_MASON=On
This commit is contained in:
Daniel J. Hofmann
2017-03-01 18:27:57 +01:00
committed by Patrick Niklaus
parent ff238c2724
commit 2351b5a084
53 changed files with 4871 additions and 244 deletions
+8 -8
View File
@@ -5,7 +5,7 @@
#include <vector>
// Somewhere in 2b8dd9343d5e615afc9c67bcc7028a63 Monaco
// Somewhere in d41d8cd98f00b204e9800998ecf8427e Berlin
// Convenience aliases
using Longitude = osrm::util::FloatLongitude;
@@ -15,21 +15,21 @@ using Locations = std::vector<Location>;
inline Location get_dummy_location()
{
return {osrm::util::FloatLongitude{7.437069}, osrm::util::FloatLatitude{43.749249}};
return {osrm::util::FloatLongitude{13.388860}, osrm::util::FloatLatitude{52.517037}};
}
inline Locations get_locations_in_small_component()
{
return {{Longitude{7.438023}, Latitude{43.746465}},
{Longitude{7.439263}, Latitude{43.746543}},
{Longitude{7.438190}, Latitude{43.747560}}};
return {{Longitude{13.459765}, Latitude{52.543193}},
{Longitude{13.461455}, Latitude{52.542381}},
{Longitude{13.462940}, Latitude{52.541774}}};
}
inline Locations get_locations_in_big_component()
{
return {{Longitude{7.415800}, Latitude{43.734132}},
{Longitude{7.417710}, Latitude{43.736721}},
{Longitude{7.421315}, Latitude{43.738814}}};
return {{Longitude{13.442631}, Latitude{52.551110}},
{Longitude{13.441193}, Latitude{52.549506}},
{Longitude{13.439648}, Latitude{52.547705}}};
}
#endif
+1 -1
View File
@@ -19,7 +19,7 @@ BOOST_AUTO_TEST_CASE(test_extract_with_invalid_config)
BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
{
osrm::ExtractorConfig config;
config.input_path = {OSRM_TEST_DATA_DIR "/monaco.osm.pbf"};
config.input_path = OSRM_TEST_DATA_DIR "/berlin.osm.pbf";
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
BOOST_CHECK_NO_THROW(osrm::extract(config));
}
+5 -5
View File
@@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(test_trip_limits)
using namespace osrm;
EngineConfig config;
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.storage_config = {OSRM_TEST_DATA_DIR "/berlin_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_trip = 2;
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(test_route_limits)
using namespace osrm;
EngineConfig config;
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.storage_config = {OSRM_TEST_DATA_DIR "/berlin_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_viaroute = 2;
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(test_table_limits)
using namespace osrm;
EngineConfig config;
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.storage_config = {OSRM_TEST_DATA_DIR "/berlin_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_distance_table = 2;
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(test_match_limits)
using namespace osrm;
EngineConfig config;
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.storage_config = {OSRM_TEST_DATA_DIR "/berlin_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_map_matching = 2;
@@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_limits)
using namespace osrm;
EngineConfig config;
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.storage_config = {OSRM_TEST_DATA_DIR "/berlin_CH.osrm"};
config.use_shared_memory = false;
config.max_results_nearest = 2;
+1 -1
View File
@@ -19,7 +19,7 @@ BOOST_AUTO_TEST_CASE(test_match)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
MatchParameters params;
params.coordinates.push_back(get_dummy_location());
+4 -4
View File
@@ -16,7 +16,7 @@ BOOST_AUTO_TEST_SUITE(nearest)
BOOST_AUTO_TEST_CASE(test_nearest_response)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response)
BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates)
BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates)
BOOST_AUTO_TEST_CASE(test_nearest_response_for_location_in_small_component)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
+3 -3
View File
@@ -14,7 +14,7 @@ BOOST_AUTO_TEST_CASE(test_ch)
using namespace osrm;
EngineConfig config;
config.use_shared_memory = false;
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
config.algorithm = EngineConfig::Algorithm::CH;
OSRM osrm{config};
}
@@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(test_corech)
using namespace osrm;
EngineConfig config;
config.use_shared_memory = false;
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_CoreCH.osrm");
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/berlin_CoreCH.osrm");
config.algorithm = EngineConfig::Algorithm::CoreCH;
OSRM osrm{config};
}
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_mld)
using namespace osrm;
EngineConfig config;
config.use_shared_memory = false;
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_MLD.osrm");
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/berlin_MLD.osrm");
config.algorithm = EngineConfig::Algorithm::MLD;
OSRM osrm{config};
}
+18 -24
View File
@@ -17,7 +17,7 @@ BOOST_AUTO_TEST_SUITE(route)
BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -25,44 +25,38 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
params.steps = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.generate_hints = false;
json::Object result;
const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok);
// unset snapping dependent hint
for (auto &itr : result.values["waypoints"].get<json::Array>().values)
itr.get<json::Object>().values["hint"] = "";
const auto location = json::Array{{{7.437070}, {43.749248}}};
const auto location = json::Array{{{13.3888}, {52.517033}}};
json::Object reference{
{{"code", "Ok"},
{"waypoints",
json::Array{
{json::Object{
{{"name", "Boulevard du Larvotto"}, {"location", location}, {"hint", ""}}},
json::Object{
{{"name", "Boulevard du Larvotto"}, {"location", location}, {"hint", ""}}}}}},
json::Array{{json::Object{{{"name", "Friedrichstraße"}, {"location", location}}},
json::Object{{{"name", "Friedrichstraße"}, {"location", location}}}}}},
{"routes",
json::Array{{json::Object{
{{"distance", 0.},
{"duration", 0.},
{"weight", 0.},
{"weight_name", "routability"},
{"geometry", "yw_jGupkl@??"},
{"geometry", "mfp_I__vpA??"},
{"legs",
json::Array{{json::Object{
{{"distance", 0.},
{"duration", 0.},
{"weight", 0.},
{"summary", "Boulevard du Larvotto"},
{"summary", "Friedrichstraße"},
{"steps",
json::Array{{{json::Object{{{"duration", 0.},
{"distance", 0.},
{"weight", 0.},
{"geometry", "yw_jGupkl@??"},
{"name", "Boulevard du Larvotto"},
{"geometry", "mfp_I__vpA??"},
{"name", "Friedrichstraße"},
{"mode", "driving"},
{"maneuver",
json::Object{{
@@ -81,8 +75,8 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
json::Object{{{"duration", 0.},
{"distance", 0.},
{"weight", 0.},
{"geometry", "yw_jGupkl@"},
{"name", "Boulevard du Larvotto"},
{"geometry", "mfp_I__vpA"},
{"name", "Friedrichstraße"},
{"mode", "driving"},
{"maneuver",
json::Object{{{"location", location},
@@ -103,7 +97,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -255,7 +249,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -290,7 +284,7 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component)
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_big_component)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -325,7 +319,7 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_big_component)
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_across_components)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -362,7 +356,7 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_across_components)
BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -382,7 +376,7 @@ BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints)
BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
@@ -416,7 +410,7 @@ BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
using namespace osrm;
+3 -3
View File
@@ -19,7 +19,7 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
TableParameters params;
params.coordinates.push_back(get_dummy_location());
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
TableParameters params;
params.coordinates.push_back(get_dummy_location());
@@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(test_table_three_coordinates_matrix)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
TableParameters params;
params.coordinates.push_back(get_dummy_location());
+17 -33
View File
@@ -24,16 +24,17 @@ BOOST_AUTO_TEST_CASE(test_tile)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
// This tile should contain most of monaco
TileParameters params{17059, 11948, 15};
// Tile within Berlin dataset at Hackescher Markt (13.40294, 52.52330)
TileParameters params{140831, 85967, 18};
std::string result;
const auto rc = osrm.Tile(params, result);
BOOST_CHECK(rc == Status::Ok);
BOOST_CHECK(result.size() > 114000);
BOOST_CHECK_GT(result.size(), 1500);
BOOST_CHECK_LT(result.size(), 2500);
protozero::pbf_reader tile_message(result);
tile_message.next();
@@ -208,22 +209,24 @@ BOOST_AUTO_TEST_CASE(test_tile)
}
BOOST_CHECK_EQUAL(number_of_turn_keys, 3);
BOOST_CHECK(number_of_turns_found > 700);
BOOST_CHECK_GT(number_of_turns_found, 10); // roughly ten turns in the tile
}
BOOST_AUTO_TEST_CASE(test_tile_turns)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
// Small tile where we can test all the values
TileParameters params{272953, 191177, 19};
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
// Tile within Berlin dataset at Hackescher Markt (13.40294, 52.52330)
TileParameters params{140831, 85967, 18};
std::string result;
const auto rc = osrm.Tile(params, result);
BOOST_CHECK(rc == Status::Ok);
BOOST_CHECK_GT(result.size(), 128);
BOOST_CHECK_GT(result.size(), 1500);
BOOST_CHECK_LT(result.size(), 2500);
protozero::pbf_reader tile_message(result);
tile_message.next();
@@ -331,7 +334,7 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
}
std::sort(actual_turn_penalties.begin(), actual_turn_penalties.end());
const std::vector<float> expected_turn_penalties = {
0, 0, 0, 0, 0, 0, .1f, .1f, .3f, .4f, 1.2f, 1.9f, 5.3f, 5.5f, 5.8f, 7.1f, 7.2f, 7.2f};
0., 0., 0., 0., 0., 0., 0., 0., 0.1, 0.7, 5.2, 7.1, 7.4};
CHECK_EQUAL_RANGE(actual_turn_penalties, expected_turn_penalties);
// Verify the expected turn angles
@@ -343,7 +346,7 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
}
std::sort(actual_turn_angles.begin(), actual_turn_angles.end());
const std::vector<std::int64_t> expected_turn_angles = {
-122, -120, -117, -65, -57, -30, -28, -3, -2, 2, 3, 28, 30, 57, 65, 117, 120, 122};
-142, -118, -49, -13, -4, -2, -2, 2, 4, 13, 34, 49, 118};
CHECK_EQUAL_RANGE(actual_turn_angles, expected_turn_angles);
// Verify the expected bearings
@@ -355,7 +358,7 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
}
std::sort(actual_turn_bearings.begin(), actual_turn_bearings.end());
const std::vector<std::int64_t> expected_turn_bearings = {
49, 49, 107, 107, 169, 169, 171, 171, 229, 229, 257, 257, 286, 286, 349, 349, 352, 352};
75, 75, 124, 124, 128, 242, 242, 255, 304, 304, 306, 308, 308};
CHECK_EQUAL_RANGE(actual_turn_bearings, expected_turn_bearings);
}
@@ -363,7 +366,7 @@ BOOST_AUTO_TEST_CASE(test_tile_speeds)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
// Small tile so we can test all the values
// TileParameters params{272953, 191177, 19};
@@ -499,26 +502,7 @@ BOOST_AUTO_TEST_CASE(test_tile_speeds)
actual_names.push_back(string_vals[i]);
}
std::sort(actual_names.begin(), actual_names.end());
const std::vector<std::string> expected_names = {"Avenue du Carnier",
"Avenue du Carnier",
"Avenue du Carnier",
"Avenue du Carnier",
"Avenue du Carnier",
"Avenue du Maréchal Foch",
"Avenue du Maréchal Foch",
"Avenue du Maréchal Foch",
"Avenue du Maréchal Foch",
"Avenue du Maréchal Foch",
"Avenue du Maréchal Foch",
"Avenue du Professeur Langevin",
"Avenue du Professeur Langevin",
"Avenue du Professeur Langevin",
"Montée de la Crémaillère",
"Montée de la Crémaillère",
"Rue Jules Ferry",
"Rue Jules Ferry",
"Rue Professeur Calmette",
"Rue Professeur Calmette"};
const std::vector<std::string> expected_names = {};
BOOST_CHECK(actual_names == expected_names);
}
+7 -7
View File
@@ -18,7 +18,7 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
@@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto locations = get_locations_in_big_component();
TripParameters params;
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_across_components)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto small = get_locations_in_small_component();
const auto big = get_locations_in_big_component();
@@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(test_tfse_1)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(test_tfse_2)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto locations = get_locations_in_big_component();
TripParameters params;
@@ -265,7 +265,7 @@ BOOST_AUTO_TEST_CASE(test_tfse_illegal_parameters)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto locations = get_locations_in_big_component();
auto params = osrm::TripParameters();
@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(test_tfse_illegal_parameters)
BOOST_AUTO_TEST_CASE(test_tfse_legal_parameters)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/berlin_CH.osrm");
const auto locations = get_locations_in_big_component();
json::Object result;
TripParameters params;