geo/overlapCalc
Spatial intersection detection between lanes and other map elements, producing ApolloOverlap proto objects.
computeAllOverlaps
function computeAllOverlaps(params: {
lanes: LaneFeature[]
crosswalks: CrosswalkFeature[]
signals: SignalFeature[]
stopSigns: StopSignFeature[]
junctions: JunctionFeature[]
clearAreas: ClearAreaFeature[]
speedBumps: SpeedBumpFeature[]
}): ComputedOverlap[]Iterates all lane × element pairs and detects spatial intersections. Returns one ComputedOverlap per detected overlap.
Returns
Each ComputedOverlap contains:
interface ComputedOverlap {
overlap: ApolloOverlap // ready-to-include proto object
laneOverlapIds: Record<string, string[]> // laneId → overlap ID list
}laneOverlapIds is a cumulative map built across all overlaps — buildBaseMap uses it to populate ApolloLane.overlap_id[].
Intersection methods by element type
Lane vs Polygon (crosswalk, clear area)
const polyLine = turf.polygonToLine(polygon) as Feature<LineString>
const intersections = turf.lineIntersect(centerLine, polyLine)For each intersection point, nearestPointOnLine computes s on the centerline. The overlap s-range is [min(s), max(s)].
Lane vs Line (signal stop line, stop sign, speed bump)
const intersections = turf.lineIntersect(centerLine, stopLine)Single intersection → s-point ± 0.5 m, clamped to [0, laneLength].
Lane vs Junction
const midPt = turf.point(centerLine.geometry.coordinates[Math.floor(n / 2)])
const inside = turf.booleanPointInPolygon(midPt, junction.polygon)If inside: s-range = [0, laneLength] (entire lane is in junction).
ComputedOverlap
interface ComputedOverlap {
overlap: ApolloOverlap
laneOverlapIds: Record<string, string[]>
}The overlap.object array contains exactly two entries:
- The lane, with
laneOverlapInfo: { startS, endS, isMerge: false } - The other element, with the appropriate
*OverlapInfo: {}field set
Overlap ID format: overlap_N where N increments from 1 per computeAllOverlaps call (counter resets on each call).