Repository navigation
refactor(area): stop the area headers leaking names into boost - #7687
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the area-routing Boost.Geometry trait headers to avoid leaking osrm::extractor::area symbols into boost::geometry::traits via a namespace-scope using namespace in headers. It also relocates the coordinate scaling constant from Boost’s namespace to OSRM’s namespace while keeping the behavior unchanged.
Changes:
- Remove
using namespace osrm::extractor::area;from Boost.Geometry traits blocks in two headers. - Move the generic
COEFFconstant out ofboost::geometry::traitsand intoosrm::extractor::areaasMERCATOR_COEFF, updating trait accessors to use the fully qualified name. - Update
VisibilityGraph::VertexBoost.Geometry trait specializations to refer to the vertex type with a fully qualified name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/extractor/area/visibility_graph.hpp | Moves the Mercator scaling constant into OSRM’s namespace and removes Boost-namespace leakage by fully qualifying the adapted Vertex type. |
| include/extractor/area/typedefs.hpp | Removes an unnecessary using namespace directive from the Boost.Geometry traits block (traits there only specialize osmium:: types). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔧 Code Formatting Required
Option 1 — Download and apply formatting-fixes.zip: curl -LO https://nightly.link/Project-OSRM/osrm-backend/actions/runs/31478167057/formatting-fixes.zip
unzip formatting-fixes.zip
git apply formatting-fixes.patchOption 2 — Run locally: ./scripts/format.shThen commit the changes. |
Both traits blocks opened with `using namespace osrm::extractor::area;`, which every translation unit that includes the header inherits inside `boost::geometry::traits`. The one in typedefs.hpp was not needed at all: every specialisation in that block is on an `osmium::` type. The one in visibility_graph.hpp is replaced by naming `osrm::extractor::area::VisibilityGraph::Vertex` in full. `COEFF` moves out with it. It was declared in `boost::geometry::traits`, so a name that generic was being added to a namespace we do not own; it is now `osrm::extractor::area::MERCATOR_COEFF`, next to the `Vertex::point` it describes. Addresses a review comment on #7161.
a728fe2 to
b98b18d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7687 +/- ##
=======================================
Coverage 94.38% 94.38%
=======================================
Files 503 503
Lines 39154 39155 +1
=======================================
+ Hits 36955 36958 +3
+ Misses 2199 2197 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Addresses a review comment on #7161. Small and independent of the area work in flight, so it should go in first; #7684 will rebase on it.
Two headers adapt our types to
boost::geometry, and both opened the traits block withA using-directive at namespace scope in a header is inherited by every translation unit that includes it, and here it lands inside a namespace we do not own.
typedefs.hppit was not needed at all. Every specialisation in that block is on anosmium::type.visibility_graph.hppit is replaced by namingosrm::extractor::area::VisibilityGraph::Vertexin full.COEFFgoes with it. It wasinline constexpr double COEFF = 100.0;declared insideboost::geometry::traits, so a name that generic was being added to boost. It is nowosrm::extractor::area::MERCATOR_COEFF, next to theVertex::pointwhose scaling it describes.No behaviour change: same constant, same specialisations, same types.
extractor-testsandutil-testspass, and the fourfeatures/foot/area_mesh.featurescenarios pass.Written with AI assistance: Claude Code, Claude Opus 5 🤖