@versatiles/versatiles-rs 4.9.0 → 4.10.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.
Files changed (6) hide show
  1. package/index.cjs +55 -54
  2. package/index.d.ts +24 -3
  3. package/index.js +56 -55
  4. package/package.json +13 -13
  5. package/vpl.d.ts +398 -170
  6. package/vpl.js +44 -36
package/vpl.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // AUTO-GENERATED — DO NOT EDIT
2
2
  // Generated from Rust VPL operation metadata
3
- import { TileSource, parseVpl, parseVplCst, stringifyVpl, stringifyVplCst } from './index.js';
3
+ import { TileSource, formatVplCst, parseVpl, parseVplCst, stringifyVpl, stringifyVplCst } from './index.js';
4
4
  /** Parse VPL text into a lossless syntax tree, returning the error rather than throwing. */
5
5
  export function parseCstResult(vpl) {
6
6
  return JSON.parse(parseVplCst(vpl));
@@ -19,12 +19,22 @@ export function parseCst(vpl) {
19
19
  export function stringifyCst(cst) {
20
20
  return stringifyVplCst(JSON.stringify(cst));
21
21
  }
22
+ /**
23
+ * Reformat a syntax tree, keeping its comments.
24
+ *
25
+ * Whitespace and nothing else is rewritten: parameters keep the order they were written in
26
+ * and values keep the quotes the author chose. Every comment keeps the token it was attached
27
+ * to and takes that token's line and indentation. The returned tree carries fresh spans.
28
+ */
29
+ export function formatCst(cst) {
30
+ return JSON.parse(formatVplCst(JSON.stringify(cst)));
31
+ }
22
32
  export class VPL {
23
33
  steps;
24
34
  constructor(steps) {
25
35
  this.steps = steps;
26
36
  }
27
- /** Generates solid-color tiles of the specified size and format. */
37
+ /** Generates raster tiles of a single solid colour. */
28
38
  static fromColor(options) {
29
39
  const params = {};
30
40
  if (options?.color !== undefined)
@@ -43,7 +53,7 @@ export class VPL {
43
53
  params['ssh_identity'] = options.sshIdentity;
44
54
  return new VPL([{ name: 'from_container', params }]);
45
55
  }
46
- /** Reads a CSV file with longitude/latitude columns and emits MVT point tiles. */
56
+ /** Reads a CSV file with longitude and latitude columns and emits MVT point tiles. */
47
57
  static fromCsv(options) {
48
58
  const params = {};
49
59
  params['filename'] = options.filename;
@@ -77,7 +87,7 @@ export class VPL {
77
87
  params['max_tile_bytes'] = options.maxTileBytes;
78
88
  return new VPL([{ name: 'from_csv', params }]);
79
89
  }
80
- /** Generates debug tiles that display their coordinates as text. */
90
+ /** Generates tiles that draw their own coordinates, for inspecting a pipeline. */
81
91
  static fromDebug(options) {
82
92
  const params = {};
83
93
  if (options?.format !== undefined)
@@ -120,7 +130,7 @@ export class VPL {
120
130
  params['ignore_id'] = options.ignoreId;
121
131
  return new VPL([{ name: 'from_geo', params }]);
122
132
  }
123
- /** Generates vector tiles containing the cells of a projected square grid, ready to be joined with data keyed on the cell id. */
133
+ /** Generates vector tiles holding the cells of a projected square grid. */
124
134
  static fromGrid(options) {
125
135
  const params = {};
126
136
  params['epsg'] = options.epsg;
@@ -148,7 +158,7 @@ export class VPL {
148
158
  params['layer_name'] = options.layerName;
149
159
  return new VPL([{ name: 'from_grid', params }]);
150
160
  }
151
- /** Generates vector tiles containing H3 grid cells, ready to be joined with data keyed on the H3 index. */
161
+ /** Generates vector tiles holding H3 hexagons. */
152
162
  static fromH3(options) {
153
163
  const params = {};
154
164
  params['resolution'] = options.resolution;
@@ -163,12 +173,12 @@ export class VPL {
163
173
  params['id_field'] = options.idField;
164
174
  return new VPL([{ name: 'from_h3', params }]);
165
175
  }
166
- /** Merges multiple vector tile sources. Each resulting tile will contain all the features and properties from all the sources. */
176
+ /** Merges several vector tile sources into one, keeping every feature. */
167
177
  static fromMergedVector(sources) {
168
178
  const params = {};
169
179
  return new VPL([{ name: 'from_merged_vector', params, sources }]);
170
180
  }
171
- /** Overlays multiple raster tile sources on top of each other. */
181
+ /** Blends several raster tile sources into one by alpha-compositing them. */
172
182
  static fromStackedRaster(sources, options) {
173
183
  const params = {};
174
184
  if (options?.format !== undefined)
@@ -177,18 +187,18 @@ export class VPL {
177
187
  params['auto_overscale'] = options?.autoOverscale;
178
188
  return new VPL([{ name: 'from_stacked_raster', params, sources }]);
179
189
  }
180
- /** Overlays multiple tile sources, using the tile from the first source that provides it. */
190
+ /** Overlays several tile sources, taking each tile from the first source that has it. */
181
191
  static fromStacked(sources) {
182
192
  const params = {};
183
193
  return new VPL([{ name: 'from_stacked', params, sources }]);
184
194
  }
185
- /** Reads a single tile file and uses it as a template for all tile requests. */
195
+ /** Reads one tile file and returns it for every requested coordinate. */
186
196
  static fromTile(options) {
187
197
  const params = {};
188
198
  params['filename'] = options.filename;
189
199
  return new VPL([{ name: 'from_tile', params }]);
190
200
  }
191
- /** Reads tiles from a remote tile server via a TileJSON endpoint. The TileJSON is fetched from the given URL, and tiles are loaded individually using the URL template from the TileJSON `tiles` array. */
201
+ /** Reads tiles from a remote tile server described by a TileJSON endpoint. */
192
202
  static fromTilejson(options) {
193
203
  const params = {};
194
204
  params['url'] = options.url;
@@ -198,7 +208,7 @@ export class VPL {
198
208
  params['max_concurrent_requests'] = options.maxConcurrentRequests;
199
209
  return new VPL([{ name: 'from_tilejson', params }]);
200
210
  }
201
- /** Filter tiles by bounding box, zoom levels, and/or the tile coordinates present in another container. */
211
+ /** Filters tiles by bounding box, zoom range, or the coordinates present in another container. */
202
212
  filter(options) {
203
213
  const params = {};
204
214
  if (options?.bbox !== undefined)
@@ -213,7 +223,7 @@ export class VPL {
213
223
  params['filename'] = options?.filename;
214
224
  return new VPL([...this.steps, { name: 'filter', params }]);
215
225
  }
216
- /** Update metadata, see also <https://github.com/mapbox/tilejson-spec/tree/master/3.0.0> */
226
+ /** Overwrites fields of the source's TileJSON metadata. */
217
227
  metaUpdate(options) {
218
228
  const params = {};
219
229
  if (options?.attribution !== undefined)
@@ -246,7 +256,7 @@ export class VPL {
246
256
  params['vector_layers_file'] = options?.vectorLayersFile;
247
257
  return new VPL([...this.steps, { name: 'meta_update', params }]);
248
258
  }
249
- /** Relabels tile coordinates, e.g. to correct a source that uses TMS row order or `z/y/x` paths. */
259
+ /** Relabels tile coordinates, correcting a source that uses TMS row order or `z/y/x` paths. */
250
260
  remapCoords(options) {
251
261
  const params = {};
252
262
  if (options?.flipX !== undefined)
@@ -257,7 +267,7 @@ export class VPL {
257
267
  params['swap_xy'] = options?.swapXy;
258
268
  return new VPL([...this.steps, { name: 'remap_coords', params }]);
259
269
  }
260
- /** Generate lower-zoom DEM overview tiles by averaging 24-bit elevation values. */
270
+ /** Generates lower-zoom DEM overview tiles by averaging 24-bit elevation values. */
261
271
  demOverview(options) {
262
272
  const params = {};
263
273
  if (options?.level !== undefined)
@@ -266,7 +276,7 @@ export class VPL {
266
276
  params['encoding'] = options?.encoding;
267
277
  return new VPL([...this.steps, { name: 'dem_overview', params }]);
268
278
  }
269
- /** Quantize DEM (elevation) raster tiles by rounding to a per-tile power-of-two step. */
279
+ /** Quantizes DEM raster tiles by rounding elevations to a per-tile power-of-two step. */
270
280
  demQuantize(options) {
271
281
  const params = {};
272
282
  if (options?.elevationError !== undefined)
@@ -277,23 +287,22 @@ export class VPL {
277
287
  params['encoding'] = options?.encoding;
278
288
  return new VPL([...this.steps, { name: 'dem_quantize', params }]);
279
289
  }
280
- /** Convert DEM tile size between 256px and 512px by splitting or merging tiles. */
290
+ /** Converts DEM tiles between 256 and 512 pixels by splitting or merging them. */
281
291
  demTileResize(options) {
282
292
  const params = {};
283
- if (options?.tileSize !== undefined)
284
- params['tile_size'] = options?.tileSize;
285
- if (options?.encoding !== undefined)
286
- params['encoding'] = options?.encoding;
293
+ params['tile_size'] = options.tileSize;
294
+ if (options.encoding !== undefined)
295
+ params['encoding'] = options.encoding;
287
296
  return new VPL([...this.steps, { name: 'dem_tile_resize', params }]);
288
297
  }
289
- /** Flattens (translucent) raster tiles onto a background */
298
+ /** Composites translucent raster tiles onto an opaque background colour. */
290
299
  rasterFlatten(options) {
291
300
  const params = {};
292
301
  if (options?.color !== undefined)
293
302
  params['color'] = options?.color;
294
303
  return new VPL([...this.steps, { name: 'raster_flatten', params }]);
295
304
  }
296
- /** Convert raster tiles to a different image format and/or adjust quality/effort settings. */
305
+ /** Re-encodes raster tiles into another image format, quality or effort setting. */
297
306
  rasterFormat(options) {
298
307
  const params = {};
299
308
  if (options?.format !== undefined)
@@ -306,7 +315,7 @@ export class VPL {
306
315
  params['effort'] = options?.effort;
307
316
  return new VPL([...this.steps, { name: 'raster_format', params }]);
308
317
  }
309
- /** Adjust brightness, contrast and gamma of raster tiles. */
318
+ /** Adjusts the brightness, contrast and gamma of raster tiles. */
310
319
  rasterLevels(options) {
311
320
  const params = {};
312
321
  if (options?.brightness !== undefined)
@@ -317,7 +326,7 @@ export class VPL {
317
326
  params['gamma'] = options?.gamma;
318
327
  return new VPL([...this.steps, { name: 'raster_levels', params }]);
319
328
  }
320
- /** Apply a polygon mask from GeoJSON to raster tiles. Pixels outside the polygon become transparent. */
329
+ /** Makes raster pixels outside a GeoJSON polygon transparent. */
321
330
  rasterMask(options) {
322
331
  const params = {};
323
332
  params['geojson'] = options.geojson;
@@ -329,7 +338,7 @@ export class VPL {
329
338
  params['blur_function'] = options.blurFunction;
330
339
  return new VPL([...this.steps, { name: 'raster_mask', params }]);
331
340
  }
332
- /** Raster overscale operation - generates tiles beyond the source's native resolution. */
341
+ /** Serves raster tiles above the source's native resolution by upscaling. */
333
342
  rasterOverscale(options) {
334
343
  const params = {};
335
344
  if (options?.levelBase !== undefined)
@@ -340,28 +349,27 @@ export class VPL {
340
349
  params['enable_climbing'] = options?.enableClimbing;
341
350
  return new VPL([...this.steps, { name: 'raster_overscale', params }]);
342
351
  }
343
- /** Generate lower-zoom overview tiles by downscaling from a base zoom level. */
352
+ /** Generates the lower zoom levels of a raster pyramid by downscaling. */
344
353
  rasterOverview(options) {
345
354
  const params = {};
346
355
  if (options?.level !== undefined)
347
356
  params['level'] = options?.level;
348
357
  return new VPL([...this.steps, { name: 'raster_overview', params }]);
349
358
  }
350
- /** Convert the size of tiles by splitting or merging them to a width of 256px or 512px. */
359
+ /** Converts raster tiles between 256 and 512 pixels by splitting or merging them. */
351
360
  rasterTileResize(options) {
352
361
  const params = {};
353
- if (options?.tileSize !== undefined)
354
- params['tile_size'] = options?.tileSize;
362
+ params['tile_size'] = options.tileSize;
355
363
  return new VPL([...this.steps, { name: 'raster_tile_resize', params }]);
356
364
  }
357
- /** Drops vector features in selected layers that do not satisfy a boolean CEL expression. Features in layers outside `layer` pass through untouched. */
365
+ /** Drops vector features in selected layers that do not satisfy a boolean expression. */
358
366
  vectorFilterFeatures(options) {
359
367
  const params = {};
360
368
  params['layer'] = options.layer;
361
369
  params['expr'] = options.expr;
362
370
  return new VPL([...this.steps, { name: 'vector_filter_features', params }]);
363
371
  }
364
- /** Filters vector tile layers by name. */
372
+ /** Removes whole layers from vector tiles by name. */
365
373
  vectorFilterLayers(options) {
366
374
  const params = {};
367
375
  params['filter'] = options.filter;
@@ -369,7 +377,7 @@ export class VPL {
369
377
  params['invert'] = options.invert;
370
378
  return new VPL([...this.steps, { name: 'vector_filter_layers', params }]);
371
379
  }
372
- /** Filters properties based on a regular expressions. */
380
+ /** Removes feature properties from vector tiles by matching their names against a regex. */
373
381
  vectorFilterProperties(options) {
374
382
  const params = {};
375
383
  params['regex'] = options.regex;
@@ -377,7 +385,7 @@ export class VPL {
377
385
  params['invert'] = options.invert;
378
386
  return new VPL([...this.steps, { name: 'vector_filter_properties', params }]);
379
387
  }
380
- /** Vector overzoom operation - generates vector tiles beyond the source's native max zoom. */
388
+ /** Serves vector tiles above the source's highest zoom level by clipping and rescaling. */
381
389
  vectorOverzoom(options) {
382
390
  const params = {};
383
391
  if (options?.levelBase !== undefined)
@@ -390,14 +398,14 @@ export class VPL {
390
398
  params['buffer'] = options?.buffer;
391
399
  return new VPL([...this.steps, { name: 'vector_overzoom', params }]);
392
400
  }
393
- /** Repairs vector tiles to conform to MVT 2.1. */
401
+ /** Repairs vector tiles so that they conform to MVT 2.1. */
394
402
  vectorRepair(options) {
395
403
  const params = {};
396
404
  if (options?.dropOffenders !== undefined)
397
405
  params['drop_offenders'] = options?.dropOffenders;
398
406
  return new VPL([...this.steps, { name: 'vector_repair', params }]);
399
407
  }
400
- /** Arguments for the `vector_update_properties` operation. */
408
+ /** Joins tabular data onto vector features, matching on an id column. */
401
409
  vectorUpdateProperties(options) {
402
410
  const params = {};
403
411
  params['data_source_path'] = options.dataSourcePath;