@drawtonomy/sdk 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export { exportToOpenDrive } from './opendrive';
1
+ export { exportToOpenDrive, type OpenDriveExportOptions } from './opendrive';
2
2
  export { latLonToTmercProj, latLonToUtmProj, originToProjString, FALLBACK_GEO_REFERENCE, type GeoOrigin, } from './projection';
3
3
  export { exportToOpenScenario, templateIdToVehicleCategory, type OpenScenarioExportOptions, type TemplateResolver, } from './openscenario';
4
4
  export { buildPathTrajectory, DEFAULT_PATH_SPEED_MPS, type PathSamplePoint, type PathTrajectoryInput, } from './trajectory';
@@ -12,5 +12,5 @@ export { parseOsmXml, latLonToCanvas, canvasToLatLon, type OsmData, type OsmNode
12
12
  export { osmToShapes, alignBoundaries, createShapeIdAllocator, type ImportedShapes, type ImportedPoint, type ImportedLinestring, type ImportedLane, type ImportedTrafficLight, type ImportedCrosswalk, type ImportBounds, type OsmToShapesOptions, type ShapeIdAllocator, } from './osmToShapes';
13
13
  export { parseOpenDriveXml, type OdrMap, type OdrHeader, type OdrRoad, type OdrGeometry, type OdrLane, type OdrLaneSection, type OdrLaneOffset, type OdrWidth, type OdrRoadMark, type OdrRoadLink, type OdrSignal, type OdrSignalValidity, type OdrObject, type OdrJunction, type OdrJunctionConnection, type OdrJunctionLaneLink, type OdrCubic, } from './opendriveParser';
14
14
  export { evalGeometry, evalPoly3, fresnel, sampleReferenceLine, type GeomPose, type ReferenceSample, type SampleReferenceLineOptions, } from './odrGeometry';
15
- export { odrToShapes, parseGeoReferenceOrigin, type OdrImportResult, type OdrSidecar, type OdrToShapesOptions, } from './odrToShapes';
15
+ export { odrToShapes, parseGeoReferenceOrigin, type OdrImportResult, type OdrRoadRecord, type OdrSidecar, type OdrToShapesOptions, } from './odrToShapes';
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.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,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,QAAQ,GACd,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,YAAY,EACZ,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exporter/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,SAAS,GACf,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,eAAe,EACf,KAAK,OAAO,EACZ,K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P,mBAAmB,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exporter/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,yCAAyC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAG5B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GAGvB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,eAAe,GAGhB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,cAAc,EAAuD,MAAM,iBAAiB,CAAA;AACrG,OAAO,EAAE,QAAQ,EAAiB,MAAM,OAAO,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GAInB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,GAKf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,eAAe,EACf,sBAAsB,GAUvB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,iBAAiB,GAk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,OAAO,EACP,mBAAmB,GAIpB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,WAAW,EACX,uBAAuB,GAKxB,MAAM,eAAe,CAAA"}
@@ -0,0 +1,89 @@
1
+ import type { Point2D } from './laneCenterline';
2
+ /** Per-road record captured at import time (stored in the sidecar). */
3
+ export interface OdrRoadRecord {
4
+ /** Lane shape ids materialized from this road, in materialization order. */
5
+ laneShapeIds: string[];
6
+ /** Hash of the road's editable shape state at import time. */
7
+ stateHash: string;
8
+ }
9
+ /** Editable state of one lane shape, as fed into the road state hash. */
10
+ export interface CarryLaneState {
11
+ /** Left boundary points in travel order (canvas px), or null when unusable. */
12
+ leftPts: readonly Point2D[] | null;
13
+ rightPts: readonly Point2D[] | null;
14
+ attributes: Record<string, string | undefined>;
15
+ next: readonly string[];
16
+ prev: readonly string[];
17
+ yieldLaneIds: readonly string[];
18
+ }
19
+ /** Editable state of a regulatory shape (traffic light / crosswalk). */
20
+ export interface CarryRegulatoryState {
21
+ kind: 'traffic_light' | 'crosswalk';
22
+ shapeId: string;
23
+ /** Positional numeric fields (position, size, rotation). */
24
+ numbers: readonly number[];
25
+ attributes: Record<string, string | undefined>;
26
+ affectedLaneIds: readonly string[];
27
+ stopLinePts: readonly Point2D[] | null;
28
+ controllerId: string;
29
+ }
30
+ /**
31
+ * Deterministic serialization of a road's editable shape state. Lane order
32
+ * follows the record's laneShapeIds (identical on both sides by
33
+ * construction); regulatory shapes are sorted by shape id.
34
+ */
35
+ export declare function serializeRoadState(lanes: readonly CarryLaneState[], regulatory: readonly CarryRegulatoryState[]): string;
36
+ /** Hash of `serializeRoadState` (two independent 32-bit FNV-1a streams). */
37
+ export declare function hashRoadState(lanes: readonly CarryLaneState[], regulatory: readonly CarryRegulatoryState[]): string;
38
+ export interface OdrDocRoad {
39
+ id: string;
40
+ /** Junction this road belongs to ("-1" for normal roads). */
41
+ junction: string;
42
+ /** Verbatim element text (exact substring of the original XML). */
43
+ text: string;
44
+ /** elementIds of road-level <predecessor>/<successor> with elementType="road". */
45
+ linkRoadRefs: string[];
46
+ /** elementIds of road-level links with elementType="junction". */
47
+ linkJunctionRefs: string[];
48
+ /** ids of <signal> definitions inside this road. */
49
+ signalIds: string[];
50
+ }
51
+ export interface OdrDocJunction {
52
+ id: string;
53
+ text: string;
54
+ /** incomingRoad / connectingRoad ids referenced by <connection> records. */
55
+ memberRoadIds: string[];
56
+ }
57
+ export interface OdrDocController {
58
+ id: string;
59
+ text: string;
60
+ /** signalIds referenced by <control> records. */
61
+ signalIds: string[];
62
+ }
63
+ export interface OdrDocument {
64
+ headerText: string | null;
65
+ roads: OdrDocRoad[];
66
+ junctions: OdrDocJunction[];
67
+ controllers: OdrDocController[];
68
+ /** Largest numeric id over roads / junctions (0 when none are numeric). */
69
+ maxNumericElementId: number;
70
+ /** Largest numeric id over <signal>/<signalReference> records. */
71
+ maxNumericSignalId: number;
72
+ /** Largest numeric <controller> id. */
73
+ maxNumericControllerId: number;
74
+ }
75
+ /**
76
+ * Extract the verbatim header / road / junction / controller blocks from an
77
+ * OpenDRIVE document. Returns null when the input does not look like
78
+ * OpenDRIVE XML. Regex block matching is safe here because none of these
79
+ * elements nest within themselves.
80
+ */
81
+ export declare function extractOdrDocument(xml: string): OdrDocument | null;
82
+ /**
83
+ * Rewrite the elementId of road-level <predecessor>/<successor> records
84
+ * according to `roadMapping` (elementType="road") and `junctionMapping`
85
+ * (elementType="junction"), each original id -> new id. Every byte outside
86
+ * the rewritten attribute values is preserved.
87
+ */
88
+ export declare function rewriteRoadLinkTargets(text: string, roadMapping: Map<string, string>, junctionMapping?: Map<string, string>): string;
89
+ //# sourceMappingURL=odrCarryThrough.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odrCarryThrough.d.ts","sourceRoot":"","sources":["../../src/exporter/odrCarryThrough.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C,uEAAuE;AACvE,MAAM,WAAW,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IACnE,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,oDAAoD;IACpD,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,iDAAiD;IACjD,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,SAAS,EAAE,cAAc,EAAE,CAAA;IAC3B,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,2EAA2E;IAC3E,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,CAAA;IAC1B,uCAAuC;IACvC,sBAAsB,EAAE,MAAM,CAAA;CAC/B;AAgBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAgFlE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,eAAe,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,GAC/C,MAAM,CAYR"}
@@ -0,0 +1,186 @@
1
+ // Carry-through support for OpenDRIVE round trips.
2
+ //
3
+ // An imported .xodr keeps its original XML in the sidecar. On export, roads
4
+ // whose shapes were NOT edited since import are re-emitted verbatim (the
5
+ // exact original <road> element text), and only edited roads go through the
6
+ // regular fitting exporter. This makes an unedited import -> export round
7
+ // trip lossless at the XML level, including features the shape model does
8
+ // not represent (elevation profiles, unknown signal types, custom userData).
9
+ //
10
+ // Two halves live here, shared by the importer and the exporter:
11
+ //
12
+ // 1. Road state hashing. At import time `odrToShapes` records, per source
13
+ // road, the shape ids it materialized plus a hash over their editable
14
+ // state: boundary point sequences (in travel order), lane attributes,
15
+ // next/prev connectivity, right-of-way links, and every regulatory shape
16
+ // (traffic light / crosswalk) touching the road. At export time the same
17
+ // hash is recomputed from the live shapes; equality means "unedited".
18
+ //
19
+ // 2. Raw document access. <header> / <road> / <junction> / <controller>
20
+ // elements are extracted from the original XML as verbatim text blocks
21
+ // together with their ids and cross-references (link targets, junction
22
+ // membership, signal definitions), so the exporter can decide what stays
23
+ // verbatim, propagate dirtiness across junctions, keep id spaces
24
+ // collision-free, and rewrite only the link elementIds that must point at
25
+ // regenerated roads — leaving every other byte untouched.
26
+ const fmtPts = (pts) => pts ? pts.map(p => `${p.x},${p.y}`).join(';') : 'null';
27
+ const fmtAttrs = (attrs) => Object.entries(attrs)
28
+ .filter(([, v]) => v !== undefined && v !== null)
29
+ .map(([k, v]) => `${k}=${v}`)
30
+ .sort()
31
+ .join('&');
32
+ const fmtIds = (ids) => [...ids].sort().join(',');
33
+ /**
34
+ * Deterministic serialization of a road's editable shape state. Lane order
35
+ * follows the record's laneShapeIds (identical on both sides by
36
+ * construction); regulatory shapes are sorted by shape id.
37
+ */
38
+ export function serializeRoadState(lanes, regulatory) {
39
+ const laneStr = lanes
40
+ .map(l => `L:${fmtPts(l.leftPts)}|R:${fmtPts(l.rightPts)}|A:${fmtAttrs(l.attributes)}` +
41
+ `|N:${fmtIds(l.next)}|P:${fmtIds(l.prev)}|Y:${fmtIds(l.yieldLaneIds)}`)
42
+ .join('\n');
43
+ const regStr = [...regulatory]
44
+ .sort((a, b) => (a.shapeId < b.shapeId ? -1 : a.shapeId > b.shapeId ? 1 : 0))
45
+ .map(r => `${r.kind}:${r.shapeId}|#:${r.numbers.join(',')}|A:${fmtAttrs(r.attributes)}` +
46
+ `|F:${fmtIds(r.affectedLaneIds)}|S:${fmtPts(r.stopLinePts)}|C:${r.controllerId}`)
47
+ .join('\n');
48
+ return `${laneStr}\u0000${regStr}`;
49
+ }
50
+ /** Hash of `serializeRoadState` (two independent 32-bit FNV-1a streams). */
51
+ export function hashRoadState(lanes, regulatory) {
52
+ const s = serializeRoadState(lanes, regulatory);
53
+ let a = 0x811c9dc5 | 0;
54
+ let b = (0x811c9dc5 ^ 0x5bd1e995) | 0;
55
+ for (let i = 0; i < s.length; i++) {
56
+ const c = s.charCodeAt(i);
57
+ a = Math.imul(a ^ c, 0x01000193);
58
+ b = Math.imul(b ^ c, 0x01000197);
59
+ }
60
+ return ((a >>> 0).toString(16).padStart(8, '0') + (b >>> 0).toString(16).padStart(8, '0'));
61
+ }
62
+ /** Match all `<tag .../>` or `<tag ...>...</tag>` blocks (tags do not nest). */
63
+ function matchBlocks(xml, tag) {
64
+ const re = new RegExp(`<${tag}\\b[^>]*(?:/>|>[\\s\\S]*?</${tag}>)`, 'g');
65
+ return xml.match(re) ?? [];
66
+ }
67
+ /** Attribute value from an element's opening tag, or null. */
68
+ function attrOf(block, name) {
69
+ const end = block.indexOf('>');
70
+ const open = end >= 0 ? block.slice(0, end + 1) : block;
71
+ const m = open.match(new RegExp(`\\b${name}="([^"]*)"`));
72
+ return m ? m[1] : null;
73
+ }
74
+ /**
75
+ * Extract the verbatim header / road / junction / controller blocks from an
76
+ * OpenDRIVE document. Returns null when the input does not look like
77
+ * OpenDRIVE XML. Regex block matching is safe here because none of these
78
+ * elements nest within themselves.
79
+ */
80
+ export function extractOdrDocument(xml) {
81
+ if (!/<OpenDRIVE[\s>]/.test(xml))
82
+ return null;
83
+ const headerMatch = xml.match(/<header\b[^>]*(?:\/>|>[\s\S]*?<\/header>)/);
84
+ const roads = [];
85
+ for (const text of matchBlocks(xml, 'road')) {
86
+ const id = attrOf(text, 'id');
87
+ if (id === null)
88
+ continue;
89
+ const linkRoadRefs = [];
90
+ const linkJunctionRefs = [];
91
+ for (const tag of text.match(/<(?:predecessor|successor)\b[^>]*\/?>/g) ?? []) {
92
+ const elementType = tag.match(/\belementType="([^"]*)"/)?.[1];
93
+ const elementId = tag.match(/\belementId="([^"]*)"/)?.[1];
94
+ if (elementId === undefined)
95
+ continue;
96
+ if (elementType === 'road')
97
+ linkRoadRefs.push(elementId);
98
+ else if (elementType === 'junction')
99
+ linkJunctionRefs.push(elementId);
100
+ }
101
+ const signalIds = [];
102
+ for (const tag of text.match(/<signal\b[^>]*/g) ?? []) {
103
+ const sid = tag.match(/\bid="([^"]*)"/)?.[1];
104
+ if (sid !== undefined)
105
+ signalIds.push(sid);
106
+ }
107
+ roads.push({
108
+ id,
109
+ junction: attrOf(text, 'junction') ?? '-1',
110
+ text,
111
+ linkRoadRefs,
112
+ linkJunctionRefs,
113
+ signalIds,
114
+ });
115
+ }
116
+ const junctions = [];
117
+ for (const text of matchBlocks(xml, 'junction')) {
118
+ const id = attrOf(text, 'id');
119
+ if (id === null)
120
+ continue;
121
+ const memberRoadIds = [];
122
+ for (const tag of text.match(/<connection\b[^>]*/g) ?? []) {
123
+ for (const name of ['incomingRoad', 'connectingRoad']) {
124
+ const v = tag.match(new RegExp(`\\b${name}="([^"]*)"`))?.[1];
125
+ if (v !== undefined && !memberRoadIds.includes(v))
126
+ memberRoadIds.push(v);
127
+ }
128
+ }
129
+ junctions.push({ id, text, memberRoadIds });
130
+ }
131
+ const controllers = [];
132
+ for (const text of matchBlocks(xml, 'controller')) {
133
+ const id = attrOf(text, 'id') ?? '';
134
+ const signalIds = [];
135
+ for (const tag of text.match(/<control\b[^>]*/g) ?? []) {
136
+ const sid = tag.match(/\bsignalId="([^"]*)"/)?.[1];
137
+ if (sid !== undefined)
138
+ signalIds.push(sid);
139
+ }
140
+ controllers.push({ id, text, signalIds });
141
+ }
142
+ const numericMax = (ids) => {
143
+ let max = 0;
144
+ for (const id of ids) {
145
+ if (/^\d+$/.test(id))
146
+ max = Math.max(max, parseInt(id, 10));
147
+ }
148
+ return max;
149
+ };
150
+ const signalRefIds = [];
151
+ for (const tag of xml.match(/<signalReference\b[^>]*/g) ?? []) {
152
+ const sid = tag.match(/\bid="([^"]*)"/)?.[1];
153
+ if (sid !== undefined)
154
+ signalRefIds.push(sid);
155
+ }
156
+ return {
157
+ headerText: headerMatch ? headerMatch[0] : null,
158
+ roads,
159
+ junctions,
160
+ controllers,
161
+ maxNumericElementId: numericMax([...roads.map(r => r.id), ...junctions.map(j => j.id)]),
162
+ maxNumericSignalId: numericMax([...roads.flatMap(r => r.signalIds), ...signalRefIds]),
163
+ maxNumericControllerId: numericMax(controllers.map(c => c.id)),
164
+ };
165
+ }
166
+ /**
167
+ * Rewrite the elementId of road-level <predecessor>/<successor> records
168
+ * according to `roadMapping` (elementType="road") and `junctionMapping`
169
+ * (elementType="junction"), each original id -> new id. Every byte outside
170
+ * the rewritten attribute values is preserved.
171
+ */
172
+ export function rewriteRoadLinkTargets(text, roadMapping, junctionMapping = new Map()) {
173
+ if (roadMapping.size === 0 && junctionMapping.size === 0)
174
+ return text;
175
+ return text.replace(/<(?:predecessor|successor)\b[^>]*\/?>/g, tag => {
176
+ const elementType = tag.match(/\belementType="([^"]*)"/)?.[1];
177
+ const mapping = elementType === 'road' ? roadMapping : elementType === 'junction' ? junctionMapping : null;
178
+ if (!mapping || mapping.size === 0)
179
+ return tag;
180
+ return tag.replace(/(\belementId=")([^"]*)(")/, (m, pre, idv, post) => {
181
+ const repl = mapping.get(idv);
182
+ return repl !== undefined ? pre + repl + post : m;
183
+ });
184
+ });
185
+ }
186
+ //# sourceMappingURL=odrCarryThrough.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odrCarryThrough.js","sourceRoot":"","sources":["../../src/exporter/odrCarryThrough.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,4EAA4E;AAC5E,yEAA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QAC9C,OAAO,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC,EAAE,GAAW,EAAE,GAAW,EAAE,IAAY,EAAE,EAAE;YAC5F,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC7B,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { OdrGeometry } from './opendriveParser';
2
+ export interface FitPoint {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export interface PlanViewFitOptions {
7
+ /** Maximum position deviation between samples and the fit (m). Default 0.05. */
8
+ maxPosErrorMeters?: number;
9
+ /** Maximum end-heading deviation per segment (rad). Default 0.5 degrees. */
10
+ maxHdgErrorRad?: number;
11
+ /** Moving-median window (odd) for heading de-noising. Default 3; 1 disables. */
12
+ headingMedianWindow?: number;
13
+ }
14
+ /** Station + pose on the fitted reference line for one input sample. */
15
+ export interface FittedSamplePose {
16
+ s: number;
17
+ x: number;
18
+ y: number;
19
+ hdg: number;
20
+ }
21
+ export interface PlanViewFit {
22
+ /** Fitted primitives with contiguous stations starting at s = 0. */
23
+ geometries: OdrGeometry[];
24
+ /** Fitted station and pose for every input point (duplicates share poses). */
25
+ samplePoses: FittedSamplePose[];
26
+ /** Total fitted arc length (m). */
27
+ length: number;
28
+ }
29
+ /**
30
+ * Fit a plan-view primitive sequence to a polyline of reference-line samples.
31
+ *
32
+ * The returned geometries are C1-continuous (each starts at the previous
33
+ * one's analytic end pose) except across degraded sharp-corner chords, and
34
+ * deviate from the input samples by at most the position tolerance.
35
+ */
36
+ export declare function fitPlanView(points: readonly FitPoint[], options?: PlanViewFitOptions): PlanViewFit;
37
+ //# sourceMappingURL=odrGeometryFit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odrGeometryFit.d.ts","sourceRoot":"","sources":["../../src/exporter/odrGeometryFit.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,8EAA8E;IAC9E,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAuDD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAsZb"}