@urban-toolkit/autk-grammar 5.1.0 → 5.3.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 +222 -1
- package/build/autk-grammar-schema.json +844 -24
- package/dist/autk-grammar.js +942 -671
- 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 +1 -1
- package/dist/data/autk-grammar-data.cjs.map +1 -1
- package/dist/data/autk-grammar-data.js +98 -94
- package/dist/data/autk-grammar-data.js.map +1 -1
- package/dist/index.d.ts +261 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -273,6 +273,8 @@ A GPGPU pass runs a WGSL function once per feature of a table:
|
|
|
273
273
|
|
|
274
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
275
|
|
|
276
|
+
A pass reads such a `fromFeature` table as an earlier pass wrote it; else, when a GeoJSON source of the run loaded it with its coordinates in its workspace's CRS, as the source gave its features, as a plot reads its table; else as autk-db keeps it. autk-db keeps each feature of a `buildings` table in its building model, with the geometry inside a GeometryCollection, so a path such as `geometry.coordinates.0` reads a building part's outline only from the source's own features. The pass's own `dataRef` is read as autk-db keeps it, as a map draws it.
|
|
277
|
+
|
|
276
278
|
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
279
|
|
|
278
280
|
| Field | Effect |
|
|
@@ -329,6 +331,67 @@ The camera turns around the point the map looks at, which the view that fits the
|
|
|
329
331
|
map: { id: 'downtown', camera: { zoom: 15, pitch: 50, bearing: 30 }, layerRefs: [{ dataRef: 'buildings' }] }
|
|
330
332
|
```
|
|
331
333
|
|
|
334
|
+
### `terrain`
|
|
335
|
+
|
|
336
|
+
A map's `terrain` raises its ground to the heights a raster band gives, through autk-map's terrain mode: the ground the raster covers rises to its heights, the map's flat layers are draped over it, and its buildings stand on it. The view fits the raster, and the map's `camera` moves from there.
|
|
337
|
+
|
|
338
|
+
| Field | Effect |
|
|
339
|
+
|---|---|
|
|
340
|
+
| `dataRef` | The raster table of heights, in the workspace's units: a `geotiff` source of an elevation model in meters, for example. It is a table of the map's workspace. A cell without a value lies at height 0. |
|
|
341
|
+
| `band` | The band of heights, by its id (`band_1`, ...) or its label, as a raster layer's `getFnv` names one. Defaults to the first band. |
|
|
342
|
+
|
|
343
|
+
A run refuses a `dataRef` that names no raster table of the map's workspace, and a `band` that names none of the bands of a raster of several.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
data: [
|
|
347
|
+
{ type: 'geojson', outputTableName: 'neighborhoods', geojsonFileUrl: '/data/mnt_neighs.geojson' },
|
|
348
|
+
{ type: 'geotiff', outputTableName: 'elevation', geotiffFileUrl: '/data/mnt_dem.tif', coordinateFormat: 'EPSG:3857' },
|
|
349
|
+
],
|
|
350
|
+
map: { terrain: { dataRef: 'elevation' }, camera: { zoom: 10, pitch: 60, bearing: 30 }, layerRefs: [{ dataRef: 'neighborhoods' }] },
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### `style`
|
|
354
|
+
|
|
355
|
+
A map's `style` names one of autk-map's styles, such as `apple`, its default, or `light`, and a name autk-map does not know draws in `apple`. It can also give the colors of a style of the spec's own, each `#rrggbb`: autk-map takes a style only whole, so a run refuses one that lacks any of the nine.
|
|
356
|
+
|
|
357
|
+
| Color | Effect |
|
|
358
|
+
|---|---|
|
|
359
|
+
| `background` | The map's background, where no layer is drawn. |
|
|
360
|
+
| `surface`, `parks`, `water`, `roads`, `buildings`, `points`, `polylines`, `polygons` | The layers of each of those types. |
|
|
361
|
+
|
|
362
|
+
A layer with a `color` is drawn in it instead, and a layer colored by value in its scheme.
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
map: {
|
|
366
|
+
style: {
|
|
367
|
+
background: '#0b1a2a', surface: '#13263a', parks: '#1f4d3a', water: '#08121d', roads: '#3a5068',
|
|
368
|
+
buildings: '#5b7083', points: '#f2c14e', polylines: '#7f97ad', polygons: '#2a3d52',
|
|
369
|
+
},
|
|
370
|
+
layerRefs: [{ dataRef: 'downtown_surface' }, { dataRef: 'downtown_roads' }, { dataRef: 'downtown_buildings' }],
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### `highlightColor` and `invalidValueColor`
|
|
375
|
+
|
|
376
|
+
| Key | Effect |
|
|
377
|
+
|---|---|
|
|
378
|
+
| `highlightColor` | The color of the features the map draws as picked: by the user, by a layer's `pickedComps`, by a link, or by a call such as `highlightOnMap`, `#rrggbb`. autk-map's is `#5dade2`. |
|
|
379
|
+
| `invalidValueColor` | The color of the features of a layer colored by value whose value autk-map cannot color: one without a value, or with one that is not on the layer's scale, `#rrggbb`. autk-map's is `#ffffff`. |
|
|
380
|
+
|
|
381
|
+
autk-map keeps both for each map, unlike autk-plot's mark and highlight colors, which are the page's: each map of a spec draws in its own.
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
map: { highlightColor: '#ff7f0e', invalidValueColor: '#bfbfbf', layerRefs: [{ dataRef: 'parcels', getFnv: 'value', isPick: true }] }
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### `showUi`
|
|
388
|
+
|
|
389
|
+
autk-map puts a menu of the map's layers at the map's top left and a legend at its bottom right. A map with `showUi: false` has neither; its "made with autark" credit stays. Without it, or with `true`, the map shows both.
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
map: { showUi: false, layerRefs: [{ dataRef: 'parcels', getFnv: 'area' }] }
|
|
393
|
+
```
|
|
394
|
+
|
|
332
395
|
## Layer styling
|
|
333
396
|
|
|
334
397
|
Besides `dataRef`, a layer of `map.layerRefs` takes these styling options:
|
|
@@ -346,6 +409,8 @@ Besides `dataRef`, a layer of `map.layerRefs` takes these styling options:
|
|
|
346
409
|
| `colorMapReverse` | On a raster layer, runs the color scale from the highest value to the lowest, or from `colorMapRange`'s high to its low. |
|
|
347
410
|
| `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. |
|
|
348
411
|
|
|
412
|
+
On a raster layer, `getFnv` names the band to draw: by its id, such as a GeoTIFF's `band_24`, or by its label, such as `count.noise` for a heatmap's `count_noise`. Without it, the layer draws the first band. A run refuses a `getFnv` that names none of the bands of a raster of several, and a raster of one band draws that band.
|
|
413
|
+
|
|
349
414
|
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)).
|
|
350
415
|
|
|
351
416
|
```ts
|
|
@@ -364,6 +429,64 @@ const { map, layerId } = grammar.mapLayer('routes')!; // layerId is 'Fastest rou
|
|
|
364
429
|
map.updateRenderInfo(layerId, { opacity: 0.5 });
|
|
365
430
|
```
|
|
366
431
|
|
|
432
|
+
### `buildingsZeroHeight`
|
|
433
|
+
|
|
434
|
+
autk-map leaves out a building part that has no height: none of `height`, `building:height`, `levels` and `building:levels`. A buildings layer with `buildingsZeroHeight: true` draws each such part with a random height of 3 to 7 floors of 3.4 m, from 10.2 to 23.8 m, so a city whose map data gives few heights is not left half empty. The heights are drawn again at each run. A part with one of those keys whose height is not above its minimum, such as `height: 0`, is still left out. Other layers ignore it.
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
map: { layerRefs: [{ dataRef: 'downtown_buildings', buildingsZeroHeight: true }] }
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### `legend`
|
|
441
|
+
|
|
442
|
+
A map's legend shows the color scale of one layer: the last layer whose colors autk-map set, about the last layer colored by value. A layer with `legend: true` is the one it shows, and on a raster layer, whose legend autk-map hides without a scale of its own, it shows it. Picking stays as the layers' `isPick` sets it: autk-map's own legend choice, `changeActiveLayer`, would also make the layer the only one of the map that picks.
|
|
443
|
+
|
|
444
|
+
A run refuses `legend` on two layers of a map, on a layer drawn in one color, and on a map whose `showUi` is `false`, which has no legend.
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
map: { layerRefs: [{ dataRef: 'income', getFnv: 'median', legend: true }, { dataRef: 'schools', getFnv: 'enrollment', isPick: true }] }
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### `skippedComps`
|
|
451
|
+
|
|
452
|
+
A layer's `skippedComps` lists the features it hides, by their positions among those it draws, as `map:picking` events and `highlightOnMap` give them: a filter the map applies as it is drawn. It hides features of every layer of polygons, lines, points or buildings. A run refuses it on a raster layer, and a position that is not a whole number from 0 or is past the last feature the layer draws. With autk-map 4.1.1, a hidden feature of a polygons or buildings layer can still be picked.
|
|
453
|
+
|
|
454
|
+
```ts
|
|
455
|
+
map: { layerRefs: [{ dataRef: 'parcels', skippedComps: [2, 5] }] }
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### `widthBy`
|
|
459
|
+
|
|
460
|
+
A roads layer draws each line as wide as autk-map draws its kind of road, and `width` gives every line one width. A roads layer's `widthBy` is the dot path to each line's own width, relative to `feature.properties`, in the map's planar units: autk-map's widths by feature. A line without a positive number there keeps the width of its kind of road.
|
|
461
|
+
|
|
462
|
+
autk-map draws every line of a polylines layer at one width, which wins over widths by feature, so a run refuses `widthBy` on a polylines layer: draw the table as roads, with `layerType: 'roads'`. A run also refuses `widthBy` with `width`, and a path that gives no line of the layer a width.
|
|
463
|
+
|
|
464
|
+
```ts
|
|
465
|
+
map: { layerRefs: [{ dataRef: 'segments', layerType: 'roads', widthBy: 'compute.width', getFnv: 'traffic' }] }
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### `layerType`
|
|
469
|
+
|
|
470
|
+
A layer draws its table as the table's own type, which its source or compute pass gave it. A layer's `layerType` draws the table as another type of its kind of geometry, in that type's color of the map's style and the way autk-map draws that type:
|
|
471
|
+
|
|
472
|
+
| Table | `layerType` |
|
|
473
|
+
|---|---|
|
|
474
|
+
| Polygons, and the surface, parks, water and buildings tables | `polygons`, `surface`, `parks`, `water`, or `buildings`, raised by each feature's height |
|
|
475
|
+
| Lines, and the roads tables | `polylines`, or `roads`, each line as wide as its kind of road |
|
|
476
|
+
| Points | `points` |
|
|
477
|
+
| A raster | `raster` |
|
|
478
|
+
|
|
479
|
+
A run refuses a type of another kind of geometry, for which autk-map would draw nothing. autk-map draws surface, parks, water and roads layers below every other layer, in that order, whatever the order of `layerRefs`.
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
map: {
|
|
483
|
+
layerRefs: [
|
|
484
|
+
{ dataRef: 'green_space', layerType: 'parks' }, // a polygons table, in the style's parks color
|
|
485
|
+
{ dataRef: 'downtown_buildings', layerType: 'polygons' }, // the footprints, flat
|
|
486
|
+
],
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
367
490
|
## Plots and links
|
|
368
491
|
|
|
369
492
|
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`.
|
|
@@ -390,6 +513,84 @@ await grammar.run({
|
|
|
390
513
|
});
|
|
391
514
|
```
|
|
392
515
|
|
|
516
|
+
## Plot styling
|
|
517
|
+
|
|
518
|
+
Besides its table, mark and columns, a plot takes these keys. The Autark adapter reads them; the deck.gl adapter ignores them.
|
|
519
|
+
|
|
520
|
+
### `colorMapInterpolator` and `categoricalColorMapInterpolator`
|
|
521
|
+
|
|
522
|
+
A plot colors its marks by the values of its `color` column: a scatter plot's points, a bar chart's bars, and the lines of parallel coordinates, which a click on an axis's title colors by that axis instead. A heat matrix colors its cells by their values. Line charts and tables color no mark by value. When every value is a number, or a string that reads as one, the marks take the scheme of numbers; otherwise the values are categories, and take the scheme of categories.
|
|
523
|
+
|
|
524
|
+
| Key | Effect |
|
|
525
|
+
|---|---|
|
|
526
|
+
| `colorMapInterpolator` | The scheme of numbers: a sequential or diverging `interpolate*` scheme, `interpolateReds` by default. The scale's low end takes its first color and its high end its last: the lowest and highest values, unless `colorMapRange` or `normalization` sets them. |
|
|
527
|
+
| `categoricalColorMapInterpolator` | The scheme of categories: a `scheme*` scheme, `schemeObservable10` by default. The categories take its colors in the order they first appear, or in `colorMapDomain`'s order, and those past its last color take that one. |
|
|
528
|
+
|
|
529
|
+
A run refuses a `scheme*` name as `colorMapInterpolator`, and an `interpolate*` name as `categoricalColorMapInterpolator`.
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
plot: { dataRef: 'parcels', mark: 'bar', axis: ['id', 'area'], color: 'landuse', categoricalColorMapInterpolator: ColorMapInterpolator.CAT_SET2 }
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### `colorMapRange`, `colorMapDomain` and `normalization`
|
|
536
|
+
|
|
537
|
+
These set the domain of a plot's color scale as they set a map layer's:
|
|
538
|
+
|
|
539
|
+
| Key | Effect |
|
|
540
|
+
|---|---|
|
|
541
|
+
| `colorMapRange` | The ends of the scale of numbers, `[low, high]` with low less than high. The plot is colored over this range instead of its own lowest and highest values, so plots and map layers that set the same range color the same value alike. A plot colored by categories ignores it, as a layer with a categorical scheme does, and a plot cannot set both `colorMapRange` and `colorMapDomain`. |
|
|
542
|
+
| `colorMapDomain` | The categories the plot is colored over, in order: the first takes the scheme of categories' first color, and so on. The values are read as categories, numbers too, and a mark whose value it does not name is drawn in the mark color. |
|
|
543
|
+
| `normalization` | How the ends of the scale of numbers are found: `{ mode: 'minMax' }`, the default, takes the lowest and highest values, and `{ mode: 'percentile', lowerPercentile, upperPercentile }` the values at those percentiles, 2 and 98 when it gives neither, else 0 and 100 for the one it leaves out. |
|
|
544
|
+
|
|
545
|
+
Parallel coordinates read them for their `color` column, and keep them for any axis a click on its title colors the lines by: under a `colorMapRange`, an axis of categories colors no line.
|
|
546
|
+
|
|
547
|
+
```ts
|
|
548
|
+
map: { layerRefs: [{ dataRef: 'tracts', getFnv: 'income', colorMapInterpolator: ColorMapInterpolator.SEQ_BLUES, colorMapRange: [0, 200000] }] },
|
|
549
|
+
plot: { dataRef: 'tracts', mark: 'scatter', axis: ['area', 'income'], color: 'income', colorMapInterpolator: ColorMapInterpolator.SEQ_BLUES, colorMapRange: [0, 200000] },
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### `tickFormats`
|
|
553
|
+
|
|
554
|
+
The d3-format specifiers of the tick labels of a plot's axes, `[x, y]`, such as `~s`, `,d`, `.2f` or `.0%`. Without it, `['~s', '~s']`.
|
|
555
|
+
|
|
556
|
+
| Mark | Reads |
|
|
557
|
+
|---|---|
|
|
558
|
+
| `scatter` | x for the x axis and y for the y axis. |
|
|
559
|
+
| `bar` | x for the x axis's labels that read as numbers, and y for the y axis. |
|
|
560
|
+
| `line`, `linechart` | x for the x axis's buckets that read as numbers, and y for the y axis. |
|
|
561
|
+
| `parallel-coordinates` | x for every axis of numbers. |
|
|
562
|
+
| `heatmatrix`, `table` | Neither. |
|
|
563
|
+
|
|
564
|
+
A run refuses a list that is not two specifiers d3-format reads.
|
|
565
|
+
|
|
566
|
+
```ts
|
|
567
|
+
plot: { dataRef: 'parcels', mark: 'scatter', axis: ['area', 'share'], tickFormats: [',.0f', '.0%'] }
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### `axisLabels`
|
|
571
|
+
|
|
572
|
+
The titles of a plot's axes, in the order of `axis`, in place of the column names: the x and y titles of a scatter plot, a bar chart, a line chart and a heat matrix, each axis's title of parallel coordinates, and a table's column headers. An axis without a title keeps its column's name, and an axis that holds a transform's output, `@transform`, is titled `value`. A run refuses more titles than `axis` has columns, and two titles alike.
|
|
573
|
+
|
|
574
|
+
```ts
|
|
575
|
+
plot: { dataRef: 'parcels', mark: 'bar', axis: ['area', '@transform'], transform: { preset: 'binning-1d' }, axisLabels: ['Area (m²)', 'Parcels'] }
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### `markColor` and `highlightColor`
|
|
579
|
+
|
|
580
|
+
| Key | Effect |
|
|
581
|
+
|---|---|
|
|
582
|
+
| `markColor` | The color of the marks that are neither colored by value nor selected, `#rrggbb`. autk-plot's is `#bfbfbf`. |
|
|
583
|
+
| `highlightColor` | The color of the selected marks, and of a table's selected rows, `#rrggbb`. autk-plot's is `#5dade2`. |
|
|
584
|
+
|
|
585
|
+
autk-plot keeps one mark color and one highlight color for the whole page, which every plot on it reads as it draws and as it shows a selection. So the plots of one spec cannot differ: a run refuses two plots that set different ones, and a plot that sets neither takes the others'. A run sets them for the page, other specs' plots too, and a run whose plots set neither gives back autk-plot's own: each run draws in the colors its spec gives. A run that draws no plot leaves them as they are, and a page whose specs never set them keeps the colors autk-plot has.
|
|
586
|
+
|
|
587
|
+
```ts
|
|
588
|
+
plot: [
|
|
589
|
+
{ id: 'heights', dataRef: 'buildings', mark: 'bar', axis: ['id', 'height'], markColor: '#4e79a7', highlightColor: '#e15759' },
|
|
590
|
+
{ id: 'areas', dataRef: 'buildings', mark: 'scatter', axis: ['area', 'height'] }, // drawn in the same colors
|
|
591
|
+
]
|
|
592
|
+
```
|
|
593
|
+
|
|
393
594
|
## Interactions
|
|
394
595
|
|
|
395
596
|
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.
|
|
@@ -427,6 +628,24 @@ grammar.highlightOnMap('buildings', [3, 7], 'after'); // the map whose id is 'a
|
|
|
427
628
|
grammar.clearHighlightOnMap('buildings', 0); // the first map
|
|
428
629
|
```
|
|
429
630
|
|
|
631
|
+
### `selection`
|
|
632
|
+
|
|
633
|
+
A plot's `selection` lists the rows selected as it is drawn, by their feature ids, as `plot:selection` events and `setPlotSelection` give them. The run applies it once the plots and their links exist, as `setPlotSelection` does: the plot draws the rows in its highlight color (a binned plot, the bins that hold them), and the layers it is linked to, by `mapRef` or `links`, highlight the same rows. No `plot:selection` event reports it. A run refuses a feature id that is not a whole number from 0, or one past the plot's last row.
|
|
634
|
+
|
|
635
|
+
```ts
|
|
636
|
+
plot: { id: 'sizes', dataRef: 'parcels', mark: 'scatter', axis: ['area', 'perimeter'], mapRef: 'parcels', selection: [0, 4] }
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### `pickedComps`
|
|
640
|
+
|
|
641
|
+
A layer's `pickedComps` lists the features drawn as picked as the map is drawn, in the map's highlight color, as if the user had picked them: their positions among those the layer draws, as `map:picking` events and `highlightOnMap` give them. The run applies it once the plots and their links exist, as `highlightOnMap` does for that one layer: the layer highlights the features, and the plots linked to it select the same rows. No `map:picking` event reports it.
|
|
642
|
+
|
|
643
|
+
autk-map draws picked features only on the layer of a map that picks, and lets one layer of a map pick: the last that sets `isPick`, unless a link or a plot's `mapRef` makes another layer pick. So a layer with `pickedComps` sets `isPick: true`, and a run refuses `pickedComps` on a layer without it, or on a layer a later layer of its map, a link or a plot's `mapRef` takes picking from. A run also refuses it on a raster layer, on a layer linked to a plot that sets `selection`, and a position that is not a whole number from 0 or is past the last feature the layer draws.
|
|
644
|
+
|
|
645
|
+
```ts
|
|
646
|
+
map: { layerRefs: [{ dataRef: 'parcels', isPick: true, pickedComps: [0, 4] }] }
|
|
647
|
+
```
|
|
648
|
+
|
|
430
649
|
## Page layout
|
|
431
650
|
|
|
432
651
|
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.
|
|
@@ -478,7 +697,7 @@ A host that runs part of a spec itself, a server that loads its tables for examp
|
|
|
478
697
|
| Export | Effect |
|
|
479
698
|
|---|---|
|
|
480
699
|
| `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`. |
|
|
700
|
+
| `createComputeAdapter(cache?, types?, sources?)` | 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`. `sources` is the cache `createDataAdapter` fills, from which a pass reads a `fromFeature` table a GeoJSON source loaded in its workspace's CRS. |
|
|
482
701
|
| `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
702
|
| `tableKey(workspace, name)` | The key of a table in those caches: its name in the default workspace, `<workspace>/<name>` in another. |
|
|
484
703
|
| `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()`. |
|
|
@@ -495,6 +714,8 @@ if (spec.workspaces) db = await adapter.resolveWorkspaces(db, spec.workspaces);
|
|
|
495
714
|
for (const source of spec.data ?? []) db = await adapter.resolveSource(db, source);
|
|
496
715
|
```
|
|
497
716
|
|
|
717
|
+
The data adapter of either entry notes the coordinate system of each GeoJSON source it puts in its cache, and the two entries keep their notes in one place on the page. So a host may load a spec's tables with the data adapter of `./data` and run its passes with the compute adapter of the main entry, handing it that cache as `sources`: its passes read the sources' features as the grammar's do.
|
|
718
|
+
|
|
498
719
|
### Arranging the views
|
|
499
720
|
|
|
500
721
|
`arrangeViews(spec)` returns:
|