@urban-toolkit/autk-grammar 0.2.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,8 @@ A declarative grammar for urban visual analytics, running on [Autark](https://au
12
12
  npm install @urban-toolkit/autk-grammar
13
13
  ```
14
14
 
15
+ It runs on Autark 4: `@urban-toolkit/autk-core`, `autk-db`, `autk-map`, `autk-plot` and `autk-compute` 4.x, installed with it.
16
+
15
17
  ## Usage
16
18
 
17
19
  ```ts
@@ -27,6 +29,22 @@ const grammar = new AutkGrammar({ map: 'map', plot: 'plot' }); // ids of the map
27
29
  await grammar.run(spec);
28
30
  ```
29
31
 
32
+ ## JSON Schema
33
+
34
+ The package ships the grammar's JSON Schema (draft-07) as `@urban-toolkit/autk-grammar/build/autk-grammar-schema.json`, with `$id` `https://autarkjs.org/schema/autk-grammar/v1.json`. Validate a spec with any draft-07 validator:
35
+
36
+ ```ts
37
+ import { Ajv } from 'ajv';
38
+ import schema from '@urban-toolkit/autk-grammar/build/autk-grammar-schema.json' with { type: 'json' };
39
+
40
+ const validate = new Ajv({ allowUnionTypes: true }).compile(schema);
41
+ if (!validate(spec)) console.error(validate.errors);
42
+ ```
43
+
44
+ ## Compute helpers
45
+
46
+ `runCompute(block, layers, run)` runs one `compute` entry against named FeatureCollections with a GPU runner you pass in, for example `params => new AutkComputeEngine().gpgpuPipeline(params)`. It joins a `wglsFunction` written as an array of lines, resolves `fromFeature` uniforms, and drives `iterate: 'all'` (one dispatch per feature, outputs summed) and `iterate: 'batched'` (one dispatch over packed uniform arrays). autk-compute 4 reads each packed array from a read-only storage buffer of its own, so a batched pass packs as many features as its largest array fits in 128 MiB, the storage buffer binding every WebGPU device supports: 4,194,304 with a matrix entry (a bounding box of eight floats per feature), and `maxBatchedFeatures` gives the count for a pass. `resolveComputeParams(block, layers, iterateIndex?)` returns the parameters of a single dispatch without running anything.
47
+
30
48
  ## License
31
49
 
32
50
  MIT