feat: compile revisions from area config snapshots
This commit is contained in:
1 parent
c0c8a16dd4
commit
ba8eaba9d9
11 files changed
+403
-210
No files matched your search
+16
-7
@@ -12,13 +12,16 @@ const {
|
||||
} = require('./native-road');
|
||||
const { LAYER_REGISTRY, manifestForArea, validatePublishedLayers } = require('./layer-manifest');
|
||||
const { loadOrGenerate, runtime } = require('../native-traffic-signals');
|
||||
const { readAreaConfigSnapshot } = require('./road-revisions');
|
||||
|
||||
function compileInput(input) {
|
||||
validateInput(input);
|
||||
const options = input.areaConfigSnapshotFile ? readAreaConfigSnapshot(input.areaConfigSnapshotFile) : input.options;
|
||||
validateOptions(options);
|
||||
const area = {
|
||||
id: input.areaId,
|
||||
input: input.osmFile,
|
||||
nativeRoad: input.options,
|
||||
nativeRoad: options,
|
||||
outputs: {
|
||||
nativeRoadOverrides: input.overridesFile,
|
||||
nativeTrafficSignals: input.trafficSignalsFile,
|
||||
@@ -161,12 +164,18 @@ function validateInput(input) {
|
||||
if (typeof input[key] !== 'string' || input[key].trim() === '')
|
||||
throw new Error(`RoadCompilerInput.${key} must be a non-empty string`);
|
||||
}
|
||||
if (!input.options || typeof input.options !== 'object')
|
||||
throw new Error('RoadCompilerInput.options must be an object');
|
||||
if (typeof input.options.edgeLines !== 'boolean')
|
||||
throw new Error('RoadCompilerInput.options.edgeLines must be a boolean');
|
||||
if (!input.options.junctionTemplates || typeof input.options.junctionTemplates !== 'object')
|
||||
if (
|
||||
input.areaConfigSnapshotFile !== undefined &&
|
||||
(typeof input.areaConfigSnapshotFile !== 'string' || !input.areaConfigSnapshotFile)
|
||||
)
|
||||
throw new Error('RoadCompilerInput.areaConfigSnapshotFile must be a non-empty string when present');
|
||||
}
|
||||
|
||||
function validateOptions(options) {
|
||||
if (!options || typeof options !== 'object') throw new Error('RoadCompilerInput.options must be an object');
|
||||
if (typeof options.edgeLines !== 'boolean') throw new Error('RoadCompilerInput.options.edgeLines must be a boolean');
|
||||
if (!options.junctionTemplates || typeof options.junctionTemplates !== 'object')
|
||||
throw new Error('RoadCompilerInput.options.junctionTemplates must be an object');
|
||||
}
|
||||
|
||||
module.exports = { compileInput, validateInput };
|
||||
module.exports = { compileInput, validateInput, validateOptions };
|
||||
Reference in new issue
Block a user