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