@versatiles/versatiles-rs 4.8.0 → 4.9.1

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 (7) hide show
  1. package/README.md +71 -4
  2. package/index.cjs +57 -54
  3. package/index.d.ts +227 -19
  4. package/index.js +58 -55
  5. package/package.json +11 -11
  6. package/vpl.d.ts +430 -142
  7. package/vpl.js +99 -33
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)
@@ -39,9 +49,11 @@ export class VPL {
39
49
  static fromContainer(options) {
40
50
  const params = {};
41
51
  params['filename'] = options.filename;
52
+ if (options.sshIdentity !== undefined)
53
+ params['ssh_identity'] = options.sshIdentity;
42
54
  return new VPL([{ name: 'from_container', params }]);
43
55
  }
44
- /** 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. */
45
57
  static fromCsv(options) {
46
58
  const params = {};
47
59
  params['filename'] = options.filename;
@@ -75,7 +87,7 @@ export class VPL {
75
87
  params['max_tile_bytes'] = options.maxTileBytes;
76
88
  return new VPL([{ name: 'from_csv', params }]);
77
89
  }
78
- /** Generates debug tiles that display their coordinates as text. */
90
+ /** Generates tiles that draw their own coordinates, for inspecting a pipeline. */
79
91
  static fromDebug(options) {
80
92
  const params = {};
81
93
  if (options?.format !== undefined)
@@ -118,12 +130,55 @@ export class VPL {
118
130
  params['ignore_id'] = options.ignoreId;
119
131
  return new VPL([{ name: 'from_geo', params }]);
120
132
  }
121
- /** Merges multiple vector tile sources. */
133
+ /** Generates vector tiles holding the cells of a projected square grid. */
134
+ static fromGrid(options) {
135
+ const params = {};
136
+ params['epsg'] = options.epsg;
137
+ params['size'] = options.size;
138
+ params['bbox'] = options.bbox;
139
+ if (options.offset !== undefined)
140
+ params['offset'] = options.offset;
141
+ if (options.maxCellsPerTile !== undefined)
142
+ params['max_cells_per_tile'] = options.maxCellsPerTile;
143
+ if (options.maxZoom !== undefined)
144
+ params['max_zoom'] = options.maxZoom;
145
+ if (options.idPreset !== undefined)
146
+ params['id_preset'] = options.idPreset;
147
+ if (options.idTemplate !== undefined)
148
+ params['id_template'] = options.idTemplate;
149
+ if (options.idField !== undefined)
150
+ params['id_field'] = options.idField;
151
+ if (options.xField !== undefined)
152
+ params['x_field'] = options.xField;
153
+ if (options.yField !== undefined)
154
+ params['y_field'] = options.yField;
155
+ if (options.densifyTolerance !== undefined)
156
+ params['densify_tolerance'] = options.densifyTolerance;
157
+ if (options.layerName !== undefined)
158
+ params['layer_name'] = options.layerName;
159
+ return new VPL([{ name: 'from_grid', params }]);
160
+ }
161
+ /** Generates vector tiles holding H3 hexagons. */
162
+ static fromH3(options) {
163
+ const params = {};
164
+ params['resolution'] = options.resolution;
165
+ params['bbox'] = options.bbox;
166
+ if (options.maxCellsPerTile !== undefined)
167
+ params['max_cells_per_tile'] = options.maxCellsPerTile;
168
+ if (options.maxZoom !== undefined)
169
+ params['max_zoom'] = options.maxZoom;
170
+ if (options.layerName !== undefined)
171
+ params['layer_name'] = options.layerName;
172
+ if (options.idField !== undefined)
173
+ params['id_field'] = options.idField;
174
+ return new VPL([{ name: 'from_h3', params }]);
175
+ }
176
+ /** Merges several vector tile sources into one, keeping every feature. */
122
177
  static fromMergedVector(sources) {
123
178
  const params = {};
124
179
  return new VPL([{ name: 'from_merged_vector', params, sources }]);
125
180
  }
126
- /** Overlays multiple raster tile sources on top of each other. */
181
+ /** Blends several raster tile sources into one by alpha-compositing them. */
127
182
  static fromStackedRaster(sources, options) {
128
183
  const params = {};
129
184
  if (options?.format !== undefined)
@@ -132,18 +187,18 @@ export class VPL {
132
187
  params['auto_overscale'] = options?.autoOverscale;
133
188
  return new VPL([{ name: 'from_stacked_raster', params, sources }]);
134
189
  }
135
- /** 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. */
136
191
  static fromStacked(sources) {
137
192
  const params = {};
138
193
  return new VPL([{ name: 'from_stacked', params, sources }]);
139
194
  }
140
- /** 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. */
141
196
  static fromTile(options) {
142
197
  const params = {};
143
198
  params['filename'] = options.filename;
144
199
  return new VPL([{ name: 'from_tile', params }]);
145
200
  }
146
- /** Reads tiles from a remote tile server via a TileJSON endpoint. */
201
+ /** Reads tiles from a remote tile server described by a TileJSON endpoint. */
147
202
  static fromTilejson(options) {
148
203
  const params = {};
149
204
  params['url'] = options.url;
@@ -153,11 +208,13 @@ export class VPL {
153
208
  params['max_concurrent_requests'] = options.maxConcurrentRequests;
154
209
  return new VPL([{ name: 'from_tilejson', params }]);
155
210
  }
156
- /** 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. */
157
212
  filter(options) {
158
213
  const params = {};
159
214
  if (options?.bbox !== undefined)
160
215
  params['bbox'] = options?.bbox;
216
+ if (options?.bboxBorder !== undefined)
217
+ params['bbox_border'] = options?.bboxBorder;
161
218
  if (options?.levelMin !== undefined)
162
219
  params['level_min'] = options?.levelMin;
163
220
  if (options?.levelMax !== undefined)
@@ -166,7 +223,7 @@ export class VPL {
166
223
  params['filename'] = options?.filename;
167
224
  return new VPL([...this.steps, { name: 'filter', params }]);
168
225
  }
169
- /** Update metadata, see also <https://github.com/mapbox/tilejson-spec/tree/master/3.0.0> */
226
+ /** Overwrites fields of the source's TileJSON metadata. */
170
227
  metaUpdate(options) {
171
228
  const params = {};
172
229
  if (options?.attribution !== undefined)
@@ -199,7 +256,18 @@ export class VPL {
199
256
  params['vector_layers_file'] = options?.vectorLayersFile;
200
257
  return new VPL([...this.steps, { name: 'meta_update', params }]);
201
258
  }
202
- /** Generate lower-zoom DEM overview tiles by averaging 24-bit elevation values. */
259
+ /** Relabels tile coordinates, correcting a source that uses TMS row order or `z/y/x` paths. */
260
+ remapCoords(options) {
261
+ const params = {};
262
+ if (options?.flipX !== undefined)
263
+ params['flip_x'] = options?.flipX;
264
+ if (options?.flipY !== undefined)
265
+ params['flip_y'] = options?.flipY;
266
+ if (options?.swapXy !== undefined)
267
+ params['swap_xy'] = options?.swapXy;
268
+ return new VPL([...this.steps, { name: 'remap_coords', params }]);
269
+ }
270
+ /** Generates lower-zoom DEM overview tiles by averaging 24-bit elevation values. */
203
271
  demOverview(options) {
204
272
  const params = {};
205
273
  if (options?.level !== undefined)
@@ -208,7 +276,7 @@ export class VPL {
208
276
  params['encoding'] = options?.encoding;
209
277
  return new VPL([...this.steps, { name: 'dem_overview', params }]);
210
278
  }
211
- /** 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. */
212
280
  demQuantize(options) {
213
281
  const params = {};
214
282
  if (options?.elevationError !== undefined)
@@ -219,23 +287,22 @@ export class VPL {
219
287
  params['encoding'] = options?.encoding;
220
288
  return new VPL([...this.steps, { name: 'dem_quantize', params }]);
221
289
  }
222
- /** 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. */
223
291
  demTileResize(options) {
224
292
  const params = {};
225
- if (options?.tileSize !== undefined)
226
- params['tile_size'] = options?.tileSize;
227
- if (options?.encoding !== undefined)
228
- params['encoding'] = options?.encoding;
293
+ params['tile_size'] = options.tileSize;
294
+ if (options.encoding !== undefined)
295
+ params['encoding'] = options.encoding;
229
296
  return new VPL([...this.steps, { name: 'dem_tile_resize', params }]);
230
297
  }
231
- /** Flattens (translucent) raster tiles onto a background */
298
+ /** Composites translucent raster tiles onto an opaque background colour. */
232
299
  rasterFlatten(options) {
233
300
  const params = {};
234
301
  if (options?.color !== undefined)
235
302
  params['color'] = options?.color;
236
303
  return new VPL([...this.steps, { name: 'raster_flatten', params }]);
237
304
  }
238
- /** 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. */
239
306
  rasterFormat(options) {
240
307
  const params = {};
241
308
  if (options?.format !== undefined)
@@ -248,7 +315,7 @@ export class VPL {
248
315
  params['effort'] = options?.effort;
249
316
  return new VPL([...this.steps, { name: 'raster_format', params }]);
250
317
  }
251
- /** Adjust brightness, contrast and gamma of raster tiles. */
318
+ /** Adjusts the brightness, contrast and gamma of raster tiles. */
252
319
  rasterLevels(options) {
253
320
  const params = {};
254
321
  if (options?.brightness !== undefined)
@@ -259,7 +326,7 @@ export class VPL {
259
326
  params['gamma'] = options?.gamma;
260
327
  return new VPL([...this.steps, { name: 'raster_levels', params }]);
261
328
  }
262
- /** Apply a polygon mask from GeoJSON to raster tiles. */
329
+ /** Makes raster pixels outside a GeoJSON polygon transparent. */
263
330
  rasterMask(options) {
264
331
  const params = {};
265
332
  params['geojson'] = options.geojson;
@@ -271,7 +338,7 @@ export class VPL {
271
338
  params['blur_function'] = options.blurFunction;
272
339
  return new VPL([...this.steps, { name: 'raster_mask', params }]);
273
340
  }
274
- /** Raster overscale operation - generates tiles beyond the source's native resolution. */
341
+ /** Serves raster tiles above the source's native resolution by upscaling. */
275
342
  rasterOverscale(options) {
276
343
  const params = {};
277
344
  if (options?.levelBase !== undefined)
@@ -282,28 +349,27 @@ export class VPL {
282
349
  params['enable_climbing'] = options?.enableClimbing;
283
350
  return new VPL([...this.steps, { name: 'raster_overscale', params }]);
284
351
  }
285
- /** Generate lower-zoom overview tiles by downscaling from a base zoom level. */
352
+ /** Generates the lower zoom levels of a raster pyramid by downscaling. */
286
353
  rasterOverview(options) {
287
354
  const params = {};
288
355
  if (options?.level !== undefined)
289
356
  params['level'] = options?.level;
290
357
  return new VPL([...this.steps, { name: 'raster_overview', params }]);
291
358
  }
292
- /** 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. */
293
360
  rasterTileResize(options) {
294
361
  const params = {};
295
- if (options?.tileSize !== undefined)
296
- params['tile_size'] = options?.tileSize;
362
+ params['tile_size'] = options.tileSize;
297
363
  return new VPL([...this.steps, { name: 'raster_tile_resize', params }]);
298
364
  }
299
- /** Drops vector features in selected layers that do not satisfy a boolean CEL expression. */
365
+ /** Drops vector features in selected layers that do not satisfy a boolean expression. */
300
366
  vectorFilterFeatures(options) {
301
367
  const params = {};
302
368
  params['layer'] = options.layer;
303
369
  params['expr'] = options.expr;
304
370
  return new VPL([...this.steps, { name: 'vector_filter_features', params }]);
305
371
  }
306
- /** Filters vector tile layers by name. */
372
+ /** Removes whole layers from vector tiles by name. */
307
373
  vectorFilterLayers(options) {
308
374
  const params = {};
309
375
  params['filter'] = options.filter;
@@ -311,7 +377,7 @@ export class VPL {
311
377
  params['invert'] = options.invert;
312
378
  return new VPL([...this.steps, { name: 'vector_filter_layers', params }]);
313
379
  }
314
- /** Filters properties based on a regular expressions. */
380
+ /** Removes feature properties from vector tiles by matching their names against a regex. */
315
381
  vectorFilterProperties(options) {
316
382
  const params = {};
317
383
  params['regex'] = options.regex;
@@ -319,7 +385,7 @@ export class VPL {
319
385
  params['invert'] = options.invert;
320
386
  return new VPL([...this.steps, { name: 'vector_filter_properties', params }]);
321
387
  }
322
- /** 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. */
323
389
  vectorOverzoom(options) {
324
390
  const params = {};
325
391
  if (options?.levelBase !== undefined)
@@ -332,14 +398,14 @@ export class VPL {
332
398
  params['buffer'] = options?.buffer;
333
399
  return new VPL([...this.steps, { name: 'vector_overzoom', params }]);
334
400
  }
335
- /** Repairs vector tiles to conform to MVT 2.1. */
401
+ /** Repairs vector tiles so that they conform to MVT 2.1. */
336
402
  vectorRepair(options) {
337
403
  const params = {};
338
404
  if (options?.dropOffenders !== undefined)
339
405
  params['drop_offenders'] = options?.dropOffenders;
340
406
  return new VPL([...this.steps, { name: 'vector_repair', params }]);
341
407
  }
342
- /** Arguments for the `vector_update_properties` operation. */
408
+ /** Joins tabular data onto vector features, matching on an id column. */
343
409
  vectorUpdateProperties(options) {
344
410
  const params = {};
345
411
  params['data_source_path'] = options.dataSourcePath;