Skip to content

Commit

Permalink
split OSM link generation in an accessible coordinate function
Browse files Browse the repository at this point in the history
  • Loading branch information
chaupow committed Jan 24, 2018
1 parent b2dc980 commit d239814
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
4 changes: 1 addition & 3 deletions include/util/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
if (!static_cast<bool>(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)
Expand Down
17 changes: 17 additions & 0 deletions include/util/coordinate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <cstddef>
#include <iosfwd> //for std::ostream
#include <sstream>
#include <string>
#include <type_traits>

Expand Down Expand Up @@ -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();
}
};

/**
Expand Down Expand Up @@ -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);
Expand Down
29 changes: 21 additions & 8 deletions src/extractor/edge_based_graph_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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
Expand Down

0 comments on commit d239814

Please sign in to comment.