@urban-toolkit/autk-grammar 0.3.0 → 4.1.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.1: `@urban-toolkit/autk-core`, `autk-db`, `autk-map`, `autk-plot` and `autk-compute` 4.1 or a later 4.x, installed with it.
16
+
15
17
  ## Usage
16
18
 
17
19
  ```ts
@@ -27,6 +29,18 @@ const grammar = new AutkGrammar({ map: 'map', plot: 'plot' }); // ids of the map
27
29
  await grammar.run(spec);
28
30
  ```
29
31
 
32
+ ## Maps
33
+
34
+ Each map draws on demand: one frame once its layers are loaded, then one each time it changes. `grammar.maps` holds the `AutkMap` of each `map` entry of the last run, in order. Between frames a map canvas can read back empty, so to read a map's pixels (for example with `canvas.toDataURL()`), call its `requestRender()` and read in a `requestAnimationFrame` callback registered after that call:
35
+
36
+ ```ts
37
+ const map = grammar.maps[0];
38
+ map.requestRender();
39
+ requestAnimationFrame(() => {
40
+ const png = map.canvas.toDataURL('image/png');
41
+ });
42
+ ```
43
+
30
44
  ## JSON Schema
31
45
 
32
46
  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:
@@ -41,7 +55,7 @@ if (!validate(spec)) console.error(validate.errors);
41
55
 
42
56
  ## Compute helpers
43
57
 
44
- `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). `resolveComputeParams(block, layers, iterateIndex?)` returns the parameters of a single dispatch without running anything.
58
+ `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.
45
59
 
46
60
  ## License
47
61