fix: stabilize fengshu native road compilation
This commit is contained in:
@@ -379,6 +379,20 @@ const laneOverrides = validateOverrides({ schema: "native-road-overrides/v1", ov
|
||||
assert.equal(compileGeometry(turnModel, laneOverrides).connectors.features.length, 0);
|
||||
assert.equal(compileGeometry(turnModel, laneOverrides).movements.length, 0);
|
||||
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "bad", kind: "road", roadId: "missing", widthMeters: 4 }] }, initial), /Unknown road/);
|
||||
// Editing OSM retires ids. Saving such a reference is still an error, but a
|
||||
// consumer may ask to skip it so one stale entry cannot block the whole compile.
|
||||
const staleDoc = { schema: "native-road-overrides/v1", overrides: [
|
||||
{ id: "stale-road", kind: "road", roadId: "road:way/does-not-exist:forward", widthMeters: 4 },
|
||||
{ id: "live-road", kind: "road", roadId: target.id, widthMeters: 9 },
|
||||
] };
|
||||
assert.throws(() => validateOverrides(staleDoc, initial), /Unknown road/);
|
||||
const skipped = validateOverrides(staleDoc, initial, { skipStaleTargets: true });
|
||||
assert.equal(skipped.overrides.length, 1);
|
||||
assert.equal(skipped.overrides[0].id, "live-road");
|
||||
assert.deepEqual(skipped.stale.map((item) => item.id), ["stale-road"]);
|
||||
assert.equal(skipped.stale[0].target, "road:way/does-not-exist:forward");
|
||||
// Skipping only forgives missing targets; a malformed entry still throws.
|
||||
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "bad-width", kind: "road", roadId: target.id, widthMeters: -1 }] }, initial, { skipStaleTargets: true }), /Invalid road override/);
|
||||
const freshArea = fs.mkdtempSync(path.join(os.tmpdir(), "native-road-fresh-area-"));
|
||||
try {
|
||||
const input = path.join(freshArea, "input.osm");
|
||||
|
||||
Reference in New Issue
Block a user