fix(junction): anchor controls to sourced crossings
This commit is contained in:
1 parent
a98d170757
commit
d353b48a0b
1 file changed
+30
-1
@@ -301,6 +301,30 @@ function clusterArmRadiusPoint(arm, center, radius) {
|
||||
: reference;
|
||||
}
|
||||
|
||||
function clusterCrossingBaseRadius(model, arm, center, inferredRadius) {
|
||||
const inferredCenter = clusterArmRadiusPoint(arm, center, inferredRadius);
|
||||
if (!inferredCenter) return inferredRadius;
|
||||
const osmWayIds = new Set(
|
||||
arm.members.flatMap((member) => member.roads.flatMap((road) => (road.osmWayIds || []).map(String))),
|
||||
);
|
||||
const maximumDistance = Math.max(
|
||||
8,
|
||||
arm.members.reduce((width, member) => width + (Number(member.approach.widthMeters) || 0), 0) / 2 + 3,
|
||||
);
|
||||
const crossing = (model.crossings || [])
|
||||
.filter(
|
||||
(item) =>
|
||||
(item.osmWayIds || []).some((wayId) => osmWayIds.has(String(wayId))) &&
|
||||
haversineMeters(item.coordinate, inferredCenter) <= maximumDistance,
|
||||
)
|
||||
.sort(
|
||||
(first, second) =>
|
||||
haversineMeters(first.coordinate, inferredCenter) - haversineMeters(second.coordinate, inferredCenter) ||
|
||||
String(first.id).localeCompare(String(second.id)),
|
||||
)[0];
|
||||
return crossing ? haversineMeters(center, crossing.coordinate) : inferredRadius;
|
||||
}
|
||||
|
||||
function clusterArms(clusterId, items) {
|
||||
const byArm = new Map();
|
||||
for (const item of items) {
|
||||
@@ -1508,7 +1532,12 @@ function makeClusterCrossingHandles(model, junctionData, constraints, clusters)
|
||||
const pointAt = (distance) =>
|
||||
clusterArmRadiusPoint(arm, center, distance) ||
|
||||
coordinateAt(line, Math.min(0.9, Math.max(0.05, distance / length)));
|
||||
const baseCrosswalkDistance = Math.max(2, complexJunctionMetrics(cluster).coreRadius * 0.68);
|
||||
const baseCrosswalkDistance = clusterCrossingBaseRadius(
|
||||
model,
|
||||
arm,
|
||||
center,
|
||||
Math.max(2, complexJunctionMetrics(cluster).coreRadius * 0.68),
|
||||
);
|
||||
const insetConstraint = constraintFor(constraints, 'cluster-crossing-inset', anchor);
|
||||
const inset = numericValue(insetConstraint, 'insetMeters', 0);
|
||||
handles.push({
|
||||
|
||||
Reference in new issue
Block a user