@@ -153,6 +153,8 @@ path reconstruct(ways const& w,
153
153
auto segments = std::vector<path::segment>{{.polyline_ = dest.path_ ,
154
154
.from_level_ = dest.lvl_ ,
155
155
.to_level_ = dest.lvl_ ,
156
+ .from_ = node_idx_t::invalid (),
157
+ .to_ = node_idx_t::invalid (),
156
158
.way_ = way_idx_t::invalid ()}};
157
159
auto dist = 0.0 ;
158
160
while (true ) {
@@ -248,6 +250,25 @@ best_candidate(ways const& w,
248
250
return std::nullopt;
249
251
}
250
252
253
+ std::optional<path> try_direct (osr::location const & from,
254
+ osr::location const & to) {
255
+ auto const dist = geo::distance (from.pos_ , to.pos_ );
256
+ return dist < 5.0
257
+ ? std::optional{path{.cost_ = 60U ,
258
+ .dist_ = dist,
259
+ .segments_ = {path::segment{
260
+ .polyline_ = {from.pos_ , to.pos_ },
261
+ .from_level_ = from.lvl_ ,
262
+ .to_level_ = to.lvl_ ,
263
+ .from_ = node_idx_t::invalid (),
264
+ .to_ = node_idx_t::invalid (),
265
+ .way_ = way_idx_t::invalid (),
266
+ .cost_ = 60U ,
267
+ .dist_ = static_cast <distance_t >(dist)}},
268
+ .uses_elevator_ = false }}
269
+ : std::nullopt;
270
+ }
271
+
251
272
template <typename Profile>
252
273
std::optional<path> route (ways const & w,
253
274
lookup const & l,
@@ -267,6 +288,10 @@ std::optional<path> route(ways const& w,
267
288
return std::nullopt;
268
289
}
269
290
291
+ if (auto const direct = try_direct (from, to); direct.has_value ()) {
292
+ return *direct;
293
+ }
294
+
270
295
d.reset (max);
271
296
272
297
for (auto const & start : from_match) {
@@ -339,6 +364,8 @@ std::vector<std::optional<path>> route(
339
364
for (auto const [m, t, r] : utl::zip (to_match, to, result)) {
340
365
if (r.has_value ()) {
341
366
++found;
367
+ } else if (auto const direct = try_direct (from, t); direct.has_value ()) {
368
+ r = direct;
342
369
} else {
343
370
auto const c = best_candidate (w, d, t.lvl_ , m, max, dir);
344
371
if (c.has_value ()) {
0 commit comments