fix: align junction crossings and round pedestrian islands
No files matched your search
@@ -4,3 +4,5 @@
|
||||
|
||||
- [Road Revision Storage](./road-revision-storage.md) -- immutable workbench revision layout, validation, and recovery contract.
|
||||
- [Direct Edit Solver And API](./direct-edit-api.md) -- pure constraint solving, preview/save endpoints, version protection, and rebase behavior.
|
||||
|
||||
- [Junction Island Contact](./junction-island-contact.md) -- confirmed target contract for full crossing-edge contact, dynamic island legs and the six-point green region (implementation pending).
|
||||
@@ -0,0 +1,56 @@
|
||||
# Junction island contact
|
||||
|
||||
## Status and scope
|
||||
|
||||
Confirmed user requirement, 2026-09-11; implementation pending. Applies to the
|
||||
complex-junction composition with two adjacent arm crossings and one crossing
|
||||
beside the inward-curved hypotenuse. This is not a universal traffic-island
|
||||
definition. Simple junction behavior is unchanged.
|
||||
|
||||
## Geometry contract
|
||||
|
||||
- A contact is the complete short edge of a crossing rectangle, not an arbitrary
|
||||
white stripe, a point, or only the portion that happens to intersect the island.
|
||||
- Each of the three crossings contributes one contact segment and two endpoints.
|
||||
All three complete segments must be shared with the island outer boundary.
|
||||
- Contact positions are geometry-dependent. The two perpendicular leg lengths
|
||||
are solved from the contacts and available space; twice crossing depth is not
|
||||
a hard constraint.
|
||||
- Preserve six distinct contact endpoints in boundary order. Connecting them
|
||||
forms the green hexagon on the island. Its three contact edges coincide with
|
||||
the crossing contacts; its other three edges connect adjacent contacts.
|
||||
The green region and rounded island outer boundary are distinct geometries.
|
||||
- Rounded corners and inward curves occupy non-contact boundary portions.
|
||||
A straight contact edge must remain straight over its full length, including
|
||||
the hypotenuse-side landing. Rounding must not trim away contact endpoints.
|
||||
- Solve in local metric coordinates and reuse coordinates across consumers.
|
||||
Preserve consistent stripe dimensions and spacing, avoid positive-area
|
||||
crossing/island intersection, and maintain stop-line separation.
|
||||
- If the available space cannot satisfy the composition, report the object and
|
||||
failed constraint. Do not shorten a crossing, detach it, or report the partial
|
||||
composition as valid.
|
||||
|
||||
## Required validation
|
||||
|
||||
For each complete contact segment S and published island boundary B, measure
|
||||
the length of S covered by B, not polygon intersection area alone. Require
|
||||
uncovered length and endpoint-to-boundary distance <= 0.01 m; this tolerance
|
||||
is numerical, not a design gap. Also check interior samples to catch an arc
|
||||
touching only at the endpoints.
|
||||
|
||||
The six green vertices must equal the six contact endpoints within metric
|
||||
tolerance, with each used once; the ring must be simple, have positive area,
|
||||
lie inside the outer island, and retain all three full contact edges. An
|
||||
independently fitted polygon or a hull dropping vertices fails this contract.
|
||||
|
||||
Required cases: orthogonal base case; unequal contact offsets and crossing
|
||||
depths; translated/rotated equivalents; changed available space; roundovers
|
||||
that would cut into contacts; and an infeasible composition. On the current
|
||||
real OSM, verify all contacts and all six vertices for every published island,
|
||||
not just feature counts or a hand-picked corner. Retain image evidence showing
|
||||
the outer boundary, green hexagon, complete crossing rectangles and stop lines.
|
||||
|
||||
Wrong: move a stripe until it touches an arc at one point and declare success
|
||||
because overlap area is zero. Correct: share the complete crossing short-edge
|
||||
segment with the island boundary, then derive the green polygon from those
|
||||
same endpoints and verify non-contact curves separately.
|
||||
@@ -38,7 +38,7 @@ junction-structure/v1 保持前端投影,按需扩展展示字段;不在客
|
||||
|
||||
## 设施语义契约
|
||||
|
||||
复杂路口中的行人安全岛不是独立的固定角部多边形。它是三组过街连接之间的不可通行区域:一条进口斑马线和相邻两个角部斑马线共同限定其边界。`CrosswalkConnection` 必须连接两个有效步行边界;其内侧端点吸附到 `PedestrianIsland` 或路缘边界,不能悬空或穿过岛体。
|
||||
复杂路口中的行人安全岛不是独立的固定角部多边形。它是三组过街连接之间的不可通行区域:两条相邻道路臂斑马线和一条长边侧斑马线共同限定其边界。`CrosswalkConnection` 必须连接两个有效步行边界;其内侧端点吸附到 `PedestrianIsland` 或路缘边界,不能悬空或穿过岛体。
|
||||
|
||||
- `PedestrianIsland`:独立的不可通行区域,有连续路缘边界,可作为分阶段过街等待空间。
|
||||
- `CrosswalkConnection`:连接人行道、路缘或安全岛的过街区域;斑马线不是道路装饰层。
|
||||
@@ -53,3 +53,14 @@ junction-structure/v1 保持前端投影,按需扩展展示字段;不在客
|
||||
- 不为性能让浏览器复制几何算法。记录相同输入的冷/热预览耗时与 payload;300 ms 是既有预算提示,不是无需实测的完成承诺。pending 从排队到最新结果完成持续有效。
|
||||
- 局部米制计算与 GeoJSON 经纬度输出分离;方向绕回、曲线进口、短路段、多区域、来源不完整均为失败风险。
|
||||
- 回滚按管线/能力关闭;保留新文档的可读性和不支持诊断,禁止旧管线忽略新约束却显示成功。
|
||||
|
||||
|
||||
## 2026-09-11 完整短边接触求解(待实现)
|
||||
|
||||
执行契约见 `.trellis/spec/backend/junction-island-contact.md`。最新用户要求覆盖旧的独立岛体加端点吸附方案。
|
||||
|
||||
求解应先从整组过街矩形取得两条道路臂侧完整短边,并在局部米制坐标中求其支撑线;直角骨架来自这些短边而非道路边缘。以短边端点与可用区域约束求动态腿长和第三条接触短边的位置。三个接触段确定后,外轮廓的非接触部分才生成圆角/内弧;绿色六边形只使用六个接触端点,并按外边界顺序闭合。外轮廓与绿色区域共用接触段,不各自取近似坐标。
|
||||
|
||||
完整直线短边不可能整段贴在严格弯曲的曲线上:长边侧应提供与短边等长的直线接入段,内弧在该段两侧延续。圆角不得切入三个接触段。不能通过加描边或扩大渲染宽度掩盖几何缝隙。
|
||||
|
||||
实现边界:设施组成模块负责局部求解与验证,复杂路口生成器消费同一结果发布外轮廓、绿色区域与过街;如移动可编辑过街位置,resolver 手柄同步消费同一几何定位。不得为当前 OSM 节点 ID 单独适配。无可行解时给出对象级原因,不发布假装接通的部分组合;不得悄悄缩短斑马线短边来通过验证。
|
||||
@@ -122,3 +122,39 @@ complex-junction.js / native-road.js:构建与全部消费者;direct-edit-so
|
||||
此处采用明确省略冲突对象,尚未实现绕排除区域重新求解、孔洞或多区域连通;不能据此关闭 A3/A6。下一步需建立区域级共享边界与连通性验证,再推进剩余接入位姿/左右边界编辑,最后做真实数据视觉验收。
|
||||
|
||||
本轮验证:npm test、客户端类型检查、188 项客户端单元测试、11 项 E2E(含生产构建)、format:check 与 git diff --check 全部通过。构建保留既有 bundle 大小提示。
|
||||
|
||||
## 斑马线短边构造修正(未提交)
|
||||
|
||||
用户手绘明确:两条相邻斑马线向各自路口外侧退一个完整矩形短边长度;安全岛两条直角边来自斑马线短边延长线,不来自道路圆角切线。短边延长一倍,连接端点并向直角顶点弯曲,第三组条纹平行于连接弦。
|
||||
|
||||
已修复此前无效退让:旧代码移动 frame.center 后又用原 endpoints 覆盖,实际条带未移动。现在先移动中心再生成端点;手柄同步。岛体使用最近端点处的两条短边延长线交点及两倍 groupDepth;岛体弧线纯函数覆盖手绘象限、边界相接无面积重叠、旋转平移回归。
|
||||
|
||||
当前用户 OSM 编译实测:4 个岛体,跨组斑马线重叠面积 0 m²,岛体与条带总交集约 0.00004524 m²。纯几何图为 references/crossing-short-edge-composition.png(编译坐标直接绘制,仅含目标复杂路口道路面/岛体/斑马线)。中央铺装仍存在空洞,整体任务未完成。此次未提交,不能将上述局部通过记作 A3/A8 全部通过。
|
||||
|
||||
## 用户暂存后的白条规格与正交框架调整
|
||||
|
||||
本轮保留用户 index 暂存内容,新变更只在工作区。所有复杂斑马线白条长度 3.4m、宽度 0.42m、净间隔 0.4m;端部余量居中分配,不再通过缩放间隔填满跨度。四臂且每臂与拟合正交方向偏差不超过 15°时,斑马线方向共用正交框架;其他结构保留来源方向。岛体继续引用斑马线短边,手柄使用同一退让方向。
|
||||
|
||||
当前用户 OSM 实测:4 岛,142 白条;跨组过街重叠面积 0m²,岛体与过街交集面积 0m²。references/orthogonal-crossing-composition.png 是编译几何简图,不是浏览器整图验收。中心铺装空洞仍未解决。
|
||||
|
||||
## 弧边贴合、三个圆角、停止线避让
|
||||
|
||||
第三组第一条白条按其实际宽度范围内的岛体曲线支撑位置放置,去掉首条居中余量,避免以弦代替弧造成间隙。岛体三个顶点使用曲线过渡,保留直边和中部内弯弧。停止线与手柄加入斑马线已发生的完整退让量。
|
||||
|
||||
当前 OSM 测量:停止线/斑马线面积交集 0;跨组斑马线面积交集 0;岛/斑马线约 1e-13 m²(浮点误差)。新增圆角、有限条宽弧边支撑、停止线与对应斑马线无交集回归。references/rounded-corner-detail.png 为局部编译几何图,黄色仅用于标示停止线;正式渲染颜色未改变。未提交、未改用户暂存内容。
|
||||
|
||||
### 本轮局部复核补充
|
||||
|
||||
复核修正一处遗漏:过街手柄虽然已计算四臂拟合方向,实际固定退让仍用了原道路臂方向;现使用同一 fitted heading。纯设施测试、direct-edit-solver、format:check、客户端类型检查通过。
|
||||
|
||||
停止线默认值 3m 在当前图上无交集,但不能据此宣称完整可编辑范围无重叠:将当前真实路口各 stopLineOffsetMeters 设为已允许的 0.5m,实际编译产生 47 对停止线/对应白条交集。需统一停止线退距的边界语义/可行域与手柄,再增加下界回归;复核未擅自更改文档参数语义。
|
||||
|
||||
上述下界问题已由主会话同步修正为距过街外缘的净退距,并包含停止线半厚度;复核重跑同一真实 OSM、相同 0.5m 参数,交集对数从 47 降为 0。此为当前真实样本验证,非任意斜交结构全范围保证。
|
||||
|
||||
停止线补充:按拟合斑马线方向放置,从退让后的斑马线外缘计净距,并计入停止线半厚 0.24m;编辑手柄同步。新增 0.5m 下界与对应过街无交集回归。当前真实 OSM 全部停止线/过街交集为 0。旧五臂 fixture 在最小退距时与非对应过街仍有少量交集,跨臂极端编辑避让尚未完成,不能外推为任意拓扑无冲突。
|
||||
预览 API 单独重跑通过;之前 degraded 断言失败源于其 300ms 时间预算,不能将其解释为几何功能失败。全量 fixture 基线仍与用户更新后的 OSM 不一致,未刷新基线。此次未暂存、未提交。
|
||||
|
||||
|
||||
## 2026-09-11 基线提交与新增完整接触规则
|
||||
|
||||
用户要求先提交当前视觉基线,已执行。随后补充的五条规则已写入 PRD、design 与 backend/junction-island-contact.md。此次补充为待实现契约,不声称已有代码满足完整短边接触或绿色六边形。下一实现单元:三段完整接触的共享求解 + 六点绿色区域 + 动态腿长,一起验证后交付;不得拆成独立挪动第三条斑马线、独立画绿色六边形的中间态。
|
||||
@@ -54,3 +54,18 @@ A3 的 1 cm 是内部拼接精度,不代表影像测绘精度。视觉相似
|
||||
## 待验证技术问题
|
||||
|
||||
这些问题由实施阶段证据解决,不要求用户猜实现:现有 polygon 运算是否足以完成区域验证;车道线/步行带全部裁切调用是否统一;现有 OSM 数据能支持哪些歧义归组纠正;校正与旧半径/收口约束的兼容边界。若答案导致缩减上述支持范围,须修订规划后再实施该缩减。
|
||||
|
||||
|
||||
## 2026-09-11 用户补充:三组过街完整接触与绿色六边形
|
||||
|
||||
本节为最新用户验收要求,优先于此前固定岛体、固定两倍直角边及仅端点吸附的描述。状态:规则已确认,尚待实现;当前已提交的视觉基线不能视为满足以下全部条件。
|
||||
|
||||
1. 每个此类三角安全岛的三条关联斑马线均必须与岛体接触,不允许其中一条脱离岛体。
|
||||
2. 三条接触短边在各自岛边上的位置按现场几何确定,不固定在边中点或三角顶点。
|
||||
3. 接触必须覆盖斑马线矩形的完整短边;点接触、部分短边接触、跨圆角悬空均不合格。这里的短边是整组过街矩形的短边,不是任意一根白条的边。
|
||||
4. 三条短边各贡献两个真实端点,六个不同接触点沿岛体边界排列,连接形成岛上的绿色六边形。禁止独立拟合装饰六边形、取包围盒或以凸包删掉某些接触点。
|
||||
5. 安全岛两条直角边长度可随接触位置、过街宽度及可用空间动态调整;原先“两倍短边长度”仅为旧基线,不再作为固定长度约束。
|
||||
|
||||
仍保留:复杂路口默认过街、简单路口保持现状;三组白条规格一致;停止线与过街不重叠;岛体非接触部分保留圆角与内弯轮廓。绿色六边形与岛体外轮廓属于不同几何对象。
|
||||
|
||||
新增验收 A9:三条完整短边均与岛边共享线段;六点一一对应形成非退化绿色六边形;改变接触位置或过街宽度后同步重算岛边与绿色区域,不产生悬空、面积重叠或被圆角裁掉的接触段。不得只用岛数、条纹数和面积无交集来宣称 A9 通过。
|
||||
|
After Width: | Height: | Size: 105 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-450 -450 900 900"><rect x="-450" y="-450" width="900" height="900" fill="#dce3df"/><g transform="scale(1,-1)"><path d="M-1095.6378610867202,-614.4939932910518L-213.29226690488434,-128.75252876580362L-185.08038450530614,-180.0002021833444L-1067.425978687142,-665.7416667085926L-1095.6378610867202,-614.4939932910518Z" fill="#344352"/><path d="M-91.2281387728726,229.64177865092608L-194.88448613504542,424.73029225110537L-969.7798573551645,1844.819898804324L-918.4273067116812,1872.8410563457187L-143.49454366665378,452.68281574900556L-39.567515755664175,257.0908222480824L-91.2281387728726,229.64177865092608Z" fill="#344352"/><path d="M-1013.367775978229,1817.4923386851674L-262.9788561495375,400.81538004186086L-146.6896533301025,198.70817919698567L-197.39871872197082,169.53656171171957L-314.5539788141141,373.20371196017106L-1065.0653238878551,1790.1105613138106L-1013.367775978229,1817.4923386851674Z" fill="#344352"/><path d="M1368.0796969464438,-2497.5619398169756L1298.5039289205843,-2321.5560045661964L316.32932831210917,-515.4917555691998L172.69059072657845,-262.76892271129526L139.74385428270983,-204.78813411798058L190.6034741496094,-175.88568880651906L223.54823064656085,-233.8629932858376L367.6540087507484,-487.4235204310719L1350.1791565375627,-2294.1385514342214L1422.460628744775,-2476.0041521797184L1368.0796969464438,-2497.5619398169756Z" fill="#344352"/><path d="M-224.68214389959246,-105.37017947501909L-515.0872279286506,-268.508405769127L-1099.0689655095262,-609.8660146614541L-1128.5905818785022,-559.3613413365554L-544.3226771218121,-217.8375422311953L-253.33401979912497,-54.3670620023488L-224.68214389959246,-105.37017947501909Z" fill="#344352"/><path d="M96.00729472259131,-228.77471298523346L259.08850043594725,-547.7179305910286L1249.035871739387,-2282.3800965627515L1416.959086702971,-2467.1578178123714L1373.5812389882476,-2506.408274184322L1198.951459080782,-2312.6089394377386L208.07894106190946,-576.3580334061273L43.923097404736296,-255.4105197703302L96.00729472259131,-228.77471298523346Z" fill="#344352"/><path d="M233.23107689054936,78.32407338530714L596.3544862783302,263.51917209344833L644.0531963822988,287.82449395537043L1464.6279507213658,744.848294714763L2733.7803972421652,1439.870843622405L3165.7907692256213,1674.53741182216L3193.714150425086,1623.1318086737379L2761.834721195716,1388.5365843781185L1492.8709774984325,693.617613287837L672.4153846549552,236.65968604452843L622.932673703392,211.40534390628602L259.80943702630776,26.210333281251508L233.23107689054936,78.32407338530714Z" fill="#344352"/><path d="M3147.6316218828397,1721.022561086041L2724.144484536824,1481.957558222841L577.6875866113246,321.5831882999811L212.34319469364561,129.0496153944369L185.06847262156228,180.80267784761674L549.9450577610664,373.08700770021403L2696.1665469654463,1533.333885778533L3118.871664840227,1771.9652669166117L3147.6316218828397,1721.022561086041Z" fill="#344352"/><path d="M-39.56753130044502,257.0908514991723L36.48324042870114,113.96004334034217L-15.177237858416202,86.5109412410061L-91.22812322809177,229.64174939983621L-39.56753130044502,257.0908514991723Z" fill="#344352"/><path d="M212.3748085644226,129.06645133415338L72.97722234187077,55.605564096148896L45.703749759271446,107.3589171856139L185.10130518679426,180.8198044236184L212.3748085644226,129.06645133415338Z" fill="#344352"/><path d="M139.736084322184,-204.77603973318537L61.03073045062238,-66.26777311758019L111.89272412009689,-37.36615585850927L190.59796971816922,-175.87442247411445L139.736084322184,-204.77603973318537Z" fill="#344352"/><path d="M259.8094309965691,26.210330205936145L109.72581404490273,-37.513663091724254L90.91580285029158,17.879778502846477L233.2310829202881,78.3240764606225L259.8094309965691,26.210330205936145Z" fill="#344352"/><path d="M-146.6944393063166,198.71540106493455L-65.673415128586,57.88414994031797L-116.3807613167821,28.711929180688287L-197.4018952570284,169.54318030530487L-146.6944393063166,198.71540106493455Z" fill="#344352"/><path d="M-253.33403535208728,-54.367070739471615L-115.10164963295416,23.287542778271302L-86.44970842897918,-27.715557220153357L-224.68212834663015,-105.37017073789627L-253.33403535208728,-54.367070739471615Z" fill="#344352"/><path d="M43.923082138125224,-255.41048990465185L-28.346815539813434,-114.09152384517881L23.7375254445424,-87.45577679143878L96.00730998920238,-228.77474285091182L43.923082138125224,-255.41048990465185Z" fill="#344352"/><path d="M-213.2864112595747,-128.7492471907484L-76.57309690087986,-53.4869759236247L-48.360777562056626,-104.7345427112495L-185.07412454842827,-179.9968139783732L-213.2864112595747,-128.7492471907484Z" fill="#344352"/><path d="M185.65754388327525,-10.779602121181426L174.0285612176718,-15.295153231759002L163.97411612862376,-20.40940060306184L155.49420855886086,-26.12234424932751L148.58883856565333,-32.4339841610643L143.2580060835495,-39.344320350136854L139.501711194364,-46.85335279518881L137.31995383264513,-54.96108151Line truncated
|
||||
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 103 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-450 -450 900 900"><rect x="-450" y="-450" width="900" height="900" fill="#dce3df"/><g transform="scale(1,-1)"><path d="M-1095.6378610867202,-614.4939932910518L-213.29226690488434,-128.75252876580362L-185.08038450530614,-180.0002021833444L-1067.425978687142,-665.7416667085926L-1095.6378610867202,-614.4939932910518Z" fill="#344352"/><path d="M-91.2281387728726,229.64177865092608L-194.88448613504542,424.73029225110537L-969.7798573551645,1844.819898804324L-918.4273067116812,1872.8410563457187L-143.49454366665378,452.68281574900556L-39.567515755664175,257.0908222480824L-91.2281387728726,229.64177865092608Z" fill="#344352"/><path d="M-1013.367775978229,1817.4923386851674L-262.9788561495375,400.81538004186086L-146.6896533301025,198.70817919698567L-197.39871872197082,169.53656171171957L-314.5539788141141,373.20371196017106L-1065.0653238878551,1790.1105613138106L-1013.367775978229,1817.4923386851674Z" fill="#344352"/><path d="M1368.0796969464438,-2497.5619398169756L1298.5039289205843,-2321.5560045661964L316.32932831210917,-515.4917555691998L172.69059072657845,-262.76892271129526L139.74385428270983,-204.78813411798058L190.6034741496094,-175.88568880651906L223.54823064656085,-233.8629932858376L367.6540087507484,-487.4235204310719L1350.1791565375627,-2294.1385514342214L1422.460628744775,-2476.0041521797184L1368.0796969464438,-2497.5619398169756Z" fill="#344352"/><path d="M-224.68214389959246,-105.37017947501909L-515.0872279286506,-268.508405769127L-1099.0689655095262,-609.8660146614541L-1128.5905818785022,-559.3613413365554L-544.3226771218121,-217.8375422311953L-253.33401979912497,-54.3670620023488L-224.68214389959246,-105.37017947501909Z" fill="#344352"/><path d="M96.00729472259131,-228.77471298523346L259.08850043594725,-547.7179305910286L1249.035871739387,-2282.3800965627515L1416.959086702971,-2467.1578178123714L1373.5812389882476,-2506.408274184322L1198.951459080782,-2312.6089394377386L208.07894106190946,-576.3580334061273L43.923097404736296,-255.4105197703302L96.00729472259131,-228.77471298523346Z" fill="#344352"/><path d="M233.23107689054936,78.32407338530714L596.3544862783302,263.51917209344833L644.0531963822988,287.82449395537043L1464.6279507213658,744.848294714763L2733.7803972421652,1439.870843622405L3165.7907692256213,1674.53741182216L3193.714150425086,1623.1318086737379L2761.834721195716,1388.5365843781185L1492.8709774984325,693.617613287837L672.4153846549552,236.65968604452843L622.932673703392,211.40534390628602L259.80943702630776,26.210333281251508L233.23107689054936,78.32407338530714Z" fill="#344352"/><path d="M3147.6316218828397,1721.022561086041L2724.144484536824,1481.957558222841L577.6875866113246,321.5831882999811L212.34319469364561,129.0496153944369L185.06847262156228,180.80267784761674L549.9450577610664,373.08700770021403L2696.1665469654463,1533.333885778533L3118.871664840227,1771.9652669166117L3147.6316218828397,1721.022561086041Z" fill="#344352"/><path d="M-39.56753130044502,257.0908514991723L36.48324042870114,113.96004334034217L-15.177237858416202,86.5109412410061L-91.22812322809177,229.64174939983621L-39.56753130044502,257.0908514991723Z" fill="#344352"/><path d="M212.3748085644226,129.06645133415338L72.97722234187077,55.605564096148896L45.703749759271446,107.3589171856139L185.10130518679426,180.8198044236184L212.3748085644226,129.06645133415338Z" fill="#344352"/><path d="M139.736084322184,-204.77603973318537L61.03073045062238,-66.26777311758019L111.89272412009689,-37.36615585850927L190.59796971816922,-175.87442247411445L139.736084322184,-204.77603973318537Z" fill="#344352"/><path d="M259.8094309965691,26.210330205936145L109.72581404490273,-37.513663091724254L90.91580285029158,17.879778502846477L233.2310829202881,78.3240764606225L259.8094309965691,26.210330205936145Z" fill="#344352"/><path d="M-146.6944393063166,198.71540106493455L-65.673415128586,57.88414994031797L-116.3807613167821,28.711929180688287L-197.4018952570284,169.54318030530487L-146.6944393063166,198.71540106493455Z" fill="#344352"/><path d="M-253.33403535208728,-54.367070739471615L-115.10164963295416,23.287542778271302L-86.44970842897918,-27.715557220153357L-224.68212834663015,-105.37017073789627L-253.33403535208728,-54.367070739471615Z" fill="#344352"/><path d="M43.923082138125224,-255.41048990465185L-28.346815539813434,-114.09152384517881L23.7375254445424,-87.45577679143878L96.00730998920238,-228.77474285091182L43.923082138125224,-255.41048990465185Z" fill="#344352"/><path d="M-213.2864112595747,-128.7492471907484L-76.57309690087986,-53.4869759236247L-48.360777562056626,-104.7345427112495L-185.07412454842827,-179.9968139783732L-213.2864112595747,-128.7492471907484Z" fill="#344352"/><path d="M185.65754388327525,-10.779602121181426L174.0285612176718,-15.295153231759002L163.97411612862376,-20.40940060306184L155.49420855886086,-26.12234424932751L148.58883856565333,-32.4339841610643L143.2580060835495,-39.344320350136854L139.501711194364,-46.85335279518881L137.31995383264513,-54.96108151Line truncated
|
||||
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 105 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-450 -450 900 900"><rect x="-450" y="-450" width="900" height="900" fill="#dce3df"/><g transform="scale(1,-1)"><path d="M-1095.6378610867202,-614.4939932910518L-213.29226690488434,-128.75252876580362L-185.08038450530614,-180.0002021833444L-1067.425978687142,-665.7416667085926L-1095.6378610867202,-614.4939932910518Z" fill="#344352"/><path d="M-91.2281387728726,229.64177865092608L-194.88448613504542,424.73029225110537L-969.7798573551645,1844.819898804324L-918.4273067116812,1872.8410563457187L-143.49454366665378,452.68281574900556L-39.567515755664175,257.0908222480824L-91.2281387728726,229.64177865092608Z" fill="#344352"/><path d="M-1013.367775978229,1817.4923386851674L-262.9788561495375,400.81538004186086L-146.6896533301025,198.70817919698567L-197.39871872197082,169.53656171171957L-314.5539788141141,373.20371196017106L-1065.0653238878551,1790.1105613138106L-1013.367775978229,1817.4923386851674Z" fill="#344352"/><path d="M1368.0796969464438,-2497.5619398169756L1298.5039289205843,-2321.5560045661964L316.32932831210917,-515.4917555691998L172.69059072657845,-262.76892271129526L139.74385428270983,-204.78813411798058L190.6034741496094,-175.88568880651906L223.54823064656085,-233.8629932858376L367.6540087507484,-487.4235204310719L1350.1791565375627,-2294.1385514342214L1422.460628744775,-2476.0041521797184L1368.0796969464438,-2497.5619398169756Z" fill="#344352"/><path d="M-224.68214389959246,-105.37017947501909L-515.0872279286506,-268.508405769127L-1099.0689655095262,-609.8660146614541L-1128.5905818785022,-559.3613413365554L-544.3226771218121,-217.8375422311953L-253.33401979912497,-54.3670620023488L-224.68214389959246,-105.37017947501909Z" fill="#344352"/><path d="M96.00729472259131,-228.77471298523346L259.08850043594725,-547.7179305910286L1249.035871739387,-2282.3800965627515L1416.959086702971,-2467.1578178123714L1373.5812389882476,-2506.408274184322L1198.951459080782,-2312.6089394377386L208.07894106190946,-576.3580334061273L43.923097404736296,-255.4105197703302L96.00729472259131,-228.77471298523346Z" fill="#344352"/><path d="M233.23107689054936,78.32407338530714L596.3544862783302,263.51917209344833L644.0531963822988,287.82449395537043L1464.6279507213658,744.848294714763L2733.7803972421652,1439.870843622405L3165.7907692256213,1674.53741182216L3193.714150425086,1623.1318086737379L2761.834721195716,1388.5365843781185L1492.8709774984325,693.617613287837L672.4153846549552,236.65968604452843L622.932673703392,211.40534390628602L259.80943702630776,26.210333281251508L233.23107689054936,78.32407338530714Z" fill="#344352"/><path d="M3147.6316218828397,1721.022561086041L2724.144484536824,1481.957558222841L577.6875866113246,321.5831882999811L212.34319469364561,129.0496153944369L185.06847262156228,180.80267784761674L549.9450577610664,373.08700770021403L2696.1665469654463,1533.333885778533L3118.871664840227,1771.9652669166117L3147.6316218828397,1721.022561086041Z" fill="#344352"/><path d="M-39.56753130044502,257.0908514991723L36.48324042870114,113.96004334034217L-15.177237858416202,86.5109412410061L-91.22812322809177,229.64174939983621L-39.56753130044502,257.0908514991723Z" fill="#344352"/><path d="M212.3748085644226,129.06645133415338L72.97722234187077,55.605564096148896L45.703749759271446,107.3589171856139L185.10130518679426,180.8198044236184L212.3748085644226,129.06645133415338Z" fill="#344352"/><path d="M139.736084322184,-204.77603973318537L61.03073045062238,-66.26777311758019L111.89272412009689,-37.36615585850927L190.59796971816922,-175.87442247411445L139.736084322184,-204.77603973318537Z" fill="#344352"/><path d="M259.8094309965691,26.210330205936145L109.72581404490273,-37.513663091724254L90.91580285029158,17.879778502846477L233.2310829202881,78.3240764606225L259.8094309965691,26.210330205936145Z" fill="#344352"/><path d="M-146.6944393063166,198.71540106493455L-65.673415128586,57.88414994031797L-116.3807613167821,28.711929180688287L-197.4018952570284,169.54318030530487L-146.6944393063166,198.71540106493455Z" fill="#344352"/><path d="M-253.33403535208728,-54.367070739471615L-115.10164963295416,23.287542778271302L-86.44970842897918,-27.715557220153357L-224.68212834663015,-105.37017073789627L-253.33403535208728,-54.367070739471615Z" fill="#344352"/><path d="M43.923082138125224,-255.41048990465185L-28.346815539813434,-114.09152384517881L23.7375254445424,-87.45577679143878L96.00730998920238,-228.77474285091182L43.923082138125224,-255.41048990465185Z" fill="#344352"/><path d="M-213.2864112595747,-128.7492471907484L-76.57309690087986,-53.4869759236247L-48.360777562056626,-104.7345427112495L-185.07412454842827,-179.9968139783732L-213.2864112595747,-128.7492471907484Z" fill="#344352"/><path d="M185.65754388327525,-10.779602121181426L174.0285612176718,-15.295153231759002L163.97411612862376,-20.40940060306184L155.49420855886086,-26.12234424932751L148.58883856565333,-32.4339841610643L143.2580060835495,-39.344320350136854L139.501711194364,-46.85335279518881L137.31995383264513,-54.96108151Line truncated
|
||||
|
After Width: | Height: | Size: 44 KiB |
@@ -1,10 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const { COMPLEX_CROSSWALK_DEPTH_METERS } = require('./junction-metrics');
|
||||
const { structureFromTopology } = require('./junction-topology');
|
||||
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan');
|
||||
const { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap } = require('./junction-boundary-graph');
|
||||
const { solveCornerFeasibleRegion } = require('./junction-region-solver');
|
||||
const {
|
||||
buildIslandFromCrossingEdges,
|
||||
orthogonalCrossingHeadings,
|
||||
stripeLayout,
|
||||
crossingArcSupport,
|
||||
} = require('./junction-facility-composition');
|
||||
const { complexJunctionMetrics: calculateComplexJunctionMetrics } = require('./junction-metrics');
|
||||
const { convertGeoJson, boundsOf } = require('../reference/gaode');
|
||||
const metricsCache = new WeakMap();
|
||||
@@ -157,41 +163,37 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
.map((roadId) => model.roads.find((road) => road.id === roadId))
|
||||
.find((road) => String(road?.sourceNodeIds.at(-1)) === String(item.nodeId));
|
||||
if (incomingRoad) {
|
||||
// Keep the stop bar just outside the road crosswalk. The previous fixed
|
||||
// core-radius offset placed it nearly ten metres beyond the crossing.
|
||||
// Offset is clear space beyond the relocated crossing outer edge; include
|
||||
// half the stop bar thickness so the minimum offset cannot cut into it.
|
||||
const arm = arms.find((candidate) => candidate.members.includes(item));
|
||||
const crossingKey = `crossing:${arm.key}`;
|
||||
const crossingRadius = armCrosswalkRadiusFor(arm);
|
||||
const stopOffset = crossingControls.get(crossingKey)?.stopLineOffsetMeters || 3;
|
||||
const stopCenter = pointOnCarriagewayRadius(item, center, crossingRadius + stopOffset, helpers);
|
||||
const stopHeading = orthogonalCrossingHeadings(arms.map((candidate) => candidate.heading))[arms.indexOf(arm)];
|
||||
const envelope = armEnvelopeAtRadius(arm, crossingRadius, center, helpers);
|
||||
const basePoint = pointOnCarriagewayRadius(item, center, crossingRadius, helpers);
|
||||
const lateral = signedLateralMeters(envelope.center, basePoint, stopHeading);
|
||||
const stopCenter = helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(envelope.center, stopHeading + 90, lateral),
|
||||
stopHeading,
|
||||
COMPLEX_CROSSWALK_DEPTH_METERS * 1.5 + 0.24 + stopOffset,
|
||||
);
|
||||
const crossingEvidence = crossingPlans.get(arm.key)?.evidence || {
|
||||
kind: 'unknown-no-crossing-source',
|
||||
crossingNodeIds: [],
|
||||
};
|
||||
const ring = [
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stopCenter, item.heading + 90, -outerHalf),
|
||||
item.heading,
|
||||
helpers.offsetCoordinate(stopCenter, stopHeading + 90, -outerHalf),
|
||||
stopHeading,
|
||||
-0.24,
|
||||
),
|
||||
helpers.offsetCoordinate(helpers.offsetCoordinate(stopCenter, stopHeading + 90, outerHalf), stopHeading, -0.24),
|
||||
helpers.offsetCoordinate(helpers.offsetCoordinate(stopCenter, stopHeading + 90, outerHalf), stopHeading, 0.24),
|
||||
helpers.offsetCoordinate(helpers.offsetCoordinate(stopCenter, stopHeading + 90, -outerHalf), stopHeading, 0.24),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stopCenter, item.heading + 90, outerHalf),
|
||||
item.heading,
|
||||
-0.24,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stopCenter, item.heading + 90, outerHalf),
|
||||
item.heading,
|
||||
0.24,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stopCenter, item.heading + 90, -outerHalf),
|
||||
item.heading,
|
||||
0.24,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stopCenter, item.heading + 90, -outerHalf),
|
||||
item.heading,
|
||||
helpers.offsetCoordinate(stopCenter, stopHeading + 90, -outerHalf),
|
||||
stopHeading,
|
||||
-0.24,
|
||||
),
|
||||
];
|
||||
@@ -258,57 +260,68 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
}
|
||||
arm.crosswalkFrame = {
|
||||
center: envelope.center,
|
||||
groupDepth: 3.4,
|
||||
groupDepth: COMPLEX_CROSSWALK_DEPTH_METERS,
|
||||
supportHeading: normalizeHeading(arm.heading + 90),
|
||||
envelopeWidthMeters: envelope.widthMeters,
|
||||
};
|
||||
arm.crosswalkEvidence = evidence;
|
||||
}
|
||||
const crossingHeadings = orthogonalCrossingHeadings(arms.map((arm) => arm.heading));
|
||||
arms.forEach((arm, index) => {
|
||||
if (arm.crosswalkFrame) {
|
||||
arm.crosswalkFrame.heading = crossingHeadings[index];
|
||||
arm.crosswalkFrame.supportHeading = normalizeHeading(crossingHeadings[index] + 90);
|
||||
}
|
||||
});
|
||||
for (let index = 0; index < arms.length; index += 1) {
|
||||
const arm = arms[index];
|
||||
if (!arm.crosswalkFrame) continue;
|
||||
const item = arm.representative;
|
||||
const crossingHeading = arm.crosswalkFrame.heading;
|
||||
const roadEdgeInset = 0.35;
|
||||
const usableSpan = Math.max(0.42, arm.crosswalkFrame.envelopeWidthMeters - roadEdgeInset * 2);
|
||||
const endpoints = [
|
||||
helpers.offsetCoordinate(arm.crosswalkFrame.center, arm.heading + 90, -usableSpan / 2),
|
||||
helpers.offsetCoordinate(arm.crosswalkFrame.center, arm.heading + 90, usableSpan / 2),
|
||||
];
|
||||
const groupDepth = arm.crosswalkFrame.groupDepth;
|
||||
arm.crosswalkFrame.center = helpers.offsetCoordinate(arm.crosswalkFrame.center, crossingHeading, groupDepth);
|
||||
arm.crosswalkRadius += groupDepth;
|
||||
const endpoints = [
|
||||
helpers.offsetCoordinate(arm.crosswalkFrame.center, crossingHeading + 90, -usableSpan / 2),
|
||||
helpers.offsetCoordinate(arm.crosswalkFrame.center, crossingHeading + 90, usableSpan / 2),
|
||||
];
|
||||
const stripeWidth = 0.42;
|
||||
const stripeCount = Math.max(6, Math.floor((usableSpan - stripeWidth) / 0.82) + 1);
|
||||
const stripeSpacing = stripeCount > 1 ? (usableSpan - stripeWidth) / (stripeCount - 1) : 0;
|
||||
const layout = stripeLayout(usableSpan);
|
||||
const stripeCount = layout.centers.length;
|
||||
const stripeSpacing = layout.pitch;
|
||||
arm.crosswalkFrame.center = midpoint(...endpoints);
|
||||
arm.crosswalkFrame.endpoints = endpoints;
|
||||
arm.crosswalkFrame.spanMeters = usableSpan;
|
||||
arm.crosswalkFrame.roadEdgeInsetMeters = roadEdgeInset;
|
||||
for (let stripe = 0; stripe < stripeCount; stripe += 1) {
|
||||
const along = stripeWidth / 2 + stripe * stripeSpacing;
|
||||
const along = layout.centers[stripe];
|
||||
const centerPoint = helpers.offsetCoordinate(endpoints[0], bearing(...endpoints), along);
|
||||
const ring = [
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(centerPoint, arm.heading, -groupDepth / 2),
|
||||
arm.heading + 90,
|
||||
helpers.offsetCoordinate(centerPoint, crossingHeading, -groupDepth / 2),
|
||||
crossingHeading + 90,
|
||||
-stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(centerPoint, arm.heading, groupDepth / 2),
|
||||
arm.heading + 90,
|
||||
helpers.offsetCoordinate(centerPoint, crossingHeading, groupDepth / 2),
|
||||
crossingHeading + 90,
|
||||
-stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(centerPoint, arm.heading, groupDepth / 2),
|
||||
arm.heading + 90,
|
||||
helpers.offsetCoordinate(centerPoint, crossingHeading, groupDepth / 2),
|
||||
crossingHeading + 90,
|
||||
stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(centerPoint, arm.heading, -groupDepth / 2),
|
||||
arm.heading + 90,
|
||||
helpers.offsetCoordinate(centerPoint, crossingHeading, -groupDepth / 2),
|
||||
crossingHeading + 90,
|
||||
stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(centerPoint, arm.heading, -groupDepth / 2),
|
||||
arm.heading + 90,
|
||||
helpers.offsetCoordinate(centerPoint, crossingHeading, -groupDepth / 2),
|
||||
crossingHeading + 90,
|
||||
-stripeWidth / 2,
|
||||
),
|
||||
];
|
||||
@@ -323,7 +336,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
kind: 'complex-crosswalk',
|
||||
crossing_node_id: item.nodeId,
|
||||
road_id: item.approach.roadIds[0],
|
||||
direction: arm.heading,
|
||||
direction: crossingHeading,
|
||||
radial_distance_m: arm.crosswalkRadius,
|
||||
span_m: usableSpan,
|
||||
road_envelope_span_m: arm.crosswalkFrame.envelopeWidthMeters,
|
||||
@@ -448,27 +461,29 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
},
|
||||
geometry: { type: 'Polygon', coordinates: [ring] },
|
||||
});
|
||||
const islandDepth = Math.min(7, Math.max(3, apexReach * 0.35));
|
||||
const islandHalfWidth = Math.min(
|
||||
2.2,
|
||||
Math.max(1.2, Math.min(first.widthMeters || 4, second.widthMeters || 4) * 0.28),
|
||||
if (!first.crosswalkFrame?.endpoints || !second.crosswalkFrame?.endpoints) continue;
|
||||
const endpointPairs = first.crosswalkFrame.endpoints.flatMap((a) =>
|
||||
second.crosswalkFrame.endpoints.map((b) => ({ a, b, distance: helpers.distanceMeters(a, b) })),
|
||||
);
|
||||
const islandCenter = helpers.offsetCoordinate(apex, bisector, -islandDepth * 0.5);
|
||||
const islandRing = [
|
||||
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, -islandHalfWidth),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(islandCenter, bisector, islandDepth * 0.5),
|
||||
bisector + 90,
|
||||
-islandHalfWidth * 0.72,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(islandCenter, bisector, islandDepth * 0.5),
|
||||
bisector + 90,
|
||||
islandHalfWidth * 0.72,
|
||||
),
|
||||
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, islandHalfWidth),
|
||||
helpers.offsetCoordinate(helpers.offsetCoordinate(apex, bisector, 0.6), bisector + 90, -islandHalfWidth),
|
||||
];
|
||||
const pair = endpointPairs.sort((a, b) => a.distance - b.distance)[0];
|
||||
const crossingCorner = rayIntersection(
|
||||
{ point: pair.a, heading: first.crosswalkFrame.heading },
|
||||
{ point: pair.b, heading: second.crosswalkFrame.heading },
|
||||
center,
|
||||
);
|
||||
if (!crossingCorner) continue;
|
||||
const stripeWidth = 0.42;
|
||||
const outerFirst = helpers.offsetCoordinate(
|
||||
crossingCorner,
|
||||
first.crosswalkFrame.heading,
|
||||
first.crosswalkFrame.groupDepth * 2,
|
||||
);
|
||||
const outerSecond = helpers.offsetCoordinate(
|
||||
crossingCorner,
|
||||
second.crosswalkFrame.heading,
|
||||
second.crosswalkFrame.groupDepth * 2,
|
||||
);
|
||||
const islandRing = buildIslandFromCrossingEdges(crossingCorner, outerFirst, outerSecond);
|
||||
const publishedIslandRing = islandRing;
|
||||
if (!cornerOverlapsExclusion(publishedIslandRing, first.cornerKey, '安全岛'))
|
||||
islands.push({
|
||||
@@ -493,48 +508,51 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
// Complex junctions carry a default diagonal crossing across each safe
|
||||
// corner. Source crossing nodes refine provenance/inset values, but are
|
||||
// not required for the default visual treatment.
|
||||
const islandMidpoint = publishedIslandRing
|
||||
.slice(0, -1)
|
||||
.reduce(
|
||||
(sum, point) => [
|
||||
sum[0] + point[0] / (publishedIslandRing.length - 1),
|
||||
sum[1] + point[1] / (publishedIslandRing.length - 1),
|
||||
],
|
||||
[0, 0],
|
||||
);
|
||||
const diagonalCenter = helpers.offsetCoordinate(islandMidpoint, bisector, islandHalfWidth + 1.2);
|
||||
const diagonalSpan = Math.min(6, Math.max(2.4, helpers.distanceMeters(tangents[0], tangents[1]) * 0.35));
|
||||
const diagonalDepth = 2.4;
|
||||
const stripeCount = 7;
|
||||
const stripeWidth = 0.32;
|
||||
const stripeSpacing = diagonalDepth / stripeCount;
|
||||
const outerMidpoint = [(outerFirst[0] + outerSecond[0]) / 2, (outerFirst[1] + outerSecond[1]) / 2];
|
||||
const diagonalDepth = COMPLEX_CROSSWALK_DEPTH_METERS;
|
||||
const diagonalHeading = bearing(outerFirst, outerSecond) - 90;
|
||||
const outwardHeading = bearing(crossingCorner, outerMidpoint);
|
||||
const theta = (outwardHeading * Math.PI) / 180;
|
||||
const lonScale = 111320 * Math.cos((outerMidpoint[1] * Math.PI) / 180);
|
||||
const projectedIsland = publishedIslandRing.map((p) => {
|
||||
const east = (p[0] - outerMidpoint[0]) * lonScale;
|
||||
const north = (p[1] - outerMidpoint[1]) * 111320;
|
||||
return [east * Math.cos(theta) - north * Math.sin(theta), east * Math.sin(theta) + north * Math.cos(theta)];
|
||||
});
|
||||
const support = crossingArcSupport(projectedIsland, COMPLEX_CROSSWALK_DEPTH_METERS / 2);
|
||||
if (support === null) continue;
|
||||
const diagonalCenter = helpers.offsetCoordinate(outerMidpoint, outwardHeading, support + diagonalDepth / 2);
|
||||
const diagonalSpan = COMPLEX_CROSSWALK_DEPTH_METERS;
|
||||
const layout = stripeLayout(diagonalDepth);
|
||||
const stripeCount = layout.centers.length;
|
||||
const stripeSpacing = layout.pitch;
|
||||
for (let stripe = 0; stripe < stripeCount; stripe += 1) {
|
||||
const along = -diagonalDepth / 2 + (stripe + 0.5) * stripeSpacing;
|
||||
const stripeCenter = helpers.offsetCoordinate(diagonalCenter, bisector, along);
|
||||
const along = -diagonalDepth / 2 + layout.centers[stripe] - (layout.centers[0] - stripeWidth / 2);
|
||||
const stripeCenter = helpers.offsetCoordinate(diagonalCenter, diagonalHeading, along);
|
||||
const ring = [
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stripeCenter, bisector + 90, -diagonalSpan / 2),
|
||||
bisector,
|
||||
helpers.offsetCoordinate(stripeCenter, diagonalHeading + 90, -diagonalSpan / 2),
|
||||
diagonalHeading,
|
||||
-stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stripeCenter, bisector + 90, diagonalSpan / 2),
|
||||
bisector,
|
||||
helpers.offsetCoordinate(stripeCenter, diagonalHeading + 90, diagonalSpan / 2),
|
||||
diagonalHeading,
|
||||
-stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stripeCenter, bisector + 90, diagonalSpan / 2),
|
||||
bisector,
|
||||
helpers.offsetCoordinate(stripeCenter, diagonalHeading + 90, diagonalSpan / 2),
|
||||
diagonalHeading,
|
||||
stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stripeCenter, bisector + 90, -diagonalSpan / 2),
|
||||
bisector,
|
||||
helpers.offsetCoordinate(stripeCenter, diagonalHeading + 90, -diagonalSpan / 2),
|
||||
diagonalHeading,
|
||||
stripeWidth / 2,
|
||||
),
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stripeCenter, bisector + 90, -diagonalSpan / 2),
|
||||
bisector,
|
||||
helpers.offsetCoordinate(stripeCenter, diagonalHeading + 90, -diagonalSpan / 2),
|
||||
diagonalHeading,
|
||||
-stripeWidth / 2,
|
||||
),
|
||||
];
|
||||
@@ -549,6 +567,9 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
to_boundary: `island:inferred/${first.cornerKey}`,
|
||||
cluster_id: cluster.id,
|
||||
kind: 'complex-corner-crosswalk',
|
||||
stripe_width_m: stripeWidth,
|
||||
stripe_spacing_m: stripeSpacing,
|
||||
group_depth_m: COMPLEX_CROSSWALK_DEPTH_METERS,
|
||||
corner_key: first.cornerKey,
|
||||
facility_evidence: 'default-complex-junction',
|
||||
provenance: 'native-road-complex-junction-corner-crosswalk/v1',
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { orthogonalCrossingHeadings } = require('./junction-facility-composition');
|
||||
|
||||
const { COMPLEX_CROSSWALK_DEPTH_METERS } = require('./junction-metrics');
|
||||
|
||||
const { diagnostic } = require('./diagnostics');
|
||||
const { approachForCrossing, arrivalEndpointIds, effectiveCrosswalkInsetMax } = require('./crossing-approach');
|
||||
const { haversineMeters, metersAt, polylineLength } = require('../geometry/lane-geometry');
|
||||
@@ -1798,7 +1802,9 @@ function makeClusterCrossingHandles(model, junctionData, constraints, clusters)
|
||||
if (cluster.template !== 'complex-junction-v1') continue;
|
||||
const clusterId = String(cluster.id);
|
||||
const center = clusterCenter(model, cluster);
|
||||
for (const arm of clusterArms(clusterId, itemsByCluster.get(clusterId) || [])) {
|
||||
const crossingArms = clusterArms(clusterId, itemsByCluster.get(clusterId) || []);
|
||||
const crossingHeadings = orthogonalCrossingHeadings(crossingArms.map((arm) => arm.heading));
|
||||
for (const [armIndex, arm] of crossingArms.entries()) {
|
||||
const item = arm.representative;
|
||||
const line = clusterApproachLine(item);
|
||||
const length = polylineLength(line);
|
||||
@@ -1831,7 +1837,11 @@ function makeClusterCrossingHandles(model, junctionData, constraints, clusters)
|
||||
handleId: `handle:cluster-crossing-inset:${crossingKey}`,
|
||||
kind: 'cluster-crossing-inset',
|
||||
anchor,
|
||||
position: pointAt(baseCrosswalkDistance + inset),
|
||||
position: offsetCoordinate(
|
||||
pointAt(baseCrosswalkDistance + inset),
|
||||
crossingHeadings[armIndex],
|
||||
COMPLEX_CROSSWALK_DEPTH_METERS,
|
||||
),
|
||||
axisAzimuth: arm.heading,
|
||||
value: { current: inset, min: 0, max: MAX_CROSSWALK_INSET_METERS, unit: 'meter' },
|
||||
...(insetConstraint ? { constraintId: insetConstraint.id } : {}),
|
||||
@@ -1844,7 +1854,11 @@ function makeClusterCrossingHandles(model, junctionData, constraints, clusters)
|
||||
handleId: `handle:cluster-stop-line-offset:${crossingKey}`,
|
||||
kind: 'cluster-stop-line-offset',
|
||||
anchor,
|
||||
position: pointAt(baseCrosswalkDistance + (Number.isFinite(sourceCrossingDistance) ? inset : 0) + offset),
|
||||
position: offsetCoordinate(
|
||||
pointAt(baseCrosswalkDistance + (Number.isFinite(sourceCrossingDistance) ? inset : 0)),
|
||||
crossingHeadings[armIndex],
|
||||
COMPLEX_CROSSWALK_DEPTH_METERS * 1.5 + 0.24 + offset,
|
||||
),
|
||||
axisAzimuth: arm.heading,
|
||||
value: { current: offset, min: MIN_STOP_LINE_OFFSET_METERS, max: 12, unit: 'meter' },
|
||||
...(stopConstraint ? { constraintId: stopConstraint.id } : {}),
|
||||
|
||||
@@ -17,4 +17,90 @@ function validateFacilityComposition(island, crossings) {
|
||||
return { valid: true, reason: null };
|
||||
}
|
||||
|
||||
module.exports = { buildPedestrianIsland, validateFacilityComposition };
|
||||
// The two legs are extensions of crossing short edges, in the same coordinate frame.
|
||||
function buildIslandFromCrossingEdges(corner, firstEnd, secondEnd, segments = 12) {
|
||||
const control = corner.map((value, axis) => (value + (firstEnd[axis] + secondEnd[axis]) / 2) / 2);
|
||||
const mix = (a, b, t) => a.map((v, axis) => v * (1 - t) + b[axis] * t);
|
||||
const evaluate = (t) =>
|
||||
corner.map((_, axis) => (1 - t) ** 2 * firstEnd[axis] + 2 * t * (1 - t) * control[axis] + t * t * secondEnd[axis]);
|
||||
const derivative = (t) =>
|
||||
corner.map((_, axis) => 2 * (1 - t) * (control[axis] - firstEnd[axis]) + 2 * t * (secondEnd[axis] - control[axis]));
|
||||
const cubic = (a, b, c, d) =>
|
||||
Array.from({ length: 9 }, (_, i) => {
|
||||
const t = i / 8,
|
||||
u = 1 - t;
|
||||
return a.map((v, axis) => u ** 3 * v + 3 * u * u * t * b[axis] + 3 * u * t * t * c[axis] + t ** 3 * d[axis]);
|
||||
});
|
||||
const trim = 0.2;
|
||||
const left = mix(corner, firstEnd, 1 - trim),
|
||||
right = mix(corner, secondEnd, 1 - trim);
|
||||
const arcStart = evaluate(trim),
|
||||
arcEnd = evaluate(1 - trim);
|
||||
const leftCurve = cubic(
|
||||
left,
|
||||
mix(left, firstEnd, 0.65),
|
||||
arcStart.map((v, i) => v - (derivative(trim)[i] * trim) / 3),
|
||||
arcStart,
|
||||
);
|
||||
const rightCurve = cubic(
|
||||
arcEnd,
|
||||
arcEnd.map((v, i) => v + (derivative(1 - trim)[i] * trim) / 3),
|
||||
mix(right, secondEnd, 0.65),
|
||||
right,
|
||||
);
|
||||
const nearFirst = mix(corner, firstEnd, trim),
|
||||
nearSecond = mix(corner, secondEnd, trim);
|
||||
const nose = Array.from({ length: 9 }, (_, i) => {
|
||||
const t = i / 8;
|
||||
return corner.map((v, axis) => (1 - t) ** 2 * nearSecond[axis] + 2 * t * (1 - t) * v + t * t * nearFirst[axis]);
|
||||
});
|
||||
const middle = Array.from({ length: segments + 1 }, (_, i) => evaluate(trim + ((1 - 2 * trim) * i) / segments));
|
||||
const points = [nearFirst, ...leftCurve, ...middle.slice(1), ...rightCurve.slice(1), ...nose.slice(0, -1)];
|
||||
return [...points, points[0]];
|
||||
}
|
||||
|
||||
module.exports = { buildPedestrianIsland, validateFacilityComposition, buildIslandFromCrossingEdges };
|
||||
|
||||
// Fit a common orthogonal frame only for a near-orthogonal four-arm crossing.
|
||||
function orthogonalCrossingHeadings(headings) {
|
||||
if (headings.length !== 4) return headings;
|
||||
const radians = Math.PI / 180;
|
||||
const axis =
|
||||
Math.atan2(
|
||||
headings.reduce((sum, h) => sum + Math.sin(h * radians * 4), 0),
|
||||
headings.reduce((sum, h) => sum + Math.cos(h * radians * 4), 0),
|
||||
) /
|
||||
(4 * radians);
|
||||
const fitted = headings.map((h) => axis + Math.round((h - axis) / 90) * 90);
|
||||
if (fitted.some((h, i) => Math.abs(h - headings[i]) > 15)) return headings;
|
||||
if (new Set(fitted.map((h) => ((h % 360) + 360) % 360)).size !== 4) return headings;
|
||||
return fitted;
|
||||
}
|
||||
|
||||
function stripeLayout(span, width = 0.42, gap = 0.4) {
|
||||
const pitch = width + gap;
|
||||
const count = Math.max(0, Math.floor((span + gap) / pitch));
|
||||
const margin = (span - (count * width + Math.max(0, count - 1) * gap)) / 2;
|
||||
return { width, gap, pitch, centers: Array.from({ length: count }, (_, i) => margin + width / 2 + i * pitch) };
|
||||
}
|
||||
module.exports.orthogonalCrossingHeadings = orthogonalCrossingHeadings;
|
||||
module.exports.stripeLayout = stripeLayout;
|
||||
|
||||
// Support of the curved island inside the white bar's lateral footprint.
|
||||
// Coordinates are local metres: x along the bar, y toward the outside.
|
||||
function crossingArcSupport(ring, halfWidth) {
|
||||
const candidates = [];
|
||||
for (let i = 1; i < ring.length; i++) {
|
||||
const a = ring[i - 1],
|
||||
b = ring[i];
|
||||
if (Math.abs(a[0]) <= halfWidth) candidates.push(a[1]);
|
||||
for (const x of [-halfWidth, halfWidth]) {
|
||||
if ((a[0] < x && b[0] > x) || (b[0] < x && a[0] > x)) {
|
||||
const t = (x - a[0]) / (b[0] - a[0]);
|
||||
candidates.push(a[1] + t * (b[1] - a[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return candidates.length ? Math.max(...candidates) : null;
|
||||
}
|
||||
module.exports.crossingArcSupport = crossingArcSupport;
|
||||
@@ -28,4 +28,4 @@ function complexJunctionMetrics(cluster, calibration = null) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { complexJunctionMetrics, transitionLengthForCutback };
|
||||
module.exports = { complexJunctionMetrics, transitionLengthForCutback, COMPLEX_CROSSWALK_DEPTH_METERS: 3.4 };
|
||||
@@ -479,7 +479,14 @@ const sourceCrossingRadius = Math.hypot(
|
||||
(sourceCrossingModel.crossings[0].coordinate[0] - sourceCenter[0]) * sourceLatitudeScale,
|
||||
(sourceCrossingModel.crossings[0].coordinate[1] - sourceCenter[1]) * 111320,
|
||||
);
|
||||
assert.ok(Math.abs(sourcedComplexCrosswalk.properties.radial_distance_m - sourceCrossingRadius) < 0.1);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
sourcedComplexCrosswalk.properties.radial_distance_m -
|
||||
sourceCrossingRadius -
|
||||
sourcedComplexCrosswalk.properties.group_depth_m,
|
||||
) < 0.1,
|
||||
'complex crossing retreats by its full rectangle depth from its source station',
|
||||
);
|
||||
const sourcedStopLine = sourceCrossingGeometry.vehicleStopLines.features.find(
|
||||
(feature) => feature.properties?.crossing_key === inferredStopLine.properties.crossing_key,
|
||||
);
|
||||
@@ -532,3 +539,62 @@ assert.equal(
|
||||
'source-osm-region',
|
||||
);
|
||||
console.log('road compiler package tests passed');
|
||||
|
||||
// Stop lines must remain outside the relocated matching crossing stripes.
|
||||
const polygonClipping = require('polygon-clipping');
|
||||
for (const stop of sourceCrossingGeometry.vehicleStopLines.features) {
|
||||
if (stop.properties.kind !== 'complex-stop-line') continue;
|
||||
for (const stripe of sourceCrossingGeometry.crosswalks.features) {
|
||||
if (stripe.properties.crossing_key !== stop.properties.crossing_key) continue;
|
||||
assert.deepEqual(
|
||||
polygonClipping.intersection(stop.geometry.coordinates, stripe.geometry.coordinates),
|
||||
[],
|
||||
'stop line does not intersect its crosswalk after default retreat',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const minimumStopGeometry = compiler.nativeRoad.compileGeometry(
|
||||
sourceCrossingModel,
|
||||
{ schema: 'native-road-overrides/v1', overrides: [] },
|
||||
{
|
||||
edgeLines: false,
|
||||
junctionTemplates: {
|
||||
enabled: true,
|
||||
clusters: [
|
||||
{
|
||||
id: 'fixture-five-arm',
|
||||
template: 'complex-junction-v1',
|
||||
nodeIds: ['8005332807', '8024512135', '8024512145', '8024512147', '8613058676'],
|
||||
coreRadiusMeters: 24,
|
||||
},
|
||||
],
|
||||
},
|
||||
directEdit: {
|
||||
clusterCrossings: new Map([
|
||||
[
|
||||
'fixture-five-arm',
|
||||
new Map(
|
||||
sourceCrossingGeometry.vehicleStopLines.features
|
||||
.filter((f) => f.properties.kind === 'complex-stop-line')
|
||||
.map((f) => [f.properties.crossing_key, { stopLineOffsetMeters: 0.5 }]),
|
||||
),
|
||||
],
|
||||
]),
|
||||
},
|
||||
},
|
||||
);
|
||||
const minimumStops = minimumStopGeometry.vehicleStopLines.features.filter(
|
||||
(f) => f.properties.kind === 'complex-stop-line',
|
||||
);
|
||||
assert.ok(minimumStops.length > 0);
|
||||
for (const stop of minimumStops) {
|
||||
for (const stripe of minimumStopGeometry.crosswalks.features) {
|
||||
if (stripe.properties.crossing_key !== stop.properties.crossing_key) continue;
|
||||
assert.deepEqual(
|
||||
polygonClipping.intersection(stop.geometry.coordinates, stripe.geometry.coordinates),
|
||||
[],
|
||||
'minimum stop offset must not overlap its matching crossing',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,3 +20,88 @@ assert.equal(validateFacilityComposition(island, crossings).valid, true);
|
||||
assert.equal(buildPedestrianIsland({ key: 'bad', ring, crossingKeys: ['a', 'b'] }), null);
|
||||
assert.equal(validateFacilityComposition(island, crossings.slice(0, 2)).reason, 'crossing-reference-missing');
|
||||
console.log('junction facility composition tests passed');
|
||||
|
||||
// User's sketch: a horizontal crossing to the right, a vertical crossing down,
|
||||
// and the island in the upper-left quadrant, bounded by doubled short edges.
|
||||
const { buildIslandFromCrossingEdges } = require('../src/compile/junction-facility-composition');
|
||||
const clipping = require('polygon-clipping');
|
||||
const sketchIsland = buildIslandFromCrossingEdges([0, 0], [0, 6.8], [-6.8, 0]);
|
||||
assert.deepEqual(sketchIsland[0], sketchIsland.at(-1));
|
||||
assert.ok(sketchIsland.every(([x, y]) => x <= 0 && y >= 0));
|
||||
const arcMiddle = sketchIsland[7];
|
||||
assert.ok(arcMiddle[1] - arcMiddle[0] < 6.8, 'hypotenuse bends toward the right-angle vertex');
|
||||
for (const crossing of [
|
||||
[
|
||||
[0, 0],
|
||||
[12, 0],
|
||||
[12, 3.4],
|
||||
[0, 3.4],
|
||||
[0, 0],
|
||||
],
|
||||
[
|
||||
[0, 0],
|
||||
[0, -12],
|
||||
[-3.4, -12],
|
||||
[-3.4, 0],
|
||||
[0, 0],
|
||||
],
|
||||
])
|
||||
assert.deepEqual(clipping.intersection([sketchIsland], [crossing]), [], 'short-edge attachment has no area overlap');
|
||||
const rotate = ([x, y]) => [-y + 20, x - 10];
|
||||
const rotatedIsland = buildIslandFromCrossingEdges(
|
||||
...[
|
||||
[0, 0],
|
||||
[0, 6.8],
|
||||
[-6.8, 0],
|
||||
].map(rotate),
|
||||
);
|
||||
rotatedIsland.forEach((p, i) =>
|
||||
assert.ok(
|
||||
Math.hypot(...p.map((v, j) => v - rotate(sketchIsland[i])[j])) < 1e-10,
|
||||
'composition is independent of world orientation',
|
||||
),
|
||||
);
|
||||
|
||||
const { stripeLayout, orthogonalCrossingHeadings } = require('../src/compile/junction-facility-composition');
|
||||
for (const span of [3.4, 8.123, 31.7]) {
|
||||
const layout = stripeLayout(span);
|
||||
for (let i = 1; i < layout.centers.length; i++)
|
||||
assert.ok(Math.abs(layout.centers[i] - layout.centers[i - 1] - layout.width - layout.gap) < 1e-10);
|
||||
assert.ok(layout.centers[0] >= layout.width / 2);
|
||||
assert.ok(layout.centers.at(-1) + layout.width / 2 <= span + 1e-10);
|
||||
}
|
||||
const fitted = orthogonalCrossingHeadings([62.2, 150.4, 240.7, 332]);
|
||||
for (let i = 1; i < 4; i++) assert.ok(Math.abs(fitted[i] - fitted[i - 1] - 90) < 1e-10);
|
||||
assert.deepEqual(orthogonalCrossingHeadings([0, 120, 240]), [0, 120, 240]);
|
||||
assert.deepEqual(orthogonalCrossingHeadings([0, 40, 180, 270]), [0, 40, 180, 270]);
|
||||
|
||||
const { crossingArcSupport } = require('../src/compile/junction-facility-composition');
|
||||
assert.ok(!sketchIsland.some(([x, y]) => x === 0 && y === 0), 'right-angle vertex is rounded');
|
||||
assert.ok(!sketchIsland.some(([x, y]) => x === 0 && y === 6.8), 'first arc/leg vertex is rounded');
|
||||
assert.ok(!sketchIsland.some(([x, y]) => x === -6.8 && y === 0), 'second arc/leg vertex is rounded');
|
||||
// Curve support must consider the ends of a finite-width bar, not only its centre.
|
||||
const curved = [
|
||||
[-3, 2],
|
||||
[-1, 0],
|
||||
[1, 0],
|
||||
[3, 2],
|
||||
[3, -2],
|
||||
[-3, -2],
|
||||
[-3, 2],
|
||||
];
|
||||
assert.equal(crossingArcSupport(curved, 2), 1);
|
||||
assert.deepEqual(
|
||||
clipping.intersection(
|
||||
[curved],
|
||||
[
|
||||
[
|
||||
[-2, 1],
|
||||
[2, 1],
|
||||
[2, 1.42],
|
||||
[-2, 1.42],
|
||||
[-2, 1],
|
||||
],
|
||||
],
|
||||
),
|
||||
[],
|
||||
);
|
||||