feat: generate direct edit handle manifest
This commit is contained in:
1 parent
3297d0c97a
commit
ab63d23896
6 files changed
+501
-35
No files matched your search
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
// Native ids link a compiled GeoJSON feature back to the semantic object it came
|
||||
// from. The constraint solver has to name the features a handle will change
|
||||
// before compileGeometry runs, so the builders live here rather than inline in
|
||||
// the geometry code: two independently written id templates would drift the
|
||||
// moment either side changed, and a stale `affects` entry silently highlights
|
||||
// the wrong road.
|
||||
//
|
||||
// Features that get split during compilation (edge lines around a junction,
|
||||
// dashed centre lines, per-lane connectors) append `:<part>` to the id below.
|
||||
// A consumer matching a handle's `affects` entry therefore tests
|
||||
// `id === entry || id.startsWith(`${entry}:`)`, which holds for both the split
|
||||
// and unsplit forms.
|
||||
|
||||
// Way-level segments keep the way id so a single-segment road reads as its OSM
|
||||
// way; split segments fall back to the segment key.
|
||||
function roadSurfaceId(road) {
|
||||
return road.segmentId.endsWith('/0') ? `surface:way/${road.osmWayIds.join(',')}` : `surface:${road.segmentId}`;
|
||||
}
|
||||
|
||||
function sidewalkId(road, side) {
|
||||
return road.segmentId.endsWith('/0')
|
||||
? `sidewalk:way/${road.osmWayIds.join(',')}:${side}`
|
||||
: `sidewalk:${road.segmentId}:${side}`;
|
||||
}
|
||||
|
||||
function laneId(roadId, index) {
|
||||
return `lane:${roadId}:${index}`;
|
||||
}
|
||||
|
||||
function laneSeparatorId(roadId, index) {
|
||||
return `lane-separator:${roadId}:${index}-${index + 1}`;
|
||||
}
|
||||
|
||||
function edgeLineId(roadId, side, part) {
|
||||
return `edge-line:${roadId}:${side}${part ? `:${part}` : ''}`;
|
||||
}
|
||||
|
||||
function centerLineId(segmentId) {
|
||||
return `center-line:${segmentId}`;
|
||||
}
|
||||
|
||||
function junctionSurfaceId(nodeId) {
|
||||
return `junction:node/${nodeId}`;
|
||||
}
|
||||
|
||||
function movementConnectorId(movementId) {
|
||||
return `connector:${movementId}`;
|
||||
}
|
||||
|
||||
function connectionConnectorId(connectionId) {
|
||||
return `connector:movement:${connectionId}`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
roadSurfaceId,
|
||||
sidewalkId,
|
||||
laneId,
|
||||
laneSeparatorId,
|
||||
edgeLineId,
|
||||
centerLineId,
|
||||
junctionSurfaceId,
|
||||
movementConnectorId,
|
||||
connectionConnectorId,
|
||||
};
|
||||
Reference in new issue
Block a user