Skip to content

Commit

Permalink
feat: Reuse shape
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Feb 17, 2023
1 parent 30dd70a commit 37a7091
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 2 additions & 2 deletions website/src/pages/api/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
formatExtensions,
initMiddleware,
parseOptions,
shapeIndexComparator,
} from "./_utils";

enableMapSet();
Expand All @@ -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=*`,
],
Expand Down
9 changes: 1 addition & 8 deletions website/src/pages/api/v0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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=*`,
Expand Down

0 comments on commit 37a7091

Please sign in to comment.