RoutingCost.cpp
Go to the documentation of this file.
2 
3 #include <lanelet2_core/geometry/Lanelet.h>
6 
7 #include <boost/geometry/algorithms/perimeter.hpp>
8 
9 namespace lanelet {
10 namespace routing {
11 namespace {
12 Velocity speedLimit(const traffic_rules::TrafficRules& trafficRules, const ConstLaneletOrArea& la) {
13  auto limit = la.applyVisitor([&](auto& la) { return trafficRules.speedLimit(la); });
14  if (limit.speedLimit.value() == 0.) {
15  limit.speedLimit = std::numeric_limits<double>::max() * Velocity();
16  }
17  if (std::isinf(limit.speedLimit.value())) {
18  throw lanelet::InvalidInputError("Infinite speed limit returned by trafficRules object");
19  }
20  return limit.speedLimit;
21 }
22 } // namespace
23 
25  auto limit = speedLimit(trafficRules, ll);
27 }
28 
30  auto limit = speedLimit(trafficRules, ar);
31  auto diameter = boost::geometry::perimeter(utils::to2D(ar.outerBoundPolygon()));
32  return units::SecondQuantity(diameter * units::Meter() / limit).value();
33 }
34 
36 
37 double RoutingCostDistance::length(const ConstArea& ar) noexcept {
38  return double(boost::geometry::perimeter(utils::to2D(ar.outerBoundPolygon())));
39 }
40 } // namespace routing
41 } // namespace lanelet
Velocity
units::MPSQuantity Velocity
lanelet
lanelet::traffic_rules::TrafficRules
lanelet::ConstArea
lanelet::geometry::approximatedLength2d
double approximatedLength2d(const LaneletT &lanelet)
lanelet::units::SecondQuantity
boost::units::quantity< Second > SecondQuantity
Units.h
LaneletOrArea.h
lanelet::routing::RoutingCostDistance::length
static double length(const ConstLanelet &ll) noexcept
Definition: RoutingCost.cpp:35
lanelet::routing::RoutingCostTravelTime::travelTime
static double travelTime(const traffic_rules::TrafficRules &trafficRules, const ConstLanelet &ll)
Definition: RoutingCost.cpp:24
lanelet::units::Meter
boost::units::si::meter_base_unit::unit_type Meter
lanelet::ConstArea::outerBoundPolygon
CompoundPolygon3d outerBoundPolygon() const
lanelet::ConstLanelet
RoutingCost.h
ll
LaneletAdjacency ll
Definition: LaneletPath.cpp:88
lanelet::InvalidInputError


lanelet2_routing
Author(s): Matthias Mayr
autogenerated on Sun Oct 27 2024 02:27:49