feat(workbench): drag control markings as elements
This commit is contained in:
1 parent
834470cfa1
commit
31552a5b6f
9 files changed
+244
-75
No files matched your search
@@ -777,7 +777,13 @@ function compileGeometry(model, overrides = { overrides: [] }, options = {}) {
|
||||
});
|
||||
const edgeLines =
|
||||
options.edgeLines === false ? [] : compileEdgeLines(model, overrides, junctionPlans, options, features);
|
||||
const controls = compileControlMarkings(model, lanes, diagnostics, junctionPlans);
|
||||
const controls = compileControlMarkings(
|
||||
model,
|
||||
lanes,
|
||||
diagnostics,
|
||||
junctionPlans,
|
||||
options.directEdit?.crossingControls,
|
||||
);
|
||||
const allControls = {
|
||||
crosswalks: [...controls.crosswalks, ...generatedComplexCrosswalks],
|
||||
stopLines: [...controls.stopLines, ...generatedComplexStopLines],
|
||||
@@ -1223,7 +1229,7 @@ function edgeLineStyle(overrides, roadId, side) {
|
||||
return value ? { color: value.color, pattern: value.pattern } : { color: 'white', pattern: 'solid' };
|
||||
}
|
||||
|
||||
function compileControlMarkings(model, lanes, diagnostics, junctionPlans = new Map()) {
|
||||
function compileControlMarkings(model, lanes, diagnostics, junctionPlans = new Map(), crossingControls = new Map()) {
|
||||
const crosswalks = [];
|
||||
const stopLines = [];
|
||||
const arrivalEndpointIds = new Set(
|
||||
@@ -1267,7 +1273,10 @@ function compileControlMarkings(model, lanes, diagnostics, junctionPlans = new M
|
||||
(a, b) => a.junctionDistanceMeters - b.junctionDistanceMeters || a.placement.distance - b.placement.distance,
|
||||
)[0];
|
||||
const crosswalkCandidate = approach || candidate;
|
||||
const junctionInsetMeters = approach ? crossingJunctionInset(approach, junctionPlans, model) : 0;
|
||||
const crossingOverride = crossingControls.get(String(crossing.id));
|
||||
const junctionInsetMeters = approach
|
||||
? crossingJunctionInset(approach, junctionPlans, model, crossingOverride?.crosswalkInsetMeters)
|
||||
: 0;
|
||||
const controlCenter = offsetByMeters(crossing.coordinate, crosswalkCandidate.placement.axis, junctionInsetMeters);
|
||||
const { axis } = crosswalkCandidate.placement;
|
||||
const across = [-axis[1], axis[0]];
|
||||
@@ -1314,7 +1323,9 @@ function compileControlMarkings(model, lanes, diagnostics, junctionPlans = new M
|
||||
const stopCenter = offsetByMeters(
|
||||
laneCenterAtCrossing,
|
||||
approach.placement.axis,
|
||||
-approachControls(junctionPlans, approach.road, model).stopLineOffsetMeters,
|
||||
-(Number.isFinite(crossingOverride?.stopLineOffsetMeters)
|
||||
? crossingOverride.stopLineOffsetMeters
|
||||
: approachControls(junctionPlans, approach.road, model).stopLineOffsetMeters),
|
||||
);
|
||||
stopLines.push(
|
||||
controlFeature(
|
||||
@@ -1379,11 +1390,13 @@ function approachControls(junctionPlans, road, model) {
|
||||
};
|
||||
}
|
||||
|
||||
function crossingJunctionInset(candidate, junctionPlans, model) {
|
||||
function crossingJunctionInset(candidate, junctionPlans, model, overrideInset) {
|
||||
const junctionNodeId = candidate.road.sourceNodeIds.at(-1);
|
||||
const plan = junctionPlans.get(junctionNodeId);
|
||||
if (!plan) return 0;
|
||||
const inset = approachControls(junctionPlans, candidate.road, model).crosswalkInsetMeters;
|
||||
const inset = Number.isFinite(overrideInset)
|
||||
? overrideInset
|
||||
: approachControls(junctionPlans, candidate.road, model).crosswalkInsetMeters;
|
||||
const targetDistance = Math.max(0, plan.cutbackMeters - inset);
|
||||
return Math.min(CROSSWALK_MAX_JUNCTION_INSET_METERS, Math.max(0, candidate.junctionDistanceMeters - targetDistance));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user