itowns 2.36.2 → 2.38.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 (122) hide show
  1. package/CONTRIBUTING.md +30 -17
  2. package/README.md +12 -1
  3. package/changelog.md +138 -0
  4. package/dist/debug.js +1 -1
  5. package/dist/debug.js.LICENSE.txt +2 -2
  6. package/dist/debug.js.map +1 -1
  7. package/dist/itowns.js +1 -1
  8. package/dist/itowns.js.LICENSE.txt +2 -2
  9. package/dist/itowns.js.map +1 -1
  10. package/dist/itowns_widgets.js +2 -0
  11. package/dist/itowns_widgets.js.map +1 -0
  12. package/examples/config.json +28 -6
  13. package/examples/css/example.css +21 -1
  14. package/examples/css/widgets.css +360 -0
  15. package/examples/geoid_geoidLayer.html +102 -0
  16. package/examples/images/code-logo.svg +43 -0
  17. package/examples/index.html +5 -5
  18. package/examples/itowns-potree.html +252 -0
  19. package/examples/js/GUI/GuiTools.js +17 -0
  20. package/examples/mars.html +0 -1
  21. package/examples/misc_orthographic_camera.html +7 -19
  22. package/examples/source_file_from_fetched_data.html +90 -0
  23. package/examples/source_file_from_format.html +85 -0
  24. package/examples/source_file_from_methods.html +87 -0
  25. package/examples/source_file_from_parsed_data.html +104 -0
  26. package/examples/source_file_geojson_raster.html +21 -45
  27. package/examples/source_file_gpx_raster.html +28 -36
  28. package/examples/source_file_kml_raster.html +1 -4
  29. package/examples/source_file_shapefile.html +39 -34
  30. package/examples/source_stream_wfs_25d.html +21 -13
  31. package/examples/source_stream_wfs_3d.html +21 -12
  32. package/examples/source_stream_wfs_raster.html +20 -20
  33. package/examples/vector_tile_3d_mesh.html +155 -0
  34. package/examples/vector_tile_raster_3d.html +0 -5
  35. package/examples/view_25d_map.html +6 -19
  36. package/examples/view_2d_map.html +6 -19
  37. package/examples/view_3d_map.html +106 -81
  38. package/examples/view_immersive.html +13 -14
  39. package/examples/widgets_minimap.html +124 -0
  40. package/examples/widgets_navigation.html +124 -0
  41. package/examples/widgets_scale.html +96 -0
  42. package/examples/widgets_searchbar.html +124 -0
  43. package/lib/Controls/GlobeControls.js +13 -0
  44. package/lib/Controls/PlanarControls.js +11 -43
  45. package/lib/Converter/Feature2Mesh.js +203 -45
  46. package/lib/Converter/convertToTile.js +13 -4
  47. package/lib/Core/3DTiles/C3DTBoundingVolume.js +4 -1
  48. package/lib/Core/Deprecated/Undeprecator.js +1 -1
  49. package/lib/Core/Feature.js +60 -34
  50. package/lib/Core/Geographic/Extent.js +1 -1
  51. package/lib/Core/Geographic/GeoidGrid.js +143 -0
  52. package/lib/Core/MainLoop.js +137 -63
  53. package/lib/Core/Math/Ellipsoid.js +1 -1
  54. package/lib/Core/Prefab/Globe/SkyShader.js +3 -1
  55. package/lib/Core/Prefab/Planar/PlanarLayer.js +3 -1
  56. package/lib/Core/Style.js +1 -1
  57. package/lib/Core/TileGeometry.js +3 -1
  58. package/lib/Core/TileMesh.js +32 -22
  59. package/lib/Core/View.js +81 -15
  60. package/lib/Layer/ElevationLayer.js +6 -2
  61. package/lib/Layer/FeatureGeometryLayer.js +36 -7
  62. package/lib/Layer/GeoidLayer.js +142 -0
  63. package/lib/Layer/GeometryLayer.js +6 -54
  64. package/lib/Layer/InfoLayer.js +1 -1
  65. package/lib/Layer/Layer.js +1 -1
  66. package/lib/Layer/LayerUpdateStrategy.js +1 -1
  67. package/lib/Layer/OrientedImageLayer.js +1 -0
  68. package/lib/Layer/PotreeLayer.js +3 -1
  69. package/lib/Layer/RasterLayer.js +3 -1
  70. package/lib/Layer/ReferencingLayerProperties.js +50 -0
  71. package/lib/Layer/TiledGeometryLayer.js +3 -1
  72. package/lib/Main.js +214 -174
  73. package/lib/MainBundle.js +1 -1
  74. package/lib/Parser/B3dmParser.js +5 -3
  75. package/lib/Parser/GDFParser.js +118 -0
  76. package/lib/Parser/GTXParser.js +92 -0
  77. package/lib/Parser/GeoJsonParser.js +29 -7
  78. package/lib/Parser/ISGParser.js +121 -0
  79. package/lib/Parser/LASParser.js +3 -1
  80. package/lib/Parser/VectorTileParser.js +4 -3
  81. package/lib/Parser/XbilParser.js +1 -1
  82. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -1
  83. package/lib/Process/3dTilesProcessing.js +2 -2
  84. package/lib/Process/FeatureProcessing.js +38 -86
  85. package/lib/Process/LayeredMaterialNodeProcessing.js +16 -7
  86. package/lib/Process/ObjectRemovalHelper.js +4 -0
  87. package/lib/Provider/3dTilesProvider.js +2 -7
  88. package/lib/Provider/Fetcher.js +4 -1
  89. package/lib/Provider/TileProvider.js +18 -2
  90. package/lib/Provider/URLBuilder.js +1 -1
  91. package/lib/Renderer/Camera.js +33 -12
  92. package/lib/Renderer/ColorLayersOrdering.js +3 -1
  93. package/lib/Renderer/LayeredMaterial.js +34 -9
  94. package/lib/Renderer/OBB.js +22 -25
  95. package/lib/Renderer/OrientedImageMaterial.js +8 -5
  96. package/lib/Renderer/PointsMaterial.js +6 -6
  97. package/lib/Renderer/RasterTile.js +1 -1
  98. package/lib/Renderer/RenderMode.js +3 -1
  99. package/lib/Renderer/Shader/ShaderChunk.js +5 -1
  100. package/lib/Renderer/Shader/ShaderUtils.js +4 -2
  101. package/lib/Renderer/c3DEngine.js +9 -6
  102. package/lib/Source/C3DTilesSource.js +3 -1
  103. package/lib/Source/EntwinePointTileSource.js +3 -1
  104. package/lib/Source/FileSource.js +8 -1
  105. package/lib/Source/PotreeSource.js +3 -1
  106. package/lib/Source/Source.js +15 -10
  107. package/lib/Source/VectorTilesSource.js +5 -0
  108. package/lib/Source/WFSSource.js +9 -3
  109. package/lib/Source/WMTSSource.js +3 -1
  110. package/lib/ThreeExtended/{WebGL.js → capabilities/WebGL.js} +8 -7
  111. package/lib/ThreeExtended/loaders/GLTFLoader.js +88 -39
  112. package/lib/Utils/CameraUtils.js +11 -1
  113. package/lib/Utils/DEMUtils.js +4 -2
  114. package/lib/Utils/FeaturesUtils.js +8 -4
  115. package/lib/Utils/gui/Main.js +39 -0
  116. package/lib/Utils/gui/Minimap.js +197 -0
  117. package/lib/Utils/gui/Navigation.js +322 -0
  118. package/lib/Utils/gui/Scale.js +154 -0
  119. package/lib/Utils/gui/Searchbar.js +299 -0
  120. package/lib/Utils/gui/Widget.js +119 -0
  121. package/package.json +32 -27
  122. package/examples/js/Scale.js +0 -40
package/lib/MainBundle.js CHANGED
@@ -11,13 +11,13 @@ var _exportNames = {
11
11
  THREE: true,
12
12
  proj4: true
13
13
  };
14
+ exports.THREE = void 0;
14
15
  Object.defineProperty(exports, "proj4", {
15
16
  enumerable: true,
16
17
  get: function get() {
17
18
  return _proj["default"];
18
19
  }
19
20
  });
20
- exports.THREE = void 0;
21
21
 
22
22
  var THREE = _interopRequireWildcard(require("three"));
23
23
 
@@ -7,8 +7,9 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
+ exports["default"] = void 0;
10
11
  exports.enableDracoLoader = enableDracoLoader;
11
- exports["default"] = exports.legacyGLTFLoader = exports.glTFLoader = void 0;
12
+ exports.legacyGLTFLoader = exports.glTFLoader = void 0;
12
13
 
13
14
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
14
15
 
@@ -28,6 +29,8 @@ var _Utf8Decoder = _interopRequireDefault(require("../Utils/Utf8Decoder"));
28
29
 
29
30
  var _C3DTBatchTable = _interopRequireDefault(require("../Core/3DTiles/C3DTBatchTable"));
30
31
 
32
+ var _ReferencingLayerProperties = _interopRequireDefault(require("../Layer/ReferencingLayerProperties"));
33
+
31
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
32
35
 
33
36
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -257,8 +260,7 @@ var _default = {
257
260
  console.warn('b3dm shader has been patched to add log depth buffer support');
258
261
  }
259
262
 
260
- mesh.material.transparent = options.opacity < 1.0;
261
- mesh.material.opacity = options.opacity;
263
+ (0, _ReferencingLayerProperties["default"])(mesh.material, options.layer);
262
264
  }
263
265
  });
264
266
  resolve(gltf);
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+ exports.getHeaderAttribute = getHeaderAttribute;
12
+
13
+ var THREE = _interopRequireWildcard(require("three"));
14
+
15
+ var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
16
+
17
+ var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
18
+
19
+ var _GTXParser = require("./GTXParser");
20
+
21
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
+
23
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
+
25
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
26
+
27
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
+
29
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
30
+
31
+ function getHeaderAttribute(header, attributeName) {
32
+ var attributeRow = header[header.indexOf(header.find(function (element) {
33
+ return element.includes(attributeName);
34
+ }))].split(' ').filter(function (value) {
35
+ return value !== '';
36
+ });
37
+ return parseFloat(attributeRow[attributeRow.length - 1]);
38
+ }
39
+ /**
40
+ * The `GDFParser` module provides a `[parse]{@link module:GDFParser.parse}` method. This method takes the content of a
41
+ * GDF file in, and returns a `{@link GeoidGrid}`. the `{@link GeoidGrid}` contains all the necessary attributes and
42
+ * methods to access the GDF data in iTowns.
43
+ *
44
+ * @module GDFParser
45
+ */
46
+
47
+
48
+ var _default = {
49
+ /**
50
+ * Parses a GDF file content and returns a corresponding `{@link GeoidGrid}`.
51
+ *
52
+ * @param {string} gdf The content of the GDF file to parse.
53
+ * @param {Object} options An object gathering the optional parameters to pass to
54
+ * the parser.
55
+ * @param {Object} [options.in={}] Information on the GDF data.
56
+ * @param {string} [options.in.crs='EPSG:4326'] The Coordinates Reference System (CRS) of the GDF data.
57
+ * It must be a geographic CRS, and must be given as an EPSG
58
+ * code.
59
+ *
60
+ * @returns {Promise<GeoidGrid>} A promise resolving with a `{@link GeoidGrid}`, which contains all the necessary
61
+ * attributes and methods to access GDF file data.
62
+ */
63
+ parse: function parse(gdf) {
64
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
65
+ "in": {}
66
+ };
67
+ var rows = gdf.split('\n');
68
+ var firstMeasureLine = rows.indexOf(rows.find(function (row) {
69
+ return row.includes('end_of_head');
70
+ })) + 1;
71
+ var rawHeaderData = rows.slice(0, firstMeasureLine); // ---------- GET METADATA FROM THE FILE : ----------
72
+
73
+ var metadata = {
74
+ minX: getHeaderAttribute(rawHeaderData, 'longlimit_west'),
75
+ maxX: getHeaderAttribute(rawHeaderData, 'longlimit_east'),
76
+ minY: getHeaderAttribute(rawHeaderData, 'latlimit_south'),
77
+ maxY: getHeaderAttribute(rawHeaderData, 'latlimit_north'),
78
+ stepX: getHeaderAttribute(rawHeaderData, 'gridstep'),
79
+ stepY: getHeaderAttribute(rawHeaderData, 'gridstep'),
80
+ nRows: getHeaderAttribute(rawHeaderData, 'latitude_parallels'),
81
+ nColumns: getHeaderAttribute(rawHeaderData, 'longitude_parallels')
82
+ }; // ---------- BUILD A DATA VIEWER FROM THE TEXT DATA : ----------
83
+
84
+ var data = new DataView(new ArrayBuffer(_GTXParser.BYTES_PER_DOUBLE * metadata.nRows * metadata.nColumns));
85
+ var index = 0;
86
+
87
+ var _iterator = _createForOfIteratorHelper(rows.slice(firstMeasureLine, rows.length)),
88
+ _step;
89
+
90
+ try {
91
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
92
+ var row = _step.value;
93
+ row = row.split(' ').filter(function (value) {
94
+ return value !== '';
95
+ });
96
+
97
+ if (!row.length) {
98
+ continue;
99
+ }
100
+
101
+ data.setFloat64(index * _GTXParser.BYTES_PER_DOUBLE, parseFloat(row[2]));
102
+ index++;
103
+ } // ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
104
+
105
+ } catch (err) {
106
+ _iterator.e(err);
107
+ } finally {
108
+ _iterator.f();
109
+ }
110
+
111
+ var dataExtent = new _Extent["default"](options["in"].crs || 'EPSG:4326', metadata.minX, metadata.maxX, metadata.minY, metadata.maxY);
112
+ var dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
113
+ return Promise.resolve(new _GeoidGrid["default"](dataExtent, dataStep, function getData(verticalIndex, horizontalIndex) {
114
+ return data.getFloat64((metadata.nColumns * (metadata.nRows - verticalIndex - 1) + horizontalIndex) * _GTXParser.BYTES_PER_DOUBLE);
115
+ }));
116
+ }
117
+ };
118
+ exports["default"] = _default;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = exports.BYTES_PER_FLOAT = exports.BYTES_PER_DOUBLE = void 0;
11
+
12
+ var THREE = _interopRequireWildcard(require("three"));
13
+
14
+ var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
15
+
16
+ var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ var BYTES_PER_DOUBLE = 8;
23
+ exports.BYTES_PER_DOUBLE = BYTES_PER_DOUBLE;
24
+ var BYTES_PER_FLOAT = 4;
25
+ /**
26
+ * The `GTXParser` module provides a `[parse]{@link module:GTXParser.parse}` method. This method takes the content of a
27
+ * GTX file in, and returns a `{@link GeoidGrid}`. The `{@link GeoidGrid}` contains all the necessary attributes and
28
+ * methods to access the GTX data in iTowns.
29
+ *
30
+ * @module GTXParser
31
+ */
32
+
33
+ exports.BYTES_PER_FLOAT = BYTES_PER_FLOAT;
34
+ var _default = {
35
+ /**
36
+ * Parses a GTX file content and returns a corresponding `{@link GeoidGrid}`.
37
+ *
38
+ * @param {ArrayBuffer} gtx The content of the GTX file to parse.
39
+ * @param {Object} options An object gathering the optional parameters to pass to
40
+ * the parser.
41
+ * @param {Object} [options.in={}] Information on the GTX data.
42
+ * @param {string} [options.in.crs='EPSG:4326'] The Coordinates Reference System (CRS) of the GTX data.
43
+ * It must be a geographic CRS, and must be given as an
44
+ * EPSG code.
45
+ * @param {string} [options.in.dataType='float'] The encoding of geoid height data within the GTX file.
46
+ * Must be `'float'` or `'double'`.
47
+ *
48
+ * @returns {Promise<GeoidGrid>} A promise resolving with a `{@link GeoidGrid}`, which contains all the necessary
49
+ * attributes and methods to access GTX file data.
50
+ */
51
+ parse: function parse(gtx) {
52
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
53
+ "in": {}
54
+ };
55
+ var dataType = options["in"].dataType || 'float';
56
+
57
+ if (!['float', 'double'].includes(dataType)) {
58
+ throw new Error('`dataType` parameter is incorrect for GTXParser.parse method. ' + 'This parameter must be either `double` or `float`.');
59
+ } // ---------- GET METADATA FROM THE FILE : ----------
60
+
61
+
62
+ var headerView = new DataView(gtx, 0, 40);
63
+ var metadata = {
64
+ minX: headerView.getFloat64(8),
65
+ minY: headerView.getFloat64(0),
66
+ stepX: headerView.getFloat64(24),
67
+ stepY: headerView.getFloat64(16),
68
+ nColumns: headerView.getInt32(36),
69
+ nRows: headerView.getInt32(32)
70
+ }; // ---------- BUILD A DATA VIEWER : ----------
71
+
72
+ var dataView = new DataView(gtx, 40); // ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
73
+ // formula for the max longitude : maxLongitude = minLongitude + deltaLongitude * (nColumns - 1)
74
+
75
+ var maxX = metadata.minX + metadata.stepX * (metadata.nColumns - 1); // formula for the max latitude : maxLatitude = minLatitude + deltaLatitude * (nRows - 1)
76
+
77
+ var maxY = metadata.minY + metadata.stepY * (metadata.nRows - 1);
78
+ var dataExtent = new _Extent["default"](options["in"].crs || 'EPSG:4326', metadata.minX, maxX, metadata.minY, maxY);
79
+ var dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
80
+ return Promise.resolve(new _GeoidGrid["default"](dataExtent, dataStep, function getData(verticalIndex, horizontalIndex) {
81
+ // formula to get the index of a geoid height from a latitude and longitude indexes is :
82
+ // ``(nColumns * latIndex + lonIndex) * nBytes``, where nBytes stands for the number of bytes geoid
83
+ // height data are encoded on.
84
+ if (dataType === 'float') {
85
+ return dataView.getFloat32((metadata.nColumns * verticalIndex + horizontalIndex) * BYTES_PER_FLOAT);
86
+ } else if (dataType === 'double') {
87
+ return dataView.getFloat64((metadata.nColumns * verticalIndex + horizontalIndex) * BYTES_PER_DOUBLE);
88
+ }
89
+ }));
90
+ }
91
+ };
92
+ exports["default"] = _default;
@@ -26,16 +26,17 @@ function readCRS(json) {
26
26
  if (json.crs.type.toLowerCase() == 'epsg') {
27
27
  return "EPSG:".concat(json.crs.properties.code);
28
28
  } else if (json.crs.type.toLowerCase() == 'name') {
29
- var epsgIdx = json.crs.properties.name.toLowerCase().indexOf('epsg:');
30
-
31
- if (epsgIdx >= 0) {
32
- // authority:version:code => EPSG:[...]:code
33
- var codeStart = json.crs.properties.name.indexOf(':', epsgIdx + 5);
29
+ if (json.crs.properties.name.toLowerCase().includes('epsg:')) {
30
+ // OGC CRS URN: urn:ogc:def:crs:authority:version:code => EPSG:[...]:code
31
+ // legacy identifier: authority:code => EPSG:code
32
+ var codeStart = json.crs.properties.name.lastIndexOf(':');
34
33
 
35
34
  if (codeStart > 0) {
36
35
  return "EPSG:".concat(json.crs.properties.name.substr(codeStart + 1));
37
36
  }
38
37
  }
38
+
39
+ throw new Error("Unsupported CRS authority '".concat(json.crs.properties.name, "'"));
39
40
  }
40
41
 
41
42
  throw new Error("Unsupported CRS type '".concat(json.crs, "'"));
@@ -45,7 +46,9 @@ function readCRS(json) {
45
46
  return 'EPSG:4326';
46
47
  }
47
48
 
48
- var coord = new _Coordinates["default"]('EPSG:4978', 0, 0, 0); // filter with the first point
49
+ var coord = new _Coordinates["default"]('EPSG:4978', 0, 0, 0);
50
+ var last = new _Coordinates["default"]('EPSG:4978', 0, 0, 0);
51
+ var first = new _Coordinates["default"]('EPSG:4978', 0, 0, 0); // filter with the first point
49
52
 
50
53
  var firstPtIsOut = function (extent, aCoords, crs) {
51
54
  coord.crs = crs;
@@ -76,6 +79,25 @@ var toFeature = {
76
79
 
77
80
  geometry.updateExtent();
78
81
  },
82
+ // compute clockwise polygon
83
+ populateGeometryWithCCW: function populateGeometryWithCCW(crsIn, coordinates, geometry, feature) {
84
+ geometry.startSubGeometry(coordinates.length, feature);
85
+ coord.crs = crsIn;
86
+ var sum = 0;
87
+ first.setFromValues(coordinates[0][0], coordinates[0][1], coordinates[0][2]);
88
+ last.copy(first);
89
+
90
+ for (var i = 0; i < coordinates.length; i++) {
91
+ coord.setFromValues(coordinates[i][0], coordinates[i][1], coordinates[i][2]);
92
+ sum += (last.x - coord.x) * (last.y + coord.y);
93
+ last.copy(coord);
94
+ geometry.pushCoordinates(coord, feature);
95
+ }
96
+
97
+ sum += (last.x - first.x) * (last.y + first.y);
98
+ geometry.getLastSubGeometry().ccw = sum < 0;
99
+ geometry.updateExtent();
100
+ },
79
101
  point: function point(feature, crsIn, coordsIn, collection, properties) {
80
102
  this["default"](feature, crsIn, [coordsIn], collection, properties);
81
103
  },
@@ -101,7 +123,7 @@ var toFeature = {
101
123
  geometry.properties.style = new _Style["default"]({}, feature.style).setFromGeojsonProperties(properties, feature.type); // Then read contour and holes
102
124
 
103
125
  for (var i = 0; i < coordsIn.length; i++) {
104
- this.populateGeometry(crsIn, coordsIn[i], geometry, feature);
126
+ this.populateGeometryWithCCW(crsIn, coordsIn[i], geometry, feature);
105
127
  }
106
128
 
107
129
  feature.updateExtent(geometry);
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var THREE = _interopRequireWildcard(require("three"));
13
+
14
+ var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
15
+
16
+ var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
17
+
18
+ var _GDFParser = require("./GDFParser");
19
+
20
+ var _GTXParser = require("./GTXParser");
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
27
+
28
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
+
30
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
31
+
32
+ /**
33
+ * The `ISGParser` module provides a `[parse]{@link module:ISGParser.parse}` method. This method takes the content of a
34
+ * ISG file in, and returns a `{@link GeoidGrid}`. the `{@link GeoidGrid}` contains all the necessary attributes and
35
+ * methods to access the ISG data in iTowns.
36
+ *
37
+ * @module ISGParser
38
+ */
39
+ var _default = {
40
+ /**
41
+ * Parses an ISG file content and returns a corresponding `{@link GeoidGrid}`.
42
+ *
43
+ * @param {string} isg The content of the ISG file to parse.
44
+ * @param {Object} options An object gathering the optional parameters to pass to
45
+ * the parser.
46
+ * @param {Object} [options.in={}] Information on the ISG data.
47
+ * @param {string} [options.in.crs='EPSG:4326'] The Coordinates Reference System (CRS) of the ISG data.
48
+ * It must be a geographic CRS, and must be given as an EPSG
49
+ * code.
50
+ *
51
+ * @returns {Promise<GeoidGrid>} A promise resolving with a `{@link GeoidGrid}`, which contains all the necessary
52
+ * attributes and methods to access ISG file data.
53
+ */
54
+ parse: function parse(isg) {
55
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
56
+ "in": {}
57
+ };
58
+ var rows = isg.split('\n');
59
+ var firstMeasureLine = rows.indexOf(rows.find(function (row) {
60
+ return row.includes('end_of_head');
61
+ })) + 1;
62
+ var rawHeaderData = rows.slice(0, firstMeasureLine); // ---------- GET METADATA FROM THE FILE : ----------
63
+
64
+ var metadata = {
65
+ minX: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lon min'),
66
+ maxX: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lon max'),
67
+ minY: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lat min'),
68
+ maxY: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'lat max'),
69
+ stepX: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'delta lon'),
70
+ stepY: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'delta lat'),
71
+ nRows: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'nrows'),
72
+ nColumns: (0, _GDFParser.getHeaderAttribute)(rawHeaderData, 'ncols')
73
+ }; // ---------- BUILD A DATA VIEWER FROM THE TEXT DATA : ----------
74
+
75
+ var data = new DataView(new ArrayBuffer(_GTXParser.BYTES_PER_DOUBLE * metadata.nRows * metadata.nColumns));
76
+ var index = 0;
77
+
78
+ var _iterator = _createForOfIteratorHelper(rows.slice(firstMeasureLine, rows.length)),
79
+ _step;
80
+
81
+ try {
82
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
83
+ var row = _step.value;
84
+ row = row.split(' ').filter(function (value) {
85
+ return value !== '';
86
+ });
87
+
88
+ if (!row.length) {
89
+ continue;
90
+ }
91
+
92
+ var _iterator2 = _createForOfIteratorHelper(row),
93
+ _step2;
94
+
95
+ try {
96
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
97
+ var value = _step2.value;
98
+ data.setFloat64(index * _GTXParser.BYTES_PER_DOUBLE, parseFloat(value));
99
+ index++;
100
+ }
101
+ } catch (err) {
102
+ _iterator2.e(err);
103
+ } finally {
104
+ _iterator2.f();
105
+ }
106
+ } // ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
107
+
108
+ } catch (err) {
109
+ _iterator.e(err);
110
+ } finally {
111
+ _iterator.f();
112
+ }
113
+
114
+ var dataExtent = new _Extent["default"](options["in"].crs || 'EPSG:4326', metadata.minX + metadata.stepX / 2, metadata.maxX - metadata.stepX / 2, metadata.minY + metadata.stepY / 2, metadata.maxY - metadata.stepY / 2);
115
+ var dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
116
+ return Promise.resolve(new _GeoidGrid["default"](dataExtent, dataStep, function getData(verticalIndex, horizontalIndex) {
117
+ return data.getFloat64((metadata.nColumns * verticalIndex + horizontalIndex) * _GTXParser.BYTES_PER_DOUBLE);
118
+ }));
119
+ }
120
+ };
121
+ exports["default"] = _default;
@@ -56,7 +56,9 @@ var _default = {
56
56
  }
57
57
  }).then(function (parsedData) {
58
58
  var geometry = new THREE.BufferGeometry();
59
- geometry.userData = parsedData.loaderData.header;
59
+ geometry.userData = parsedData.loaderData;
60
+ geometry.userData.vertexCount = parsedData.header.vertexCount;
61
+ geometry.userData.boundingBox = parsedData.header.boundingBox;
60
62
  var positionBuffer = new THREE.BufferAttribute(parsedData.attributes.POSITION.value, 3, false);
61
63
  geometry.setAttribute('position', positionBuffer);
62
64
  var intensityBuffer = new THREE.BufferAttribute(parsedData.attributes.intensity.value, 1, true);
@@ -38,7 +38,8 @@ var firstPoint = new _three.Vector2(); // Classify option, it allows to classify
38
38
  function vtFeatureToFeatureGeometry(vtFeature, feature) {
39
39
  var classify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
40
40
  var geometry = feature.bindNewGeometry();
41
- classify = classify && feature.type === _Feature.FEATURE_TYPES.POLYGON;
41
+ var isPolygon = feature.type === _Feature.FEATURE_TYPES.POLYGON;
42
+ classify = classify && isPolygon;
42
43
  geometry.properties = vtFeature.properties;
43
44
  var pbf = vtFeature._pbf;
44
45
  pbf.pos = vtFeature._geometry;
@@ -85,7 +86,7 @@ function vtFeatureToFeatureGeometry(vtFeature, feature) {
85
86
  if (count == 1) {
86
87
  firstPoint.set(x, y);
87
88
  lastPoint.set(x, y);
88
- } else if (classify && count > 1) {
89
+ } else if (isPolygon && count > 1) {
89
90
  sum += (lastPoint.x - x) * (lastPoint.y + y);
90
91
  lastPoint.set(x, y);
91
92
  }
@@ -94,7 +95,7 @@ function vtFeatureToFeatureGeometry(vtFeature, feature) {
94
95
  count++;
95
96
  geometry.pushCoordinatesValues(feature, firstPoint.x, firstPoint.y);
96
97
 
97
- if (classify) {
98
+ if (isPolygon) {
98
99
  sum += (lastPoint.x - firstPoint.x) * (lastPoint.y + firstPoint.y);
99
100
  }
100
101
  }
@@ -5,8 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.computeMinMaxElevation = computeMinMaxElevation;
9
8
  exports.checkNodeElevationTextureValidity = checkNodeElevationTextureValidity;
9
+ exports.computeMinMaxElevation = computeMinMaxElevation;
10
10
  exports.insertSignificantValuesFromParent = insertSignificantValuesFromParent;
11
11
 
12
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -385,7 +385,7 @@ threeExamples.LegacyGLTFLoader = function () {
385
385
  5121: THREE.UnsignedByteType,
386
386
  32819: THREE.UnsignedShort4444Type,
387
387
  32820: THREE.UnsignedShort5551Type,
388
- 33635: THREE.UnsignedShort565Type
388
+ 33635: THREE.UnsignedShort5551Type
389
389
  };
390
390
  var WEBGL_SIDES = {
391
391
  1028: THREE.BackSide,
@@ -8,11 +8,11 @@ Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
  exports.$3dTilesCulling = $3dTilesCulling;
11
- exports.pre3dTilesUpdate = pre3dTilesUpdate;
11
+ exports.$3dTilesSubdivisionControl = $3dTilesSubdivisionControl;
12
12
  exports.computeNodeSSE = computeNodeSSE;
13
13
  exports.init3dTilesLayer = init3dTilesLayer;
14
+ exports.pre3dTilesUpdate = pre3dTilesUpdate;
14
15
  exports.process3dTilesNode = process3dTilesNode;
15
- exports.$3dTilesSubdivisionControl = $3dTilesSubdivisionControl;
16
16
 
17
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
18
18