Skip to content

Commit b3ad73e

Browse files
authored
Merge pull request #50 from slub/add-external-vector-map-feature
Add external vector map feature
2 parents b696250 + 538d923 commit b3ad73e

File tree

264 files changed

+12985
-9174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+12985
-9174
lines changed

Build/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# auto-generated during build process
2+
src/util/schemas/*

Build/esbuild.map.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* file 'LICENSE.txt', which is part of this source code package.
66
*/
77
import { build } from "./esbuild.base.js";
8+
import { generateAjvFeatureCollectionValidator } from "./esbuild.validate-feature-collection.js";
89

910
// Define constants
1011
const outputDir = "../Resources/Public/Build/";
@@ -14,5 +15,7 @@ const options = {
1415
outfile: `${outputDir}plugin-map.js`,
1516
};
1617

18+
await generateAjvFeatureCollectionValidator();
19+
1720
// Run the build process with the supplied options
1821
build(options);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Created by tom.schulze@pikobytes.de on 13.05.25.
3+
*
4+
* This file is subject to the terms and conditions defined in
5+
* file "LICENSE.txt", which is part of this source code package.
6+
*/
7+
8+
import { readFile } from "fs/promises";
9+
import fs from "node:fs";
10+
import path from "node:path";
11+
import Ajv from "ajv";
12+
import { default as standaloneCode } from "ajv/dist/standalone/index.js";
13+
14+
export const generateAjvFeatureCollectionValidator = async () => {
15+
console.log("Generating AJV FeatureCollection standalone validator");
16+
const pathToSchema = new URL(
17+
"./node_modules/geojson-schema/FeatureCollection.json",
18+
import.meta.url
19+
);
20+
21+
const schema = JSON.parse(await readFile(pathToSchema));
22+
23+
// The generated code will have a default export:
24+
// `module.exports = <validateFunctionCode>;module.exports.default = <validateFunctionCode>;`
25+
const ajv = new Ajv({ strict: true, code: { source: true, esm: true } });
26+
const validate = ajv.compile(schema);
27+
let moduleCode = standaloneCode(ajv, validate);
28+
29+
const destination = "src/util/schemas/validateFeatureCollection.js";
30+
const outputPath = path.join(import.meta.dirname, destination);
31+
32+
fs.writeFileSync(outputPath, moduleCode);
33+
console.log(`Saved FeatureCollection validator to '${outputPath}'\n`);
34+
};

0 commit comments

Comments
 (0)