Skip to content

Commit 22a8e0a

Browse files
committed
Fix saving 110m maps
1 parent f4c3d48 commit 22a8e0a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/topojson/process_geodata.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,18 @@ async function convertLayersToTopojson({ name, resolution }) {
231231

232232
// Get polygon features from UN GeoJSON
233233
const inputFilePath = `${inputDir}/${unFilename}.geojson`;
234-
const outputFilePath = `${outputDirGeojson}/${unFilename}_50m/all_features.geojson`;
235-
const commandsAllFeatures = [inputFilePath, `-o target=1 ${outputFilePath}`].join(' ');
234+
const outputFilePath50m = `${outputDirGeojson}/${unFilename}_50m/all_features.geojson`;
235+
const outputPath110m = `${outputDirGeojson}/${unFilename}_110m`;
236+
const commandsAllFeatures = [inputFilePath, `-o target=1 ${outputFilePath50m}`].join(' ');
236237
await mapshaper.runCommands(commandsAllFeatures);
237238

238-
const geojson = getJsonFile(outputFilePath);
239+
const geojson = getJsonFile(outputFilePath50m);
239240
const simplifiedGeojson = {
240241
...geojson,
241242
features: geojson.features.map((f) => simplify(f, { tolerance: 0.01, highQuality: true }))
242243
};
243-
fs.writeFileSync(`${outputDirGeojson}/${unFilename}_110m/all_features.geojson`, JSON.stringify(simplifiedGeojson));
244+
if (!fs.existsSync(outputPath110m)) fs.mkdirSync(outputPath110m, { recursive: true });
245+
fs.writeFileSync(`${outputPath110m}/all_features.geojson`, JSON.stringify(simplifiedGeojson));
244246

245247
for (const resolution of resolutions) {
246248
for (const { source } of Object.values(vectors)) {

0 commit comments

Comments
 (0)