itowns 2.44.3-next.26 → 2.44.3-next.28

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.
@@ -87,8 +87,10 @@
87
87
  eptSource = new itowns.EntwinePointTileSource({ url });
88
88
 
89
89
  if (eptLayer) {
90
- view.removeLayer('ept');
90
+ debugGui.removeFolder(eptLayer.debugUI);
91
+ view.removeLayer('Entwine Point Tile');
91
92
  view.notifyChange();
93
+ eptLayer.delete();
92
94
  }
93
95
 
94
96
  eptLayer = new itowns.EntwinePointTileLayer('Entwine Point Tile', {
@@ -88,7 +88,7 @@
88
88
  eptSource = new itowns.EntwinePointTileSource({ url });
89
89
 
90
90
  if (eptLayer) {
91
- debugGUI.removeFolder(eptLayer.debugUI);
91
+ debugGui.removeFolder(eptLayer.debugUI);
92
92
  view.removeLayer('Entwine Point Tile');
93
93
  view.notifyChange();
94
94
  eptLayer.delete();
@@ -35,7 +35,11 @@ export const UNIT = {
35
35
  /**
36
36
  * Distance unit in meter.
37
37
  */
38
- METER: 2
38
+ METER: 2,
39
+ /**
40
+ * Distance unit in foot.
41
+ */
42
+ FOOT: 3
39
43
  };
40
44
 
41
45
  /**
@@ -50,8 +54,10 @@ export function is4326(crs) {
50
54
  function unitFromProj4Unit(proj) {
51
55
  if (proj.units === 'degrees') {
52
56
  return UNIT.DEGREE;
53
- } else if (proj.units === 'm') {
57
+ } else if (proj.units === 'm' || proj.units === 'meter') {
54
58
  return UNIT.METER;
59
+ } else if (proj.units === 'foot') {
60
+ return UNIT.FOOT;
55
61
  } else if (proj.units === undefined && proj.to_meter === undefined) {
56
62
  // See https://proj.org/en/9.4/usage/projections.html [17/10/2024]
57
63
  // > The default unit for projected coordinates is the meter.
@@ -65,7 +71,7 @@ function unitFromProj4Unit(proj) {
65
71
  * Returns the horizontal coordinates system units associated with this CRS.
66
72
  *
67
73
  * @param crs - The CRS to extract the unit from.
68
- * @returns Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
74
+ * @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
69
75
  */
70
76
  export function getUnit(crs) {
71
77
  mustBeString(crs);
package/lib/Core/Style.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FEATURE_TYPES } from "./Feature.js";
2
2
  import Cache from "./Scheduler/Cache.js";
3
3
  import Fetcher from "../Provider/Fetcher.js";
4
- import * as mapbox from '@mapbox/mapbox-gl-style-spec';
4
+ import * as maplibre from '@maplibre/maplibre-gl-style-spec';
5
5
  import { Color } from 'three';
6
6
  import { deltaE } from "../Renderer/Color.js";
7
7
  import Coordinates from "./Geographic/Coordinates.js";
@@ -73,8 +73,8 @@ function rgba2rgb(orig) {
73
73
  }
74
74
  function readVectorProperty(property, options) {
75
75
  if (property != undefined) {
76
- if (mapbox.expression.isExpression(property)) {
77
- return mapbox.expression.createExpression(property, options).value;
76
+ if (maplibre.expression.isExpression(property)) {
77
+ return maplibre.expression.createExpression(property, options).value;
78
78
  } else {
79
79
  return property;
80
80
  }
@@ -291,9 +291,6 @@ class PointCloudLayer extends GeometryLayer {
291
291
  redraw: true,
292
292
  earlyDropFunction: cmd => !cmd.requester.visible || !this.visible
293
293
  }).then(pts => {
294
- if (this.onPointsCreated) {
295
- this.onPointsCreated(layer, pts);
296
- }
297
294
  elt.obj = pts;
298
295
  // store tightbbox to avoid ping-pong (bbox = larger => visible, tight => invisible)
299
296
  elt.tightbbox = pts.tightbbox;
@@ -302,11 +299,12 @@ class PointCloudLayer extends GeometryLayer {
302
299
  // be added nor cleaned
303
300
  this.group.add(elt.obj);
304
301
  elt.obj.updateMatrixWorld(true);
305
- elt.promise = null;
306
- }, err => {
307
- if (err.isCancelledCommandException) {
308
- elt.promise = null;
302
+ }).catch(err => {
303
+ if (!err.isCancelledCommandException) {
304
+ return err;
309
305
  }
306
+ }).finally(() => {
307
+ elt.promise = null;
310
308
  });
311
309
  }
312
310
  }
@@ -1,3 +1,4 @@
1
+ import proj4 from 'proj4';
1
2
  import { Binary, Info, Las } from 'copc';
2
3
  import Extent from "../Core/Geographic/Extent.js";
3
4
  import Fetcher from "../Provider/Fetcher.js";
@@ -102,8 +103,18 @@ class CopcSource extends Source {
102
103
  this.header = metadata.header;
103
104
  this.info = metadata.info;
104
105
  this.eb = metadata.eb;
105
- // TODO: use wkt definition in `metadata.wkt` to infer/define crs
106
- this.crs = config.crs || 'EPSG:4326';
106
+ proj4.defs('unknown', metadata.wkt);
107
+ let projCS;
108
+ if (proj4.defs('unknown').type === 'COMPD_CS') {
109
+ console.warn('CopcSource: compound coordinate system is not yet supported.');
110
+ projCS = proj4.defs('unknown').PROJCS;
111
+ } else {
112
+ projCS = proj4.defs('unknown');
113
+ }
114
+ this.crs = projCS.title || projCS.name || 'EPSG:4326';
115
+ if (!(this.crs in proj4.defs)) {
116
+ proj4.defs(this.crs, projCS);
117
+ }
107
118
  const bbox = new THREE.Box3();
108
119
  bbox.min.fromArray(this.info.cube, 0);
109
120
  bbox.max.fromArray(this.info.cube, 3);
@@ -38,10 +38,19 @@ class EntwinePointTileSource extends Source {
38
38
  // Set parser and its configuration from schema
39
39
  this.parse = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
40
40
  this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
41
- if (metadata.srs && metadata.srs.authority && metadata.srs.horizontal) {
42
- this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
43
- if (!proj4.defs(this.crs)) {
44
- proj4.defs(this.crs, metadata.srs.wkt);
41
+ if (metadata.srs) {
42
+ if (metadata.srs.authority && metadata.srs.horizontal) {
43
+ this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
44
+ if (!proj4.defs(this.crs)) {
45
+ proj4.defs(this.crs, metadata.srs.wkt);
46
+ }
47
+ } else if (metadata.srs.wkt) {
48
+ proj4.defs('unknown', metadata.srs.wkt);
49
+ const projCS = proj4.defs('unknown');
50
+ this.crs = projCS.title || projCS.name;
51
+ if (!(this.crs in proj4.defs)) {
52
+ proj4.defs(this.crs, projCS);
53
+ }
45
54
  }
46
55
  if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
47
56
  console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
@@ -53,6 +62,7 @@ class EntwinePointTileSource extends Source {
53
62
  // span in ept.json. This needs improvements.
54
63
  this.spacing = (Math.abs(metadata.boundsConforming[3] - metadata.boundsConforming[0]) + Math.abs(metadata.boundsConforming[4] - metadata.boundsConforming[1])) / (2 * metadata.span);
55
64
  this.boundsConforming = metadata.boundsConforming;
65
+ this.bounds = metadata.bounds;
56
66
  this.span = metadata.span;
57
67
  return this;
58
68
  });
@@ -1,4 +1,4 @@
1
- import { featureFilter } from '@mapbox/mapbox-gl-style-spec';
1
+ import { featureFilter } from '@maplibre/maplibre-gl-style-spec';
2
2
  import Style from "../Core/Style.js";
3
3
  import TMSSource from "./TMSSource.js";
4
4
  import URLBuilder from "../Provider/URLBuilder.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.44.3-next.26",
3
+ "version": "2.44.3-next.28",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -57,8 +57,8 @@
57
57
  },
58
58
  "homepage": "https://itowns.github.io/",
59
59
  "dependencies": {
60
- "@mapbox/mapbox-gl-style-spec": "^13.28.0",
61
60
  "@mapbox/vector-tile": "^2.0.3",
61
+ "@maplibre/maplibre-gl-style-spec": "^22.0.0",
62
62
  "@tmcw/togeojson": "^5.8.1",
63
63
  "@tweenjs/tween.js": "^25.0.0",
64
64
  "3d-tiles-renderer": "^0.3.39",