From 37a7091985d71d2886594576d9142401ae14134e Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Fri, 17 Feb 2023 17:06:37 +0100 Subject: [PATCH] feat: Reuse shape --- website/src/pages/api/generate.ts | 4 ++-- website/src/pages/api/v0.ts | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/website/src/pages/api/generate.ts b/website/src/pages/api/generate.ts index 48099662..c057f3c9 100644 --- a/website/src/pages/api/generate.ts +++ b/website/src/pages/api/generate.ts @@ -8,6 +8,7 @@ import { formatExtensions, initMiddleware, parseOptions, + shapeIndexComparator, } from "./_utils"; enableMapSet(); @@ -29,13 +30,12 @@ export default async function handler( const options = parseOptions(req, res)!; const { format, year, shapes } = options; - const cwd = process.cwd(); const output = await generate({ ...options, year, simplify: query.simplify as string, - shapes: [...shapes], + shapes: [...shapes].sort(shapeIndexComparator), mapshaperCommands: [ `-o output.${format} format=${format} drop-table id-field=id target=*`, ], diff --git a/website/src/pages/api/v0.ts b/website/src/pages/api/v0.ts index 00197f79..a0d13258 100644 --- a/website/src/pages/api/v0.ts +++ b/website/src/pages/api/v0.ts @@ -40,13 +40,6 @@ export default async function handler( res.status(500).json({ message: `Unsupported format ${format}` }); } - const cwd = process.cwd(); - const shpFilenames = [...options.shapes] - .map((shapeName) => { - return path.join(cwd, "public", "swiss-maps", year, `${shapeName}.shp`); - }) - .sort(shapeIndexComparator); - const hasCantons = shapes.has("cantons"); const hasMunicipalities = shapes.has("municipalities"); const hasLakes = shapes.has("lakes"); @@ -81,7 +74,7 @@ export default async function handler( ...options, simplify: query.simplify as string, year, - shapes: [...shapes], + shapes: [...shapes].sort(shapeIndexComparator), mapshaperCommands: [ ...styleCommands, `-o output.${format} format=${format} target=*`,