Implement tiered route system with enhanced CSV export

This commit introduces a comprehensive tiered route generation system that replaces the basic route categories with specific route types based on medieval transportation networks:

Route System Changes:
- Major Sea Routes (majorSea): Long-distance maritime trade routes connecting capitals and major ports across water bodies, simulating Hanseatic League-style trade networks
- Regional Sea Routes (regional): Shorter routes within specific water bodies for high-traffic local maritime trade
- Royal Roads (royal): Capital-to-capital connections for diplomatic and military movement using minimum spanning tree algorithm
- Market Roads (market): Regional trade networks connecting market towns with 15-30km spacing based on medieval market day travel distances
- Local Roads (local): Village-to-market connections linking settlements to their nearest commercial centers
- Footpaths (footpath): Hamlet paths with 3-8km range for local community connections

Implementation Details:
- Removed fallback calls to legacy route generation functions to ensure clean tiered system operation
- Routes now include both 'group' (general category) and 'type' (specific tier) properties for detailed classification
- Enhanced route generation uses settlement hierarchy and geographic constraints for realistic medieval transportation patterns
- Route cost modifiers applied based on route type importance (royal and majorSea routes have priority routing)

CSV Export Enhancements:
- Added 'Type' column to routes CSV export to distinguish between route tiers
- Updated routes overview UI to display both group and type information
- Enhanced header layout to accommodate new type column
- Routes can now be analyzed by both general category and specific function

Technical Changes:
- Fixed route ID assignment conflicts between immediate and background processing phases
- Improved route data structure consistency across generation phases
- Updated routes overview display to show detailed route type information
- Enhanced CSV export function to include route type data from pack.routes
This commit is contained in:
barrulus 2025-08-14 23:47:14 +01:00
parent 8ec53293b7
commit 82eb441845
3 changed files with 17 additions and 16 deletions

View file

@ -5375,13 +5375,16 @@
</div>
<div id="routesOverview" class="dialog stable" style="display: none">
<div id="routesHeader" class="header" style="grid-template-columns: 17em 8em 8em">
<div id="routesHeader" class="header" style="grid-template-columns: 12em 6em 6em 8em">
<div data-tip="Click to sort by route name" class="sortable alphabetically" data-sortby="name">
Route&nbsp;
</div>
<div data-tip="Click to sort by route group" class="sortable alphabetically" data-sortby="group">
Group&nbsp;
</div>
<div data-tip="Click to sort by route type" class="sortable alphabetically" data-sortby="type">
Type&nbsp;
</div>
<div data-tip="Click to sort by route length" class="sortable icon-sort-number-down" data-sortby="length">
Length&nbsp;
</div>

View file

@ -353,9 +353,6 @@ window.Routes = (function () {
});
}
// Also use existing main roads logic for primary centers
const mainRoads = generateMainRoads();
marketRoads.push(...mainRoads);
TIME && console.timeEnd("generateMarketRoads");
return marketRoads;
@ -428,9 +425,6 @@ window.Routes = (function () {
}
});
// Also include existing secondary roads
const secondaryRoads = generateSecondaryRoads();
localRoads.push(...secondaryRoads);
TIME && console.timeEnd("generateLocalRoads");
return localRoads;
@ -504,9 +498,6 @@ window.Routes = (function () {
}
});
// Also include existing trails for backward compatibility
const trails = generateTrails();
footpaths.push(...trails);
TIME && console.timeEnd("generateFootpaths");
return footpaths;
@ -757,8 +748,9 @@ window.Routes = (function () {
return segments;
}
function createRoutesData(routes) {
function createRoutesData(lockedRoutes) {
const pointsArray = preparePointsArray();
const routes = [...lockedRoutes]; // Create a new array from locked routes
// Process critical routes (Tier 1 & 2) - these run immediately
for (const {feature, cells, merged, type} of mergeRoutes(majorSeaRoutes)) {

View file

@ -37,16 +37,19 @@ function overviewRoutes() {
route.length = route.length || Routes.getLength(route.i);
const length = rn(route.length * distanceScale) + " " + distanceUnitInput.value;
const routeType = route.type || route.group; // Use specific type if available
lines += /* html */ `<div
class="states"
data-id="${route.i}"
data-name="${route.name}"
data-group="${route.group}"
data-type="${routeType}"
data-length="${route.length}"
>
<span data-tip="Click to focus on route" class="icon-dot-circled pointer"></span>
<div data-tip="Route name" style="width: 15em; margin-left: 0.4em;">${route.name}</div>
<div data-tip="Route group" style="width: 8em;">${route.group}</div>
<div data-tip="Route name" style="width: 12em; margin-left: 0.4em;">${route.name}</div>
<div data-tip="Route group" style="width: 6em;">${route.group}</div>
<div data-tip="Route type" style="width: 6em;">${routeType}</div>
<div data-tip="Route length" style="width: 6em;">${length}</div>
<span data-tip="Edit route" class="icon-pencil"></span>
<span class="locks pointer ${
@ -99,13 +102,16 @@ function overviewRoutes() {
}
function downloadRoutesData() {
// Export all route types: roads (main), secondary (plaza connections), trails, searoutes
let data = "Id,Route,Group,Length\n"; // headers
// Export all route types with specific type identifiers
let data = "Id,Route,Group,Type,Length\n"; // headers
body.querySelectorAll(":scope > div").forEach(function (el) {
const d = el.dataset;
const routeId = +d.id;
const route = pack.routes.find(r => r.i === routeId);
const routeType = route?.type || d.group; // Use specific type if available, fallback to group
const length = rn(d.length * distanceScale) + " " + distanceUnitInput.value;
data += [d.id, d.name, d.group, length].join(",") + "\n";
data += [d.id, d.name, d.group, routeType, length].join(",") + "\n";
});
const name = getFileName("Routes") + ".csv";