diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f15ea664..3e5c6aa4b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ * FIXED: Fixed roundoff issue in Tiles Row and Col methods [#4585](https://github.com/valhalla/valhalla/pull/4585) * ADDED: isochrone proper polygon support & pbf output for isochrone [#4575](https://github.com/valhalla/valhalla/pull/4575) * ADDED: return isotile grid as geotiff [#4594](https://github.com/valhalla/valhalla/pull/4594) + * FIXED: Conflict with signinfo's temporary linguistic node sequence file caused test failures. [#4625](https://github.com/valhalla/valhalla/pull/4625) ## Release Date: 2023-05-11 Valhalla 3.4.0 * **Removed** diff --git a/test/graphparser.cc b/test/graphparser.cc index 6038aaec4e..4df5671a1f 100644 --- a/test/graphparser.cc +++ b/test/graphparser.cc @@ -28,6 +28,16 @@ namespace { const std::string config_file = "test/test_config_gp"; +std::string ways_file = "test_ways.bin"; +std::string way_nodes_file = "test_way_nodes.bin"; +std::string nodes_file = "test_nodes.bin"; +std::string edges_file = "test_edges.bin"; +std::string access_file = "test_access.bin"; +std::string from_restriction_file = "test_from_complex_restrictions.bin"; +std::string to_restriction_file = "test_to_complex_restrictions.bin"; +std::string bss_nodes_file = "test_bss_nodes.bin"; +std::string linguistic_node_file = "test_linguistic_node.bin"; + const auto node_predicate = [](const OSMWayNode& a, const OSMWayNode& b) { return a.node.osmid_ < b.node.osmid_; }; @@ -48,18 +58,55 @@ OSMWay GetWay(uint32_t way_id, sequence& ways) { return *found; } +void DoConfig() { + std::ofstream file; + try { + file.open(config_file, std::ios_base::trunc); + file << "{ \ + \"mjolnir\": { \ + \"id_table_size\": 1000, \ + \"tile_dir\": \"test/data/parser_tiles\" \ + } \ + }"; + } catch (...) {} + file.close(); +} + +// must do clean up here vs TearDown() as we are building data +// in the same directory multiple times +void CleanUp() { + if (filesystem::exists(ways_file)) + filesystem::remove(ways_file); + + if (filesystem::exists(way_nodes_file)) + filesystem::remove(way_nodes_file); + + if (filesystem::exists(nodes_file)) + filesystem::remove(nodes_file); + + if (filesystem::exists(edges_file)) + filesystem::remove(edges_file); + + if (filesystem::exists(access_file)) + filesystem::remove(access_file); + + if (filesystem::exists(from_restriction_file)) + filesystem::remove(from_restriction_file); + + if (filesystem::exists(to_restriction_file)) + filesystem::remove(to_restriction_file); + + if (filesystem::exists(bss_nodes_file)) + filesystem::remove(bss_nodes_file); + + if (filesystem::exists(linguistic_node_file)) + filesystem::remove(linguistic_node_file); +} + void BollardsGatesAndAccess(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/liechtenstein-latest.osm.pbf"}, @@ -206,27 +253,13 @@ void BollardsGatesAndAccess(const std::string& config_file) { EXPECT_TRUE((bike_network & kMcn) && (bike_network & kRcn) && way_75786176.bike_network() == 0) << "rcn and mtb not marked on way 75786176."; - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } void RemovableBollards(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/rome.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -250,27 +283,13 @@ void RemovableBollards(const std::string& config_file) { kEmergencyAccess | kPedestrianAccess | kWheelchairAccess | kBicycleAccess | kMopedAccess | kMotorcycleAccess); - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } void Exits(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/harrisburg.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -302,27 +321,13 @@ void Exits(const std::string& config_file) { EXPECT_EQ(osmdata.node_names.name(node.exit_to_index()), "PA441") << "node exit_to not set correctly ."; - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } void Baltimore(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/baltimore.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -430,27 +435,13 @@ void Baltimore(const std::string& config_file) { FAIL() << "98040438 restriction test failed."; } - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } void Bike(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/bike.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -528,26 +519,13 @@ void Bike(const std::string& config_file) { EXPECT_TRUE(way_156539491.moped_forward()); EXPECT_TRUE(way_156539491.bike_backward()); - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } void Bus(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/bus.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -610,27 +588,13 @@ void Bus(const std::string& config_file) { EXPECT_FALSE(way_225895737.bus_backward()); EXPECT_FALSE(way_225895737.bike_backward()); - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } void BicycleTrafficSignals(const std::string& config_file) { boost::property_tree::ptree conf; rapidjson::read_json(config_file, conf); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/nyc.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -661,27 +625,7 @@ void BicycleTrafficSignals(const std::string& config_file) { << "Bike rental at a shop not marked as intersection." */ - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); -} - -void DoConfig() { - std::ofstream file; - try { - file.open(config_file, std::ios_base::trunc); - file << "{ \ - \"mjolnir\": { \ - \"id_table_size\": 1000, \ - \"tile_dir\": \"test/data/parser_tiles\" \ - } \ - }"; - } catch (...) {} - file.close(); + CleanUp(); } TEST(GraphParser, TestBollardsGatesAndAccess) { @@ -726,16 +670,6 @@ TEST(GraphParser, TestImportBssNode) { conf.put("mjolnir.import_bike_share_stations", true); - std::string ways_file = "test_ways.bin"; - std::string way_nodes_file = "test_way_nodes.bin"; - std::string nodes_file = "test_nodes.bin"; - std::string edges_file = "test_edges.bin"; - std::string access_file = "test_access.bin"; - std::string from_restriction_file = "test_from_complex_restrictions.bin"; - std::string to_restriction_file = "test_to_complex_restrictions.bin"; - std::string bss_nodes_file = "test_bss_nodes.bin"; - std::string linguistic_node_file = "test_linguistic_node.bin"; - auto osmdata = PBFGraphParser::ParseWays(conf.get_child("mjolnir"), {VALHALLA_SOURCE_DIR "test/data/rome.osm.pbf"}, ways_file, way_nodes_file, access_file); @@ -825,15 +759,7 @@ TEST(GraphParser, TestImportBssNode) { kPedestrianAccess); check_edge_attribute(local_tile->directededge(edge_idx_2 + count_2 - 2), kPedestrianAccess, kBicycleAccess); - - filesystem::remove(ways_file); - filesystem::remove(way_nodes_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(access_file); - filesystem::remove(from_restriction_file); - filesystem::remove(to_restriction_file); - filesystem::remove(bss_nodes_file); - filesystem::remove(linguistic_node_file); + CleanUp(); } } // namespace diff --git a/test/signinfo.cc b/test/signinfo.cc index a64ba0f8b9..c544bad0d6 100644 --- a/test/signinfo.cc +++ b/test/signinfo.cc @@ -30,7 +30,7 @@ TEST(Signinfo, ExitToTest) { std::vector signs; std::vector linguistics; std::vector> default_languages; - const std::string linguistic_node_file = "test_linguistic_node.bin"; + const std::string linguistic_node_file = "test_sign_linguistic_node.bin"; sequence linguistic_node(linguistic_node_file, true); bool has_guide = GraphBuilder::CreateSignInfoList(exit_node, way, pronunciationMap, langMap,