feat: import native road packages from ZIP

This commit is contained in:
2026-08-26 12:51:58 +08:00
parent 009fe34f79
commit 113ea54535
15 changed files with 200 additions and 100 deletions

View File

@@ -3,6 +3,7 @@
const fs = require("fs");
const path = require("path");
const { readAreaConfig } = require("./area-config");
const { importNativeRoadPackage } = require("./native-road-package");
const {
SCENE_LAYERS,
SCENE_FILE,
@@ -324,6 +325,11 @@ function addEndpoint(map, ref) {
function artifactStatus(area) {
const native = area.blender.roadProvider === "native";
let nativePackage = null;
let nativePackageError = null;
if (native) {
try { nativePackage = importNativeRoadPackage(area); } catch (error) { nativePackageError = error.message; }
}
const entries = [
...(native ? [] : [
["GeoJSON dir", area.outputs.geojsonDir, true, "dir"],
@@ -332,15 +338,16 @@ function artifactStatus(area) {
["QGIS preview", area.outputs.qgisPreview, true, "file"],
["Traffic signal assemblies", area.outputs.trafficSignalAssemblies, true, "file"],
]),
["Native road directory", area.outputs.nativeRoadDir, native, "dir"],
["Traffic signal runtime", native ? path.join(area.outputs.nativeRoadDir, "traffic-signals.json") : area.outputs.packageTrafficSignals, true, "file"],
["Native road ZIP", area.nativeRoadPackage, native, "file"],
["Native road import", nativePackage?.rootDir || path.join(area.outputs.pipelineDir, "native-road-import"), native, "dir"],
["Traffic signal runtime", native ? path.join(nativePackage?.rootDir || "", "traffic-signals.json") : area.outputs.packageTrafficSignals, true, "file"],
["Blend scene", area.outputs.blend, true, "file"],
["Render PNG", area.outputs.render, true, "file"],
["Package manifest", area.outputs.packageManifest, true, "file"],
["Package primary GLB", area.outputs.packagePrimaryGlb, true, "file"],
["Cesium preview", area.outputs.cesiumPreview, true, "file"],
];
return entries.map(([label, file, expected, type]) => {
const result = entries.map(([label, file, expected, type]) => {
const exists = fs.existsSync(file);
const stat = exists ? fs.statSync(file) : null;
const validType = !exists || (type === "dir" ? stat.isDirectory() : stat.isFile());
@@ -358,6 +365,8 @@ function artifactStatus(area) {
geojsonFiles,
};
});
if (nativePackageError) result.push({ label: "Native road ZIP validation", path: area.nativeRoadPackage, expected: true, type: "file", exists: false, validType: false, error: nativePackageError });
return result;
}
function metadataSummary(file, warnings) {
@@ -378,6 +387,10 @@ function metadataSummary(file, warnings) {
function stageManifestStatus(area, configPath = null) {
const native = area.blender.roadProvider === "native";
let nativePackage = null;
if (native) {
try { nativePackage = importNativeRoadPackage(area); } catch (_) { /* artifact status reports the validation failure */ }
}
const compressionComplete = fs.existsSync(stageManifestPath(area, "compress"));
const reimportManifest = stageManifestPath(area, "reimport");
const hasReimportManifest = fs.existsSync(reimportManifest);
@@ -435,7 +448,7 @@ function stageManifestStatus(area, configPath = null) {
inputs: {
...(configPath ? { config: configPath } : {}),
osm: area.input,
...(native ? nativeRoadRecords(area) : {
...(native && nativePackage ? nativeRoadRecords(nativePackage) : {
geojsonDir: area.outputs.geojsonDir,
...sceneGeojsonFiles(area),
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
@@ -468,7 +481,7 @@ function stageManifestStatus(area, configPath = null) {
glb: area.outputs.glb,
metadata: area.outputs.metadata,
}),
...(native ? nativeRoadRecords(area) : {
...(native && nativePackage ? nativeRoadRecords(nativePackage) : {
lanePolygons: path.join(area.outputs.geojsonDir, "lane_polygons.geojson"),
network: path.join(area.outputs.geojsonDir, "network.json"),
intersectionSurface: path.join(area.outputs.geojsonDir, "intersection_surface.geojson"),
@@ -609,11 +622,13 @@ function sceneGeojsonFiles(area) {
return files;
}
function nativeRoadRecords(area) {
const root = path.join(area.outputs.nativeRoadDir, "layers");
function nativeRoadRecords(nativePackage) {
const root = path.join(nativePackage.rootDir, "layers");
return {
nativeRoadCompiled: path.join(area.outputs.nativeRoadDir, "compiled.json"),
nativeRoadSignals: path.join(area.outputs.nativeRoadDir, "traffic-signals.json"),
nativeRoadZip: nativePackage.zipFile,
nativeRoadImport: nativePackage.rootDir,
nativeRoadCompiled: path.join(nativePackage.rootDir, "compiled.json"),
nativeRoadSignals: path.join(nativePackage.rootDir, "traffic-signals.json"),
nativeRoadSurface: path.join(root, "road_surface.geojson"),
nativeEdgeLines: path.join(root, "edge_lines.geojson"),
nativeIntersectionSurface: path.join(root, "intersection_surface.geojson"),