refactor(junction): keep edit metrics pure
This commit is contained in:
1 parent
88d8b841e5
commit
f56c0978b0
5 files changed
+25
-16
No files matched your search
@@ -4,6 +4,7 @@ const fs = require('fs');
|
||||
const { structureFromTopology } = require('./junction-topology');
|
||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
|
||||
const { buildJunctionBoundaryGraph, buildCoreClosure } = require('./junction-boundary-graph');
|
||||
const { complexJunctionMetrics: calculateComplexJunctionMetrics } = require('./junction-metrics');
|
||||
const { convertGeoJson, boundsOf } = require('../reference/gaode');
|
||||
const metricsCache = new WeakMap();
|
||||
const CORNER_FILLET_SEGMENTS = 12;
|
||||
@@ -665,20 +666,7 @@ function readReferenceCalibration(cluster) {
|
||||
function complexJunctionMetrics(cluster) {
|
||||
if (metricsCache.has(cluster)) return metricsCache.get(cluster);
|
||||
const calibration = readReferenceCalibration(cluster);
|
||||
// Without a reference geometry `coreRadiusMeters` is the only size input the
|
||||
// template has, so honour it literally within the schema's own 12..80 range.
|
||||
// It used to be scaled by .52 and clamped to 17, which silently capped every
|
||||
// unreferenced junction at a core far smaller than its own approach envelope
|
||||
// — a 24 m dual-carriageway arm was being fitted into a 16.6 m core no matter
|
||||
// what the config asked for. The calibrated branch is unchanged.
|
||||
const coreRadius = calibration
|
||||
? Math.max(12, Math.min(24, calibration.shortSpanMeters * 0.14))
|
||||
: Math.max(12, Math.min(80, Number(cluster.coreRadiusMeters) || 28));
|
||||
const metrics = {
|
||||
calibration,
|
||||
coreRadius,
|
||||
approachOuterRadius: coreRadius + (Number(cluster.outerRadiusExtraMeters) || 18),
|
||||
};
|
||||
const metrics = calculateComplexJunctionMetrics(cluster, calibration);
|
||||
metricsCache.set(cluster, metrics);
|
||||
return metrics;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const {
|
||||
junctionSurfaceId,
|
||||
connectionConnectorId,
|
||||
} = require('./native-ids');
|
||||
const { complexJunctionMetrics } = require('./complex-junction');
|
||||
const { complexJunctionMetrics } = require('./junction-metrics');
|
||||
const { resolveJunctionBuildPlan } = require('./junction-build-plan');
|
||||
|
||||
const RESOLUTION_SCHEMA = 'road-edit-resolution/v1';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
// Pure default geometry metrics. Reference-file calibration is resolved by the
|
||||
// compiler boundary and can be supplied as plain data by its caller.
|
||||
function complexJunctionMetrics(cluster, calibration = null) {
|
||||
const coreRadius = calibration
|
||||
? Math.max(12, Math.min(24, calibration.shortSpanMeters * 0.14))
|
||||
: Math.max(12, Math.min(80, Number(cluster.coreRadiusMeters) || 28));
|
||||
return {
|
||||
calibration,
|
||||
coreRadius,
|
||||
approachOuterRadius: coreRadius + (Number(cluster.outerRadiusExtraMeters) || 18),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { complexJunctionMetrics };
|
||||
Reference in new issue
Block a user