@urban-toolkit/autk-grammar 4.4.1 → 5.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 +424 -5
- package/build/autk-grammar-schema.json +1367 -505
- package/dist/autk-grammar.js +872 -430
- package/dist/autk-grammar.js.map +1 -1
- package/dist/autk-grammar.umd.cjs +2 -2
- package/dist/autk-grammar.umd.cjs.map +1 -1
- package/dist/data/autk-grammar-data.cjs +2 -0
- package/dist/data/autk-grammar-data.cjs.map +1 -0
- package/dist/data/autk-grammar-data.d.ts +516 -0
- package/dist/data/autk-grammar-data.js +265 -0
- package/dist/data/autk-grammar-data.js.map +1 -0
- package/dist/index.d.ts +744 -76
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -29,6 +29,157 @@ const grammar = new AutkGrammar({ map: 'map', plot: 'plot' }); // ids of the map
|
|
|
29
29
|
await grammar.run(spec);
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## Data sources
|
|
33
|
+
|
|
34
|
+
Each entry of `data` loads or builds one table, in order. Its `type` selects its fields:
|
|
35
|
+
|
|
36
|
+
| `type` | Fields | Table |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `osm` | `queryArea`, `pbfFileUrl`, `autoLoadLayers`, `tagSets` | OpenStreetMap data for an area, from Overpass or a `.osm.pbf` extract (see [OpenStreetMap areas](#openstreetmap-areas)). `autoLoadLayers.layers` splits it into one table per layer, named `<outputTableName>_<layer>`, and [`tagSets`](#tagsets) adds a table for each set of features chosen by their tags. |
|
|
39
|
+
| `csv` | `csvFileUrl` or `csvObject`, `delimiter`, `geometryColumns` | The rows of a CSV file, or of arrays whose first row names the columns. |
|
|
40
|
+
| `json` | `jsonFileUrl` or `jsonObject`, `geometryColumns` | The rows of a JSON array. |
|
|
41
|
+
| `geojson` | `geojsonFileUrl` or `geojsonObject`, `coordinateFormat`, `layerType` | A FeatureCollection. `layerType` sets how a map draws it, for example `polylines`, or `buildings` for polygons; without it, autk-db reads it from the first feature with a geometry. A feature whose geometry is null is a row without one: a map draws nothing for it, and a plot counts it. |
|
|
42
|
+
| `geotiff` | `geotiffFileUrl`, `coordinateFormat`, `maxRasterCells`, `resampleMethod` | A raster read from a GeoTIFF file. |
|
|
43
|
+
| `heatmap` | `joinDataRef`, `near`, `grid`, `groupBy` | A raster grid over the workspace's extent, whose cells aggregate the rows of another table. |
|
|
44
|
+
| `join` | `dataRef`, `joinDataRef`, `near`, `groupBy` | No new table: it joins the rows of `joinDataRef` onto the features of `dataRef`, in place. |
|
|
45
|
+
| `sql` | `query`, `layerType` | The rows of a SQL query over the workspace's tables (see [`sql` sources](#sql-sources)). |
|
|
46
|
+
| `update` | `dataRef`, `strategy`, `idColumn`, `geojsonObject` or `jsonObject` | No new table: it replaces or changes the rows of `dataRef` (see [`update` sources](#update-sources)). |
|
|
47
|
+
| `drop` | `dataRef` | No new table: it drops `dataRef` (see [`drop` sources](#drop-sources)). |
|
|
48
|
+
|
|
49
|
+
Every source but `join`, `update` and `drop` names its table with `outputTableName`, and every source takes a `workspace` (see [Workspaces](#workspaces)).
|
|
50
|
+
|
|
51
|
+
A `geotiff` source:
|
|
52
|
+
|
|
53
|
+
| Field | Effect |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `geotiffFileUrl` | The file's URL, relative to the page or absolute. Its first image is read: each of its bands becomes a band of the table (`band_1`, `band_2`, ...), and the file's no-data value reads as no value. A rotated or sheared grid is refused. |
|
|
56
|
+
| `coordinateFormat` | The file's CRS, as an EPSG string. Defaults to `EPSG:4326`. |
|
|
57
|
+
| `maxRasterCells` | The most cells to decode: a larger raster is downsampled to fit. Defaults to 1,000,000. |
|
|
58
|
+
| `resampleMethod` | How a larger raster is downsampled: `nearest` or `bilinear`, the default. |
|
|
59
|
+
|
|
60
|
+
A map layer draws the band of a raster table that its `getFnv` names, else the first band.
|
|
61
|
+
|
|
62
|
+
A `join` or a `heatmap` source:
|
|
63
|
+
|
|
64
|
+
| Field | Effect |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `dataRef` | A join's root table, which receives the joined rows. |
|
|
67
|
+
| `joinDataRef` | The table whose rows are joined onto the root table, or aggregated into a heatmap's cells. |
|
|
68
|
+
| `near` | `{ distance, useCentroid }`, with `distance` in workspace units. A join takes the rows within `distance` of each root feature instead of those that intersect it. A heatmap, which needs it, gives each cell the rows within `distance` of the cell's center. With `useCentroid`, the default, distances run between centroids: a root feature's and a row's, or a cell's center and a row's centroid. With `false`, they run between the geometries' nearest points, so features that touch are 0 apart. |
|
|
69
|
+
| `grid` | A heatmap's cells: `{ rows, columns }`, over the extent of the workspace. |
|
|
70
|
+
| `groupBy` | How the rows combine, as `[{ column, aggregateFn }]`, where `aggregateFn` is `sum`, `avg`, `count`, `min`, `max`, `weighted` or `collect`; a heatmap refuses `collect`, which lists rows, since a cell holds one value. A join writes the result on each root feature: `{ column: 'Unique Key', aggregateFn: 'count' }` writes `sjoin.count.<joinDataRef>`, and `normalize: true` adds the value rescaled from 0 to 1 across the features, under its key with `_norm` added. Without `groupBy`, a join lists the rows each feature matches in `sjoin.matches`. A heatmap has one band per entry, labelled `<aggregateFn>_<joinDataRef>`, which a layer's `getFnv` names as `<aggregateFn>.<joinDataRef>`, for example `count.noise`; without `groupBy`, one band counts the rows. |
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
await grammar.run({
|
|
74
|
+
data: [
|
|
75
|
+
{ type: 'geojson', outputTableName: 'neighborhoods', geojsonFileUrl: 'neighborhoods.geojson' },
|
|
76
|
+
{ type: 'csv', outputTableName: 'noise', csvFileUrl: 'noise.csv', geometryColumns: { latColumnName: 'Latitude', longColumnName: 'Longitude' } },
|
|
77
|
+
{ type: 'join', dataRef: 'neighborhoods', joinDataRef: 'noise', groupBy: [{ column: 'Unique Key', aggregateFn: 'count' }] },
|
|
78
|
+
{ type: 'heatmap', outputTableName: 'heat', joinDataRef: 'noise', near: { distance: 1000 }, grid: { rows: 20, columns: 20 } },
|
|
79
|
+
],
|
|
80
|
+
map: { layerRefs: [{ dataRef: 'neighborhoods', getFnv: 'sjoin.count.noise' }, { dataRef: 'heat', opacity: 0.5 }] },
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Heatmap `normalize`
|
|
85
|
+
|
|
86
|
+
An entry of a heatmap's `groupBy` with `normalize: true` asks for its band's values rescaled from 0 to 1 across the grid's cells, as a join's `normalize` rescales a value across the features. It needs an autk-db with urban-toolkit/autark#132, which also adds `_norm` to the band's label, so a layer names it as `<aggregateFn>.<joinDataRef>_norm`. autk-db 4.1.1 builds the band from the values as they are, under the label it would have without `normalize`. A layer can also name a band by its id, `band_1`, `band_2` and so on, one per entry of `groupBy`, in order.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
{ type: 'heatmap', outputTableName: 'heat', joinDataRef: 'noise', near: { distance: 1000 }, grid: { rows: 20, columns: 20 },
|
|
90
|
+
groupBy: [{ column: 'Unique Key', aggregateFn: 'count', normalize: true }] }
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `sql` sources
|
|
94
|
+
|
|
95
|
+
A `sql` source saves the rows of a query over the tables of its workspace as a new table, `outputTableName`:
|
|
96
|
+
|
|
97
|
+
| Field | Effect |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `query` | A `SELECT`, or a `WITH` query that ends in one, in DuckDB's SQL, naming the workspace's tables by their names. autk-db refuses any other statement, and any query in which `insert`, `update`, `delete`, `create`, `alter`, `drop`, `truncate` or `replace` appears as a word, even inside a string; the run's message names the source. |
|
|
100
|
+
| `layerType` | How a map draws the new table. The query then returns its geometry in a column named `geometry`, as the workspace's tables hold it, in the workspace's CRS. Without it, the table has no layer type: a plot draws its rows, but a map does not draw it and `grammar.data` does not list it. |
|
|
101
|
+
|
|
102
|
+
A GeoJSON table keeps each feature's properties in a JSON column, `properties`, which `properties->>'name'` reads as text; a CSV or JSON table keeps a column per field. A query that returns `properties` gives each feature those properties; otherwise each column but `geometry` becomes a property. Saving under a table's own name replaces it.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
await grammar.run({
|
|
106
|
+
data: [
|
|
107
|
+
{ type: 'geojson', outputTableName: 'neighborhoods', geojsonFileUrl: 'neighborhoods.geojson' },
|
|
108
|
+
{ type: 'csv', outputTableName: 'noise', csvFileUrl: 'noise.csv', geometryColumns: { latColumnName: 'Latitude', longColumnName: 'Longitude' } },
|
|
109
|
+
{ type: 'join', dataRef: 'neighborhoods', joinDataRef: 'noise', groupBy: [{ column: 'Unique Key', aggregateFn: 'count' }] },
|
|
110
|
+
{
|
|
111
|
+
type: 'sql',
|
|
112
|
+
outputTableName: 'noisiest',
|
|
113
|
+
query: "SELECT properties->>'ntaname' AS name, CAST(properties->'sjoin'->'count'->>'noise' AS INTEGER) AS complaints, geometry FROM neighborhoods ORDER BY complaints DESC NULLS LAST LIMIT 10",
|
|
114
|
+
layerType: 'polygons',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
map: { layerRefs: [{ dataRef: 'neighborhoods', color: '#d9d9d9' }, { dataRef: 'noisiest', getFnv: 'complaints' }] },
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### `update` sources
|
|
122
|
+
|
|
123
|
+
An `update` source replaces or changes the rows of a table already loaded, `dataRef`, with rows given in the spec:
|
|
124
|
+
|
|
125
|
+
| Field | Effect |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `strategy` | `replace` swaps every row of the table for the given rows. `update` changes the rows whose `idColumn` value a given row has: in a table with a geometry, each takes the given row's geometry and properties, and no row is added; in a table without one, the given rows replace them, and those that match no row are added. |
|
|
128
|
+
| `idColumn` | With `update`, the column that matches a given row to the table's rows: a column such as `month`, or a feature property as `properties.<name>`. |
|
|
129
|
+
| `geojsonObject` | The rows of a table with a geometry, as a FeatureCollection. autk-db stores their coordinates as they come, so they are in the workspace's CRS, as `grammar.data` gives a table's features. |
|
|
130
|
+
| `jsonObject` | The rows of a table without a geometry, such as a CSV or JSON table loaded without `geometryColumns`, as an array of objects. |
|
|
131
|
+
|
|
132
|
+
A source gives its rows in `geojsonObject` or in `jsonObject`, not both. The maps and plots after it draw the table's rows as they are now. The run's message names the table when autk-db refuses an update.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
await grammar.run({
|
|
136
|
+
data: [
|
|
137
|
+
{ type: 'csv', outputTableName: 'sales', csvObject: [['month', 'total'], ['Jan', 3], ['Feb', 5]] },
|
|
138
|
+
{ type: 'update', dataRef: 'sales', strategy: 'update', idColumn: 'month', jsonObject: [{ month: 'Feb', total: 9 }, { month: 'Mar', total: 4 }] },
|
|
139
|
+
],
|
|
140
|
+
plot: { dataRef: 'sales', mark: 'bar', axis: ['month', 'total'] }, // Jan 3, Feb 9, Mar 4
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### `drop` sources
|
|
145
|
+
|
|
146
|
+
A `drop` source drops a table, `dataRef`, from its workspace: the sources, compute passes, maps and plots after it no longer find it, and `grammar.data` no longer lists it. It suits a table a spec needs only on the way, such as the rows a join aggregates. The run refuses a drop of a table the workspace does not hold, with a message that names the table.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
data: [
|
|
150
|
+
{ type: 'geojson', outputTableName: 'neighborhoods', geojsonFileUrl: 'neighborhoods.geojson' },
|
|
151
|
+
{ type: 'csv', outputTableName: 'noise', csvFileUrl: 'noise.csv', geometryColumns: true },
|
|
152
|
+
{ type: 'join', dataRef: 'neighborhoods', joinDataRef: 'noise', groupBy: [{ column: 'Unique Key', aggregateFn: 'count' }] },
|
|
153
|
+
{ type: 'drop', dataRef: 'noise' },
|
|
154
|
+
],
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Workspaces
|
|
158
|
+
|
|
159
|
+
A workspace is an isolated set of tables with its own extent. The first source loaded into a workspace sets its extent, and later sources are cut to it, so two areas that must not clip each other go in two workspaces. A table is found by its name inside its workspace, so two workspaces may hold tables of the same name.
|
|
160
|
+
|
|
161
|
+
`workspace` names one, on a source (where its table goes), a compute pass (where it reads and writes), a map or a plot (where it reads its tables). An entry without one uses the default workspace.
|
|
162
|
+
|
|
163
|
+
### `workspaces`
|
|
164
|
+
|
|
165
|
+
A spec's `workspaces` sets how a workspace stores its tables, one entry per workspace, before the first source loads:
|
|
166
|
+
|
|
167
|
+
| Field | Effect |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `name` | The workspace, by the name its entries give as their `workspace`. Without it, the default workspace. |
|
|
170
|
+
| `coordinateFormat` | The CRS the workspace stores its tables in, as an EPSG string such as `EPSG:3857`. Each source is transformed to it as it loads, and its maps draw in its units. autk-db's default is `EPSG:3395`, World Mercator, in meters. |
|
|
171
|
+
| `precisionGrid` | The grid every stored coordinate is rounded to, in the CRS's units, greater than 0. autk-db's default is 0.01, a centimeter in World Mercator. A geometry the grid collapses is refused as it loads. |
|
|
172
|
+
|
|
173
|
+
Both fields are required, and a run refuses two entries for one workspace. A workspace without an entry keeps autk-db's defaults. The lengths given in workspace units are in the CRS's units: a `near.distance`, a layer's `width`, a camera's `zoom`. A layer's `pointSize`, in meters, is converted for World Mercator and Web Mercator, and read as planar units in any other CRS.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
await grammar.run({
|
|
177
|
+
workspaces: [{ coordinateFormat: 'EPSG:3857', precisionGrid: 1 }], // the default workspace, in Web Mercator to the meter
|
|
178
|
+
data: [{ type: 'geojson', outputTableName: 'parcels', geojsonFileUrl: 'parcels.geojson' }],
|
|
179
|
+
map: { layerRefs: [{ dataRef: 'parcels' }] },
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
32
183
|
## OpenStreetMap areas
|
|
33
184
|
|
|
34
185
|
An `osm` source's `queryArea` names the area to load in one of two ways, never both:
|
|
@@ -53,6 +204,103 @@ await grammar.run({
|
|
|
53
204
|
});
|
|
54
205
|
```
|
|
55
206
|
|
|
207
|
+
### `tagSets`
|
|
208
|
+
|
|
209
|
+
An `osm` source's `tagSets` choose features by their tags. Each set becomes a table of one geometry type, named `<outputTableName>_<name>_<type>` and cut to the source's area. Tag sets are read from the Overpass API only: a source with `pbfFileUrl` cannot take them, and the run refuses one that does, with a message that names the source.
|
|
210
|
+
|
|
211
|
+
| Field | Effect |
|
|
212
|
+
|---|---|
|
|
213
|
+
| `name` | Names the set's table: a lowercase letter, then up to 31 lowercase letters, digits or `_`. No two sets of a source share a name. |
|
|
214
|
+
| `type` | The table's geometry: `points`, the tagged nodes; `polylines`, the open ways and the ways tagged as lines (`highway`, `barrier`, `railway`, `waterway`, or `area=no`); `polygons`, the other closed ways and the multipolygon relations. |
|
|
215
|
+
| `tags` | 1 to 64 tags, each `{ key, value }`: a feature is in the set when it has any one of them. Without `value`, the key with any value matches. |
|
|
216
|
+
|
|
217
|
+
A source takes up to 8 sets, and may leave out `autoLoadLayers` to load its sets alone. A set that matches no feature in the area makes no table. Each feature's properties are its tags.
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
await grammar.run({
|
|
221
|
+
data: [{
|
|
222
|
+
type: 'osm',
|
|
223
|
+
outputTableName: 'downtown',
|
|
224
|
+
queryArea: { bbox: [-74.0125, 40.705, -74.008, 40.7085] },
|
|
225
|
+
tagSets: [
|
|
226
|
+
{ name: 'cafes', type: 'points', tags: [{ key: 'amenity', value: 'cafe' }] },
|
|
227
|
+
{ name: 'paths', type: 'polylines', tags: [{ key: 'highway', value: 'footway' }, { key: 'highway', value: 'path' }] },
|
|
228
|
+
],
|
|
229
|
+
}],
|
|
230
|
+
map: { layerRefs: [{ dataRef: 'downtown_paths_polylines' }, { dataRef: 'downtown_cafes_points', color: '#8c564b' }] },
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### `forceRefresh`
|
|
235
|
+
|
|
236
|
+
autk-db keeps the Overpass API's answer for an `osm` source in the browser's cache for 24 hours, by its area, its layers and its tag sets, and a later run of the same source reads it from there. `forceRefresh: true` queries the API again, and caches the new answer. A source with `pbfFileUrl` reads its file each time, and ignores it.
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
{ type: 'osm', outputTableName: 'loop', queryArea: { geocodeArea: 'Chicago', areas: ['Loop'] }, autoLoadLayers: { layers: ['roads'] }, forceRefresh: true }
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `autoLoadLayers.coordinateFormat`
|
|
243
|
+
|
|
244
|
+
The CRS of an `osm` source's coordinates, as an EPSG string. It defaults to `EPSG:4326`, the degrees the Overpass API and OpenStreetMap's extracts give, so a source sets it only for data in another CRS. The layers and the tag sets are read in it, and stored in the workspace's CRS.
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
{ type: 'osm', outputTableName: 'area', pbfFileUrl: 'area-nad83.osm.pbf', queryArea: { bbox: [-74.02, 40.70, -74.00, 40.72] }, autoLoadLayers: { layers: ['roads'], coordinateFormat: 'EPSG:4269' } }
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### `osmElements`
|
|
251
|
+
|
|
252
|
+
A map layer or a plot with `osmElements: true` reads an OpenStreetMap layer table as one feature per OSM element it was built from, rather than one per row. Each feature's properties are the element's tags, its `osm_type` (`node`, `way` or `relation`) and its `osm_id`; in a buildings table, whose parts are elements of their own, also the `building_id` of its building. A part takes only its own tags, so a buildings layer draws only the parts whose tags give their height. A table that is not an OSM layer, a surface, and an OSM table an `update` source changed are read row by row, as without it.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
map: { layerRefs: [{ dataRef: 'downtown_roads', osmElements: true, getFnv: 'highway', colorMapInterpolator: ColorMapInterpolator.CAT_TABLEAU10 }] },
|
|
256
|
+
plot: { dataRef: 'downtown_roads', mark: 'table', axis: ['osm_id', 'highway', 'name'], osmElements: true },
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Compute
|
|
260
|
+
|
|
261
|
+
Each entry of `compute` runs on the GPU with autk-compute, in order, once the data is loaded. Its `type` is `gpgpu`, the default, or `render`.
|
|
262
|
+
|
|
263
|
+
A GPGPU pass runs a WGSL function once per feature of a table:
|
|
264
|
+
|
|
265
|
+
| Field | Effect |
|
|
266
|
+
|---|---|
|
|
267
|
+
| `dataRef` | The table the function runs over. |
|
|
268
|
+
| `attributes` | WGSL variable names, each mapped to a feature property path. |
|
|
269
|
+
| `wgslFunction` | The body of the WGSL function. An array of strings is joined with newlines, which keeps long shaders readable in JSON. |
|
|
270
|
+
| `outputColumnName`, `outputColumns` | The column the function's result is written to, under `feature.properties.compute`, or the columns of a result of several values. |
|
|
271
|
+
| `outputTableName` | A new table that receives the result, so `dataRef` stays as it is and later passes, maps and plots can read both. Without it, the pass writes into `dataRef`. |
|
|
272
|
+
| `layerType` | How a map draws the new table. Defaults to the type of `dataRef`. Only used with `outputTableName`. |
|
|
273
|
+
|
|
274
|
+
`attributeArrays` and `attributeMatrices` pass more of each feature's values, and `uniforms`, `uniformArrays` and `uniformMatrices` pass values every invocation shares. `uniforms` and `uniformMatrices` can read theirs from a feature of a table (see [Compute helpers](#compute-helpers)).
|
|
275
|
+
|
|
276
|
+
A render pass renders tables on the GPU from each viewpoint, in several directions, and counts what each frame shows: a visibility or sky-view metric. Its result is a new table: the viewpoints' features, with the metrics in `feature.properties.compute.render`: `sampleCount`, the frames rendered from the feature, and `classes` or `objects`.
|
|
277
|
+
|
|
278
|
+
| Field | Effect |
|
|
279
|
+
|---|---|
|
|
280
|
+
| `outputTableName` | The new table. Required. |
|
|
281
|
+
| `layerType` | How a map draws it. Defaults to the type of the viewpoints table, or to `points` with the `building-windows` strategy, whose result holds one point per window. |
|
|
282
|
+
| `layers` | The tables drawn into the frames: `{ id, dataRef, type, objectIdProperty }`. `id` names the layer in the pass, `type` sets how it is drawn (`surface`, `parks`, `water`, `roads`, `buildings`, `polygons` or `polylines`: a render pass draws no points, and a run refuses any other type), and `objectIdProperty` names the property that holds an object's id. |
|
|
283
|
+
| `viewpoints.dataRef` | The table whose features the frames are rendered from. |
|
|
284
|
+
| `viewpoints.strategy` | `{ type: 'centroid' }`, the default: a viewpoint at each feature's centroid. `{ type: 'building-windows', floors }`: windows along each building's facades, `floors` rows of them up its height, each looking out from the facade and 30 degrees to either side. The result then holds one point per window instead of the table's features. |
|
|
285
|
+
| `viewpoints.sampling` | With `centroid`, the directions each viewpoint looks in: `directions` of them (1 by default), evenly spaced around the horizon, the first at `azimuthOffsetDeg` degrees counterclockwise from east (0 by default), all at `pitchDeg` degrees above the horizontal (0 by default). |
|
|
286
|
+
| `aggregation` | `{ type: 'classes' }` writes the share of each feature's frame pixels that each layer type covers, from 0 to 1. `includeBackground: true` also counts the pixels no layer covers, such as the sky, as one more class, `backgroundLayerType` (`background` by default). `{ type: 'objects' }` writes, for each object seen, the share of the feature's frames that show it. |
|
|
287
|
+
| `camera` | The lens of the frames: `fov`, the field of view of each square frame in degrees (90 by default), and `clip: { near, far }`, the nearest and farthest distances drawn, in workspace units (1 and 5000 by default). Unlike a map's `camera`, it sets no position or direction: `viewpoints` does. |
|
|
288
|
+
| `tileSize` | The size of each frame in pixels, a multiple of 8. Defaults to 64. |
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
await grammar.run({
|
|
292
|
+
data: [/* a buildings table named buildings, and a points table named sensors */],
|
|
293
|
+
compute: [{
|
|
294
|
+
type: 'render',
|
|
295
|
+
outputTableName: 'skyView',
|
|
296
|
+
layers: [{ id: 'buildings', dataRef: 'buildings', type: 'buildings' }],
|
|
297
|
+
viewpoints: { dataRef: 'sensors', sampling: { directions: 8, pitchDeg: 30 } },
|
|
298
|
+
aggregation: { type: 'classes', includeBackground: true },
|
|
299
|
+
}],
|
|
300
|
+
map: { layerRefs: [{ dataRef: 'buildings' }, { dataRef: 'skyView', getFnv: 'compute.render.classes.background' }] },
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
56
304
|
## Maps
|
|
57
305
|
|
|
58
306
|
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:
|
|
@@ -65,6 +313,22 @@ requestAnimationFrame(() => {
|
|
|
65
313
|
});
|
|
66
314
|
```
|
|
67
315
|
|
|
316
|
+
A map's `id` names it as the `target` of a link (see [Plots and links](#plots-and-links)). No two maps or plots of a spec share an id, and an id is never empty.
|
|
317
|
+
|
|
318
|
+
A map's `camera` moves its view from the one that fits its layers:
|
|
319
|
+
|
|
320
|
+
| Option | Effect |
|
|
321
|
+
|---|---|
|
|
322
|
+
| `zoom` | The eye's distance from the point the view looks at: `10000 / 2^(zoom - 10)` workspace units, so each step halves it. Without it, the distance of the view that fits the layers. |
|
|
323
|
+
| `pitch` | The tilt from straight down, in degrees, at least 0 and less than 90. At 90 the eye would sit on the ground, edge-on to the flat layers, and the map could not pan, so a run refuses it. |
|
|
324
|
+
| `bearing` | The compass heading the view faces, clockwise from north, from 0 to 360 degrees. |
|
|
325
|
+
|
|
326
|
+
The camera turns around the point the map looks at, which the view that fits the layers sets: the eye moves on a sphere around that point, so the layers stay in view at any pitch and bearing. The view's up direction stays across its line of sight, as autk-map's own tilt leaves it, so the map's pan, tilt and zoom at the cursor carry on from the spec's view as they do from a view the user tilted.
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
map: { id: 'downtown', camera: { zoom: 15, pitch: 50, bearing: 30 }, layerRefs: [{ dataRef: 'buildings' }] }
|
|
330
|
+
```
|
|
331
|
+
|
|
68
332
|
## Layer styling
|
|
69
333
|
|
|
70
334
|
Besides `dataRef`, a layer of `map.layerRefs` takes these styling options:
|
|
@@ -75,21 +339,23 @@ Besides `dataRef`, a layer of `map.layerRefs` takes these styling options:
|
|
|
75
339
|
| `color` | The layer's color, `#rrggbb`. The layer is drawn in it rather than by its `getFnv` value, unless `isColorMap` is `true`. |
|
|
76
340
|
| `stroke` | A polygon layer's outline: its color, `#rrggbb`, or `false` for none. |
|
|
77
341
|
| `width` | The width of a polylines or roads layer's lines, in the map's planar units (autk-map's `polylinesWidth`). |
|
|
342
|
+
| `pointSize` | The radius of each point of a points layer, in meters on the ground. The adapter converts it to the workspace's planar units at the middle of the layer, where World Mercator stretches a meter by about 1.34 at Chicago, and passes it as autk-map's `pointSize`. Without it, autk-map draws each point with a radius of 64 planar units, about 48 m at Chicago. Other layers ignore it. |
|
|
78
343
|
| `colorMapInterpolator` | The color scheme. A raster layer's cells and its legend's labels follow it. |
|
|
79
344
|
| `colorMapRange` | The ends of the color scale, `[low, high]` with low less than high. The layer is colored over this range instead of its own lowest and highest values, so layers that set the same range, in one map or in maps side by side, color the same value alike. Raster and vector layers. A categorical scheme ignores it, and a layer cannot set both `colorMapRange` and `colorMapDomain`. On a raster layer, a `transferFunction` still sets opacity from the layer's own values. |
|
|
80
345
|
| `colorMapCenter` | On a raster layer, the value at the middle of the color scale. With `colorMapRange`, the scale runs from the range's low through the center to its high (a sequential scheme keeps only the ends). Without it, the scale runs from the center less the farthest value's distance to it, to the center plus that distance. |
|
|
81
346
|
| `colorMapReverse` | On a raster layer, runs the color scale from the highest value to the lowest, or from `colorMapRange`'s high to its low. |
|
|
82
347
|
| `transferFunction` | On a raster layer, how opaque its cells are by value: autk-map's transfer function (`mode`, `opacityMin`, `opacityMax`, `gamma`, `zeroCenter`). `{ opacityMin: 1, opacityMax: 1 }` draws every cell with a value fully opaque. |
|
|
83
348
|
|
|
84
|
-
After a run, `grammar.mapLayer(dataRef)` finds the layer a map draws for a table: the `AutkMap` and the layer's id in it. `highlightOnMap`, `clearHighlightOnMap` and a plot's `mapRef` also name
|
|
349
|
+
After a run, `grammar.mapLayer(dataRef)` finds the layer a map draws for a table: the `AutkMap` and the layer's id in it, the last map's when several maps draw the table. `grammar.mapLayers(dataRef)` lists every layer that draws it, in every map. `highlightOnMap`, `clearHighlightOnMap` and a plot's `mapRef` also name layers by their `dataRef` (see [Interactions](#interactions)).
|
|
85
350
|
|
|
86
351
|
```ts
|
|
87
352
|
await grammar.run({
|
|
88
|
-
data: [/* tables named routes and parcels, and a heatmap raster named change */],
|
|
353
|
+
data: [/* tables named routes and parcels, a points table named fixes, and a heatmap raster named change */],
|
|
89
354
|
map: {
|
|
90
355
|
layerRefs: [
|
|
91
356
|
{ dataRef: 'parcels', color: '#4e79a7', stroke: false },
|
|
92
357
|
{ dataRef: 'routes', title: 'Fastest route', color: '#e15759', width: 30 },
|
|
358
|
+
{ dataRef: 'fixes', title: 'GPS fixes', color: '#f28e2b', pointSize: 2 }, // discs 4 m across
|
|
93
359
|
{ dataRef: 'change', title: 'Change', colorMapInterpolator: ColorMapInterpolator.DIV_RED_BLUE, colorMapCenter: 0, colorMapReverse: true },
|
|
94
360
|
],
|
|
95
361
|
},
|
|
@@ -98,15 +364,97 @@ const { map, layerId } = grammar.mapLayer('routes')!; // layerId is 'Fastest rou
|
|
|
98
364
|
map.updateRenderInfo(layerId, { opacity: 0.5 });
|
|
99
365
|
```
|
|
100
366
|
|
|
367
|
+
## Plots and links
|
|
368
|
+
|
|
369
|
+
A plot reads only its table's properties, so it also draws a table without a geometry, such as a CSV or JSON table loaded without `geometryColumns`.
|
|
370
|
+
|
|
371
|
+
A plot's `id` names it: as the `source` of a link, as the `plotId` of its `plot:selection` events, and for `setPlotSelection` and `clearHighlightOnPlot`. Without an id, a plot is known by its `dataRef`, so a run refuses two plots known by one name: two plots of one table without ids, or a plot whose id is the `dataRef` of a plot without one. Give each plot an id.
|
|
372
|
+
|
|
373
|
+
`links` connect a plot to a layer of a map. Picking on the layer selects the same features in the plot (a pick on another layer of the map does not), and a selection in the plot, by an event its `events` lists, highlights them on the layer. The link makes the layer pickable. A selection passes by the rows each view drew, not by positions: a plot draws its table's rows in the order its source gave them, while a layer draws the rows autk-db holds, which can come in another order, and leaves out the rows without a geometry. Each row is found in the other view by its feature id: a GeoJSON feature's `id`, else the one autk-db gives it, `autk-feature-<index>`.
|
|
374
|
+
|
|
375
|
+
| Field | Effect |
|
|
376
|
+
|---|---|
|
|
377
|
+
| `source` | The plot: its `id`, else its `dataRef`. |
|
|
378
|
+
| `target` | The map: its `id`. |
|
|
379
|
+
| `layer` | The layer of the target map, by its `title`, else its `dataRef`. Defaults to the layer that draws the plot's `dataRef`. |
|
|
380
|
+
|
|
381
|
+
A run refuses a link that names no plot, map or layer of the spec. A plot's `mapRef` is a shorthand for links: it names the table (`dataRef`) of map layers, and links the plot to every layer that draws it, in every map.
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
await grammar.run({
|
|
385
|
+
layout: { type: 'horizontal', gap: 8 },
|
|
386
|
+
data: [/* a table named parcels */],
|
|
387
|
+
map: { id: 'city', layerRefs: [{ dataRef: 'parcels', title: 'Parcels' }] },
|
|
388
|
+
plot: { id: 'sizes', dataRef: 'parcels', mark: 'scatter', axis: ['area', 'perimeter'], events: ['brush'] },
|
|
389
|
+
links: [{ source: 'sizes', target: 'city', layer: 'Parcels' }],
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
101
393
|
## Interactions
|
|
102
394
|
|
|
103
|
-
A layer with `isPick` and a plot with `events` report what the user selects on `grammar.interactions`: `map:picking` and `plot:selection` give feature ids, the positions of the selected features among those the layer or the plot draws (a map layer leaves out features without a geometry). To link a selection to other tables, name the columns whose values identify those rows with `selectFields` on the layer or the plot, for example `selectFields: ['nta2020']`. The grammar does not read it; the events still report feature ids, and the app reads the key values from those rows.
|
|
395
|
+
A layer with `isPick` and a plot with `events` report what the user selects on `grammar.interactions`: `map:picking` and `plot:selection` give feature ids, the positions of the selected features among those the layer or the plot draws (a map layer leaves out features without a geometry). Every map of the spec reports its picks, though several draw one table. To link a selection to other tables, name the columns whose values identify those rows with `selectFields` on the layer or the plot, for example `selectFields: ['nta2020']`. The grammar does not read it; the events still report feature ids, and the app reads the key values from those rows.
|
|
396
|
+
|
|
397
|
+
| Event | Field | Value |
|
|
398
|
+
|---|---|---|
|
|
399
|
+
| `map:picking` | `mapId` | The map the pick was made on: its `id`, else its index in `map` (0 for a single map). |
|
|
400
|
+
| `map:picking` | `layerId` | The picked layer's id in its map: its `title`, else its `dataRef`. |
|
|
401
|
+
| `map:picking` | `selection` | The picked features' ids. |
|
|
402
|
+
| `plot:selection` | `plotId` | The plot: its `id`, else its `dataRef`. |
|
|
403
|
+
| `plot:selection` | `event` | The interaction: `click`, `brush`, `brushX` or `brushY`. |
|
|
404
|
+
| `plot:selection` | `selection` | The selected features' ids. |
|
|
104
405
|
|
|
105
406
|
```ts
|
|
106
|
-
grammar.interactions.on('map:picking', ({ layerId, selection }) => { /* feature ids */ });
|
|
407
|
+
grammar.interactions.on('map:picking', ({ mapId, layerId, selection }) => { /* feature ids */ });
|
|
107
408
|
grammar.interactions.on('plot:selection', ({ plotId, event, selection }) => { /* feature ids */ });
|
|
108
409
|
```
|
|
109
410
|
|
|
411
|
+
An app sets selections with these calls, which take feature ids as the events give them. Each reaches every map that draws the table, or only the map its last argument, `mapId`, names:
|
|
412
|
+
|
|
413
|
+
| Call | Effect |
|
|
414
|
+
|---|---|
|
|
415
|
+
| `mapLayers(dataRef, mapId?)` | Every layer that draws the table, each as `{ map, layerId }`: the maps in the spec's order, each map's layers bottom first. |
|
|
416
|
+
| `mapLayer(dataRef, mapId?)` | The last of those: the last map's layer when several maps draw the table. |
|
|
417
|
+
| `highlightOnMap(dataRef, featureIds, mapId?)` | Highlights the features on each of those layers, and selects the same rows in the plots linked to the layers. |
|
|
418
|
+
| `clearHighlightOnMap(dataRef, mapId?)` | Clears those highlights, and the linked plots' selections. |
|
|
419
|
+
| `setPlotSelection(plotId, featureIds, mapId?)` | Selects the features in the plot (its `id`, else its `dataRef`), and highlights the same rows on the layers it is linked to. |
|
|
420
|
+
| `clearHighlightOnPlot(plotId, mapId?)` | Clears the plot's selection, and the highlights on the layers it is linked to. |
|
|
421
|
+
|
|
422
|
+
`mapId` names one map: a string by its `id`, a number by its index in `map`. The `mapId` of a `map:picking` event names the map it came from, so it can be passed back as it is.
|
|
423
|
+
|
|
424
|
+
```ts
|
|
425
|
+
grammar.highlightOnMap('buildings', [3, 7]); // every map that draws buildings
|
|
426
|
+
grammar.highlightOnMap('buildings', [3, 7], 'after'); // the map whose id is 'after'
|
|
427
|
+
grammar.clearHighlightOnMap('buildings', 0); // the first map
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## Page layout
|
|
431
|
+
|
|
432
|
+
A spec's `layout` says how its maps and plots are arranged on the page. The grammar's run never reads it: the page that hosts the views does, when it makes their canvases and elements, with `arrangeViews(spec)` (see [For hosts](#for-hosts)), so every host arranges a spec's views alike.
|
|
433
|
+
|
|
434
|
+
| Field | Effect |
|
|
435
|
+
|---|---|
|
|
436
|
+
| `type` | `vertical`, the default, stacks the views; `horizontal` puts them side by side; `grid` fills `columns` columns, row by row. |
|
|
437
|
+
| `columns` | The number of columns of a `grid`, a whole number. Defaults to 2. |
|
|
438
|
+
| `gap` | The space between views, in pixels. Defaults to 0. |
|
|
439
|
+
|
|
440
|
+
Each view has its own pane: the maps first, in the order of `map`, then the plots, in the order of `plot`, as the grammar draws them.
|
|
441
|
+
|
|
442
|
+
The constructor names the elements the views draw in, by id:
|
|
443
|
+
|
|
444
|
+
| Target | Effect |
|
|
445
|
+
|---|---|
|
|
446
|
+
| `map` | The canvas a map draws on, or a list of ids, one canvas per entry of `map`, in order. |
|
|
447
|
+
| `plot` | The element the plots draw in, or a list of ids, one element per entry of `plot`, in order. With one id, every plot draws in that element. |
|
|
448
|
+
| `db` | An element that lists the loaded tables after each data source. |
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
const grammar = new AutkGrammar({ map: ['before', 'after'], plot: ['heights', 'areas'] });
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
## Lifecycle
|
|
455
|
+
|
|
456
|
+
`destroy()` releases what the last run made: it destroys each map (its layers' GPU buffers, its textures, its canvas context, the controls it adds to the page and its event handlers) and clears the grammar's registries, caches and event forwarding. autk-map's maps share one GPU device, which stays for the maps of the next run. `run()` calls it before it starts, so running a new spec on the same instance does not leak the maps of the old one, and its maps and plots draw only its own tables. Call it yourself before the page or the canvases go away. A map whose layers fail to load is destroyed as the run fails, so it leaves nothing on the page.
|
|
457
|
+
|
|
110
458
|
## JSON Schema
|
|
111
459
|
|
|
112
460
|
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:
|
|
@@ -121,7 +469,78 @@ if (!validate(spec)) console.error(validate.errors);
|
|
|
121
469
|
|
|
122
470
|
## Compute helpers
|
|
123
471
|
|
|
124
|
-
`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 `
|
|
472
|
+
`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 `wgslFunction` 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.
|
|
473
|
+
|
|
474
|
+
## For hosts
|
|
475
|
+
|
|
476
|
+
A host that runs part of a spec itself, a server that loads its tables for example, calls the functions the grammar runs, so it does exactly what `AutkGrammar` does, and a page arranges a spec's views with `arrangeViews`, as every host does:
|
|
477
|
+
|
|
478
|
+
| Export | Effect |
|
|
479
|
+
|---|---|
|
|
480
|
+
| `createDataAdapter(targets?, cache?)` | The data adapter. Its `resolveWorkspaces(db, workspaces)` sets up a spec's `workspaces` before the first source loads, and its `resolveSource(db, source)` loads one `data` entry. Each takes an autk-db database, a new one when `db` is undefined, and returns it. `cache` receives each GeoJSON table and each table a join or an update wrote. |
|
|
481
|
+
| `createComputeAdapter(cache?, types?)` | The compute adapter. Its `resolveCompute(db, pass)` runs one `compute` entry on the GPU. The results are kept only in `cache`, and `types` receives the layer type of each table a pass wrote under its own `outputTableName`. |
|
|
482
|
+
| `enterWorkspace(db, workspace?)` | Makes an entry's workspace (the default one without a name) the one autk-db works in, and switches only when another is current. Every adapter calls it before it reads or writes an entry's tables. |
|
|
483
|
+
| `tableKey(workspace, name)` | The key of a table in those caches: its name in the default workspace, `<workspace>/<name>` in another. |
|
|
484
|
+
| `applyCamera(map, camera)` | Moves an `AutkMap`'s camera as a map's `camera` says, from the view that fits its layers, and refuses a `pitch` that is not at least 0 and less than 90. The map adapter calls it once the layers are loaded, before the map's first `draw()`. |
|
|
485
|
+
| `arrangeViews(spec)` | Where each view of a spec goes on the page, as its `layout` says: a grid of panes, one per view (see [Arranging the views](#arranging-the-views)). It refuses a `layout` it cannot arrange, with a sentence that names the value. |
|
|
486
|
+
|
|
487
|
+
`@urban-toolkit/autk-grammar/data` exports `createDataAdapter`, `enterWorkspace` and `tableKey` with their types, as an ES module and a CommonJS one. Its code imports `@urban-toolkit/autk-db` alone, never autk-map, autk-plot, autk-compute or autk-core, so it loads where they cannot, such as Node:
|
|
488
|
+
|
|
489
|
+
```ts
|
|
490
|
+
import { createDataAdapter } from '@urban-toolkit/autk-grammar/data';
|
|
491
|
+
|
|
492
|
+
const adapter = createDataAdapter();
|
|
493
|
+
let db: unknown; // the AutkDb the first call creates
|
|
494
|
+
if (spec.workspaces) db = await adapter.resolveWorkspaces(db, spec.workspaces);
|
|
495
|
+
for (const source of spec.data ?? []) db = await adapter.resolveSource(db, source);
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Arranging the views
|
|
499
|
+
|
|
500
|
+
`arrangeViews(spec)` returns:
|
|
501
|
+
|
|
502
|
+
| Field | Value |
|
|
503
|
+
|---|---|
|
|
504
|
+
| `type` | `vertical`, `horizontal` or `grid`: the `layout`'s, else `vertical`. |
|
|
505
|
+
| `rows` | The rows of panes. |
|
|
506
|
+
| `columns` | The columns of panes: 1 for `vertical`, one per view for `horizontal`, and `layout.columns`, else 2, for `grid`. |
|
|
507
|
+
| `gap` | The space between neighboring panes, in pixels: `layout.gap`, else 0. |
|
|
508
|
+
| `panes` | One pane per view, in the order the grammar draws the views: the maps in the order of `map`, then the plots in the order of `plot`. |
|
|
509
|
+
|
|
510
|
+
Each pane has:
|
|
511
|
+
|
|
512
|
+
| Field | Value |
|
|
513
|
+
|---|---|
|
|
514
|
+
| `kind` | `map` or `plot`, which is also the target list, `map` or `plot`, that names the element the view draws in. |
|
|
515
|
+
| `index` | The view's position among the views of its kind: its element is entry `index` of that target list. |
|
|
516
|
+
| `id` | The view's `id`, when it has one. |
|
|
517
|
+
| `key` | The name the grammar knows the view by: its `id`, else a map's index or a plot's `dataRef`. A map's is the `mapId` of its `map:picking` events, a plot's the `plotId` of its `plot:selection` events. |
|
|
518
|
+
| `row` | The pane's row, from 0 at the top. |
|
|
519
|
+
| `column` | The pane's column, from 0 at the left. |
|
|
520
|
+
|
|
521
|
+
A host makes an element for each pane (a canvas for a map, a div for a plot), places it on a grid of `rows` by `columns`, `gap` pixels apart, and names it in the targets. Each map's canvas goes in a positioned pane of its own, since autk-map adds its controls to the canvas's parent:
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
import { AutkGrammar, arrangeViews } from '@urban-toolkit/autk-grammar';
|
|
525
|
+
|
|
526
|
+
const { rows, columns, gap, panes } = arrangeViews(spec);
|
|
527
|
+
Object.assign(container.style, {
|
|
528
|
+
display: 'grid', gap: `${gap}px`,
|
|
529
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gridTemplateRows: `repeat(${rows}, minmax(0, 1fr))`,
|
|
530
|
+
});
|
|
531
|
+
const targets: { map: string[]; plot: string[] } = { map: [], plot: [] };
|
|
532
|
+
for (const pane of panes) {
|
|
533
|
+
const cell = document.createElement('div');
|
|
534
|
+
Object.assign(cell.style, { position: 'relative', gridRow: `${pane.row + 1}`, gridColumn: `${pane.column + 1}` });
|
|
535
|
+
const element = document.createElement(pane.kind === 'map' ? 'canvas' : 'div');
|
|
536
|
+
element.id = `${pane.kind}-${pane.index}`;
|
|
537
|
+
Object.assign(element.style, { width: '100%', height: '100%' });
|
|
538
|
+
cell.appendChild(element);
|
|
539
|
+
container.appendChild(cell);
|
|
540
|
+
targets[pane.kind][pane.index] = element.id;
|
|
541
|
+
}
|
|
542
|
+
await new AutkGrammar(targets).run(spec);
|
|
543
|
+
```
|
|
125
544
|
|
|
126
545
|
## License
|
|
127
546
|
|