feat(junction): enable complex carriageway width editing
This commit is contained in:
1 parent
56647fcdaa
commit
c4bcbe8ff9
22 files changed
+449
-52
No files matched your search
+24
-16
@@ -442,23 +442,14 @@ function editPreview(area, body = {}) {
|
||||
...(Array.isArray(body.operations) ? { operations: body.operations } : {}),
|
||||
});
|
||||
const activeState = readJson(activeStateFile);
|
||||
const persistedOverrides = loadOverrides(area.outputs.nativeRoadOverrides);
|
||||
const model = compileRoadModel(fs.readFileSync(area.input, 'utf8'), persistedOverrides);
|
||||
const selection = selectionFrom(body.selection);
|
||||
const previewSeq = Number.isInteger(body.previewSeq) ? body.previewSeq : 0;
|
||||
const resolution = resolveDirectEditConstraints(model, draft, {
|
||||
const candidate = compileEditCandidate(area, draft, {
|
||||
revisionId: activeState.activeRevisionId,
|
||||
previewSeq,
|
||||
compilerGeometryVersion: GEOMETRY_VERSION,
|
||||
junctionTemplates: area.nativeRoad?.junctionTemplates,
|
||||
selection,
|
||||
});
|
||||
const compiled = compileGeometry(model, persistedOverrides, {
|
||||
edgeLines: area.nativeRoad.edgeLines,
|
||||
junctionTemplates: area.nativeRoad.junctionTemplates,
|
||||
directEdit: resolution,
|
||||
});
|
||||
const diagnostics = [...compiled.diagnostics, ...resolution.diagnostics];
|
||||
const { model, resolution, compiled, diagnostics } = candidate;
|
||||
const junctionStructure = projectJunctionStructure({
|
||||
model,
|
||||
junctionRef: junctionRefFromSelection(selection),
|
||||
@@ -505,6 +496,24 @@ function editPreview(area, body = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function compileEditCandidate(area, draft, { revisionId, previewSeq = 0, selection = null } = {}) {
|
||||
const persistedOverrides = loadOverrides(area.outputs.nativeRoadOverrides);
|
||||
const model = compileRoadModel(fs.readFileSync(area.input, 'utf8'), persistedOverrides);
|
||||
const resolution = resolveDirectEditConstraints(model, draft, {
|
||||
revisionId,
|
||||
previewSeq,
|
||||
compilerGeometryVersion: GEOMETRY_VERSION,
|
||||
junctionTemplates: area.nativeRoad?.junctionTemplates,
|
||||
selection,
|
||||
});
|
||||
const compiled = compileGeometry(model, persistedOverrides, {
|
||||
edgeLines: area.nativeRoad.edgeLines,
|
||||
junctionTemplates: area.nativeRoad.junctionTemplates,
|
||||
directEdit: resolution,
|
||||
});
|
||||
return { model, resolution, compiled, diagnostics: [...compiled.diagnostics, ...resolution.diagnostics] };
|
||||
}
|
||||
|
||||
function saveEdits(area, body = {}) {
|
||||
const workspace = path.dirname(area.input);
|
||||
const initialized = ensureRevisionStore(workspace, area.nativeRoad);
|
||||
@@ -524,20 +533,19 @@ function saveEdits(area, body = {}) {
|
||||
...(Array.isArray(body.operations) ? { operations: body.operations } : {}),
|
||||
documentVersion: current.documentVersion,
|
||||
};
|
||||
const model = compileRoadModel(fs.readFileSync(area.input, 'utf8'), loadOverrides(area.outputs.nativeRoadOverrides));
|
||||
const resolution = resolveDirectEditConstraints(model, candidate, {
|
||||
const checked = validateEditDocument(candidate);
|
||||
const evaluation = compileEditCandidate(area, checked, {
|
||||
revisionId: initialized.active.activeRevisionId,
|
||||
compilerGeometryVersion: GEOMETRY_VERSION,
|
||||
junctionTemplates: area.nativeRoad?.junctionTemplates,
|
||||
});
|
||||
const blockingDiagnostic = resolution.diagnostics.find((item) => item.severity === 'error');
|
||||
const blockingDiagnostic = evaluation.diagnostics.find((item) => item.severity === 'error');
|
||||
if (blockingDiagnostic) {
|
||||
const error = new Error(blockingDiagnostic.message);
|
||||
error.statusCode = 400;
|
||||
error.diagnostic = blockingDiagnostic;
|
||||
throw error;
|
||||
}
|
||||
const saved = saveEditDocument(initialized.paths.activeEdits, candidate);
|
||||
const saved = saveEditDocument(initialized.paths.activeEdits, checked);
|
||||
writeJsonAtomic(initialized.paths.activeState, {
|
||||
...initialized.active,
|
||||
documentVersion: saved.documentVersion,
|
||||
|
||||
Reference in new issue
Block a user