53 lines
2.3 KiB
JavaScript
53 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
const { startWorkbench } = require('../workbench/server');
|
|
|
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'road-compiler-e2e-'));
|
|
const source = path.join(__dirname, 'fixtures', 'fengshu-er-road.osm');
|
|
const osmFile = path.join(root, 'source.osm');
|
|
const sourceXml = fs.readFileSync(source, 'utf8');
|
|
const threeArmFixture = `
|
|
<node id="-91001" lat="30.470000" lon="114.110000" />
|
|
<node id="-91002" lat="30.470000" lon="114.110100" />
|
|
<node id="-91003" lat="30.470086" lon="114.110050" />
|
|
<node id="-91011" lat="30.469600" lon="114.109600" />
|
|
<node id="-91012" lat="30.469600" lon="114.110500" />
|
|
<node id="-91013" lat="30.470550" lon="114.110050" />
|
|
<way id="-91101"><nd ref="-91001"/><nd ref="-91002"/><tag k="highway" v="secondary"/></way>
|
|
<way id="-91102"><nd ref="-91002"/><nd ref="-91003"/><tag k="highway" v="secondary"/></way>
|
|
<way id="-91103"><nd ref="-91003"/><nd ref="-91001"/><tag k="highway" v="secondary"/></way>
|
|
<way id="-91111"><nd ref="-91011"/><nd ref="-91001"/><tag k="highway" v="secondary"/></way>
|
|
<way id="-91112"><nd ref="-91012"/><nd ref="-91002"/><tag k="highway" v="secondary"/></way>
|
|
<way id="-91113"><nd ref="-91013"/><nd ref="-91003"/><tag k="highway" v="secondary"/></way>`;
|
|
fs.writeFileSync(osmFile, sourceXml.replace('</osm>', `${threeArmFixture}\n</osm>`));
|
|
const input = {
|
|
areaId: 'e2e-fengshu-er-road',
|
|
osmFile,
|
|
outDir: path.join(root, 'native-road'),
|
|
stagingDir: path.join(root, 'pipeline'),
|
|
overridesFile: path.join(root, 'native-road-overrides.json'),
|
|
trafficSignalsFile: path.join(root, 'native-traffic-signals.json'),
|
|
options: { edgeLines: false, junctionTemplates: { enabled: false, references: [] } },
|
|
};
|
|
fs.writeFileSync(input.overridesFile, JSON.stringify({ schema: 'native-road-overrides/v1', overrides: [] }));
|
|
fs.writeFileSync(
|
|
input.trafficSignalsFile,
|
|
fs.readFileSync(path.join(__dirname, '..', 'outputs', 'fengshu-er-road', 'native-traffic-signals.json')),
|
|
);
|
|
|
|
const server = startWorkbench({
|
|
input,
|
|
repoRoot: path.resolve(__dirname, '..'),
|
|
dataRoot: root,
|
|
debug: true,
|
|
port: 8899,
|
|
});
|
|
const cleanup = () => {
|
|
server.close(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
};
|
|
process.once('SIGINT', cleanup);
|
|
process.once('SIGTERM', cleanup);
|