tracktracker/script/update-network.js

31 lines
723 B
JavaScript
Executable File

#!/usr/bin/env node
import * as network from '../src/data/network.js';
import fs from 'fs/promises';
/** Geographical bounds of the Montpellier metropolitan area. */
const bounds = [
"43.49552248630757", "3.660507202148437",
"43.73736766145917", "4.092750549316406",
];
const data = await network.fetch("TaM", "tram", bounds);
await fs.writeFile(
new URL("../src/data/network.json", import.meta.url),
JSON.stringify(
data,
(_, value) =>
{
if (value instanceof Set)
{
// Convert sets to arrays for JSON representation
return Array.from(value.values());
}
return value;
},
4
)
);