feat: on-device Meili map matching on Android (trace_attributes) + persistent actor + HTTP tile client#83
Open
matt-jsb wants to merge 1 commit into
Conversation
…rsistent actor + HTTP tile client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three coherent additions to the Android side of the wrapper, all aimed at
enabling Valhalla as a navigation runtime rather than just a routing endpoint:
On-device map matching —
Valhalla.traceAttributes(...)exposesValhalla's
trace_attributesaction, backed by Meili's HMM matcher. Usefulfor off-route detection, lane reasoning, and any consumer that needs the
matched road-graph edge for a sequence of GPS samples.
Persistent JNI actor — resolves the existing
// TODO: Android currently creates a new actor every time. Optimize to be like iOS later.EachValhallainstance now owns one nativeValhallaActorfor its lifetime (mmap'd tile extract held open). Requiredfor any production matching path; routing also benefits.
OkHttp-backed
ValhallaHttpClient— Android counterpart to theexisting iOS
ValhallaMobileHttpClient. Lets the wrapper pull tiles overHTTP when the tile extract isn't bundled locally; consumers pass in their
own preconfigured
OkHttpClient.A small build-script portability fix (
nprocnot available on macOS) and anoptional Cloudsmith publishing target ride along — both opt-in and don't
change upstream behaviour by default.
API additions (Android)
Valhalla : CloseableValhalla.traceAttributes(request: TraceAttributesRequest): StringValhalla.traceAttributesRaw(json: String): Stringcom.valhalla.valhalla.mapmatching.*TraceAttributesRequest,TracePoint,TraceFilters,TraceOptions,ShapeMatch,FilterAction.OkHttpValhallaHttpClientiOS is unchanged
All edits to
src/wrapper/main.cppare guarded by#ifdef __ANDROID__. The#elif __APPLE__block is byte-identical tomain. iOS Swift / Obj-C++ APIsare not touched.
Behaviour change (worth flagging)
Valhalla(context, badConfig)now throwsValhallaException.Internalatconstruction time, carrying the original native error message. Previously,
construction succeeded and every subsequent
route()returned an error JSON.The new contract is fail-fast and matches what most Android consumers expect.
Existing tests were updated to match.
Documentation
android/valhalla/docs/MapMatching.md— request/response shape, off-routedetection recipe, lifecycle notes.
android/valhalla/docs/Publishing.md— Cloudsmith publishing recipe (opt-in).Test plan
./gradlew :valhalla:connectedAndroidTest— all existing tests pass,plus new
ValhallaTraceAttributesTest(smoke test against bundledAndorra fixture) and
ValhallaHttpTileTest../gradlew ktfmtCheck— clean../build.sh android) — clean../build.sh iosstill green.What's not in this PR
MapMatcher::AppendMeasurementsbinding (Path B in the designdoc) — only worthwhile if profiling shows batch
trace_attributesis tooexpensive for live navigation. Deferred until there's evidence.
trace_attributes— followable in a separate PR.