@mapwhit/tilerenderer 1.3.0 → 1.5.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 (46) 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 +112 -40
  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/index.js +23 -23
  15. package/src/render/draw_circle.js +45 -4
  16. package/src/render/draw_symbol.js +190 -22
  17. package/src/render/painter.js +1 -1
  18. package/src/source/geojson_source.js +118 -21
  19. package/src/source/geojson_source_diff.js +148 -0
  20. package/src/source/geojson_tiler.js +89 -0
  21. package/src/source/rtl_text_plugin.js +133 -66
  22. package/src/source/source.js +16 -5
  23. package/src/source/source_cache.js +6 -6
  24. package/src/source/source_state.js +4 -2
  25. package/src/source/tile.js +5 -3
  26. package/src/source/vector_tile_source.js +2 -0
  27. package/src/source/worker_tile.js +6 -2
  28. package/src/style/evaluation_parameters.js +2 -3
  29. package/src/style/pauseable_placement.js +39 -7
  30. package/src/style/style.js +34 -23
  31. package/src/style/style_layer/circle_style_layer_properties.js +8 -1
  32. package/src/style/style_layer/fill_style_layer_properties.js +8 -1
  33. package/src/style/style_layer/line_style_layer_properties.js +4 -0
  34. package/src/style/style_layer/symbol_style_layer_properties.js +17 -2
  35. package/src/style-spec/reference/v8.json +161 -4
  36. package/src/symbol/one_em.js +4 -0
  37. package/src/symbol/placement.js +406 -173
  38. package/src/symbol/projection.js +3 -3
  39. package/src/symbol/quads.js +1 -6
  40. package/src/symbol/shaping.js +18 -29
  41. package/src/symbol/symbol_layout.js +243 -81
  42. package/src/symbol/transform_text.js +3 -4
  43. package/src/util/config.js +1 -9
  44. package/src/util/script_detection.js +19 -7
  45. package/src/util/vectortile_to_geojson.js +3 -4
  46. package/src/source/geojson_worker_source.js +0 -97
@@ -415,6 +415,15 @@ export function charHasRotatedVerticalOrientation(char) {
415
415
  return !(charHasUprightVerticalOrientation(char) || charHasNeutralVerticalOrientation(char));
416
416
  }
417
417
 
418
+ export function charInRTLScript(char) {
419
+ // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts
420
+ return (
421
+ (char >= 0x0590 && char <= 0x08ff) ||
422
+ isChar['Arabic Presentation Forms-A'](char) ||
423
+ isChar['Arabic Presentation Forms-B'](char)
424
+ );
425
+ }
426
+
418
427
  export function charInSupportedScript(char, canRenderRTL) {
419
428
  // This is a rough heuristic: whether we "can render" a script
420
429
  // actually depends on the properties of the font being used
@@ -423,13 +432,7 @@ export function charInSupportedScript(char, canRenderRTL) {
423
432
 
424
433
  // Even in Latin script, we "can't render" combinations such as the fi
425
434
  // ligature, but we don't consider that semantically significant.
426
- if (
427
- !canRenderRTL &&
428
- ((char >= 0x0590 && char <= 0x08ff) ||
429
- isChar['Arabic Presentation Forms-A'](char) ||
430
- isChar['Arabic Presentation Forms-B'](char))
431
- ) {
432
- // Main blocks for Hebrew, Arabic, Thaana and other RTL scripts
435
+ if (!canRenderRTL && charInRTLScript(char)) {
433
436
  return false;
434
437
  }
435
438
  if (
@@ -448,6 +451,15 @@ export function charInSupportedScript(char, canRenderRTL) {
448
451
  return true;
449
452
  }
450
453
 
454
+ export function stringContainsRTLText(chars) {
455
+ for (const char of chars) {
456
+ if (charInRTLScript(char.charCodeAt(0))) {
457
+ return true;
458
+ }
459
+ }
460
+ return false;
461
+ }
462
+
451
463
  export function isStringInSupportedScript(chars, canRenderRTL) {
452
464
  for (const char of chars) {
453
465
  if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {
@@ -6,16 +6,15 @@ export default class GeoJSONFeature {
6
6
  #geometry;
7
7
  #xyz;
8
8
 
9
- constructor(vectorTileFeature, z, x, y) {
9
+ constructor(vectorTileFeature, z, x, y, id) {
10
10
  this.type = 'Feature';
11
11
 
12
12
  this.#vectorTileFeature = vectorTileFeature;
13
13
  this.#xyz = { z, x, y };
14
14
 
15
15
  this.properties = vectorTileFeature.properties;
16
-
17
- if (vectorTileFeature.id != null) {
18
- this.id = vectorTileFeature.id;
16
+ if (id !== undefined) {
17
+ this.id = id;
19
18
  }
20
19
  }
21
20
 
@@ -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;