@drawtonomy/sdk 0.7.0 → 0.9.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 +5 -1
- package/dist/exporter/index.d.ts.map +1 -1
- package/dist/exporter/index.js +4 -0
- package/dist/exporter/index.js.map +1 -1
- package/dist/exporter/lanelet2.d.ts.map +1 -1
- package/dist/exporter/lanelet2.js +434 -2
- package/dist/exporter/lanelet2.js.map +1 -1
- package/dist/exporter/odrGeometry.d.ts +64 -0
- package/dist/exporter/odrGeometry.d.ts.map +1 -0
- package/dist/exporter/odrGeometry.js +324 -0
- package/dist/exporter/odrGeometry.js.map +1 -0
- package/dist/exporter/odrToShapes.d.ts +45 -0
- package/dist/exporter/odrToShapes.d.ts.map +1 -0
- package/dist/exporter/odrToShapes.js +1370 -0
- package/dist/exporter/odrToShapes.js.map +1 -0
- package/dist/exporter/opendrive.d.ts.map +1 -1
- package/dist/exporter/opendrive.js +547 -69
- package/dist/exporter/opendrive.js.map +1 -1
- package/dist/exporter/opendriveParser.d.ts +186 -0
- package/dist/exporter/opendriveParser.d.ts.map +1 -0
- package/dist/exporter/opendriveParser.js +426 -0
- package/dist/exporter/opendriveParser.js.map +1 -0
- package/dist/exporter/osmToShapes.d.ts +52 -3
- package/dist/exporter/osmToShapes.d.ts.map +1 -1
- package/dist/exporter/osmToShapes.js +208 -5
- package/dist/exporter/osmToShapes.js.map +1 -1
- package/dist/exporter/projection.d.ts +36 -0
- package/dist/exporter/projection.d.ts.map +1 -0
- package/dist/exporter/projection.js +64 -0
- package/dist/exporter/projection.js.map +1 -0
- package/dist/types.d.ts +38 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { OdrCubic, OdrGeometry, OdrRoad } from './opendriveParser';
|
|
2
|
+
/** Pose on the reference line: inertial position + heading. */
|
|
3
|
+
export interface GeomPose {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
hdg: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Fresnel integrals in the normalized convention:
|
|
10
|
+
* C(t) = ∫₀ᵗ cos(π u² / 2) du, S(t) = ∫₀ᵗ sin(π u² / 2) du
|
|
11
|
+
*
|
|
12
|
+
* Implementation follows the classic two-regime scheme (see Abramowitz &
|
|
13
|
+
* Stegun §7.3 and Press et al., "Numerical Recipes", §6.9 "Fresnel Integrals"):
|
|
14
|
+
* - |t| ≤ 1.5: power series expansion (A&S 7.3.11/7.3.13), which converges
|
|
15
|
+
* rapidly in this range.
|
|
16
|
+
* - |t| > 1.5: evaluation through the complex continued fraction for the
|
|
17
|
+
* related complementary error function, computed with the modified Lentz
|
|
18
|
+
* algorithm. Accuracy is limited only by EPS (~1e-12 here), far better
|
|
19
|
+
* than the ~1e-8 needed for sub-millimeter road geometry.
|
|
20
|
+
*
|
|
21
|
+
* Both C and S are odd functions, so negative arguments are handled by sign.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fresnel(t: number): {
|
|
24
|
+
C: number;
|
|
25
|
+
S: number;
|
|
26
|
+
};
|
|
27
|
+
/** Evaluate a cubic polynomial record at a local offset ds. */
|
|
28
|
+
export declare function evalPoly3(rec: OdrCubic, ds: number): number;
|
|
29
|
+
/** Derivative of a cubic polynomial record at a local offset ds. */
|
|
30
|
+
export declare function evalPoly3Derivative(rec: OdrCubic, ds: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Evaluate a plan-view geometry at offset `ds` (m) from its start.
|
|
33
|
+
* Returns the inertial position and heading.
|
|
34
|
+
*/
|
|
35
|
+
export declare function evalGeometry(geom: OdrGeometry, ds: number): GeomPose;
|
|
36
|
+
export interface SampleReferenceLineOptions {
|
|
37
|
+
/** Maximum allowed chord deviation at the midpoint of a step (m). Default 0.05. */
|
|
38
|
+
maxChordErrorMeters?: number;
|
|
39
|
+
/** Maximum station spacing (m). Default 5. */
|
|
40
|
+
maxStepMeters?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Additional stations that must appear in the output (e.g. laneSection
|
|
43
|
+
* starts, laneOffset breakpoints). Values outside [0, road.length] are
|
|
44
|
+
* clamped/ignored.
|
|
45
|
+
*/
|
|
46
|
+
extraStations?: readonly number[];
|
|
47
|
+
}
|
|
48
|
+
export interface ReferenceSample {
|
|
49
|
+
/** Station along the road reference line (m). */
|
|
50
|
+
s: number;
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
hdg: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Adaptively sample a road's reference line.
|
|
57
|
+
*
|
|
58
|
+
* Stations always include s = 0, s = road.length, every plan-view geometry
|
|
59
|
+
* boundary, and the caller's `extraStations`. Between those, intervals are
|
|
60
|
+
* recursively bisected until the chord deviation at the interval midpoint is
|
|
61
|
+
* below `maxChordErrorMeters` and the step is at most `maxStepMeters`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function sampleReferenceLine(road: OdrRoad, options?: SampleReferenceLineOptions): ReferenceSample[];
|
|
64
|
+
//# sourceMappingURL=odrGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"odrGeometry.d.ts","sourceRoot":"","sources":["../../src/exporter/odrGeometry.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEvE,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,GAAG,EAAE,MAAM,CAAA;CACZ;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAsF3D;AAMD,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAErE;AAyGD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,QAAQ,CAapE;AAMD,MAAM,WAAW,0BAA0B;IACzC,mFAAmF;IACnF,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,GAAG,EAAE,MAAM,CAAA;CACZ;AAsBD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,0BAA+B,GACvC,eAAe,EAAE,CAgEnB"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// Analytic evaluation of OpenDRIVE plan-view geometry.
|
|
2
|
+
//
|
|
3
|
+
// Supported primitives: line, arc, spiral (Euler clothoid via Fresnel
|
|
4
|
+
// integrals), paramPoly3 (both pRange modes), and the deprecated poly3.
|
|
5
|
+
// `sampleReferenceLine` adaptively samples a road's reference line under a
|
|
6
|
+
// maximum chord error + maximum step, always including geometry boundaries
|
|
7
|
+
// (and any caller-supplied stations such as laneSection starts).
|
|
8
|
+
//
|
|
9
|
+
// No external dependencies.
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Fresnel integrals
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* Fresnel integrals in the normalized convention:
|
|
15
|
+
* C(t) = ∫₀ᵗ cos(π u² / 2) du, S(t) = ∫₀ᵗ sin(π u² / 2) du
|
|
16
|
+
*
|
|
17
|
+
* Implementation follows the classic two-regime scheme (see Abramowitz &
|
|
18
|
+
* Stegun §7.3 and Press et al., "Numerical Recipes", §6.9 "Fresnel Integrals"):
|
|
19
|
+
* - |t| ≤ 1.5: power series expansion (A&S 7.3.11/7.3.13), which converges
|
|
20
|
+
* rapidly in this range.
|
|
21
|
+
* - |t| > 1.5: evaluation through the complex continued fraction for the
|
|
22
|
+
* related complementary error function, computed with the modified Lentz
|
|
23
|
+
* algorithm. Accuracy is limited only by EPS (~1e-12 here), far better
|
|
24
|
+
* than the ~1e-8 needed for sub-millimeter road geometry.
|
|
25
|
+
*
|
|
26
|
+
* Both C and S are odd functions, so negative arguments are handled by sign.
|
|
27
|
+
*/
|
|
28
|
+
export function fresnel(t) {
|
|
29
|
+
const EPS = 1e-12;
|
|
30
|
+
const MAXIT = 120;
|
|
31
|
+
const SERIES_MAX = 1.5;
|
|
32
|
+
const ax = Math.abs(t);
|
|
33
|
+
let c;
|
|
34
|
+
let s;
|
|
35
|
+
if (ax < 1e-30) {
|
|
36
|
+
c = ax;
|
|
37
|
+
s = 0;
|
|
38
|
+
}
|
|
39
|
+
else if (ax <= SERIES_MAX) {
|
|
40
|
+
// Power series (A&S 7.3.11 / 7.3.13):
|
|
41
|
+
// C(x) = Σ (-1)^n (π/2)^(2n) x^(4n+1) / ((2n)! (4n+1))
|
|
42
|
+
// S(x) = Σ (-1)^n (π/2)^(2n+1) x^(4n+3) / ((2n+1)! (4n+3))
|
|
43
|
+
const h = (Math.PI / 2) * ax * ax;
|
|
44
|
+
const h2 = h * h;
|
|
45
|
+
let cTerm = ax; // x * (π/2 x²)^0 / 0!
|
|
46
|
+
let sTerm = ax * h; // x * (π/2 x²)^1 / 1!
|
|
47
|
+
c = cTerm; // n = 0 contribution: cTerm / 1
|
|
48
|
+
s = sTerm / 3; // n = 0 contribution: sTerm / 3
|
|
49
|
+
for (let n = 1; n <= MAXIT; n++) {
|
|
50
|
+
cTerm *= -h2 / ((2 * n - 1) * (2 * n));
|
|
51
|
+
sTerm *= -h2 / ((2 * n) * (2 * n + 1));
|
|
52
|
+
const dc = cTerm / (4 * n + 1);
|
|
53
|
+
const ds = sTerm / (4 * n + 3);
|
|
54
|
+
c += dc;
|
|
55
|
+
s += ds;
|
|
56
|
+
if (Math.abs(dc) + Math.abs(ds) < EPS * (Math.abs(c) + Math.abs(s)))
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Complex continued fraction via modified Lentz (Numerical Recipes §6.9).
|
|
62
|
+
const pix2 = Math.PI * ax * ax;
|
|
63
|
+
let bRe = 1;
|
|
64
|
+
let bIm = -pix2;
|
|
65
|
+
const BIG = 1e100;
|
|
66
|
+
let ccRe = BIG;
|
|
67
|
+
let ccIm = 0;
|
|
68
|
+
let den = bRe * bRe + bIm * bIm;
|
|
69
|
+
let dRe = bRe / den;
|
|
70
|
+
let dIm = -bIm / den;
|
|
71
|
+
let hRe = dRe;
|
|
72
|
+
let hIm = dIm;
|
|
73
|
+
let n = -1;
|
|
74
|
+
for (let k = 2; k <= MAXIT; k++) {
|
|
75
|
+
n += 2;
|
|
76
|
+
const a = -n * (n + 1);
|
|
77
|
+
bRe += 4;
|
|
78
|
+
// d = 1 / (a*d + b)
|
|
79
|
+
let tRe = a * dRe + bRe;
|
|
80
|
+
let tIm = a * dIm + bIm;
|
|
81
|
+
den = tRe * tRe + tIm * tIm;
|
|
82
|
+
dRe = tRe / den;
|
|
83
|
+
dIm = -tIm / den;
|
|
84
|
+
// cc = b + a / cc
|
|
85
|
+
den = ccRe * ccRe + ccIm * ccIm;
|
|
86
|
+
ccRe = bRe + (a * ccRe) / den;
|
|
87
|
+
ccIm = bIm - (a * ccIm) / den;
|
|
88
|
+
// del = cc * d ; h *= del
|
|
89
|
+
const delRe = ccRe * dRe - ccIm * dIm;
|
|
90
|
+
const delIm = ccRe * dIm + ccIm * dRe;
|
|
91
|
+
tRe = hRe * delRe - hIm * delIm;
|
|
92
|
+
tIm = hRe * delIm + hIm * delRe;
|
|
93
|
+
hRe = tRe;
|
|
94
|
+
hIm = tIm;
|
|
95
|
+
if (Math.abs(delRe - 1) + Math.abs(delIm) < EPS)
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
// h *= (ax - i*ax)
|
|
99
|
+
const t2Re = ax * (hRe + hIm);
|
|
100
|
+
const t2Im = ax * (hIm - hRe);
|
|
101
|
+
hRe = t2Re;
|
|
102
|
+
hIm = t2Im;
|
|
103
|
+
// cs = (0.5 + 0.5i) * (1 - (cos(πx²/2) + i sin(πx²/2)) * h)
|
|
104
|
+
const cosv = Math.cos(0.5 * pix2);
|
|
105
|
+
const sinv = Math.sin(0.5 * pix2);
|
|
106
|
+
const mRe = 1 - (cosv * hRe - sinv * hIm);
|
|
107
|
+
const mIm = -(cosv * hIm + sinv * hRe);
|
|
108
|
+
c = 0.5 * (mRe - mIm);
|
|
109
|
+
s = 0.5 * (mRe + mIm);
|
|
110
|
+
}
|
|
111
|
+
if (t < 0) {
|
|
112
|
+
c = -c;
|
|
113
|
+
s = -s;
|
|
114
|
+
}
|
|
115
|
+
return { C: c, S: s };
|
|
116
|
+
}
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// Geometry evaluation
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
/** Evaluate a cubic polynomial record at a local offset ds. */
|
|
121
|
+
export function evalPoly3(rec, ds) {
|
|
122
|
+
return rec.a + ds * (rec.b + ds * (rec.c + ds * rec.d));
|
|
123
|
+
}
|
|
124
|
+
/** Derivative of a cubic polynomial record at a local offset ds. */
|
|
125
|
+
export function evalPoly3Derivative(rec, ds) {
|
|
126
|
+
return rec.b + ds * (2 * rec.c + ds * 3 * rec.d);
|
|
127
|
+
}
|
|
128
|
+
const CURVATURE_EPS = 1e-12;
|
|
129
|
+
function evalLine(geom, ds) {
|
|
130
|
+
return {
|
|
131
|
+
x: geom.x + Math.cos(geom.hdg) * ds,
|
|
132
|
+
y: geom.y + Math.sin(geom.hdg) * ds,
|
|
133
|
+
hdg: geom.hdg,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function evalArc(geom, curvature, ds) {
|
|
137
|
+
if (Math.abs(curvature) < CURVATURE_EPS)
|
|
138
|
+
return evalLine(geom, ds);
|
|
139
|
+
const hdg1 = geom.hdg + curvature * ds;
|
|
140
|
+
return {
|
|
141
|
+
x: geom.x + (Math.sin(hdg1) - Math.sin(geom.hdg)) / curvature,
|
|
142
|
+
y: geom.y - (Math.cos(hdg1) - Math.cos(geom.hdg)) / curvature,
|
|
143
|
+
hdg: hdg1,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Evaluate an Euler spiral (clothoid) with linearly varying curvature.
|
|
148
|
+
*
|
|
149
|
+
* The general spiral maps onto the unit clothoid κ(σ) = cDot·σ via the
|
|
150
|
+
* standard parameter transform (a textbook property of the Euler spiral —
|
|
151
|
+
* see e.g. Abramowitz & Stegun §7.3 on Fresnel integrals):
|
|
152
|
+
* the road geometry covers the parameter window σ ∈ [s0, s0 + ds] with
|
|
153
|
+
* s0 = curvStart / cDot. On that base clothoid,
|
|
154
|
+
* position(σ) = scale · (C(σ/scale), sign(cDot) · S(σ/scale)),
|
|
155
|
+
* tangent(σ) = cDot · σ² / 2,
|
|
156
|
+
* with scale = sqrt(π / |cDot|). The window is then rotated/translated so
|
|
157
|
+
* that its start coincides with the geometry's (x, y, hdg).
|
|
158
|
+
*/
|
|
159
|
+
function evalSpiral(geom, curvStart, curvEnd, ds) {
|
|
160
|
+
const cDot = (curvEnd - curvStart) / geom.length;
|
|
161
|
+
if (Math.abs(cDot) < CURVATURE_EPS) {
|
|
162
|
+
// Degenerate spiral: constant curvature (arc) or straight line.
|
|
163
|
+
return evalArc(geom, curvStart, ds);
|
|
164
|
+
}
|
|
165
|
+
const s0 = curvStart / cDot;
|
|
166
|
+
const scale = Math.sqrt(Math.PI / Math.abs(cDot));
|
|
167
|
+
const sgn = Math.sign(cDot);
|
|
168
|
+
const clothoid = (sigma) => {
|
|
169
|
+
const f = fresnel(sigma / scale);
|
|
170
|
+
return { x: scale * f.C, y: sgn * scale * f.S };
|
|
171
|
+
};
|
|
172
|
+
const p0 = clothoid(s0);
|
|
173
|
+
const p1 = clothoid(s0 + ds);
|
|
174
|
+
const theta0 = 0.5 * cDot * s0 * s0;
|
|
175
|
+
const rot = geom.hdg - theta0;
|
|
176
|
+
const cosR = Math.cos(rot);
|
|
177
|
+
const sinR = Math.sin(rot);
|
|
178
|
+
const dx = p1.x - p0.x;
|
|
179
|
+
const dy = p1.y - p0.y;
|
|
180
|
+
return {
|
|
181
|
+
x: geom.x + dx * cosR - dy * sinR,
|
|
182
|
+
y: geom.y + dx * sinR + dy * cosR,
|
|
183
|
+
hdg: geom.hdg + curvStart * ds + 0.5 * cDot * ds * ds,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function evalParamPoly3(geom, ds) {
|
|
187
|
+
const p = geom.pRange === 'arcLength' ? ds : geom.length > 0 ? ds / geom.length : 0;
|
|
188
|
+
const u = geom.aU + p * (geom.bU + p * (geom.cU + p * geom.dU));
|
|
189
|
+
const v = geom.aV + p * (geom.bV + p * (geom.cV + p * geom.dV));
|
|
190
|
+
const du = geom.bU + p * (2 * geom.cU + p * 3 * geom.dU);
|
|
191
|
+
const dv = geom.bV + p * (2 * geom.cV + p * 3 * geom.dV);
|
|
192
|
+
const cosH = Math.cos(geom.hdg);
|
|
193
|
+
const sinH = Math.sin(geom.hdg);
|
|
194
|
+
return {
|
|
195
|
+
x: geom.x + u * cosH - v * sinH,
|
|
196
|
+
y: geom.y + u * sinH + v * cosH,
|
|
197
|
+
hdg: geom.hdg + Math.atan2(dv, du),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function evalCubicPoly3(geom, ds) {
|
|
201
|
+
// Deprecated primitive (replaced by paramPoly3 in OpenDRIVE 1.6). The
|
|
202
|
+
// polynomial is v(u) in the local frame; we approximate the local abscissa
|
|
203
|
+
// u by the arc length ds, which is exact for flat curves and a small
|
|
204
|
+
// overestimate for strongly bent ones. Callers surface this as a warning.
|
|
205
|
+
const u = ds;
|
|
206
|
+
const v = evalPoly3(geom, u);
|
|
207
|
+
const dv = evalPoly3Derivative(geom, u);
|
|
208
|
+
const cosH = Math.cos(geom.hdg);
|
|
209
|
+
const sinH = Math.sin(geom.hdg);
|
|
210
|
+
return {
|
|
211
|
+
x: geom.x + u * cosH - v * sinH,
|
|
212
|
+
y: geom.y + u * sinH + v * cosH,
|
|
213
|
+
hdg: geom.hdg + Math.atan2(dv, 1),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Evaluate a plan-view geometry at offset `ds` (m) from its start.
|
|
218
|
+
* Returns the inertial position and heading.
|
|
219
|
+
*/
|
|
220
|
+
export function evalGeometry(geom, ds) {
|
|
221
|
+
switch (geom.kind) {
|
|
222
|
+
case 'line':
|
|
223
|
+
return evalLine(geom, ds);
|
|
224
|
+
case 'arc':
|
|
225
|
+
return evalArc(geom, geom.curvature, ds);
|
|
226
|
+
case 'spiral':
|
|
227
|
+
return evalSpiral(geom, geom.curvStart, geom.curvEnd, ds);
|
|
228
|
+
case 'paramPoly3':
|
|
229
|
+
return evalParamPoly3(geom, ds);
|
|
230
|
+
case 'poly3':
|
|
231
|
+
return evalCubicPoly3(geom, ds);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const STATION_EPS = 1e-9;
|
|
235
|
+
const MIN_STEP = 1e-3;
|
|
236
|
+
const MAX_REFINE_DEPTH = 32;
|
|
237
|
+
/** Distance from point p to the chord segment a-b. */
|
|
238
|
+
function chordDeviation(a, b, p) {
|
|
239
|
+
const dx = b.x - a.x;
|
|
240
|
+
const dy = b.y - a.y;
|
|
241
|
+
const len2 = dx * dx + dy * dy;
|
|
242
|
+
if (len2 < 1e-18)
|
|
243
|
+
return Math.hypot(p.x - a.x, p.y - a.y);
|
|
244
|
+
let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2;
|
|
245
|
+
if (t < 0)
|
|
246
|
+
t = 0;
|
|
247
|
+
if (t > 1)
|
|
248
|
+
t = 1;
|
|
249
|
+
return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Adaptively sample a road's reference line.
|
|
253
|
+
*
|
|
254
|
+
* Stations always include s = 0, s = road.length, every plan-view geometry
|
|
255
|
+
* boundary, and the caller's `extraStations`. Between those, intervals are
|
|
256
|
+
* recursively bisected until the chord deviation at the interval midpoint is
|
|
257
|
+
* below `maxChordErrorMeters` and the step is at most `maxStepMeters`.
|
|
258
|
+
*/
|
|
259
|
+
export function sampleReferenceLine(road, options = {}) {
|
|
260
|
+
const tol = options.maxChordErrorMeters ?? 0.05;
|
|
261
|
+
const maxStep = options.maxStepMeters ?? 5;
|
|
262
|
+
const roadLength = road.length;
|
|
263
|
+
if (road.planView.length === 0 || roadLength <= 0)
|
|
264
|
+
return [];
|
|
265
|
+
// Base stations: geometry boundaries + caller stations + road ends.
|
|
266
|
+
const baseSet = [0, roadLength];
|
|
267
|
+
for (const g of road.planView) {
|
|
268
|
+
if (g.s > 0 && g.s < roadLength)
|
|
269
|
+
baseSet.push(g.s);
|
|
270
|
+
const end = g.s + g.length;
|
|
271
|
+
if (end > 0 && end < roadLength)
|
|
272
|
+
baseSet.push(end);
|
|
273
|
+
}
|
|
274
|
+
if (options.extraStations) {
|
|
275
|
+
for (const s of options.extraStations) {
|
|
276
|
+
if (s > 0 && s < roadLength)
|
|
277
|
+
baseSet.push(s);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
baseSet.sort((a, b) => a - b);
|
|
281
|
+
const base = [];
|
|
282
|
+
for (const s of baseSet) {
|
|
283
|
+
if (base.length === 0 || s - base[base.length - 1] > STATION_EPS)
|
|
284
|
+
base.push(s);
|
|
285
|
+
}
|
|
286
|
+
// Locate the geometry containing a station (last geometry with g.s <= s).
|
|
287
|
+
const geomAt = (s) => {
|
|
288
|
+
let found = road.planView[0];
|
|
289
|
+
for (const g of road.planView) {
|
|
290
|
+
if (g.s <= s + STATION_EPS)
|
|
291
|
+
found = g;
|
|
292
|
+
else
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
return found;
|
|
296
|
+
};
|
|
297
|
+
const evalAt = (s) => {
|
|
298
|
+
const g = geomAt(s);
|
|
299
|
+
return evalGeometry(g, Math.min(Math.max(s - g.s, 0), g.length));
|
|
300
|
+
};
|
|
301
|
+
const stations = [];
|
|
302
|
+
const refine = (sa, sb, pa, pb, depth) => {
|
|
303
|
+
const step = sb - sa;
|
|
304
|
+
if (step > MIN_STEP && depth < MAX_REFINE_DEPTH) {
|
|
305
|
+
const sm = (sa + sb) / 2;
|
|
306
|
+
const pm = evalAt(sm);
|
|
307
|
+
if (step > maxStep || chordDeviation(pa, pb, pm) > tol) {
|
|
308
|
+
refine(sa, sm, pa, pm, depth + 1);
|
|
309
|
+
refine(sm, sb, pm, pb, depth + 1);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
stations.push(sa);
|
|
314
|
+
};
|
|
315
|
+
for (let i = 0; i < base.length - 1; i++) {
|
|
316
|
+
refine(base[i], base[i + 1], evalAt(base[i]), evalAt(base[i + 1]), 0);
|
|
317
|
+
}
|
|
318
|
+
stations.push(roadLength);
|
|
319
|
+
return stations.map(s => {
|
|
320
|
+
const pose = evalAt(s);
|
|
321
|
+
return { s, x: pose.x, y: pose.y, hdg: pose.hdg };
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=odrGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"odrGeometry.js","sourceRoot":"","sources":["../../src/expor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AEzB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QACtB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { OdrMap } from './opendriveParser';
|
|
2
|
+
import { type ImportedShapes, type ShapeIdAllocator } from './osmToShapes';
|
|
3
|
+
/** Sidecar captured at OpenDRIVE import time (for verbatim round-trip export). */
|
|
4
|
+
export interface OdrSidecar {
|
|
5
|
+
rawXml: string;
|
|
6
|
+
originLat: number | null;
|
|
7
|
+
originLon: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface OdrImportResult extends ImportedShapes {
|
|
10
|
+
sidecar: OdrSidecar;
|
|
11
|
+
/** Human-readable notes about unsupported features (flattened elevation, etc.). */
|
|
12
|
+
warnings: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface OdrToShapesOptions {
|
|
15
|
+
/** Custom id allocator. A fresh `createShapeIdAllocator()` is used when omitted. */
|
|
16
|
+
idAllocator?: ShapeIdAllocator;
|
|
17
|
+
/** Restrict conversion to the given road ids. When omitted, all roads are converted. */
|
|
18
|
+
selectedRoadIds?: readonly string[];
|
|
19
|
+
/** Maximum chord error for reference-line sampling (m). Default 0.05. */
|
|
20
|
+
maxChordErrorMeters?: number;
|
|
21
|
+
/** Maximum station spacing for reference-line sampling (m). Default 5. */
|
|
22
|
+
maxStepMeters?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Derive a WGS84 origin from an OpenDRIVE <geoReference> PROJ string.
|
|
26
|
+
*
|
|
27
|
+
* Supports `+proj=tmerc +lat_0=.. +lon_0=..` (exact: the projection origin is
|
|
28
|
+
* the local (0, 0)) and `+proj=utm +zone=..` (approximate: the zone's central
|
|
29
|
+
* meridian on the equator; UTM's false easting/northing is not compensated).
|
|
30
|
+
* Returns null when the origin cannot be derived.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseGeoReferenceOrigin(geoReference: string | null): {
|
|
33
|
+
lat: number;
|
|
34
|
+
lon: number;
|
|
35
|
+
approximate: boolean;
|
|
36
|
+
} | null;
|
|
37
|
+
/**
|
|
38
|
+
* Convert a parsed OpenDRIVE map into editor-ready point/linestring/lane
|
|
39
|
+
* records plus a sidecar for round-trip export.
|
|
40
|
+
*
|
|
41
|
+
* Pass `selectedRoadIds` to restrict the conversion to a subset of roads
|
|
42
|
+
* (selective import); leave it `undefined` to import every road.
|
|
43
|
+
*/
|
|
44
|
+
export declare function odrToShapes(map: OdrMap, options?: OdrToShapesOptions): OdrImportResult;
|
|
45
|
+
//# sourceMappingURL=odrToShapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"odrToShapes.d.ts","sourceRoot":"","sources":["../../src/exporter/odrToShapes.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAGV,MAAM,EAIP,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAOL,KAAK,cAAc,EAEnB,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAA;AAGtB,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,OAAO,EAAE,UAAU,CAAA;IACnB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,oFAAoF;IACpF,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,wFAAwF;IACxF,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAqBD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAyB3D;AAmID;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,eAAe,CAgxB1F"}
|