Skip to content

Add leg notifications - #230

Open
jsparidaans wants to merge 2 commits into
maplibre:mainfrom
jsparidaans:add-leg-notifications
Open

Add leg notifications#230
jsparidaans wants to merge 2 commits into
maplibre:mainfrom
jsparidaans:add-leg-notifications

Conversation

@jsparidaans

@jsparidaans jsparidaans commented Jul 17, 2026

Copy link
Copy Markdown

Description of PR

In this PR we are adding notifications to route legs. These offer us the possibility to warn drives of potential risks on their route. These notifications are implemented in accordance with the Mapbox spec outlined here.

Why

At Flitsmeister we are looking to implement ferry notifications in our routing module. At the moment the DirectionsRoute object does not know how to parse said ferry notifications, so we could either parse the raw json ourselves and hack some way around it, or we could add it to the DirectionsRoute object as an expansion.

Summary by CodeRabbit

  • New Features

    • Added support for route-leg notifications, including alerts, violations, refresh behavior, subtypes, and notification details.
    • Added notification metadata for geometry ranges, requested and actual values, units, and messages.
    • Added predefined notification types, subtypes, refresh modes, and common notification reasons.
    • Notifications are preserved through route-leg builders and default to an empty list when unavailable.
  • Tests

    • Added coverage for notification parsing, serialization, validation, defaults, and forward compatibility.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds serializable route-leg notification models, integrates notifications into RouteLeg and its builder, and adds tests for JSON handling, optional fields, unknown values, defaults, required fields, and round-tripping.

Changes

Route-leg notifications

Layer / File(s) Summary
Notification serialization contracts
maplibre-navigation-core/src/commonMain/kotlin/org/maplibre/navigation/core/models/notification/*
Defines serializable notification types, subtypes, refresh types, reasons, details, optional geometry fields, and JSON wire-name mappings.
RouteLeg notification integration
maplibre-navigation-core/src/commonMain/kotlin/org/maplibre/navigation/core/models/RouteLeg.kt
Adds notifications with an empty-list default and preserves it through Builder, build(), and toBuilder().
Notification behavior validation
maplibre-navigation-core/src/androidUnitTest/kotlin/org/maplibre/navigation/core/models/NotificationTest.kt
Tests notification deserialization and serialization, optional fields, unknown values, required fields, defaults, and builder round-tripping.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JSON
  participant RouteLeg
  participant Notification
  JSON->>RouteLeg: Decode notifications array
  RouteLeg->>Notification: Deserialize each notification
  Notification-->>RouteLeg: Populate notification fields and details
  RouteLeg-->>JSON: Serialize mapped wire field names
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding notifications to route legs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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