From d23981460a4bb51aa77839c5d8290ae12fe5e364 Mon Sep 17 00:00:00 2001 From: Huyen Chau Nguyen Date: Wed, 24 Jan 2018 10:59:25 -0500 Subject: [PATCH] split OSM link generation in an accessible coordinate function --- include/util/assert.hpp | 4 +-- include/util/coordinate.hpp | 17 +++++++++++++ src/extractor/edge_based_graph_factory.cpp | 29 ++++++++++++++++------ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/include/util/assert.hpp b/include/util/assert.hpp index d4cd00c22b4..ac4b80797d5 100644 --- a/include/util/assert.hpp +++ b/include/util/assert.hpp @@ -20,9 +20,7 @@ if (!static_cast(cond)) \ { \ ::osrm::util::FloatCoordinate c_(loc); \ - std::cerr << "[Location] " \ - << "http://www.openstreetmap.org/?mlat=" << c_.lat << "&mlon=" << c_.lon \ - << "#map=19/" << c_.lat << "/" << c_.lon << '\n'; \ + std::cerr << "[Location] " << c_.toOSMLink() << '\n'; \ } \ BOOST_ASSERT_MSG(cond, msg); \ } while (0) diff --git a/include/util/coordinate.hpp b/include/util/coordinate.hpp index 3ff309ba90d..525727f6313 100644 --- a/include/util/coordinate.hpp +++ b/include/util/coordinate.hpp @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include //for std::ostream +#include #include #include @@ -216,6 +217,14 @@ struct Coordinate friend bool operator==(const Coordinate lhs, const Coordinate rhs); friend bool operator!=(const Coordinate lhs, const Coordinate rhs); friend std::ostream &operator<<(std::ostream &out, const Coordinate coordinate); + + std::string toOSMLink() const + { + std::stringstream link; + link << "http://www.openstreetmap.org/?mlat=" << lat << "&mlon=" << lon << "#map=19/" << lat + << "/" << lon; + return link.str(); + } }; /** @@ -257,6 +266,14 @@ struct FloatCoordinate friend bool operator==(const FloatCoordinate lhs, const FloatCoordinate rhs); friend bool operator!=(const FloatCoordinate lhs, const FloatCoordinate rhs); friend std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate); + + std::string toOSMLink() const + { + std::stringstream link; + link << "http://www.openstreetmap.org/?mlat=" << lat << "&mlon=" << lon << "#map=19/" << lat + << "/" << lon; + return link.str(); + } }; bool operator==(const Coordinate lhs, const Coordinate rhs); diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 5c9e3414e86..f983209efce 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -811,7 +811,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( auto get_connected_road_info = [&](const auto &connected_edge) { const auto &edge_data = m_node_based_graph.GetEdgeData(connected_edge.eid); - return ExtractionTurnLeg(edge_data.flags.restricted, + return ExtractionTurnLeg( + edge_data.flags.restricted, edge_data.flags.road_classification.IsMotorwayClass(), edge_data.flags.road_classification.IsLinkClass(), edge_data.flags.road_classification.GetNumberOfLanes(), @@ -832,24 +833,36 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( { if (turn != intersection.begin()) { - std::transform(intersection.begin() + 1, turn, std::back_inserter(road_legs_on_the_right), get_connected_road_info); + std::transform(intersection.begin() + 1, + turn, + std::back_inserter(road_legs_on_the_right), + get_connected_road_info); } - std::transform(turn + 1, intersection.end(), std::back_inserter(road_legs_on_the_right), get_connected_road_info); + std::transform(turn + 1, + intersection.end(), + std::back_inserter(road_legs_on_the_right), + get_connected_road_info); } else { - std::transform(intersection.begin() + 1, turn, std::back_inserter(road_legs_on_the_right), get_connected_road_info); - std::transform(turn + 1, intersection.end(), std::back_inserter(road_legs_on_the_left), get_connected_road_info); + std::transform(intersection.begin() + 1, + turn, + std::back_inserter(road_legs_on_the_right), + get_connected_road_info); + std::transform(turn + 1, + intersection.end(), + std::back_inserter(road_legs_on_the_left), + get_connected_road_info); } if (turn->instruction.IsUTurn() && turn != intersection.begin()) { util::Log(logWARNING) << "Turn is a u turn but not turning to the first connected " - "edge of the intersection. Node ID " - << intersection_node << " coordinates " - << m_coordinates[intersection_node]; + "edge of the intersection. Node ID: " + << intersection_node << ", OSM link: " + << m_coordinates[intersection_node].toOSMLink(); } // In case a way restriction starts at a given location, add a turn onto