@drawtonomy/sdk 0.9.0 → 0.11.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.
- package/dist/exporter/index.d.ts +4 -4
- package/dist/exporter/index.d.ts.map +1 -1
- package/dist/exporter/index.js +1 -1
- package/dist/exporter/index.js.map +1 -1
- package/dist/exporter/lanelet2.d.ts +12 -0
- package/dist/exporter/lanelet2.d.ts.map +1 -1
- package/dist/exporter/lanelet2.js +112 -31
- package/dist/exporter/lanelet2.js.map +1 -1
- package/dist/exporter/odrCarryThrough.d.ts +89 -0
- package/dist/exporter/odrCarryThrough.d.ts.map +1 -0
- package/dist/exporter/odrCarryThrough.js +186 -0
- package/dist/exporter/odrCarryThrough.js.map +1 -0
- package/dist/exporter/odrGeometryFit.d.ts +37 -0
- package/dist/exporter/odrGeometryFit.d.ts.map +1 -0
- package/dist/exporter/odrGeometryFit.js +476 -0
- package/dist/exporter/odrGeometryFit.js.map +1 -0
- package/dist/exporter/odrToShapes.d.ts +8 -0
- package/dist/exporter/odrToShapes.d.ts.map +1 -1
- package/dist/exporter/odrToShapes.js +444 -54
- package/dist/exporter/odrToShapes.js.map +1 -1
- package/dist/exporter/opendrive.d.ts +14 -1
- package/dist/exporter/opendrive.d.ts.map +1 -1
- package/dist/exporter/opendrive.js +1603 -315
- package/dist/exporter/opendrive.js.map +1 -1
- package/dist/exporter/opendriveParser.d.ts +12 -0
- package/dist/exporter/opendriveParser.d.ts.map +1 -1
- package/dist/exporter/opendriveParser.js +7 -2
- package/dist/exporter/opendriveParser.js.map +1 -1
- package/dist/exporter/osmToShapes.d.ts +26 -1
- package/dist/exporter/osmToShapes.d.ts.map +1 -1
- package/dist/exporter/osmToShapes.js +54 -9
- package/dist/exporter/osmToShapes.js.map +1 -1
- package/dist/exporter/units.d.ts +7 -0
- package/dist/exporter/units.d.ts.map +1 -1
- package/dist/exporter/units.js +11 -0
- package/dist/exporter/units.js.map +1 -1
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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 / sign / 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,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,6EAA6E;AAC7E,EAAE;AACF,iEAAiE;AACjE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,4EAA4E;AAC5E,mFAAmF;AACnF,yEAAyE;AACzE,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,oEAAoE;AACpE,6EAA6E;AAC7E,6DAA6D;AAmC7D,MAAM,MAAM,GAAG,CAAC,GAA8B,EAAU,EAAE,CACxD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AAExD,MAAM,QAAQ,GAAG,CAAC,KAAyC,EAAU,EAAE,CACrE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;KAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;KAChD,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;KAC5B,IAAI,EAAE;KACN,IAAI,CAA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,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAC7D,MAAM,OAAO,GACX,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAA;QAC5F,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,GAAG,CAAA;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"}
|