@mapwhit/tilerenderer 1.2.2 → 1.4.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 (40) hide show
  1. package/build/min/package.json +1 -1
  2. package/package.json +1 -1
  3. package/src/data/array_types.js +115 -64
  4. package/src/data/bucket/circle_bucket.js +42 -5
  5. package/src/data/bucket/fill_bucket.js +31 -13
  6. package/src/data/bucket/fill_extrusion_bucket.js +8 -6
  7. package/src/data/bucket/line_bucket.js +38 -14
  8. package/src/data/bucket/symbol_attributes.js +13 -5
  9. package/src/data/bucket/symbol_bucket.js +87 -33
  10. package/src/data/bucket/symbol_collision_buffers.js +1 -1
  11. package/src/data/bucket.js +3 -1
  12. package/src/data/feature_index.js +24 -11
  13. package/src/data/segment.js +15 -7
  14. package/src/render/draw_circle.js +45 -4
  15. package/src/render/draw_symbol.js +190 -22
  16. package/src/render/painter.js +1 -1
  17. package/src/source/geojson_source.js +118 -21
  18. package/src/source/geojson_source_diff.js +148 -0
  19. package/src/source/geojson_tiler.js +89 -0
  20. package/src/source/source.js +16 -5
  21. package/src/source/source_cache.js +6 -6
  22. package/src/source/source_state.js +4 -2
  23. package/src/source/tile.js +5 -3
  24. package/src/source/vector_tile_source.js +2 -0
  25. package/src/source/worker_tile.js +4 -2
  26. package/src/style/pauseable_placement.js +39 -7
  27. package/src/style/style.js +86 -34
  28. package/src/style/style_layer/circle_style_layer_properties.js +8 -1
  29. package/src/style/style_layer/fill_style_layer_properties.js +8 -1
  30. package/src/style/style_layer/line_style_layer_properties.js +4 -0
  31. package/src/style/style_layer/symbol_style_layer_properties.js +17 -2
  32. package/src/style-spec/reference/v8.json +161 -4
  33. package/src/symbol/one_em.js +4 -0
  34. package/src/symbol/placement.js +406 -173
  35. package/src/symbol/projection.js +3 -3
  36. package/src/symbol/quads.js +1 -6
  37. package/src/symbol/shaping.js +16 -27
  38. package/src/symbol/symbol_layout.js +243 -81
  39. package/src/util/vectortile_to_geojson.js +3 -4
  40. package/src/source/geojson_worker_source.js +0 -97
@@ -1,97 +0,0 @@
1
- import rewind from '@mapwhit/geojson-rewind';
2
- import geojsonvt from 'geojson-vt';
3
- import Supercluster from 'supercluster';
4
- import GeoJSONWrapper from './geojson_wrapper.js';
5
- import { makeSingleSourceLayerWorkerTile as makeWorkerTile } from './worker_tile.js';
6
-
7
- /**
8
- * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.
9
- *
10
- */
11
- class GeoJSONWorkerSource {
12
- constructor(resources, layerIndex) {
13
- this.resources = resources;
14
- this.layerIndex = layerIndex;
15
- }
16
- /**
17
- * Fetches (if appropriate), parses, and index geojson data into tiles. This
18
- * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}
19
- * can correctly serve up tiles.
20
- *
21
- * Defers to {@link GeoJSONWorkerSource#loadGeoJSON} for the fetching/parsing,
22
- * expecting `callback(error, data)` to be called with either an error or a
23
- * parsed GeoJSON object.
24
- *
25
- * @param params
26
- * @param callback
27
- */
28
- loadData(params) {
29
- const data = loadJSON(params);
30
- this._geoJSONIndex = null;
31
- this._createGeoJSONIndex = params.cluster
32
- ? () => {
33
- rewind(data, true);
34
- return new Supercluster(params.superclusterOptions).load(data.features);
35
- }
36
- : () => {
37
- rewind(data, true);
38
- return geojsonvt(data, params.geojsonVtOptions);
39
- };
40
- }
41
-
42
- getTile(tileID) {
43
- if (!this._geoJSONIndex) {
44
- if (!this._createGeoJSONIndex) {
45
- return; // we couldn't load the file
46
- }
47
-
48
- try {
49
- this._geoJSONIndex = this._createGeoJSONIndex();
50
- } finally {
51
- this._createGeoJSONIndex = null;
52
- }
53
- }
54
- const { z, x, y } = tileID.canonical;
55
- return this._geoJSONIndex.getTile(z, x, y);
56
- }
57
-
58
- /**
59
- * Implements {@link WorkerSource#loadTile}.
60
- */
61
- async loadTile(params) {
62
- const { tileID, source } = params;
63
- const geoJSONTile = this.getTile(tileID);
64
- if (!geoJSONTile) {
65
- return; // nothing in the given tile
66
- }
67
- const sourceLayer = new GeoJSONWrapper(geoJSONTile.features);
68
- const layerFamilies = this.layerIndex.familiesBySource.get(source);
69
- if (!layerFamilies) {
70
- return;
71
- }
72
- const features = new Array(sourceLayer.length);
73
- for (let index = 0; index < sourceLayer.length; index++) {
74
- features[index] = { feature: sourceLayer.feature(index), index, sourceLayerIndex: 0 };
75
- }
76
-
77
- const result = await makeWorkerTile(params, features, layerFamilies.get(sourceLayer.name), this.resources);
78
-
79
- result.vectorTile = sourceLayer;
80
- return result;
81
- }
82
- }
83
-
84
- /**
85
- * Fetch and parse GeoJSON according to the given params.
86
- *
87
- * @param data Literal GeoJSON data. Must be provided.
88
- */
89
- function loadJSON({ data, source }) {
90
- try {
91
- return typeof data === 'string' ? JSON.parse(data) : data;
92
- } catch {
93
- throw new Error(`Input data given to '${source}' is not a valid GeoJSON object.`);
94
- }
95
- }
96
-
97
- export default GeoJSONWorkerSource;