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,167 +0,0 @@
1
- import Source from "./Source.js";
2
- import Fetcher from "../Provider/Fetcher.js";
3
- import Potree2BinParser from "../Parser/Potree2BinParser.js";
4
-
5
- /**
6
- * Potree2Source are object containing informations on how to fetch potree 2.0 points cloud resources.
7
- */
8
-
9
- class Potree2Source extends Source {
10
- /**
11
- * @param {Object} source - An object that can contain all properties of a
12
- * Potree2Source
13
- * @param {string} source.url - folder url.
14
- * @param {string} source.file - metadata file name.
15
- *
16
- * This `metadata` file stores information about the potree cloud 2.0 in JSON format. the structure is :
17
- *
18
- * * __`version`__ - The metadata.json format may change over time. The version number is
19
- * necessary so that parsers know how to interpret the data.
20
- * * __`name`__ - Point cloud name.
21
- * * __`description`__ - Point cloud description.
22
- * * __`points`__ - Total number of points.
23
- * * __`projection`__ - Point cloud geographic projection system.
24
- * * __`hierarchy`__ - Information about point cloud hierarchy (first chunk size, step size, octree depth).
25
- * * __`offset`__ - Position offset used to determine the global point position.
26
- * * __`scale`__ - Point cloud scale.
27
- * * __`spacing`__ - The minimum distance between points at root level.
28
- * * __`boundingBox`__ - Contains the minimum and maximum of the axis aligned bounding box. This bounding box is cubic and aligned to fit to the octree root.
29
- * * __`encoding`__ - Encoding type: BROTLI or DEFAULT (uncompressed).
30
- * * __`attributes`__ - Array of attributes (position, intensity, return number, number of returns, classification, scan angle rank, user data, point source id, gps-time, rgb).
31
- * ```
32
- * {
33
- * version: '2.0',
34
- * name: "sample",
35
- * description: "",
36
- * points: 534909153,
37
- * projection: "",
38
- * hierarchy: {
39
- * firstChunkSize: 1276,
40
- * stepSize: 4,
41
- * depth: 16
42
- * },
43
- * offset: [1339072.07, 7238866.339, 85.281],
44
- * scale: [0.001, 0.001, 0.002],
45
- * spacing: 24.476062500005355,
46
- * boundingBox: {
47
- * min: [1339072.07, 7238866.339, 85.281],
48
- * max: [1342205.0060000008, 7241999.275, 3218.2170000006854]
49
- * },
50
- * encoding: "BROTLI",
51
- * attributes: [
52
- * {
53
- * name: "position",
54
- * description: "",
55
- * size: 12,
56
- * numElements: 3,
57
- * elementSize: 4,
58
- * type: "int32",
59
- * min: [-0.74821299314498901, -2.7804059982299805, 2.5478212833404541],
60
- * max: [2.4514148223438199, 1.4893437627414672, 7.1957106576508663]
61
- * },
62
- * {
63
- * name: "intensity",
64
- * description: "",
65
- * size: 2,
66
- * numElements: 1,
67
- * elementSize: 2,
68
- * type: "uint16",
69
- * min: [0],
70
- * max: [0]
71
- * },{
72
- * name: "return number",
73
- * description: "",
74
- * size: 1,
75
- * numElements: 1,
76
- * elementSize: 1,
77
- * type: "uint8",
78
- * min: [0],
79
- * max: [0]
80
- * },{
81
- * name: "number of returns",
82
- * description: "",
83
- * size: 1,
84
- * numElements: 1,
85
- * elementSize: 1,
86
- * type: "uint8",
87
- * min: [0],
88
- * max: [0]
89
- * },{
90
- * name: "classification",
91
- * description: "",
92
- * size: 1,
93
- * numElements: 1,
94
- * elementSize: 1,
95
- * type: "uint8",
96
- * min: [0],
97
- * max: [0]
98
- * },{
99
- * name: "scan angle rank",
100
- * description: "",
101
- * size: 1,
102
- * numElements: 1,
103
- * elementSize: 1,
104
- * type: "uint8",
105
- * min: [0],
106
- * max: [0]
107
- * },{
108
- * name: "user data",
109
- * description: "",
110
- * size: 1,
111
- * numElements: 1,
112
- * elementSize: 1,
113
- * type: "uint8",
114
- * min: [0],
115
- * max: [0]
116
- * },{
117
- * name: "point source id",
118
- * description: "",
119
- * size: 2,
120
- * numElements: 1,
121
- * elementSize: 2,
122
- * type: "uint16",
123
- * min: [0],
124
- * max: [0]
125
- * },{
126
- * name: "gps-time",
127
- * description: "",
128
- * size: 8,
129
- * numElements: 1,
130
- * elementSize: 8,
131
- * type: "double",
132
- * min: [0],
133
- * max: [0]
134
- * },{
135
- * name: "rgb",
136
- * description: "",
137
- * size: 6,
138
- * numElements: 3,
139
- * elementSize: 2,
140
- * type: "uint16",
141
- * min: [5632, 5376, 4864],
142
- * max: [65280, 65280, 65280]
143
- * }
144
- * ]
145
- * }
146
- * ```
147
- *
148
- * @extends Source
149
- */
150
- constructor(source) {
151
- if (!source.file) {
152
- throw new Error('New Potree2Source: file is required');
153
- }
154
- super(source);
155
- this.file = source.file;
156
- this.fetcher = Fetcher.arrayBuffer;
157
- this.whenReady = (source.metadata ? Promise.resolve(source.metadata) : Fetcher.json(`${this.url}/${this.file}`, this.networkOptions)).then(metadata => {
158
- this.metadata = metadata;
159
- this.pointAttributes = metadata.attributes;
160
- this.baseurl = `${this.url}`;
161
- this.extension = 'bin';
162
- this.parser = Potree2BinParser.parse;
163
- return metadata;
164
- });
165
- }
166
- }
167
- export default Potree2Source;
@@ -1,82 +0,0 @@
1
- import Source from "./Source.js";
2
- import Fetcher from "../Provider/Fetcher.js";
3
- import PotreeBinParser from "../Parser/PotreeBinParser.js";
4
- import PotreeCinParser from "../Parser/PotreeCinParser.js";
5
-
6
- /**
7
- * PotreeSource are object containing informations on how to fetch points cloud resources.
8
- */
9
-
10
- class PotreeSource extends Source {
11
- /**
12
- * @param {Object} source - An object that can contain all properties of a
13
- * PotreeSource
14
- * @param {string} source.url - folder url.
15
- * @param {string} source.file - cloud file name.
16
- *
17
- * This `cloud` file stores information about the potree cloud in JSON format. the structure is :
18
- *
19
- * * __`version`__ - The cloud.js format may change over time. The version number is
20
- * necessary so that parsers know how to interpret the data.
21
- * * __`octreeDir`__ - Directory or URL where node data is stored. Usually points to
22
- * "data".
23
- * * __`boundingBox`__ - Contains the minimum and maximum of the axis aligned bounding box. This bounding box is cubic and aligned to fit to the octree root.
24
- * * __`tightBoundingBox`__ - This bounding box thightly fits the point data.
25
- * * __`pointAttributes`__ - Declares the point data format. May be 'LAS', 'LAZ' or in case if the BINARY format an array of attributes like
26
- * `['POSITION_CARTESIAN', 'COLOR_PACKED', 'INTENSITY']`
27
- * * __`POSITION_CARTESIAN`__ - 3 x 32bit signed integers for x/y/z coordinates
28
- * * __`COLOR_PACKED`__ - 4 x unsigned byte for r,g,b,a colors.
29
- * * __`spacing`__ - The minimum distance between points at root level.
30
- * ```
31
- * {
32
- * version: '1.6',
33
- * octreeDir: 'data',
34
- * boundingBox: {
35
- * lx: -4.9854,
36
- * ly: 1.0366,
37
- * lz: -3.4494,
38
- * ux: 0.702300000000001,
39
- * uy: 6.7243,
40
- * uz: 2.2383
41
- * },
42
- * tightBoundingBox: {
43
- * lx: -4.9854,
44
- * ly: 1.0375,
45
- * lz: -3.4494,
46
- * ux: -0.7889,
47
- * uy: 6.7243,
48
- * uz: 1.1245
49
- * },
50
- * pointAttributes: [
51
- * 'POSITION_CARTESIAN',
52
- * 'COLOR_PACKED'
53
- * ],
54
- * spacing: 0.03,
55
- * scale: 0.001,
56
- * hierarchyStepSize: 5
57
- * }
58
- * ```
59
- *
60
- * @extends Source
61
- */
62
- constructor(source) {
63
- if (!source.file) {
64
- throw new Error('New PotreeSource: file is required');
65
- }
66
- super(source);
67
- this.file = source.file;
68
- this.fetcher = Fetcher.arrayBuffer;
69
- this.extensionOctree = 'hrc';
70
-
71
- // For cloud specification visit:
72
- // https://github.com/PropellerAero/potree-propeller-private/blob/master/docs/file_format.md#cloudjs
73
- this.whenReady = (source.cloud ? Promise.resolve(source.cloud) : Fetcher.json(`${this.url}/${this.file}`, this.networkOptions)).then(cloud => {
74
- this.pointAttributes = cloud.pointAttributes;
75
- this.baseurl = `${this.url}/${cloud.octreeDir}/r`;
76
- this.extension = cloud.pointAttributes === 'CIN' ? 'cin' : 'bin';
77
- this.parse = this.extension === 'cin' ? PotreeCinParser.parse : PotreeBinParser.parse;
78
- return cloud;
79
- });
80
- }
81
- }
82
- export default PotreeSource;
@@ -1,203 +0,0 @@
1
- import * as CRS from "../Core/Geographic/Crs.js";
2
- import Extent from "../Core/Geographic/Extent.js";
3
- import GeoJsonParser from "../Parser/GeoJsonParser.js";
4
- import KMLParser from "../Parser/KMLParser.js";
5
- import GDFParser from "../Parser/GDFParser.js";
6
- import GpxParser from "../Parser/GpxParser.js";
7
- import GTXParser from "../Parser/GTXParser.js";
8
- import ISGParser from "../Parser/ISGParser.js";
9
- import VectorTileParser from "../Parser/VectorTileParser.js";
10
- import Fetcher from "../Provider/Fetcher.js";
11
- // import Cache from 'Core/Scheduler/Cache';
12
- import { LRUCache } from 'lru-cache';
13
-
14
- /** @private */
15
- export const supportedParsers = new Map([['application/geo+json', GeoJsonParser.parse], ['application/json', GeoJsonParser.parse], ['application/kml', KMLParser.parse], ['application/gpx', GpxParser.parse], ['application/x-protobuf;type=mapbox-vector', VectorTileParser.parse], ['application/gtx', GTXParser.parse], ['application/isg', ISGParser.parse], ['application/gdf', GDFParser.parse]]);
16
- const noCache = {
17
- get: () => {},
18
- set: a => a,
19
- clear: () => {}
20
- };
21
-
22
- /**
23
- * This interface describes parsing options.
24
- * @typedef {Object} ParsingOptions
25
- * @property {Source} in - data informations contained in the file.
26
- * @property {FeatureBuildingOptions|Layer} out - options indicates how the features should be built.
27
- */
28
-
29
- let uid = 0;
30
-
31
- /**
32
- * Sources are object containing informations on how to fetch resources, from a
33
- * set source.
34
- *
35
- * To extend a Source, it is necessary to implement two functions:
36
- * `urlFromExtent` and `extentInsideLimit`.
37
- *
38
- * @extends InformationsData
39
- *
40
- * @property {boolean} isSource - Used to checkout whether this source is a
41
- * Source. Default is true. You should not change this, as it is used internally
42
- * for optimisation.
43
- * @property {number} uid - Unique uid mainly used to store data linked to this
44
- * source into Cache.
45
- * @property {string} url - The url of the resources that are fetched.
46
- * @property {string} format - The format of the resources that are fetched.
47
- * @property {function} fetcher - The method used to fetch the resources from
48
- * the source. iTowns provides some methods in {@link Fetcher}, but it can be
49
- * specified a custom one. This method should return a `Promise` containing the
50
- * fetched resource. If this property is set, it overrides the chosen fetcher
51
- * method with `format`.
52
- * @property {Object} networkOptions - Fetch options (passed directly to
53
- * `fetch()`), see [the syntax for more information](
54
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
55
- * By default, set to `{ crossOrigin: 'anonymous' }`.
56
- * @property {string} crs - The crs projection of the resources.
57
- * @property {string} attribution - The intellectual property rights for the
58
- * resources.
59
- * @property {Extent} extent - The extent of the resources.
60
- * @property {function} parser - The method used to parse the resources attached
61
- * to the layer. iTowns provides some parsers, visible in the `Parser/` folder.
62
- * If the method is custom, it should return a `Promise` containing the parsed
63
- * resource. If this property is set, it overrides the default selected parser
64
- * method with `source.format`. If `source.format` is also empty, no parsing
65
- * action is done.
66
- * <br><br>
67
- * When calling this method, two parameters are passed:
68
- * <ul>
69
- * <li>the fetched data, i.e. the data to parse</li>
70
- * <li>an {@link ParsingOptions} containing severals properties, set when this method is
71
- * called: it is specific to each call, so the value of each property can vary
72
- * depending on the current fetched tile for example</li>
73
- * </ul>
74
- */
75
- class Source {
76
- /**
77
- * @param {Object} source - An object that can contain all properties of a
78
- * Source. Only the `url` property is mandatory.
79
- */
80
- constructor(source) {
81
- if (source.projection) {
82
- console.warn('Source projection parameter is deprecated, use crs instead.');
83
- source.crs = source.crs || source.projection;
84
- }
85
- if (source.crs) {
86
- CRS.isValid(source.crs);
87
- }
88
- this.crs = source.crs;
89
- this.isSource = true;
90
- if (!source.url) {
91
- throw new Error('New Source: url is required');
92
- }
93
- this.uid = uid++;
94
- this.url = source.url;
95
- this.format = source.format;
96
- this.fetcher = source.fetcher || Fetcher.get(source.format);
97
- this.parser = source.parser || supportedParsers.get(source.format) || ((d, opt) => {
98
- d.extent = opt.extent;
99
- return d;
100
- });
101
- this.isVectorSource = (source.parser || supportedParsers.get(source.format)) != undefined;
102
- this.networkOptions = source.networkOptions || {
103
- crossOrigin: 'anonymous'
104
- };
105
- this.attribution = source.attribution;
106
- /** @type {Promise<any>} */
107
- this.whenReady = Promise.resolve();
108
- this._featuresCaches = {};
109
- if (source.extent && !source.extent.isExtent) {
110
- this.extent = new Extent(this.crs).setFromExtent(source.extent);
111
- } else {
112
- this.extent = source.extent;
113
- }
114
- }
115
- handlingError(err) {
116
- throw new Error(err);
117
- }
118
-
119
- /**
120
- * Generates an url from an extent. This url is a link to fetch the
121
- * resources inside the extent.
122
- *
123
- * @param {Extent} extent - Extent to convert in url.
124
- * @return {string} The URL constructed from the extent.
125
- */
126
- // eslint-disable-next-line
127
- urlFromExtent() {
128
- throw new Error('In extended Source, you have to implement the method urlFromExtent!');
129
- }
130
- getDataKey(extent) {
131
- return `z${extent.zoom}r${extent.row}c${extent.col}`;
132
- }
133
-
134
- /**
135
- * Load data from cache or Fetch/Parse data.
136
- * The loaded data is a Feature or Texture.
137
- *
138
- * @param {Extent} extent extent requested parsed data.
139
- * @param {FeatureBuildingOptions|Layer} out The feature returned options
140
- * @return {FeatureCollection|Texture} The parsed data.
141
- */
142
- loadData(extent, out) {
143
- const cache = this._featuresCaches[out.crs];
144
- const key = this.getDataKey(extent);
145
- // console.log('Source.loadData', key);
146
- // try to get parsed data from cache
147
- let features = cache.get(key);
148
- if (!features) {
149
- // otherwise fetch/parse the data
150
- features = this.fetcher(this.urlFromExtent(extent), this.networkOptions).then(file => this.parser(file, {
151
- out,
152
- in: this,
153
- extent
154
- })).catch(err => this.handlingError(err));
155
- cache.set(key, features);
156
- }
157
- return features;
158
- }
159
-
160
- /**
161
- * Called when layer added.
162
- *
163
- * @param {object} options
164
- */
165
- onLayerAdded(options) {
166
- // Added new cache by crs
167
- if (!this._featuresCaches[options.out.crs]) {
168
- // Cache feature only if it's vector data, the feature are cached in source.
169
- // It's not necessary to cache raster in Source,
170
- // because it's already cached on layer.
171
- this._featuresCaches[options.out.crs] = this.isVectorSource ? new LRUCache({
172
- max: 500
173
- }) : noCache;
174
- }
175
- }
176
-
177
- /**
178
- * Called when layer removed.
179
- *
180
- * @param {options} [options={}] options
181
- */
182
- onLayerRemoved() {
183
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
184
- // delete unused cache
185
- const unusedCache = this._featuresCaches[options.unusedCrs];
186
- if (unusedCache) {
187
- unusedCache.clear();
188
- delete this._featuresCaches[options.unusedCrs];
189
- }
190
- }
191
-
192
- /**
193
- * Tests if an extent is inside the source limits.
194
- *
195
- * @param {Extent} extent - Extent to test.
196
- * @return {boolean} True if the extent is inside the limit, false otherwise.
197
- */
198
- // eslint-disable-next-line
199
- extentInsideLimit() {
200
- throw new Error('In extented Source, you have to implement the method extentInsideLimit!');
201
- }
202
- }
203
- export default Source;
@@ -1,144 +0,0 @@
1
- import Source from "./Source.js";
2
- import URLBuilder from "../Provider/URLBuilder.js";
3
- import Extent from "../Core/Geographic/Extent.js";
4
- import Tile from "../Core/Tile/Tile.js";
5
- import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
6
- const _tile = new Tile('EPSG:4326', 0, 0, 0);
7
-
8
- /**
9
- * An object defining the source of resources to get from a
10
- * [TMS](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification) server.
11
- * It inherits from {@link Source}.
12
- *
13
- * @extends Source
14
- *
15
- * @property {boolean} isTMSSource - Used to checkout whether this source is a
16
- * TMSSource. Default is true. You should not change this, as it is used
17
- * internally for optimisation.
18
- * @property {boolean} isInverted - The isInverted property is to be set to the
19
- * correct value, true or false (default being false) if the computation of the
20
- * coordinates needs to be inverted to match the same scheme as OSM, Google Maps
21
- * or other system. See [this link](
22
- * https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/)
23
- * for more information.
24
- * @property {Object} tileMatrixSetLimits - it describes the available tile for this layer
25
- * @property {Object} extentSetlimits - these are the extents of the set of identical zoom tiles.
26
- * @property {Object} zoom - Object containing the minimum and maximum values of
27
- * the level, to zoom in the source.
28
- * @property {number} zoom.min - The minimum level of the source. Default value
29
- * is 0.
30
- * @property {number} zoom.max - The maximum level of the source. Default value
31
- * is 20.
32
- * @property {function} tileMatrixCallback - a method that create a TileMatrix
33
- * identifier from the zoom level. For example, if set to `(zoomLevel) => 'EPSG:4326:' + zoomLevel`,
34
- * the TileMatrix that will be fetched at zoom level 5 will be the one with identifier `EPSG:4326:5`.
35
- * By default, the method returns the input zoom level.
36
- *
37
- * @example <caption><b>Source from OpenStreetMap server :</b></caption>
38
- * // Create the source
39
- * const tmsSource = new itowns.TMSSource({
40
- * format: 'image/png',
41
- * url: 'http://osm.io/styles/${z}/${x}/${y}.png',
42
- * attribution: {
43
- * name: 'OpenStreetMap',
44
- * url: 'http://www.openstreetmap.org/',
45
- * },
46
- * crs: 'EPSG:3857',
47
- * });
48
- *
49
- * // Create the layer
50
- * const colorLayer = new itowns.ColorLayer('OPENSM', {
51
- * source: tmsSource,
52
- * });
53
- *
54
- * // Add the layer
55
- * view.addLayer(colorLayer);
56
- *
57
- * @example <caption><b>Source from Mapbox server :</b></caption>
58
- * // Create the source
59
- * const orthoSource = new itowns.TMSSource({
60
- * url: 'https://api.mapbox.com/v4/mapbox.satellite/${z}/${x}/${y}.jpg?access_token=' + accessToken,
61
- * crs: 'EPSG:3857',
62
- * };
63
- *
64
- * // Create the layer
65
- * const imageryLayer = new itowns.ColorLayer("Ortho", {
66
- * source: orthoSource,
67
- * };
68
- *
69
- * // Add the layer to the view
70
- * view.addLayer(imageryLayer);
71
- */
72
- class TMSSource extends Source {
73
- /**
74
- * @param {Object} source - An object that can contain all properties of a
75
- * TMSSource and {@link Source}. Only `url` is mandatory.
76
- */
77
- constructor(source) {
78
- source.format = source.format || 'image/png';
79
- super(source);
80
- if (!source.crs) {
81
- throw new Error('New TMSSource/WMTSSource: crs is required');
82
- }
83
- this.isTMSSource = true;
84
- if (!source.extent) {
85
- // default to the global extent
86
- this.extent = globalExtentTMS.get(source.crs);
87
- }
88
- this.zoom = source.zoom;
89
- this.isInverted = source.isInverted || false;
90
- this.crs = source.crs;
91
- this.tileMatrixSetLimits = source.tileMatrixSetLimits;
92
- this.extentSetlimits = {};
93
- this.tileMatrixCallback = source.tileMatrixCallback || (zoomLevel => zoomLevel);
94
- if (!this.zoom) {
95
- if (this.tileMatrixSetLimits) {
96
- const arrayLimits = Object.keys(this.tileMatrixSetLimits);
97
- const size = arrayLimits.length;
98
- const maxZoom = Number(arrayLimits[size - 1]);
99
- this.zoom = {
100
- min: maxZoom - size + 1,
101
- max: maxZoom
102
- };
103
- } else {
104
- this.zoom = {
105
- min: 0,
106
- max: Infinity
107
- };
108
- }
109
- }
110
- }
111
- urlFromExtent(tile) {
112
- return URLBuilder.xyz(tile, this);
113
- }
114
- onLayerAdded(options) {
115
- super.onLayerAdded(options);
116
- // Build extents of the set of identical zoom tiles.
117
- const parent = options.out.parent;
118
- // The extents crs is chosen to facilitate in raster tile process.
119
- const crs = parent ? parent.extent.crs : options.out.crs;
120
- if (this.tileMatrixSetLimits && !this.extentSetlimits[crs]) {
121
- this.extentSetlimits[crs] = {};
122
- _tile.crs = this.crs;
123
- for (let i = this.zoom.max; i >= this.zoom.min; i--) {
124
- const tmsl = this.tileMatrixSetLimits[i];
125
- const {
126
- west,
127
- north
128
- } = _tile.set(i, tmsl.minTileRow, tmsl.minTileCol).toExtent(crs);
129
- const {
130
- east,
131
- south
132
- } = _tile.set(i, tmsl.maxTileRow, tmsl.maxTileCol).toExtent(crs);
133
- this.extentSetlimits[crs][i] = new Extent(crs, west, east, south, north);
134
- }
135
- }
136
- }
137
- extentInsideLimit(extent, zoom) {
138
- // This layer provides data starting at level = layer.source.zoom.min
139
- // (the zoom.max property is used when building the url to make
140
- // sure we don't use invalid levels)
141
- return zoom >= this.zoom.min && zoom <= this.zoom.max && (this.extentSetlimits[extent.crs] == undefined || this.extentSetlimits[extent.crs][zoom].intersectsExtent(extent));
142
- }
143
- }
144
- export default TMSSource;