Skip to content

feat(library): add time dimension and 4D track support to FlexiblePolyline - #1833

Draft
dkhawk wants to merge 2 commits into
mainfrom
feat/flexible-polyline-time
Draft

dkhawk wants to merge 2 commits into
mainfrom
feat/flexible-polyline-time

Conversation

@dkhawk

@dkhawk dkhawk commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends FlexiblePolylineUtil, FlexiblePolyline, and FlexiblePoint with an optional, self-describing time dimension to support 3D (lat, lng, time) and 4D (lat, lng, elevation/altitude, time) tracks (e.g., hikes, runs, bike rides, and flight paths) while maintaining 100% wire compatibility with the HERE Flexible Polyline v1 specification whenever hasTime = false.

Key Changes

  • Self-Describing Header Extension (FlexiblePolylineUtil):
    • Uses bit 11 (hasTime) and bits 12..15 (timePrecision in 0..9) of the header varint. When hasTime = false, bits 11..15 are 0, producing bit-for-bit identical HERE v1 output.
    • Defaults to DEFAULT_PRECISION = 6 (~11 cm spatial resolution) and DEFAULT_TIME_PRECISION = 1 (100 ms temporal resolution), while keeping precision (0..15), thirdDimensionPrecision (0..15), and timePrecision (0..9) user-selectable per encode(...) call.
    • Scales and delta-encodes timestampMillis: Long in pure 64-bit integer arithmetic (scaleTimeMillis / unscaleTimeMillis) with half-away-from-zero tie rounding and zero floating-point precision loss.
    • Adds FlexiblePolylineUtil.hasTime(encoded) to inspect the header without decoding points.
  • Data Model & Playback Helpers (FlexiblePoint, FlexiblePolyline):
    • Adds timestampMillis: Long? = null and @RequiresApi(O) java.time.Instant constructor/property overloads to FlexiblePoint.
    • Adds hasTime, timePrecision, durationMillis, interpolateAtTime(timestampMillis / Instant), and getPrefixAtTime(timestampMillis / Instant) to FlexiblePolyline.
  • 4D Track Demo (FlexiblePolylineDemoActivity):
    • Encodes, decodes, and scrubs a 4D track across the Sydney Harbour Bridge climb with interactive playback, live elevation readout, and elapsed time telemetry.
  • Tests:
    • Adds unit tests in FlexiblePolylineUtilTest covering 3D and 4D timed tracks, default vs. user-selected precisions, Instant overloads, quantization tie-breaking, interpolateAtTime, getPrefixAtTime, and validation errors.

@googlemaps-bot

googlemaps-bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 63% -0.13% 🍏
Files changed 92.7% 🍏

Module Coverage
Kover Gradle Plugin XML report for :library 89.84% -0.82% 🍏
Files
Module File Coverage
Kover Gradle Plugin XML report for :library FlexiblePolyline.kt 95.03% -3.82% 🍏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants