Skip to content

Allow returning geometry by leg#7256

Open
TheMarex wants to merge 11 commits intomasterfrom
patrick/geometry_by_leg
Open

Allow returning geometry by leg#7256
TheMarex wants to merge 11 commits intomasterfrom
patrick/geometry_by_leg

Conversation

@TheMarex
Copy link
Member

@TheMarex TheMarex commented Oct 2, 2025

Issue

Right now it is kind of a pain to get the route geometry by leg. You can request the steps and accumulate it, but that is annoying if you are not interested in the instructions. With hindsight that wasn't the greatest API decision, alas better fix it late then never. In general it doesn't make sense to have it by route and by leg at the same time, so it seems appropriate to extend the overview option for triggering the new behavior.

Implementation

  • Add a new overview=by_legs parameter that will add the (unsimplified) geometry by leg.
  • Add support to flatbuffer API

Tasklist

@TheMarex TheMarex force-pushed the patrick/geometry_by_leg branch from dcd81c1 to 310708e Compare January 22, 2026 16:49
@TheMarex TheMarex marked this pull request as ready for review January 22, 2026 23:50
@TheMarex TheMarex requested a review from Copilot January 22, 2026 23:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for returning geometry on a per-leg basis instead of at the route level by introducing a new overview=by_legs parameter option. This addresses a usability gap where users previously had to aggregate step geometries to get per-leg geometry, which was cumbersome when step-level instructions weren't needed.

Changes:

  • Added new ByLegs enum value to RouteParameters::OverviewType to support the new parameter
  • Updated Route, Match, and Trip APIs to populate leg-level geometry when overview=by_legs is specified, while omitting route-level geometry
  • Extended FlatBuffer schema to support geometry fields on the Leg table
  • Updated documentation across HTTP API docs, Node.js API docs, and inline code documentation
  • Added comprehensive test coverage for both JSON and FlatBuffer formats across Route, Match, and Trip APIs
  • Refactored CMakeLists.txt to use a proper custom target for test data generation

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
include/engine/api/route_parameters.hpp Added ByLegs enum value to OverviewType
include/server/api/route_parameters_grammar.hpp Added "by_legs" to HTTP parameter grammar
include/nodejs/node_osrm_support.hpp Added "by_legs" support to Node.js bindings
src/nodejs/node_osrm.cpp Updated Node.js API documentation to describe by_legs option
include/engine/api/route_api.hpp Core implementation: generates leg geometries when ByLegs is set, skips route geometry
src/engine/api/json_factory.cpp Modified makeRouteLeg to accept optional leg_geometry parameter
include/engine/api/json_factory.hpp Updated function signature declarations (but has critical mismatch issue)
include/engine/api/flatbuffers/route.fbs Added polyline and coordinates fields to Leg table
generated/include/engine/api/flatbuffers/route_generated.h Auto-generated FlatBuffer code for new schema
unit_tests/library/route.cpp Added comprehensive tests for route API with by_legs option
unit_tests/library/match.cpp Added comprehensive tests for match API with by_legs option
unit_tests/library/trip.cpp Added comprehensive tests for trip API with by_legs option
unit_tests/CMakeLists.txt Refactored test data build to use custom target
test/nodejs/route.js Updated error message expectations to include by_legs
docs/nodejs/api.md Updated documentation to describe by_legs option
docs/http.md Updated HTTP API documentation for Route, Match, and Trip endpoints
CHANGELOG.md Added entry for the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TheMarex TheMarex force-pushed the patrick/geometry_by_leg branch from d845632 to 44857a6 Compare January 27, 2026 14:58
@TheMarex TheMarex requested a review from DennisOSRM January 27, 2026 15:00
TheMarex and others added 11 commits January 27, 2026 23:40
- Update HTTP API docs for route, match, and trip services
- Update Node.js API docs for route, match, and trip methods
- Update test error messages to include by_legs option

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This is mostly relevant for library-tests which expects
an extracted osrm dataset.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TheMarex TheMarex force-pushed the patrick/geometry_by_leg branch from 3742ea7 to 56129ea Compare January 27, 2026 22:40
}

util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps)
util::json::Object makeRouteLeg(guidance::RouteLeg leg,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeRouteLeg was removed from the header - should this be static or in an anonymous namespace now?

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