itowns 2.43.2-next.18 → 2.43.2-next.19

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/lib/Core/Style.js CHANGED
@@ -15,29 +15,30 @@ function baseAltitudeDefault(properties, ctx) {
15
15
  return ctx?.coordinates?.z || 0;
16
16
  }
17
17
  export function readExpression(property, ctx) {
18
- if (property != undefined) {
19
- if (property.expression) {
20
- return property.expression.evaluate(ctx);
21
- } else if (property.stops) {
22
- for (let i = property.stops.length - 1; i >= 0; i--) {
23
- const stop = property.stops[i];
24
- if (ctx.zoom >= stop[0]) {
25
- return stop[1];
26
- }
18
+ if (property.expression) {
19
+ return property.expression.evaluate(ctx);
20
+ }
21
+ if (property.stops) {
22
+ const stops = property.stops;
23
+ property = property.stops[0][1];
24
+ for (let i = stops.length - 1; i >= 0; i--) {
25
+ const stop = stops[i];
26
+ if (ctx.zoom >= stop[0]) {
27
+ property = stop[1];
28
+ break;
27
29
  }
28
- return property.stops[0][1];
29
- }
30
- if (typeof property === 'string' || property instanceof String) {
31
- property = property.replace(/\{(.+?)\}/g, (a, b) => ctx.properties[b] || '').trim();
32
30
  }
33
- if (property instanceof Function) {
34
- // TOBREAK: Pass the current `context` as a unique parameter.
35
- // In this proposal, metadata will be accessed in the callee by the
36
- // `context.properties` property.
37
- return property(ctx.properties, ctx);
38
- }
39
- return property;
40
31
  }
32
+ if (typeof property === 'string' || property instanceof String) {
33
+ return property.replace(/\{(.+?)\}/g, (a, b) => ctx.properties[b] || '').trim();
34
+ }
35
+ if (property instanceof Function) {
36
+ // TOBREAK: Pass the current `context` as a unique parameter.
37
+ // In this proposal, metadata will be accessed in the callee by the
38
+ // `context.properties` property.
39
+ return property(ctx.properties, ctx);
40
+ }
41
+ return property;
41
42
  }
42
43
  function rgba2rgb(orig) {
43
44
  if (!orig) {
@@ -48,7 +49,7 @@ function rgba2rgb(orig) {
48
49
  };
49
50
  } else if (typeof orig == 'string') {
50
51
  const result = orig.match(/(?:((hsl|rgb)a? *\(([\d.%]+(?:deg|g?rad|turn)?)[ ,]*([\d.%]+)[ ,]*([\d.%]+)[ ,/]*([\d.%]*)\))|(#((?:[\d\w]{3}){1,2})([\d\w]{1,2})?))/i);
51
- if (!result) {
52
+ if (result === null) {
52
53
  return {
53
54
  color: orig,
54
55
  opacity: 1.0
@@ -62,10 +63,10 @@ function rgba2rgb(orig) {
62
63
  color: `#${result[8]}`,
63
64
  opacity
64
65
  };
65
- } else if (result[0]) {
66
+ } else if (result[1]) {
66
67
  return {
67
68
  color: `${result[2]}(${result[3]},${result[4]},${result[5]})`,
68
- opacity: Number(result[6]) || 1.0
69
+ opacity: result[6] ? Number(result[6]) : 1.0
69
70
  };
70
71
  }
71
72
  }
@@ -692,31 +693,6 @@ class Style {
692
693
  defineStyleProperty(this, 'icon', 'color', params.icon.color);
693
694
  defineStyleProperty(this, 'icon', 'opacity', params.icon.opacity, 1.0);
694
695
  }
695
-
696
- /**
697
- * Copies the content of the target style into this style.
698
- * @param {Style} style - The style to copy.
699
- *
700
- * @return {Style} This style.
701
- */
702
- copy(style) {
703
- Object.assign(this.fill, style.fill);
704
- Object.assign(this.stroke, style.stroke);
705
- Object.assign(this.point, style.point);
706
- Object.assign(this.text, style.text);
707
- Object.assign(this.icon, style.icon);
708
- return this;
709
- }
710
-
711
- /**
712
- * Clones this style.
713
- *
714
- * @return {Style} The new style, cloned from this one.
715
- */
716
- clone() {
717
- const clone = new Style();
718
- return clone.copy(this);
719
- }
720
696
  setContext(ctx) {
721
697
  this.context = ctx;
722
698
  }
@@ -940,8 +916,35 @@ class Style {
940
916
  if (iconImg) {
941
917
  try {
942
918
  style.icon.id = iconImg;
919
+ if (iconImg.stops) {
920
+ const iconCropValue = {
921
+ ...(iconImg.base !== undefined && {
922
+ base: iconImg.base
923
+ }),
924
+ stops: iconImg.stops.map(stop => {
925
+ let cropValues = sprites[stop[1]];
926
+ if (stop[1].includes('{')) {
927
+ cropValues = function (p) {
928
+ const id = stop[1].replace(/\{(.+?)\}/g, (a, b) => p[b] || '').trim();
929
+ cropValues = sprites[id];
930
+ return sprites[id];
931
+ };
932
+ }
933
+ return [stop[0], cropValues];
934
+ })
935
+ };
936
+ style.icon.cropValues = iconCropValue;
937
+ } else {
938
+ style.icon.cropValues = sprites[iconImg];
939
+ if (iconImg[0].includes('{')) {
940
+ style.icon.cropValues = function (p) {
941
+ const id = iconImg.replace(/\{(.+?)\}/g, (a, b) => p[b] || '').trim();
942
+ style.icon.cropValues = sprites[id];
943
+ return sprites[id];
944
+ };
945
+ }
946
+ }
943
947
  style.icon.source = sprites.source;
944
- style.icon.cropValues = sprites[iconImg];
945
948
  style.icon.size = readVectorProperty(layer.layout['icon-size']) || 1;
946
949
  const {
947
950
  color,
@@ -38,7 +38,7 @@ function pntsParse(data, layer) {
38
38
  size: 1,
39
39
  mode: layer.pntsMode,
40
40
  shape: layer.pntsShape,
41
- classification: layer.classification,
41
+ classificationScheme: layer.classification,
42
42
  sizeMode: layer.pntsSizeMode,
43
43
  minAttenuatedSize: layer.pntsMinAttenuatedSize,
44
44
  maxAttenuatedSize: layer.pntsMaxAttenuatedSize
@@ -266,7 +266,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
266
266
  * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
267
267
  * @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
268
268
  * @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
269
- * @param {Scheme} [options.classification] LUT for point classification colorization.
269
+ * @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
270
270
  * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
271
271
  * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
272
272
  * (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.43.2-next.18",
3
+ "version": "2.43.2-next.19",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",