diff --git a/.claude/skills/build-open-navicore/SKILL.md b/.claude/skills/build-open-navicore/SKILL.md
index b90a2ed..a34f14c 100644
--- a/.claude/skills/build-open-navicore/SKILL.md
+++ b/.claude/skills/build-open-navicore/SKILL.md
@@ -43,10 +43,22 @@ workspace that holds this repository, so set them from a linked worktree):
| `OSMAND_QNX_ROOT` | the OsmAnd QNX build tree (`osmand-qnx-build`): compiler, core, Qt |
| `IFSBUILD_DIR` | ifs-build checkout (`ifs-build`), for `make ifs` |
-`navigation.ifs` is the whole navigation for the radio (about 100 MiB): the
-provider and its config, the backend, OsmAnd core and its resource bundle
-(`OSMAND_RESOURCES_BUNDLE`, default next to the core in the OsmAnd build),
-all under `/open-navicore`. Maps and other data are not in it.
+`make ifs` writes two things (2026-10-28):
+
+- `build/qnx/ifs/navigation.ifs` (~0.8 MB): the provider, its config, `boot.sh`
+ and `50-navicore.pre`; the slot's `50-navicore.ifs` on the radio.
+- `build/qnx/navicore-data/navicore/`: the backend `libOpenNaviBackendOsmAnd.so`,
+ OsmAnd core and its resource bundle (`OSMAND_RESOURCES_BUNDLE`, default next to
+ the core in the OsmAnd build) as plain files for the slot's data dir; the image
+ links them into `/open-navicore` at boot. They left the image on 2026-10-24
+ (boot time). Maps and other data are in neither.
+
+Install: skill `deploy-open-navicore` (a backend change is the backend file only).
+
+Build trees on the D: drive fail at configure (`configure_file ... Operation not
+permitted`): build into a Linux path with `BUILD=
` or from a clone there. A
+linked worktree has no `third_party/lvgl` checkout; copy the main checkout's
+(same commit) into the clone.
`make ifs` also needs `STOCK_NV_NAVIGATION_CFG=`
once (QR39.5, SHA-256 `c889c2b4…d680e`, not committed; take it read-only
diff --git a/.claude/skills/deploy-open-navicore/SKILL.md b/.claude/skills/deploy-open-navicore/SKILL.md
index 10e0c28..1fb1ed6 100644
--- a/.claude/skills/deploy-open-navicore/SKILL.md
+++ b/.claude/skills/deploy-open-navicore/SKILL.md
@@ -1,88 +1,103 @@
---
name: deploy-open-navicore
-description: Install Open NaviCore on the VP4R bench radio - one image, navigation.ifs (provider, OsmAnd backend, OsmAnd core and resources), staged upload, rename swap, one reboot; verification and rollback. Use when deploying a new build, checking what is installed, or rolling back to the native navigation.
+description: Install Open NaviCore on the VP4R bench radio (vp4r layer, A/B slots) - the OsmAnd backend as a plain file in the slot's data dir (deploy_backend.sh), the small provider image 50-navicore.ifs in the slot's ifs dir; staged upload, rename swap, one reboot; verification and rollback. Use when deploying a new build, checking what is installed, or rolling back.
---
# Deploy Open NaviCore to the radio
-A new version of the navigation is one file, `navigation.ifs`, and one
-reboot:
+Checked on the bench unit 2026-10-28. The unit boots through the vp4r layer
+(`/datastore/vp4r`, `vp4r-loader`): it picks the A/B slot in
+`/datastore/vp4r/slot` (`a` or `b`) and mounts `slots//ifs/NN-*.ifs` at `/`.
+The navigation is two kinds of file per slot:
| On the unit | What | Installed by |
|---|---|---|
-| `/datastore/navicore/navigation.ifs`, mounted at `/` at boot by the boot overlay | all code under `/open-navicore/`: provider `libNaviCore.so`, its `nv_navigation.cfg` and `boot.sh`, the backend `libOpenNaviBackendOsmAnd.so`, OsmAnd core and resource bundle | `deploy/navigation-ifs/deploy_navigation_ifs.sh` |
-| `/datastore/navicore-backend/` | data only: `maps/*.obf`, `recents.tsv`, `vectorcache/`, the bench marker files | by hand (maps), or written by the backend |
+| `/datastore/vp4r/slots//data/navicore/` | plain files: the backend `libOpenNaviBackendOsmAnd.so`, `libOsmAndCore_shared.so`, `libOsmAndCore_ResourcesBundle_shared.so`; the image's `50-navicore.pre` links them into `/open-navicore` at every boot (log `/datastore/vp4r/log/navicore.log`: `link rc=0`) | backend: `deploy/navigation-ifs/deploy_backend.sh`; core and bundle by hand (they rarely change) |
+| `/datastore/vp4r/slots//ifs/50-navicore.ifs` (~0.8 MB) | `make ifs`'s `navigation.ifs`: provider `libNaviCore.so`, its `nv_navigation.cfg` (also at `/pas/scfg`), `boot.sh`, `/etc/vp4r/init.d/50-navicore.pre`; mounted at `/` | not scripted yet, see 1b |
+| `/datastore/navicore-backend/` | data only: `maps/*.obf`, `recents.tsv`, `vectorcache/`, the bench marker files (`osmand-turns`, `disable-ch`, ...) | by hand (maps), or written by the backend |
-Every change (UI, map, routing, provider) is a new image. There is no
-backend-only install; the code is read-only in the mounted image.
+The OsmAnd libraries are out of the image since 2026-10-24: images are mounted
+inside the boot barrier and a 100 MB image made boots fail the RH850's J6 startup
+window (`50-navicore.pre` header). **Stale:** `/datastore/navicore/navigation.ifs`
+(a 110 MB full image of 2026-10-21) is no longer booted, and
+`deploy_navigation_ifs.sh` still installs to that path; do not use it for the slot.
+
+Most changes (UI, map, routing, turn instructions: everything in
+`backends/osmand`) are the backend only. The image changes only with the provider
+(`src/`), its config, `boot.sh` or `50-navicore.pre`.
## 0. Before touching the unit
-- Build first (skill `build-open-navicore`): `make test`, `make` and
- `make ifs` pass.
+- Build first (skill `build-open-navicore`): `make test`, `make` (and `make ifs`
+ for an image). `make ifs` also writes `build/qnx/navicore-data/navicore/` (the
+ three libraries).
- Follow the workspace skill `record-unit-modification`: confirm the unit's
identity, write the ledger entry first (`pending restart`), update it
after the check.
- Bench deploy and the one documented reboot are covered by the standing
authorization in the workspace `AGENTS.md`. A second reboot is not: ask.
- Never loop a reboot.
+ Never loop a reboot. Other sessions may be using the unit: ask before rebooting.
- The unit needs dev-tools mounted (`/usr/bin/bench_rename`,
- `/usr/bin/vp4r-sync`, `/usr/bin/vp4r-reboot`); the script checks.
-- Space: the image is about 100 MiB and the swap keeps one previous image,
- so `/datastore` needs one image of free space (it had 128 MiB on
- 2026-10-15, before the old per-file backend copies were removed).
+ `/usr/bin/vp4r-sync`, `/usr/bin/vp4r-reboot`, `/usr/bin/sha256sum`).
+- Space: a backend is ~31 MB and each install keeps the previous one as
+ `libOpenNaviBackendOsmAnd.before-.so`; delete old ones when space runs low.
-## 1. Install
+## 1a. Install the backend (the usual case)
```sh
-deploy/navigation-ifs/deploy_navigation_ifs.sh build/qnx/ifs/navigation.ifs \
- /bin/ifs-deploy --dry-run # plan only
-deploy/navigation-ifs/deploy_navigation_ifs.sh build/qnx/ifs/navigation.ifs \
- /bin/ifs-deploy
+deploy/navigation-ifs/deploy_backend.sh build/qnx/navicore-data/navicore/libOpenNaviBackendOsmAnd.so --dry-run
+deploy/navigation-ifs/deploy_backend.sh build/qnx/navicore-data/navicore/libOpenNaviBackendOsmAnd.so
```
-It uploads with ifs-build's `ifs-deploy` as `navigation.ifs.new` (read-back
-verified by scp), pulls the current image to local `ifs-deploy-backups/`,
-then on the unit renames `navigation.ifs` to `navigation.previous.ifs` and
-`navigation.ifs.new` to `navigation.ifs` (no copies), flushes and checks the
-installed file with the unit's `/usr/bin/sha256sum` (dev-tools) against the
-host hash, renaming the previous image back on a mismatch. Never copy over a
-mounted IFS in place (a truncated in-place copy once made `mountifs` crash
-at boot); renaming is safe. Do **not** use ifs-build's generic `deploy-ifs`
-target: it uploads to `/datastore/ifs-overrides`, which the navigation hook
-does not read.
+It reads the booted slot, uploads (`scp -O`) as `libOpenNaviBackendOsmAnd.so.new`,
+checks its sha256 on the unit, renames the active file to
+`libOpenNaviBackendOsmAnd.before-.so` and the new one into place (no copies),
+flushes and reads back the hash. Then one reboot: `/usr/bin/vp4r-sync`, then
+`/usr/bin/vp4r-reboot` (workspace skill `dev-tools-on-radio`). ssh returns in
+about a minute. It installs into the booted slot only; the other slot keeps its
+own files.
-Settings: `RADIO_HOST` (default the bench unit), `RADIO_SSH_KEY` (default
-`$HOME/priv_openssh`), `NAVIGATION_IFS_DIR`, `BACKUP_DIR`, `RADIO_SYNC`,
-`RADIO_RENAME` (script header).
+## 1b. Install the provider image
-Then one reboot: `/usr/bin/vp4r-sync`, then `/usr/bin/vp4r-reboot`
-(workspace skill `dev-tools-on-radio`). ssh returns in about a minute.
+Not scripted for the slot layout yet. By hand, the same pattern: upload
+`build/qnx/ifs/navigation.ifs` as `slots//ifs/50-navicore.ifs.new`, check its
+sha256 on the unit, `bench_rename` the active `50-navicore.ifs` away (keep it),
+`bench_rename` the new one into place, `vp4r-sync`, one reboot. Never copy over a
+mounted IFS in place (a truncated in-place copy once made `mountifs` crash at
+boot); renaming is safe. Do **not** use ifs-build's generic `deploy-ifs` target.
## 2. Verify
-- `/bin/cat /datastore/boot_overlay.log`: the last block has
- `open_navicore_mount_rc=0` and `open_navicore_config_link_rc=0`.
-- `for f in /open-navicore/*; do echo $f; done` lists the provider, backend,
- core and bundle; `nv_navigation` maps them:
+- `/bin/cat /datastore/vp4r/log/navicore.log`: the last three lines are
+ `link rc=0`; `/bin/cat /datastore/vp4r/log/boot.log` for the mounts.
+- `ls -l /open-navicore/` (dev-tools `ls`): the three libraries are links into
+ `slots//data/navicore/`; `nv_navigation` maps them:
`/proc/boot/pidin -p mem` (pid from `/proc/boot/pidin -f an`).
- Provider trace `/bin/cat /tmp/open-navi.log`; backend trace
`/bin/cat /tmp/open-navicore-osmand.log` (start, attach,
- `init=resources`, `surface_created=...`, `cluster=publish_status`).
+ `init=resources`, `surface_created=...`, `cluster=publish_status`; per route
+ `worker=turns source=organic_maps`, `worker=omaps turns=N ms=M`, or
+ `worker=omaps_error why=...`).
- On screen: hold the day/night button 1.5 s in free drive for the
developer menu (build commit, frame rate, raw car inputs, cluster).
-- Hash on the unit: `/usr/bin/sha256sum /datastore/navicore/navigation.ifs`
- equals the host's `sha256sum build/qnx/ifs/navigation.ifs`.
+- Hash on the unit: `/usr/bin/sha256sum
+ /datastore/vp4r/slots//data/navicore/libOpenNaviBackendOsmAnd.so` equals
+ the host's.
- Update the ledger entry to `active`, or record what failed.
## 3. Rollback
-- Previous version: on the unit `/bin/rm navigation.ifs;
- /usr/bin/bench_rename navigation.previous.ifs navigation.ifs`, flush,
- reboot (or install a local backup from `ifs-deploy-backups/` with the
- script).
-- Back to the native navigation: `touch /datastore/navicore/disabled` and
- reboot (the boot hook leaves the factory config in place).
+- Previous backend: on the unit, in `slots//data/navicore/`,
+ `/usr/bin/bench_rename libOpenNaviBackendOsmAnd.so libOpenNaviBackendOsmAnd.bad.so`
+ and the wanted `libOpenNaviBackendOsmAnd.before-.so` back to
+ `libOpenNaviBackendOsmAnd.so`, flush, reboot.
+- Turn instructions from OsmAnd instead of Organic Maps, no reinstall:
+ `touch /datastore/navicore-backend/osmand-turns`, restart the navigation.
+- Without the three library files the provider keeps its built-in backend
+ (`50-navicore.pre`).
+- Back to the native navigation: the old marker `touch
+ /datastore/navicore/disabled` was read by the pre-vp4r boot hook; not
+ checked with the vp4r layer (2026-10-28).
- A provider that crashes at every start makes System Manager reset the unit
after three relaunches; ssh comes up first, so the marker can be created
between resets.
diff --git a/AGENTS.md b/AGENTS.md
index a8d3823..d6748e7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,15 @@
# Agent notes for open_navicore
+## Failures: obvious, not silent
+
+- An obvious failure is better than a silent fallback (owner preference, 2026-10-28).
+ When a component fails, make it visible (the feature visibly missing, an error
+ trace line), do not quietly substitute an older or weaker path that hides it.
+- A fallback is only for an explicit switch: e.g. OsmAnd's own manoeuvres run only
+ when Organic Maps' turns are switched off (marker `osmand-turns`), never because
+ Organic Maps' code failed on a route (that route gets no turns and
+ `worker=omaps_error`).
+
## Merging pull requests
- Merge with **rebase**, not squash (owner preference, 2026-10-20):
diff --git a/backends/osmand/CMakeLists.txt b/backends/osmand/CMakeLists.txt
index 7614dad..6e422c5 100644
--- a/backends/osmand/CMakeLists.txt
+++ b/backends/osmand/CMakeLists.txt
@@ -99,8 +99,20 @@ add_custom_target(build_info_git
-P ${ONC_ROOT}/cmake/build_info.cmake
BYPRODUCTS ${_build_info} VERBATIM)
+# Turn instructions: Organic Maps' car turn generator on OsmAnd's routes
+# (omaps_turns.cpp; the vendored OM code in third_party/organicmaps-routing). A
+# static library so that OM's shim headers stay out of the backend's include path.
+include(${ONC_ROOT}/third_party/organicmaps-routing/sources.cmake)
+add_library(organicmaps_turns STATIC omaps_turns.cpp ${ONC_ORGANICMAPS_SOURCES})
+target_include_directories(organicmaps_turns PRIVATE ${ONC_ORGANICMAPS_INCLUDES}
+ ${ONC_OSMAND_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR})
+target_compile_definitions(organicmaps_turns PRIVATE ${ONC_OSMAND_DEFINES})
+# Vendored code: its warnings are upstream's.
+target_compile_options(organicmaps_turns PRIVATE ${ONC_OSMAND_FLAGS} -w)
+
add_library(osmand_backend SHARED
osmand_backend.cpp config.cpp session.cpp osmand_engine.cpp navigation_worker.cpp ch_planner.cpp
+ route_maneuvers.cpp
thread_priority.cpp crash_reporter.cpp frame_metrics.cpp build_info.cpp
gpu_upload_context.cpp
ui/gl_overlay_compositor.cpp
@@ -111,7 +123,7 @@ target_include_directories(osmand_backend PRIVATE ${ONC_OSMAND_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(osmand_backend PRIVATE ${ONC_OSMAND_DEFINES})
target_compile_options(osmand_backend PRIVATE ${ONC_WARNINGS} ${ONC_OSMAND_FLAGS})
-target_link_libraries(osmand_backend PRIVATE navigation_ui osmand_core EGL GLESv2 z c)
+target_link_libraries(osmand_backend PRIVATE navigation_ui organicmaps_turns osmand_core EGL GLESv2 z c)
set_target_properties(osmand_backend PROPERTIES OUTPUT_NAME OpenNaviBackendOsmAnd
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} SKIP_BUILD_RPATH ON)
target_link_options(osmand_backend PRIVATE -Wl,--as-needed -static-libstdc++ -static-libgcc
diff --git a/backends/osmand/config.cpp b/backends/osmand/config.cpp
index 9dbda38..4470478 100644
--- a/backends/osmand/config.cpp
+++ b/backends/osmand/config.cpp
@@ -78,6 +78,8 @@ Config Config::from_environment()
map_is_directory ? config.map + "/car.chr" : config.map + ".chr");
if (marker_or_environment("OPEN_NAVICORE_OSMAND_CH_DISABLE", "/datastore/navicore-backend/disable-ch"))
config.ch_sidecar.clear();
+ config.osmand_turns = marker_or_environment("OPEN_NAVICORE_OSMAND_TURNS",
+ "/datastore/navicore-backend/osmand-turns");
config.fonts = path("OPEN_NAVICORE_OSMAND_FONTS", config.fonts);
config.search_index = path("OPEN_NAVICORE_OSMAND_SEARCH_INDEX", config.search_index);
config.recents = path("OPEN_NAVICORE_OSMAND_RECENTS", config.recents);
diff --git a/backends/osmand/config.h b/backends/osmand/config.h
index 8d5f629..0cbb728 100644
--- a/backends/osmand/config.h
+++ b/backends/osmand/config.h
@@ -35,6 +35,10 @@ struct Config {
// cannot serve a route. Empty when disabled (marker
// /datastore/navicore-backend/disable-ch, or OPEN_NAVICORE_OSMAND_CH_DISABLE=1).
std::string ch_sidecar = "";
+ // Turn instructions come from Organic Maps' turn generator (omaps_turns.h).
+ // OsmAnd's own only with the marker /datastore/navicore-backend/osmand-turns
+ // (or OPEN_NAVICORE_OSMAND_TURNS=1); never as a fallback when OM fails.
+ bool osmand_turns = false;
// Bench tools (markers in /datastore/navicore-backend, see README).
bool simulate_route = false; // enable-route-simulation
diff --git a/backends/osmand/navigation_worker.cpp b/backends/osmand/navigation_worker.cpp
index b92691a..cdc80b0 100644
--- a/backends/osmand/navigation_worker.cpp
+++ b/backends/osmand/navigation_worker.cpp
@@ -7,6 +7,7 @@
#include "diagnostics.h"
#include "junction_shape.h"
#include "route_check.h"
+#include "route_maneuvers.h"
#include "search/search_index.h"
#include "session.h"
#include "ui/localization.h"
@@ -219,46 +220,6 @@ std::string duration_label(double seconds)
return ui::loc::format_duration_minutes(static_cast(std::lround(seconds / 60.0)));
}
-ui::ManeuverKind maneuver_kind(int value)
-{
- switch (value) {
- case TurnType::TL: return ui::ManeuverKind::Left;
- case TurnType::TSLL: return ui::ManeuverKind::SlightLeft;
- case TurnType::TSHL: return ui::ManeuverKind::SharpLeft;
- case TurnType::TR: return ui::ManeuverKind::Right;
- case TurnType::TSLR: return ui::ManeuverKind::SlightRight;
- case TurnType::TSHR: return ui::ManeuverKind::SharpRight;
- case TurnType::KL: return ui::ManeuverKind::KeepLeft;
- case TurnType::KR: return ui::ManeuverKind::KeepRight;
- case TurnType::TU:
- case TurnType::TRU: return ui::ManeuverKind::UTurn;
- case TurnType::RNDB:
- case TurnType::RNLB: return ui::ManeuverKind::Roundabout;
- default: return ui::ManeuverKind::Straight;
- }
-}
-
-// OsmAnd lane value: bit 0 = the route uses the lane, bits 1-4 its main
-// turn, bits 5-9 a second turn (TurnType::getPrimaryTurn/getSecondaryTurn).
-std::vector lanes_of(const SHARED_PTR& turn)
-{
- std::vector lanes;
- if (!turn)
- return lanes;
- for (const int value : turn->getLanes()) {
- ui::Lane lane;
- const int primary = TurnType::getPrimaryTurn(value);
- const int secondary = TurnType::getSecondaryTurn(value);
- lane.kind = maneuver_kind(primary ? primary : TurnType::C);
- lane.combined = secondary != 0;
- if (lane.combined)
- lane.also = maneuver_kind(secondary);
- lane.recommended = (value & 1) != 0;
- lanes.push_back(lane);
- }
- return lanes;
-}
-
// Routing runs for seconds. nv_navigation is pinned to one core, where the
// render thread (priority 20) leaves it about half the CPU: a 15 km route
// took 7.3 s there against 3.7 s free to use either core (route_bench,
@@ -289,52 +250,21 @@ void place_worker_thread(int priority = kWorkerPriority, const char* name = "wor
trace(line);
}
-using Segments = std::vector>;
-
-// Bearings over the first 10 m of each road, as OsmAnd's own turn decision
-// (getTurnInfo, DIST_BEARING_DETECT).
-constexpr float kJunctionBearingMetres = 10.0f;
-
-// The junction at the start of segments[index] (where OsmAnd puts the
-// turn): the route's and every other road's direction, relative to the
-// incoming direction (positive clockwise). Other roads: the segment's
-// attached roads at its start point (prepareResult /
-// attachRoadSegments: the incoming road's continuation and each road the
-// router could leave the node by; one-way roads that only enter the node
-// are not attached), plus the route's own road behind the node, which
-// OsmAnd does not attach (same way id).
-ui::JunctionShape junction_of(Segments& segments, std::size_t index)
-{
- if (index == 0 || index >= segments.size()) return {};
- const auto& previous = segments[index - 1];
- const auto& current = segments[index];
- if (!previous || !current || !previous->object || !current->object) return {};
- const double incoming =
- previous->getBearingEnd(previous->getEndPointIndex(), kJunctionBearingMetres);
- const int start = current->getStartPointIndex();
- const double route = current->getBearingBegin(start, kJunctionBearingMetres);
- std::vector arms;
- for (const auto& attached : current->getAttachedRoutes(start)) {
- if (!attached || !attached->object) continue;
- arms.push_back(degreesDiff(attached->getBearingBegin(), incoming));
- }
- const bool forward = current->getEndPointIndex() > start;
- const int points = static_cast(current->object->getPointsLength());
- if (current->object->getId() != previous->object->getId() &&
- (forward ? start > 0 : start < points - 1)) {
- const double behind =
- current->object->directionRoute(start, !forward, kJunctionBearingMetres) / M_PI *
- 180.0;
- arms.push_back(degreesDiff(behind, incoming));
- }
- return make_junction_shape(degreesDiff(route, incoming), arms);
-}
-
// One trace line per manoeuvre of the main route (bounded), so that a live
// drive can be checked against the cluster picture: the junction
// description, the junction picture (0: none) and the symbol sent.
constexpr std::size_t kJunctionTraceMax = 40;
+// Metres between two route points (equirectangular; route points are metres apart).
+double metres_between(const ui::GeoPoint& a, const ui::GeoPoint& b)
+{
+ constexpr double kDegrees = M_PI / 180.0;
+ const double mean = (a.latitude + b.latitude) * 0.5 * kDegrees;
+ const double dy = (b.latitude - a.latitude) * 111320.0;
+ const double dx = (b.longitude - a.longitude) * 111320.0 * std::cos(mean);
+ return std::sqrt(dx * dx + dy * dy);
+}
+
void trace_junction(std::size_t number, const ui::Maneuver& maneuver)
{
const auto& j = maneuver.junction;
@@ -391,11 +321,13 @@ class NavigationWorker::Impl {
std::vector map_paths,
std::string routing_xml,
const std::string& search_index,
- std::string ch_sidecar)
+ std::string ch_sidecar,
+ bool organic_turns)
: obfs_(std::move(obfs)), wakeup_(std::move(wakeup)),
map_paths_(std::move(map_paths)), routing_xml_(std::move(routing_xml)),
- ch_sidecar_(std::move(ch_sidecar))
+ ch_sidecar_(std::move(ch_sidecar)), organic_turns_(organic_turns)
{
+ trace(organic_turns_ ? "worker=turns source=organic_maps" : "worker=turns source=osmand");
// Opened here, read only by the worker thread started below.
trace(index_.open(search_index) ? "worker=search_index" : "worker=no_search_index");
// Start only after every request/result flag below has completed
@@ -806,6 +738,33 @@ class NavigationWorker::Impl {
if (request.heading_degrees)
trace_result("worker=route_heading", request.revision,
static_cast(*request.heading_degrees));
+ // Organic Maps' turns for each route found, while its routing context (the
+ // roads at every node) is alive; parallel to |found|.
+ std::vector found_turns;
+ const auto annotate = [&](RoutingContext& context) {
+ while (found_turns.size() < found.size()) {
+ if (!organic_turns_) {
+ found_turns.emplace_back();
+ continue;
+ }
+ const auto annotate_started = std::chrono::steady_clock::now();
+ omaps::Result result = omaps::annotate(
+ context, found[found_turns.size()], request.origin.latitude,
+ request.origin.longitude, request.destination.latitude,
+ request.destination.longitude);
+ const long long ms = std::chrono::duration_cast(
+ std::chrono::steady_clock::now() - annotate_started).count();
+ char line[200];
+ if (result.ok)
+ std::snprintf(line, sizeof(line), "worker=omaps turns=%zu ms=%lld",
+ result.turns.size(), ms);
+ else
+ std::snprintf(line, sizeof(line), "worker=omaps_error why=%.150s ms=%lld",
+ result.error.c_str(), ms);
+ trace(line);
+ found_turns.push_back(std::move(result));
+ }
+ };
// Both ends on one sidecar node: a route of a few metres, which A* finds
// at once and HH (seconds over the whole network) often does not.
bool skip_hh = false;
@@ -825,6 +784,7 @@ class NavigationWorker::Impl {
timing.road_runs, timing.base_edges, timing.settled);
trace(line);
found.push_back(std::move(segments));
+ annotate(*context);
} else if (!cancel->isAborted()) {
trace(("worker=ch_fallback why=" + (why.empty() ? std::string("route_rejected") : why)).c_str());
skip_hh = why == "too_short_for_sidecar";
@@ -835,6 +795,7 @@ class NavigationWorker::Impl {
auto context = new_context();
found = route_hh(front_end, context, sx, sy, ex, ey,
request.alternatives && kAlternativeRoutes);
+ annotate(*context);
}
if (found.empty() && !cancel->isAborted()) {
// A* (no HH data, or HH found nothing usable).
@@ -847,7 +808,10 @@ class NavigationWorker::Impl {
std::vector intermediates_y;
auto segments = front_end.searchRoute(context, sx, sy, ex, ey,
intermediates_x, intermediates_y, nullptr);
- if (!segments.empty()) found.push_back(std::move(segments));
+ if (!segments.empty()) {
+ found.push_back(std::move(segments));
+ annotate(*context);
+ }
}
if (cancel->isAborted() || found.empty()) return {};
{
@@ -860,12 +824,26 @@ class NavigationWorker::Impl {
trace(line);
}
// Fastest first; the others are labelled against it.
- std::stable_sort(found.begin(), found.end(), [](const Segments& a, const Segments& b) {
- return duration_of(a) < duration_of(b);
+ std::vector order(found.size());
+ for (std::size_t index = 0; index < order.size(); ++index) order[index] = index;
+ std::stable_sort(order.begin(), order.end(), [&](std::size_t a, std::size_t b) {
+ return duration_of(found[a]) < duration_of(found[b]);
});
+ {
+ std::vector sorted;
+ std::vector sorted_turns;
+ for (const std::size_t index : order) {
+ sorted.push_back(std::move(found[index]));
+ sorted_turns.push_back(std::move(found_turns[index]));
+ }
+ found = std::move(sorted);
+ found_turns = std::move(sorted_turns);
+ }
std::vector output;
for (std::size_t index = 0; index < found.size() && index < kMaxRoutes; ++index) {
- ui::RouteAlternative alternative = convert(request, found, index);
+ // Organic Maps switched off: OsmAnd's own manoeuvres (no Result).
+ const omaps::Result* turns = organic_turns_ ? &found_turns[index] : nullptr;
+ ui::RouteAlternative alternative = convert(request, found, index, turns);
if (alternative.geometry.size() < 2) continue;
output.push_back(std::move(alternative));
}
@@ -883,8 +861,10 @@ class NavigationWorker::Impl {
// One routing result as a UI route; geometry shorter than two points
// means unusable.
+ // turns: Organic Maps' turns for this route (omaps_turns.h); null or failed:
+ // OsmAnd's own manoeuvres.
ui::RouteAlternative convert(const Request& request, std::vector& found,
- std::size_t route_index)
+ std::size_t route_index, const omaps::Result* turns)
{
Segments& segments = found[route_index]; // getStreetName takes it non-const
ui::RouteAlternative alternative;
@@ -892,15 +872,22 @@ class NavigationWorker::Impl {
: "car-alternative-" + std::to_string(route_index);
alternative.reason = "Fastest";
alternative.arrival = "--";
+ // Per segment: route distance and geometry index at its start, its road.
+ std::vector distance_at(segments.size(), 0.0);
+ std::vector geometry_at(segments.size(), 0);
+ std::vector road_of(segments.size());
for (std::size_t segment_index = 0; segment_index < segments.size();
++segment_index) {
const auto& segment = segments[segment_index];
+ distance_at[segment_index] = alternative.distance_metres;
+ geometry_at[segment_index] =
+ alternative.geometry.empty() ? 0 : alternative.geometry.size() - 1u;
if (!segment) continue;
const double distance_at_start = alternative.distance_metres;
- const std::size_t geometry_at_start = alternative.geometry.size();
// Native road names (the design fonts include Cyrillic).
std::string road = segment->getStreetName(
"", false, segments, static_cast(segment_index));
+ road_of[segment_index] = road;
int limit = 0;
if (segment->object) {
const float metres_per_second =
@@ -911,25 +898,6 @@ class NavigationWorker::Impl {
if (alternative.roads.empty() || alternative.roads.back().name != road ||
alternative.roads.back().speed_limit_kmh != limit)
alternative.roads.push_back({distance_at_start, road, limit});
- if (segment->turnType &&
- segment->turnType->getValue() != TurnType::C) {
- ui::Maneuver maneuver;
- maneuver.kind = maneuver_kind(segment->turnType->getValue());
- maneuver.road = road;
- maneuver.distance_from_start_metres = distance_at_start;
- maneuver.geometry_index = geometry_at_start;
- maneuver.roundabout_exit = segment->turnType->getExitOut();
- maneuver.lanes = lanes_of(segment->turnType);
- maneuver.left_side = segment->turnType->isLeftSide();
- maneuver.turn_angle_degrees = segment->turnType->getTurnAngle();
- if (!segment->turnType->isRoundAbout()) {
- maneuver.junction = junction_of(segments, segment_index);
- summarize_lanes(maneuver.lanes, maneuver.junction);
- }
- if (route_index == 0 && alternative.maneuvers.size() < kJunctionTraceMax)
- trace_junction(alternative.maneuvers.size(), maneuver);
- alternative.maneuvers.push_back(std::move(maneuver));
- }
alternative.distance_metres += segment->distance;
alternative.duration_seconds += segment->segmentTime;
const int start = segment->getStartPointIndex();
@@ -947,6 +915,23 @@ class NavigationWorker::Impl {
alternative.duration = duration_label(alternative.duration_seconds);
alternative.distance = distance_label(alternative.distance_metres);
if (alternative.geometry.size() < 2) return alternative;
+ // The manoeuvres: at their route point, a segment's start or (Organic Maps'
+ // turns) any point in it; the distance along the geometry from the segment start.
+ for (auto& placed : route_maneuvers(segments, turns)) {
+ if (placed.segment >= segments.size()) continue;
+ ui::Maneuver maneuver = std::move(placed.maneuver);
+ const std::size_t at = std::min(placed.route_point, alternative.geometry.size() - 1u);
+ const std::size_t from = std::min(geometry_at[placed.segment], at);
+ double metres = distance_at[placed.segment];
+ for (std::size_t i = from; i < at; ++i)
+ metres += metres_between(alternative.geometry[i], alternative.geometry[i + 1]);
+ maneuver.road = road_of[placed.segment];
+ maneuver.distance_from_start_metres = std::min(metres, alternative.distance_metres);
+ maneuver.geometry_index = at;
+ if (route_index == 0 && alternative.maneuvers.size() < kJunctionTraceMax)
+ trace_junction(alternative.maneuvers.size(), maneuver);
+ alternative.maneuvers.push_back(std::move(maneuver));
+ }
ui::Maneuver arrive;
arrive.kind = ui::ManeuverKind::Arrive;
arrive.road = request.destination.title;
@@ -1051,6 +1036,8 @@ class NavigationWorker::Impl {
std::vector map_paths_;
std::string routing_xml_;
std::string ch_sidecar_; // empty: contraction-hierarchy routing is off
+ // Turn instructions from Organic Maps' generator (omaps_turns.h); false: OsmAnd's.
+ bool organic_turns_ = true;
std::unique_ptr ch_;
SHARED_PTR routing_config_;
std::mutex mutex_;
@@ -1080,9 +1067,11 @@ NavigationWorker::NavigationWorker(std::shared_ptr obfs,
std::vector map_paths,
std::string routing_xml,
std::string search_index,
- std::string ch_sidecar)
+ std::string ch_sidecar,
+ bool organic_turns)
: impl_(new Impl(std::move(obfs), std::move(wakeup), std::move(map_paths),
- std::move(routing_xml), search_index, std::move(ch_sidecar)))
+ std::move(routing_xml), search_index, std::move(ch_sidecar),
+ organic_turns))
{
}
diff --git a/backends/osmand/navigation_worker.h b/backends/osmand/navigation_worker.h
index 373b33f..0d1d35b 100644
--- a/backends/osmand/navigation_worker.h
+++ b/backends/osmand/navigation_worker.h
@@ -39,12 +39,15 @@ class NavigationWorker {
// search_index: the address index file (search/search_index.h); when it
// is missing or unreadable, search falls back to OsmAnd's name search.
+ // organic_turns: turn instructions from Organic Maps' generator
+ // (omaps_turns.h); false: OsmAnd's own.
NavigationWorker(std::shared_ptr obfs,
std::shared_ptr wakeup,
std::vector map_paths,
std::string routing_xml,
std::string search_index,
- std::string ch_sidecar = std::string());
+ std::string ch_sidecar = std::string(),
+ bool organic_turns = true);
~NavigationWorker();
NavigationWorker(const NavigationWorker&) = delete;
NavigationWorker& operator=(const NavigationWorker&) = delete;
diff --git a/backends/osmand/omaps_turns.cpp b/backends/osmand/omaps_turns.cpp
new file mode 100644
index 0000000..61b306e
--- /dev/null
+++ b/backends/osmand/omaps_turns.cpp
@@ -0,0 +1,947 @@
+// omaps_turns: OsmAnd route -> Organic Maps IRoutingResult -> OM car turns.
+// See omaps_turns.h. What the OM code reads from mwm features is read here from
+// OsmAnd's RouteDataObject; third_party/organicmaps-routing/README.md lists the mapping
+// and the defaults used where OsmAnd has no equivalent.
+
+#include "omaps_turns.h"
+
+// OsmAnd first: the OM shims define ASSERT/CHECK/LOG macros.
+#include "binaryRead.h"
+#include "binaryRoutePlanner.h"
+#include "generalRouter.h"
+#include "routeSegmentResult.h"
+#include "routingConfiguration.h"
+#include "routingContext.h"
+
+#include "routing/car_directions.hpp"
+#include "routing/lanes/lane_way.hpp"
+#include "routing/lanes/lanes_parser.hpp"
+#include "routing/loaded_path_segment.hpp"
+#include "routing/route.hpp"
+#include "routing/routing_result_graph.hpp"
+#include "routing/turn_candidate.hpp"
+#include "routing/turns.hpp"
+#include "routing/turns_generator.hpp"
+#include "routing/turns_generator_utils.hpp"
+
+#include "geometry/mercator.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include