Skip to content

feat: region-based road width factor with shoulder widths - #61

Merged
adam133 merged 2 commits into
mainfrom
copilot/add-region-based-road-width-factor
Mar 22, 2026
Merged

feat: region-based road width factor with shoulder widths#61
adam133 merged 2 commits into
mainfrom
copilot/add-region-based-road-width-factor

Conversation

Copilot AI commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Road widths were uniform across regions despite real-world variation — US/Canadian roads are notably wider than European equivalents. This adds a mathematical width model that accounts for lanes, road-type shoulder widths, and a per-region multiplier.

Width formula

lanes > 0:  width = (lanes × 3.5m + shoulderWidth(roadType)) × regionFactor(region)
lanes == 0: width = baseTableWidth(roadType) × regionFactor(region)

New: RegionWidthFactors class

  • GetWidthFactor(RegionType) — region multipliers: NA=1.10, EU/Boreal/Mediterranean=1.00, Desert=0.95, Arctic/Tropical=0.90, Steppe=0.85
  • GetShoulderWidth(RoadType) — total shoulder (both sides): Motorway=6m, Trunk=5m, Primary=3m, Secondary=1.5m, Tertiary=1m, Residential=0.5m, Service/Dirt/Path/Cycleway=0m

New RegionType.TemperateNorthAmerica

US and Canada are split out from Temperate (Europe/East Asia) into a dedicated TemperateNorthAmerica enum value. OSMParser maps US/CA country codes to this new type. RegionTextures uses the same asphalt/wall/roof textures as Temperate with concrete kerb (matching NA infrastructure style).

RoadMeshExtruder changes

  • New overload: GetWidthForRoadType(RoadType, int lanes, RegionType region) — applies full formula above
  • ExtrudeWithDetails(RoadType, ...) now uses the region-aware overload instead of the lane-only one, so region is factored into mesh width automatically
  • Existing 1-arg and 2-arg overloads are unchanged for backward compatibility
Original prompt

the width of roads doesn't quite match real life yet.

one factor is regionality - US roads are typically wider than most other countries.

Create a region based width factor with reasonable defaults for specific countries. come up with a mathematic function for road width - then the overall width of the roads is a function of the # of lanes for the road, width of the shoulders based on road type, and region width constant.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

- Add TemperateNorthAmerica to RegionType (US/CA wider than European Temperate)
- Update OSMParser: US, CA → TemperateNorthAmerica
- Update RegionTextures for TemperateNorthAmerica (same asphalt/roof/wall as Temperate, concrete kerb)
- Add RegionWidthFactors with GetWidthFactor(RegionType) and GetShoulderWidth(RoadType)
- Add GetWidthForRoadType(RoadType,int,RegionType) to RoadMeshExtruder using formula:
    (lanes × laneWidth + shoulder) × regionFactor  [when lanes>0]
    baseTableWidth × regionFactor                  [when lanes==0]
- Update ExtrudeWithDetails(RoadType,...) to use region-aware width formula
- Add/update tests: 622 pass (612 before)

Co-authored-by: adam133 <20442729+adam133@users.noreply.github.com>
Agent-Logs-Url: https://github.com/adam133/vectorroad/sessions/34d3b6ab-22ab-4d21-8601-8b79e570bc3a
Copilot AI changed the title [WIP] Add region based width factor for roads feat: region-based road width factor with shoulder widths Mar 22, 2026
Copilot AI requested a review from adam133 March 22, 2026 23:12
@adam133
adam133 marked this pull request as ready for review March 22, 2026 23:21
@adam133
adam133 merged commit ec4beb1 into main Mar 22, 2026
12 checks passed
@adam133
adam133 deleted the copilot/add-region-based-road-width-factor branch March 22, 2026 23:29
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