itowns 2.44.3-next.40 → 2.44.3-next.42

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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,30 +0,0 @@
1
- import Source from "./Source.js";
2
- import Fetcher from "../Provider/Fetcher.js";
3
-
4
- /**
5
- * An object defining the source connection to a 3DTiles dataset from a web server.
6
- *
7
- * @extends Source
8
- *
9
- * @property {boolean} isC3DTilesSource - Used to checkout whether this source is a isC3DTilesSource. Default is
10
- * true. You should not change this, as it is used internally for optimisation.
11
- * @property {string} url - The URL of the tileset json.
12
- * @property {string} baseUrl - The base URL to access tiles.
13
- */
14
- class C3DTilesSource extends Source {
15
- /**
16
- * Create a new Source for 3D Tiles data from a web server.
17
- *
18
- * @extends Source
19
- *
20
- * @param {Object} source An object that can contain all properties of {@link Source}.
21
- * Only `url` is mandatory.
22
- */
23
- constructor(source) {
24
- super(source);
25
- this.isC3DTilesSource = true;
26
- this.baseUrl = this.url.slice(0, this.url.lastIndexOf('/') + 1);
27
- this.whenReady = Fetcher.json(this.url, this.networkOptions);
28
- }
29
- }
30
- export default C3DTilesSource;
@@ -1,126 +0,0 @@
1
- import proj4 from 'proj4';
2
- import { Binary, Info, Las } from 'copc';
3
- import Extent from "../Core/Geographic/Extent.js";
4
- import Fetcher from "../Provider/Fetcher.js";
5
- import LASParser from "../Parser/LASParser.js";
6
- import Source from "./Source.js";
7
- import * as THREE from 'three';
8
-
9
- /**
10
- * @param {function(number, number):Promise<Uint8Array>} fetcher
11
- */
12
- async function getHeaders(fetcher) {
13
- const header = Las.Header.parse(await fetcher(0, Las.Constants.minHeaderLength));
14
- const vlrs = await Las.Vlr.walk(fetcher, header);
15
-
16
- // info VLR: required by COPC
17
- const infoVlr = Las.Vlr.find(vlrs, 'copc', 1);
18
- if (!infoVlr) {
19
- return Promise.reject('COPC info VLR is required');
20
- }
21
- const info = Info.parse(await Las.Vlr.fetch(fetcher, infoVlr));
22
-
23
- // OGC Coordinate System WKT: required by LAS1.4
24
- const wktVlr = Las.Vlr.find(vlrs, 'LASF_Projection', 2112);
25
- if (!wktVlr) {
26
- return Promise.reject('LAS1.4 WKT VLR is required');
27
- }
28
- const wkt = Binary.toCString(await Las.Vlr.fetch(fetcher, wktVlr));
29
-
30
- // Extra bytes: optional by LAS1.4
31
- const ebVlr = Las.Vlr.find(vlrs, 'LASF_Spec', 4);
32
- const eb = ebVlr ? Las.ExtraBytes.parse(await Las.Vlr.fetch(fetcher, ebVlr)) : [];
33
- return {
34
- header,
35
- info,
36
- wkt,
37
- eb
38
- };
39
- }
40
-
41
- /**
42
- * A source for [Cloud Optimised Point Cloud](https://copc.io/) (COPC) data.
43
- * Such data consists of a [LAZ 1.4](https://www.ogc.org/standard/las/) file
44
- * that stores compressed points data organized in a clustered octree.
45
- *
46
- * A freshly created source fetches and parses portions of the file
47
- * corresponding to the LAS 1.4 header, all the Variable Length Record (VLR)
48
- * headers as well the following VLRs:
49
- * - COPC [`info`](https://copc.io/#info-vlr) record (mandatory)
50
- * - LAS 1.4 `OGC Coordinate System WKT` record (mandatory, see [Las 1.4
51
- * spec](https://portal.ogc.org/files/?artifact_id=74523))
52
- * - LAS 1.4 `Extra Bytes` record (optional, see [Las 1.4
53
- * spec](https://portal.ogc.org/files/?artifact_id=74523))
54
- *
55
- * @extends {Source}
56
- *
57
- * @property {boolean} isCopcSource - Read-only flag to check that a given
58
- * object is of type CopcSource.
59
- * @property {Object} header - LAS header of the source.
60
- * @property {Object[]} eb - List of headers of each Variable Length Records
61
- * (VLRs).
62
- * @property {Object} info - COPC `info` VLR.
63
- * @property {number[]} info.cube - Bounding box of the octree as a 6-elements.
64
- * tuple `[minX, minY, minZ, maxX, maxY, maxZ]`. Computed from `center_x`,
65
- * `center_y`, `center_z` and `halfSize` properties.
66
- * @property {Object} info.rootHierarchyPage - Hierarchy page of the root node.
67
- * @property {number} info.rootHierarchyPage.pageOffset - Absolute Offset to the
68
- * root node data chunk.
69
- * @property {number} info.rootHierarchyPage.pageOffset - Size (in bytes) of the
70
- * root node data chunk.
71
- * @property {number[]} gpsTimeRange - A 2-element tuple denoting the minimum
72
- * and maximum values of attribute `gpsTime`.
73
- */
74
- class CopcSource extends Source {
75
- /**
76
- * @param {Object} config - Source configuration
77
- * @param {string} config.url - URL of the COPC resource.
78
- * @param {8 | 16} [config.colorDepth=16] - Encoding of the `color`
79
- * attribute. Either `8` or `16` bits.
80
- * @param {string} [config._lazPerfBaseUrl] - (experimental) Overrides base
81
- * url of the `las-zip.wasm` file of the `laz-perf` library.
82
- * @param {string} [config.crs='EPSG:4326'] - Native CRS of the COPC
83
- * ressource. Note that this is not for now inferred from the COPC header.
84
- * @param {RequestInit} [config.networkOptions] - Fetch options (passed
85
- * directly to `fetch()`), see [the syntax for more information](
86
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
87
- * @param {Object} [config.attribution] - Attribution of the data.
88
- */
89
- constructor(config) {
90
- super(config);
91
- this.isCopcSource = true;
92
- this.parser = LASParser.parseChunk;
93
- this.fetcher = Fetcher.arrayBuffer;
94
- this.colorDepth = config.colorDepth ?? 16;
95
- const get = (/** @type {number} */begin, /** @type {number} */end) => this.fetcher(this.url, {
96
- ...this.networkOptions,
97
- headers: {
98
- ...this.networkOptions.headers,
99
- range: `bytes=${begin}-${end - 1}`
100
- }
101
- }).then(buffer => new Uint8Array(buffer));
102
- this.whenReady = getHeaders(get).then(metadata => {
103
- this.header = metadata.header;
104
- this.info = metadata.info;
105
- this.eb = metadata.eb;
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
- }
118
- const bbox = new THREE.Box3();
119
- bbox.min.fromArray(this.info.cube, 0);
120
- bbox.max.fromArray(this.info.cube, 3);
121
- this.extent = Extent.fromBox3(this.crs, bbox);
122
- return this;
123
- });
124
- }
125
- }
126
- export default CopcSource;
@@ -1,72 +0,0 @@
1
- import proj4 from 'proj4';
2
- import LASParser from "../Parser/LASParser.js";
3
- import PotreeBinParser from "../Parser/PotreeBinParser.js";
4
- import Fetcher from "../Provider/Fetcher.js";
5
- import Source from "./Source.js";
6
-
7
- /**
8
- * An object defining the source of Entwine Point Tile data. It fetches and
9
- * parses the main configuration file of Entwine Point Tile format,
10
- * [`ept.json`](https://entwine.io/entwine-point-tile.html#ept-json).
11
- *
12
- * @extends Source
13
- *
14
- * @property {boolean} isEntwinePointTileSource - Used to checkout whether this
15
- * source is a EntwinePointTileSource. Default is true. You should not change
16
- * this, as it is used internally for optimisation.
17
- * @property {string} url - The URL of the directory containing the whole
18
- * Entwine Point Tile structure.
19
- */
20
- class EntwinePointTileSource extends Source {
21
- /**
22
- * @param {Object} config - The configuration, see {@link Source} for
23
- * available values.
24
- * @param {number|string} [config.colorDepth='auto'] - Does the color
25
- * encoding is known ? Is it `8` or `16` bits ? By default it is to
26
- * `'auto'`, but it will be more performant if a specific value is set.
27
- */
28
- constructor(config) {
29
- super(config);
30
- this.isEntwinePointTileSource = true;
31
- this.colorDepth = config.colorDepth;
32
-
33
- // Necessary because we use the url without the ept.json part as a base
34
- this.url = this.url.replace('/ept.json', '');
35
-
36
- // https://entwine.io/entwine-point-tile.html#ept-json
37
- this.whenReady = Fetcher.json(`${this.url}/ept.json`, this.networkOptions).then(metadata => {
38
- // Set parser and its configuration from schema
39
- this.parse = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
40
- this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
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
- }
54
- }
55
- if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
56
- console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
57
- }
58
- }
59
-
60
- // NOTE: this spacing is kinda arbitrary here, we take the width and
61
- // length (height can be ignored), and we divide by the specified
62
- // span in ept.json. This needs improvements.
63
- this.spacing = (Math.abs(metadata.boundsConforming[3] - metadata.boundsConforming[0]) + Math.abs(metadata.boundsConforming[4] - metadata.boundsConforming[1])) / (2 * metadata.span);
64
- this.boundsConforming = metadata.boundsConforming;
65
- this.bounds = metadata.bounds;
66
- this.span = metadata.span;
67
- return this;
68
- });
69
- this.fetcher = Fetcher.arrayBuffer;
70
- }
71
- }
72
- export default EntwinePointTileSource;
@@ -1,188 +0,0 @@
1
- import Source from "./Source.js";
2
- import { LRUCache } from 'lru-cache';
3
-
4
- /**
5
- * An object defining the source of a single resource to get from a direct
6
- * access. It inherits from {@link Source}. There is multiple ways of adding a
7
- * resource here:
8
- * <ul>
9
- * <li>add the file like any other sources, using the `url` property.</li>
10
- * <li>fetch the file, and give the data to the source using the `fetchedData`
11
- * property.</li>
12
- * <li>fetch the file, parse it and git the parsed data to the source using the
13
- * `features` property.</li>
14
- * </ul>
15
- * See the examples below for real use cases.
16
- *
17
- * @extends Source
18
- *
19
- * @property {boolean} isFileSource - Used to checkout whether this source is a
20
- * FileSource. Default is true. You should not change this, as it is used
21
- * internally for optimisation.
22
- * @property {*} fetchedData - Once the file has been loaded, the resulting data
23
- * is stored in this property.
24
- * @property {*} features - Once the file has been loaded and parsed, the
25
- * resulting data is stored in this property.
26
- *
27
- * @example <caption>Simple: create a source, a layer, and let iTowns taking
28
- * care of everything.</caption>
29
- * const kmlSource = new itowns.FileSource({
30
- * url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',
31
- * crs: 'EPSG:4326',
32
- * fetcher: itowns.Fetcher.xml,
33
- * parser: itowns.KMLParser.parse,
34
- * });
35
- *
36
- * const kmlLayer = new itowns.ColorLayer('Kml', {
37
- * name: 'kml',
38
- * transparent: true,
39
- * crs: view.tileLayer.extent.crs,
40
- * source: kmlSource,
41
- * });
42
- *
43
- * view.addLayer(kmlLayer);
44
- *
45
- * @example <caption>Advanced: fetch some data, create a source, a layer, and
46
- * let iTowns do the parsing and converting.</caption>
47
- * // Parse and Convert by iTowns
48
- * itowns.Fetcher.xml('https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx')
49
- * .then(function _(gpx) {
50
- * const gpxSource = new itowns.FileSource({
51
- * data: gpx,
52
- * crs: 'EPSG:4326',
53
- * parser: itowns.GpxParser.parse,
54
- * });
55
- *
56
- * const gpxLayer = new itowns.ColorLayer('Gpx', {
57
- * name: 'Ultra 2009',
58
- * transparent: true,
59
- * source: gpxSource,
60
- * });
61
- *
62
- * return view.addLayer(gpxLayer);
63
- * });
64
- *
65
- * @example <caption>More advanced: create a layer, fetch some data, parse the
66
- * data, append a source to the layer and add the layer to iTowns.</caption>
67
- * // Create a layer
68
- * const ariege = new itowns.GeometryLayer('ariege', new itowns.THREE.Group());
69
- *
70
- * // Specify update method and conversion
71
- * ariege.update = itowns.FeatureProcessing.update;
72
- * ariege.convert = itowns.Feature2Mesh.convert({
73
- * color: () => new itowns.THREE.Color(0xffcc00),
74
- * extrude: () => 5000,
75
- * });
76
- *
77
- * itowns.Fetcher.json('https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson')
78
- * .then(function _(geojson) {
79
- * return itowns.GeoJsonParser.parse(geojson, {
80
- * in: { crs: 'EPSG:4326' },
81
- * out: { crs: view.tileLayer.extent.crs,
82
- * style: new itowns.Style({
83
- * fill: {
84
- * color: new itowns.THREE.Color(0xffcc00),
85
- * extrusion_height: () => 5000,
86
- * }),
87
- * },
88
- * },
89
- * });
90
- * }).then(function _(features) {
91
- * ariege.source = new itowns.FileSource({
92
- * crs: 'EPSG:4326',
93
- * features,
94
- * });
95
- *
96
- * return view.addLayer(ariegeLayer);
97
- * });
98
- */
99
- class FileSource extends Source {
100
- /**
101
- * @param {Object} source - An object that can contain all properties of a
102
- * FileSource and {@link Source}. Only `crs` is mandatory, but if it
103
- * presents in `features` under the property `crs`, it is fine.
104
- */
105
- constructor(source) {
106
- if (source.parsedData) {
107
- console.warn('FileSource parsedData parameter is deprecated, use features instead of.');
108
- source.features = source.features || source.parsedData;
109
- }
110
- if (source.projection) {
111
- console.warn('FileSource projection parameter is deprecated, use crs instead.');
112
- source.crs = source.crs || source.projection;
113
- }
114
- if (!source.crs) {
115
- if (source.features && source.features.crs) {
116
- source.crs = source.features.crs;
117
- } else {
118
- throw new Error('source.crs is required in FileSource');
119
- }
120
- }
121
- if (!source.url && !source.fetchedData && !source.features) {
122
- throw new Error(`url, fetchedData and features are not set in
123
- FileSource; at least one needs to be present`);
124
- }
125
-
126
- // the fake url is for when we use the fetchedData or features mode
127
- source.url = source.url || 'none';
128
- super(source);
129
- this.isFileSource = true;
130
- this.fetchedData = source.fetchedData;
131
- if (!this.fetchedData && !source.features) {
132
- this.whenReady = this.fetcher(this.urlFromExtent(), this.networkOptions).then(f => {
133
- this.fetchedData = f;
134
- });
135
- } else if (source.features) {
136
- this._featuresCaches[source.features.crs] = new LRUCache({
137
- max: 500
138
- });
139
- this._featuresCaches[source.features.crs].set(0, Promise.resolve(source.features));
140
- }
141
- this.whenReady.then(() => this.fetchedData);
142
- this.zoom = {
143
- min: 0,
144
- max: Infinity
145
- };
146
- }
147
- urlFromExtent() {
148
- return this.url;
149
- }
150
- onLayerAdded(options) {
151
- options.in = this;
152
- super.onLayerAdded(options);
153
- let features = this._featuresCaches[options.out.crs].get(0);
154
- if (!features) {
155
- options.out.buildExtent = this.crs != 'EPSG:4978';
156
- if (options.out.buildExtent) {
157
- options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : this.crs;
158
- }
159
- features = this.parser(this.fetchedData, options);
160
- this._featuresCaches[options.out.crs].set(0, features);
161
- }
162
- features.then(data => {
163
- if (data.extent) {
164
- this.extent = data.extent.clone();
165
- // Transform local extent to data.crs projection.
166
- if (this.extent.crs == data.crs) {
167
- this.extent.applyMatrix4(data.matrixWorld);
168
- }
169
- }
170
- });
171
- }
172
-
173
- /**
174
- * load data from cache or Fetch/Parse data.
175
- * The loaded data is a Feature or Texture.
176
- *
177
- * @param {Extent} extent extent requested parsed data.
178
- * @param {FeatureBuildingOptions|Layer} out The feature returned options
179
- * @return {FeatureCollection|Texture} The parsed data.
180
- */
181
- loadData(extent, out) {
182
- return this._featuresCaches[out.crs].get(0);
183
- }
184
- extentInsideLimit(extent) {
185
- return this.extent.intersectsExtent(extent);
186
- }
187
- }
188
- export default FileSource;
@@ -1,29 +0,0 @@
1
- import OGC3DTilesSource from "./OGC3DTilesSource.js";
2
- class OGC3DTilesGoogleSource extends OGC3DTilesSource {
3
- /**
4
- * An object defining the source connection to a 3D Tiles asset from [Google Tiles API](https://tile.googleapis.com).
5
- *
6
- * @extends OGC3DTilesSource
7
- *
8
- * @property {boolean} isOGC3DTilesGoogleSource - Used to check if this source is an OGC3DTilesGoogleSource. Set to true.
9
- * You should not change this, as it is used internally for optimisation.
10
- * @property {string} url - The URL to the tileset json.
11
- * @property {string} baseUrl - The base URL to access tiles.
12
- *
13
- * @property {boolean} isOGC3DTilesGoogleSource - Used to check if this source is an OGC3DTilesGoogleSource. Set to
14
- * true. You should not change this, as it is used internally for optimisation.
15
- * @param {Object} source An object that can contain all properties of an OGC3DTilesGoogleSource and {@link Source}.
16
- * @param {String} source.key Your google tiles map API access key
17
- */
18
- constructor(source) {
19
- if (!source.key) {
20
- throw new Error('[OGC3DTilesGoogleSource]: A API key for the google map tiles API is required');
21
- }
22
- // URL to the root tileset
23
- source.url = `https://tile.googleapis.com/v1/3dtiles/root.json?key=${source.key}`;
24
- super(source);
25
- this.isOGC3DTilesGoogleSource = true;
26
- this.key = source.key;
27
- }
28
- }
29
- export default OGC3DTilesGoogleSource;
@@ -1,34 +0,0 @@
1
- import OGC3DTilesSource from "./OGC3DTilesSource.js";
2
- class OGC3DTilesIonSource extends OGC3DTilesSource {
3
- /**
4
- * An object defining the source connection to a 3DTiles asset of a [Cesium ion server](https://cesium.com/learn/ion/).
5
- *
6
- * @extends Source
7
- *
8
- * @property {boolean} isOGC3DTilesIonSource - Used to check if this source is an OGC3DTilesIonSource. Set to true.
9
- * You should not change this, as it is used internally for optimisation.
10
- * @property {string} accessToken - The Cesium ion access token used to retrieve the resource.
11
- * @property {string} assetId - The id of the asset on Cesium ion.
12
- *
13
- * @param {Object} source An object that can contain all properties of an OGC3DTilesIonSource and {@link Source}.
14
- * Only `accessToken` and `assetId` are mandatory.
15
- * @param {string} source.accessToken - The Cesium ion access token used to retrieve the resource.
16
- * @param {string} source.assetId - The id of the asset on Cesium ion.
17
- */
18
- constructor(source) {
19
- if (!source.accessToken) {
20
- throw new Error('[OGC3DTilesIonSource]: accessToken is required');
21
- }
22
- if (!source.assetId) {
23
- throw new Error('[OGC3DTilesIonSource]: assetId is required');
24
- }
25
-
26
- // Url to query cesium ion the first time to retrieve metadata of the asset with assetId
27
- source.url = `https://api.cesium.com/v1/assets/${source.assetId}/endpoint?access_token=${source.accessToken}`;
28
- super(source);
29
- this.isOGC3DTilesIonSource = true;
30
- this.accessToken = source.accessToken;
31
- this.assetId = source.assetId;
32
- }
33
- }
34
- export default OGC3DTilesIonSource;
@@ -1,21 +0,0 @@
1
- import Source from "./Source.js";
2
- class OGC3DTilesSource extends Source {
3
- /**
4
- * An object defining the source connection to a 3DTiles dataset from a web server.
5
- *
6
- * @extends Source
7
- *
8
- * @property {boolean} isOGC3DTilesSource - Used to check if this source is an isOGC3DTilesSource. Set to true.
9
- * You should not change this, as it is used internally for optimisation.
10
- * @property {string} url - The URL of the tileset json.
11
- *
12
- * @param {Object} source An object that can contain all properties of OGC3DTilesSource and of {@link Source}.
13
- * Only `url` is mandatory.
14
- * @param {string} source.url - The URL of the tileset json.
15
- */
16
- constructor(source) {
17
- super(source);
18
- this.isOGC3DTilesSource = true;
19
- }
20
- }
21
- export default OGC3DTilesSource;
@@ -1,59 +0,0 @@
1
- import Source from "./Source.js";
2
- import Fetcher from "../Provider/Fetcher.js";
3
-
4
- /**
5
- * OrientedImageSource is a specific source used to load oriented images.
6
- * @extends Source
7
- */
8
- class OrientedImageSource extends Source {
9
- /**
10
- * @param { Object } source - Configuration object
11
- * @param { string } source.url - Url for all the textures.
12
- * @param { string } source.orientationsUrl - Json Url, using GeoJSon format to represent points,
13
- * it's a set of panoramic position and orientation.
14
- * @param { string } source.calibrationUrl - Json url, representing a set of camera.
15
- * see {@link CameraCalibrationParser}
16
- * This Url must contains {sensorId} and {cameraId}, and these pattern will be replaced to build the Url,
17
- * to find the good texture for each camera for each panoramic.
18
- */
19
- constructor(source) {
20
- super(source);
21
- this.isOrientedImageSource = true;
22
-
23
- // Fetch the two files
24
- const promises = [];
25
- promises.push(source.orientationsUrl ? Fetcher.json(source.orientationsUrl, this.networkOptions) : Promise.resolve());
26
- promises.push(source.calibrationUrl ? Fetcher.json(source.calibrationUrl, this.networkOptions) : Promise.resolve());
27
- this.whenReady = Promise.all(promises).then(data => ({
28
- orientation: data[0],
29
- calibration: data[1]
30
- }));
31
- }
32
-
33
- /**
34
- * Build the url of the texture, but not from extent.
35
- *
36
- * @param {Object} imageInfo - Information about the texture
37
- * @param {string} imageInfo.camera - Id of the camera
38
- * @param {string} imageInfo.pano - Id of the panoramic
39
- * @return {string} Url of the image
40
- */
41
- urlFromExtent(imageInfo) {
42
- return this.imageUrl(imageInfo.cameraId, imageInfo.panoId);
43
- }
44
- getDataKey(image) {
45
- return `c${image.cameraId}p${image.panoId}`;
46
- }
47
-
48
- /**
49
- * Build the url of the image, for a given panoramic id, and a given camera id.
50
- *
51
- * @param {string} cameraId Id of the camera
52
- * @param {string} panoId Id of the panoramic
53
- * @return {string} Url of the image
54
- */
55
- imageUrl(cameraId, panoId) {
56
- return this.url.replace('{cameraId}', cameraId).replace('{panoId}', panoId);
57
- }
58
- }
59
- export default OrientedImageSource;