MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / ProcessWay

Method ProcessWay

src/extractor/extractor_callbacks.cpp:86–479  ·  view source on GitHub ↗

* Takes the geometry contained in the ```input_way``` and the tags computed * by the lua profile inside ```parsed_way``` and computes all edge segments. * * Depending on the forward/backwards weights the edges are split into forward * and backward edges. * * warning: caller needs to take care of synchronization! */

Source from the content-addressed store, hash-verified

84 * warning: caller needs to take care of synchronization!
85 */
86void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const ExtractionWay &parsed_way)
87{
88 if ((parsed_way.forward_travel_mode == extractor::TRAVEL_MODE_INACCESSIBLE ||
89 parsed_way.forward_speed <= 0) &&
90 (parsed_way.backward_travel_mode == extractor::TRAVEL_MODE_INACCESSIBLE ||
91 parsed_way.backward_speed <= 0) &&
92 parsed_way.duration <= 0)
93 { // Only true if the way is assigned a valid speed/duration
94 return;
95 }
96
97 if (!fallback_to_duration &&
98 (parsed_way.forward_travel_mode == extractor::TRAVEL_MODE_INACCESSIBLE ||
99 parsed_way.forward_rate <= 0) &&
100 (parsed_way.backward_travel_mode == extractor::TRAVEL_MODE_INACCESSIBLE ||
101 parsed_way.backward_rate <= 0) &&
102 parsed_way.weight <= 0)
103 { // Only true if the way is assigned a valid rate/weight and there is no duration fallback
104 return;
105 }
106
107 const auto &nodes = input_way.nodes();
108 if (nodes.size() <= 1)
109 { // safe-guard against broken data
110 return;
111 }
112
113 if (std::numeric_limits<decltype(input_way.id())>::max() == input_way.id())
114 {
115 util::Log(logDEBUG) << "found bogus way with id: " << input_way.id() << " of size "
116 << nodes.size();
117 return;
118 }
119
120 InternalExtractorEdge::DurationData forward_duration_data;
121 InternalExtractorEdge::DurationData backward_duration_data;
122 InternalExtractorEdge::WeightData forward_weight_data;
123 InternalExtractorEdge::WeightData backward_weight_data;
124
125 const auto toValueByEdgeOrByMeter = [&nodes](const double by_way, const double by_meter)
126 {
127 using Value = detail::ByEdgeOrByMeterValue;
128 // get value by weight per edge
129 if (by_way >= 0)
130 {
131 // FIXME We divide by the number of edges here, but should rather consider
132 // the length of each segment. We would either have to compute the length
133 // of the whole way here (we can't: no node coordinates) or push that back
134 // to the container and keep a reference to the way.
135 const std::size_t num_edges = (nodes.size() - 1);
136 return Value(Value::by_edge, by_way / num_edges);
137 }
138 else
139 {
140 // get value by deriving weight from speed per edge
141 return Value(Value::by_meter, by_meter);
142 }
143 };

Callers 1

ParseOSMDataMethod · 0.45

Calls 15

LogClass · 0.85
exceptionClass · 0.85
to_stringFunction · 0.85
getClassDataFunction · 0.85
isValidClassNameFunction · 0.85
copyFunction · 0.85
for_each_pairFunction · 0.85
ConcurrentFindOrAddMethod · 0.80
SetNumberOfLanesMethod · 0.80
GetNumberOfLanesMethod · 0.80
refMethod · 0.80

Tested by

no test coverage detected