itowns 2.44.3-next.8 → 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 (219) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  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/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -615
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -534
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/Tile/Tile.js +0 -219
  100. package/lib/Core/Tile/TileGrid.js +0 -46
  101. package/lib/Core/TileGeometry.js +0 -40
  102. package/lib/Core/TileMesh.js +0 -109
  103. package/lib/Core/View.js +0 -1109
  104. package/lib/Layer/C3DTilesLayer.js +0 -455
  105. package/lib/Layer/ColorLayer.js +0 -128
  106. package/lib/Layer/CopcLayer.js +0 -58
  107. package/lib/Layer/ElevationLayer.js +0 -107
  108. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  109. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  110. package/lib/Layer/GeoidLayer.js +0 -80
  111. package/lib/Layer/GeometryLayer.js +0 -202
  112. package/lib/Layer/InfoLayer.js +0 -64
  113. package/lib/Layer/LabelLayer.js +0 -456
  114. package/lib/Layer/Layer.js +0 -304
  115. package/lib/Layer/LayerUpdateState.js +0 -89
  116. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  117. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  118. package/lib/Layer/OrientedImageLayer.js +0 -222
  119. package/lib/Layer/PointCloudLayer.js +0 -359
  120. package/lib/Layer/Potree2Layer.js +0 -164
  121. package/lib/Layer/PotreeLayer.js +0 -65
  122. package/lib/Layer/RasterLayer.js +0 -27
  123. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  124. package/lib/Layer/TiledGeometryLayer.js +0 -403
  125. package/lib/Loader/LASLoader.js +0 -193
  126. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  127. package/lib/Loader/Potree2Loader.js +0 -207
  128. package/lib/Main.js +0 -115
  129. package/lib/MainBundle.js +0 -4
  130. package/lib/Parser/B3dmParser.js +0 -174
  131. package/lib/Parser/CameraCalibrationParser.js +0 -94
  132. package/lib/Parser/GDFParser.js +0 -72
  133. package/lib/Parser/GTXParser.js +0 -75
  134. package/lib/Parser/GeoJsonParser.js +0 -212
  135. package/lib/Parser/GpxParser.js +0 -25
  136. package/lib/Parser/ISGParser.js +0 -71
  137. package/lib/Parser/KMLParser.js +0 -25
  138. package/lib/Parser/LASParser.js +0 -137
  139. package/lib/Parser/MapBoxUrlParser.js +0 -83
  140. package/lib/Parser/PntsParser.js +0 -131
  141. package/lib/Parser/Potree2BinParser.js +0 -92
  142. package/lib/Parser/PotreeBinParser.js +0 -106
  143. package/lib/Parser/PotreeCinParser.js +0 -29
  144. package/lib/Parser/ShapefileParser.js +0 -78
  145. package/lib/Parser/VectorTileParser.js +0 -202
  146. package/lib/Parser/XbilParser.js +0 -119
  147. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  148. package/lib/Parser/iGLTFLoader.js +0 -168
  149. package/lib/Process/3dTilesProcessing.js +0 -304
  150. package/lib/Process/FeatureProcessing.js +0 -76
  151. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  152. package/lib/Process/ObjectRemovalHelper.js +0 -97
  153. package/lib/Process/handlerNodeError.js +0 -23
  154. package/lib/Provider/3dTilesProvider.js +0 -149
  155. package/lib/Provider/DataSourceProvider.js +0 -8
  156. package/lib/Provider/Fetcher.js +0 -229
  157. package/lib/Provider/PointCloudProvider.js +0 -45
  158. package/lib/Provider/TileProvider.js +0 -16
  159. package/lib/Provider/URLBuilder.js +0 -116
  160. package/lib/Renderer/Camera.js +0 -281
  161. package/lib/Renderer/Color.js +0 -56
  162. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  163. package/lib/Renderer/CommonMaterial.js +0 -31
  164. package/lib/Renderer/Label2DRenderer.js +0 -190
  165. package/lib/Renderer/LayeredMaterial.js +0 -243
  166. package/lib/Renderer/OBB.js +0 -153
  167. package/lib/Renderer/OrientedImageCamera.js +0 -118
  168. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  169. package/lib/Renderer/PointsMaterial.js +0 -485
  170. package/lib/Renderer/RasterTile.js +0 -209
  171. package/lib/Renderer/RenderMode.js +0 -31
  172. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  173. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  174. package/lib/Renderer/SphereHelper.js +0 -23
  175. package/lib/Renderer/WebXR.js +0 -51
  176. package/lib/Renderer/c3DEngine.js +0 -214
  177. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  178. package/lib/Source/C3DTilesIonSource.js +0 -54
  179. package/lib/Source/C3DTilesSource.js +0 -30
  180. package/lib/Source/CopcSource.js +0 -115
  181. package/lib/Source/EntwinePointTileSource.js +0 -62
  182. package/lib/Source/FileSource.js +0 -189
  183. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  184. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  185. package/lib/Source/OGC3DTilesSource.js +0 -21
  186. package/lib/Source/OrientedImageSource.js +0 -59
  187. package/lib/Source/Potree2Source.js +0 -167
  188. package/lib/Source/PotreeSource.js +0 -82
  189. package/lib/Source/Source.js +0 -223
  190. package/lib/Source/TMSSource.js +0 -145
  191. package/lib/Source/VectorTilesSource.js +0 -178
  192. package/lib/Source/WFSSource.js +0 -168
  193. package/lib/Source/WMSSource.js +0 -133
  194. package/lib/Source/WMTSSource.js +0 -86
  195. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  196. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  197. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  198. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  199. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  200. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  201. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  202. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  203. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  204. package/lib/Utils/CameraUtils.js +0 -555
  205. package/lib/Utils/DEMUtils.js +0 -350
  206. package/lib/Utils/FeaturesUtils.js +0 -156
  207. package/lib/Utils/Gradients.js +0 -16
  208. package/lib/Utils/OrientationUtils.js +0 -457
  209. package/lib/Utils/ThreeUtils.js +0 -115
  210. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  211. package/lib/Utils/gui/Main.js +0 -7
  212. package/lib/Utils/gui/Minimap.js +0 -154
  213. package/lib/Utils/gui/Navigation.js +0 -245
  214. package/lib/Utils/gui/Scale.js +0 -107
  215. package/lib/Utils/gui/Searchbar.js +0 -234
  216. package/lib/Utils/gui/Widget.js +0 -80
  217. package/lib/Utils/placeObjectOnGround.js +0 -137
  218. package/lib/Worker/LASLoaderWorker.js +0 -19
  219. 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,223 +0,0 @@
1
- import Extent from "../Core/Geographic/Extent.js";
2
- import GeoJsonParser from "../Parser/GeoJsonParser.js";
3
- import KMLParser from "../Parser/KMLParser.js";
4
- import GDFParser from "../Parser/GDFParser.js";
5
- import GpxParser from "../Parser/GpxParser.js";
6
- import GTXParser from "../Parser/GTXParser.js";
7
- import ISGParser from "../Parser/ISGParser.js";
8
- import VectorTileParser from "../Parser/VectorTileParser.js";
9
- import Fetcher from "../Provider/Fetcher.js";
10
- import Cache from "../Core/Scheduler/Cache.js";
11
- import CRS from "../Core/Geographic/Crs.js";
12
-
13
- /** @private */
14
- 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]]);
15
- const noCache = {
16
- getByArray: () => {},
17
- setByArray: a => a,
18
- clear: () => {}
19
- };
20
-
21
- /**
22
- * @property {string} crs - data crs projection.
23
- * @property {boolean} isInverted - This option is to be set to the
24
- * correct value, true or false (default being false), if the computation of
25
- * the coordinates needs to be inverted to same scheme as OSM, Google Maps
26
- * or other system. See [this link](
27
- * https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates)
28
- * for more informations.
29
- *
30
- */
31
- class InformationsData {
32
- constructor(options) {
33
- /* istanbul ignore next */
34
- if (options.projection) {
35
- console.warn('Source projection parameter is deprecated, use crs instead.');
36
- options.crs = options.crs || options.projection;
37
- }
38
- if (options.crs) {
39
- CRS.isValid(options.crs);
40
- }
41
- this.crs = options.crs;
42
- }
43
- }
44
- /**
45
- * This interface describes parsing options.
46
- * @typedef {Object} ParsingOptions
47
- * @property {Source} in - data informations contained in the file.
48
- * @property {FeatureBuildingOptions|Layer} out - options indicates how the features should be built.
49
- */
50
-
51
- let uid = 0;
52
-
53
- /**
54
- * Sources are object containing informations on how to fetch resources, from a
55
- * set source.
56
- *
57
- * To extend a Source, it is necessary to implement two functions:
58
- * `urlFromExtent` and `extentInsideLimit`.
59
- *
60
- * @extends InformationsData
61
- *
62
- * @property {boolean} isSource - Used to checkout whether this source is a
63
- * Source. Default is true. You should not change this, as it is used internally
64
- * for optimisation.
65
- * @property {number} uid - Unique uid mainly used to store data linked to this
66
- * source into Cache.
67
- * @property {string} url - The url of the resources that are fetched.
68
- * @property {string} format - The format of the resources that are fetched.
69
- * @property {function} fetcher - The method used to fetch the resources from
70
- * the source. iTowns provides some methods in {@link Fetcher}, but it can be
71
- * specified a custom one. This method should return a `Promise` containing the
72
- * fetched resource. If this property is set, it overrides the chosen fetcher
73
- * method with `format`.
74
- * @property {Object} networkOptions - Fetch options (passed directly to
75
- * `fetch()`), see [the syntax for more information](
76
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
77
- * By default, set to `{ crossOrigin: 'anonymous' }`.
78
- * @property {string} crs - The crs projection of the resources.
79
- * @property {string} attribution - The intellectual property rights for the
80
- * resources.
81
- * @property {Extent} extent - The extent of the resources.
82
- * @property {function} parser - The method used to parse the resources attached
83
- * to the layer. iTowns provides some parsers, visible in the `Parser/` folder.
84
- * If the method is custom, it should return a `Promise` containing the parsed
85
- * resource. If this property is set, it overrides the default selected parser
86
- * method with `source.format`. If `source.format` is also empty, no parsing
87
- * action is done.
88
- * <br><br>
89
- * When calling this method, two parameters are passed:
90
- * <ul>
91
- * <li>the fetched data, i.e. the data to parse</li>
92
- * <li>an {@link ParsingOptions} containing severals properties, set when this method is
93
- * called: it is specific to each call, so the value of each property can vary
94
- * depending on the current fetched tile for example</li>
95
- * </ul>
96
- */
97
- class Source extends InformationsData {
98
- /**
99
- * @param {Object} source - An object that can contain all properties of a
100
- * Source. Only the `url` property is mandatory.
101
- */
102
- constructor(source) {
103
- super(source);
104
- this.isSource = true;
105
- if (!source.url) {
106
- throw new Error('New Source: url is required');
107
- }
108
- this.uid = uid++;
109
- this.url = source.url;
110
- this.format = source.format;
111
- this.fetcher = source.fetcher || Fetcher.get(source.format);
112
- this.parser = source.parser || supportedParsers.get(source.format) || ((d, opt) => {
113
- d.extent = opt.extent;
114
- return d;
115
- });
116
- this.isVectorSource = (source.parser || supportedParsers.get(source.format)) != undefined;
117
- this.networkOptions = source.networkOptions || {
118
- crossOrigin: 'anonymous'
119
- };
120
- this.attribution = source.attribution;
121
- /** @type {Promise<any>} */
122
- this.whenReady = Promise.resolve();
123
- this._featuresCaches = {};
124
- if (source.extent && !source.extent.isExtent) {
125
- this.extent = new Extent(this.crs, source.extent);
126
- } else {
127
- this.extent = source.extent;
128
- }
129
- }
130
- handlingError(err) {
131
- throw new Error(err);
132
- }
133
-
134
- /**
135
- * Generates an url from an extent. This url is a link to fetch the
136
- * resources inside the extent.
137
- *
138
- * @param {Extent} extent - Extent to convert in url.
139
- * @return {string} The URL constructed from the extent.
140
- */
141
- // eslint-disable-next-line
142
- urlFromExtent() {
143
- throw new Error('In extended Source, you have to implement the method urlFromExtent!');
144
- }
145
- requestToKey(extent) {
146
- return [extent.zoom, extent.row, extent.col];
147
- }
148
-
149
- /**
150
- * Load data from cache or Fetch/Parse data.
151
- * The loaded data is a Feature or Texture.
152
- *
153
- * @param {Extent} extent extent requested parsed data.
154
- * @param {FeatureBuildingOptions|Layer} out The feature returned options
155
- * @return {FeatureCollection|Texture} The parsed data.
156
- */
157
- loadData(extent, out) {
158
- const cache = this._featuresCaches[out.crs];
159
- const key = this.requestToKey(extent);
160
- // try to get parsed data from cache
161
- let features = cache.getByArray(key);
162
- if (!features) {
163
- // otherwise fetch/parse the data
164
- features = cache.setByArray(this.fetcher(this.urlFromExtent(extent), this.networkOptions).then(file => this.parser(file, {
165
- out,
166
- in: this,
167
- extent
168
- })).catch(err => this.handlingError(err)), key);
169
-
170
- /* istanbul ignore next */
171
- if (this.onParsedFile) {
172
- features.then(feat => {
173
- this.onParsedFile(feat);
174
- console.warn('Source.onParsedFile was deprecated');
175
- return feat;
176
- });
177
- }
178
- }
179
- return features;
180
- }
181
-
182
- /**
183
- * Called when layer added.
184
- *
185
- * @param {object} options
186
- */
187
- onLayerAdded(options) {
188
- // Added new cache by crs
189
- if (!this._featuresCaches[options.out.crs]) {
190
- // Cache feature only if it's vector data, the feature are cached in source.
191
- // It's not necessary to cache raster in Source,
192
- // because it's already cached on layer.
193
- this._featuresCaches[options.out.crs] = this.isVectorSource ? new Cache() : noCache;
194
- }
195
- }
196
-
197
- /**
198
- * Called when layer removed.
199
- *
200
- * @param {options} [options={}] options
201
- */
202
- onLayerRemoved() {
203
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
204
- // delete unused cache
205
- const unusedCache = this._featuresCaches[options.unusedCrs];
206
- if (unusedCache) {
207
- unusedCache.clear();
208
- delete this._featuresCaches[options.unusedCrs];
209
- }
210
- }
211
-
212
- /**
213
- * Tests if an extent is inside the source limits.
214
- *
215
- * @param {Extent} extent - Extent to test.
216
- * @return {boolean} True if the extent is inside the limit, false otherwise.
217
- */
218
- // eslint-disable-next-line
219
- extentInsideLimit() {
220
- throw new Error('In extented Source, you have to implement the method extentInsideLimit!');
221
- }
222
- }
223
- export default Source;
@@ -1,145 +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
- import CRS from "../Core/Geographic/Crs.js";
7
- const _tile = new Tile(CRS.tms_4326, 0, 0, 0);
8
-
9
- /**
10
- * An object defining the source of resources to get from a
11
- * [TMS](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification) server.
12
- * It inherits from {@link Source}.
13
- *
14
- * @extends Source
15
- *
16
- * @property {boolean} isTMSSource - Used to checkout whether this source is a
17
- * TMSSource. Default is true. You should not change this, as it is used
18
- * internally for optimisation.
19
- * @property {boolean} isInverted - The isInverted property is to be set to the
20
- * correct value, true or false (default being false) if the computation of the
21
- * coordinates needs to be inverted to match the same scheme as OSM, Google Maps
22
- * or other system. See [this link](
23
- * https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/)
24
- * for more information.
25
- * @property {Object} tileMatrixSetLimits - it describes the available tile for this layer
26
- * @property {Object} extentSetlimits - these are the extents of the set of identical zoom tiles.
27
- * @property {Object} zoom - Object containing the minimum and maximum values of
28
- * the level, to zoom in the source.
29
- * @property {number} zoom.min - The minimum level of the source. Default value
30
- * is 0.
31
- * @property {number} zoom.max - The maximum level of the source. Default value
32
- * is 20.
33
- * @property {function} tileMatrixCallback - a method that create a TileMatrix
34
- * identifier from the zoom level. For example, if set to `(zoomLevel) => 'EPSG:4326:' + zoomLevel`,
35
- * the TileMatrix that will be fetched at zoom level 5 will be the one with identifier `EPSG:4326:5`.
36
- * By default, the method returns the input zoom level.
37
- *
38
- * @example <caption><b>Source from OpenStreetMap server :</b></caption>
39
- * // Create the source
40
- * const tmsSource = new itowns.TMSSource({
41
- * format: 'image/png',
42
- * url: 'http://osm.io/styles/${z}/${x}/${y}.png',
43
- * attribution: {
44
- * name: 'OpenStreetMap',
45
- * url: 'http://www.openstreetmap.org/',
46
- * },
47
- * crs: 'EPSG:3857',
48
- * });
49
- *
50
- * // Create the layer
51
- * const colorLayer = new itowns.ColorLayer('OPENSM', {
52
- * source: tmsSource,
53
- * });
54
- *
55
- * // Add the layer
56
- * view.addLayer(colorLayer);
57
- *
58
- * @example <caption><b>Source from Mapbox server :</b></caption>
59
- * // Create the source
60
- * const orthoSource = new itowns.TMSSource({
61
- * url: 'https://api.mapbox.com/v4/mapbox.satellite/${z}/${x}/${y}.jpg?access_token=' + accessToken,
62
- * crs: 'EPSG:3857',
63
- * };
64
- *
65
- * // Create the layer
66
- * const imageryLayer = new itowns.ColorLayer("Ortho", {
67
- * source: orthoSource,
68
- * };
69
- *
70
- * // Add the layer to the view
71
- * view.addLayer(imageryLayer);
72
- */
73
- class TMSSource extends Source {
74
- /**
75
- * @param {Object} source - An object that can contain all properties of a
76
- * TMSSource and {@link Source}. Only `url` is mandatory.
77
- */
78
- constructor(source) {
79
- source.format = source.format || 'image/png';
80
- super(source);
81
- if (!source.crs) {
82
- throw new Error('New TMSSource/WMTSSource: crs is required');
83
- }
84
- this.isTMSSource = true;
85
- if (!source.extent) {
86
- // default to the global extent
87
- this.extent = globalExtentTMS.get(source.crs);
88
- }
89
- this.zoom = source.zoom;
90
- this.isInverted = source.isInverted || false;
91
- this.crs = CRS.formatToTms(source.crs);
92
- this.tileMatrixSetLimits = source.tileMatrixSetLimits;
93
- this.extentSetlimits = {};
94
- this.tileMatrixCallback = source.tileMatrixCallback || (zoomLevel => zoomLevel);
95
- if (!this.zoom) {
96
- if (this.tileMatrixSetLimits) {
97
- const arrayLimits = Object.keys(this.tileMatrixSetLimits);
98
- const size = arrayLimits.length;
99
- const maxZoom = Number(arrayLimits[size - 1]);
100
- this.zoom = {
101
- min: maxZoom - size + 1,
102
- max: maxZoom
103
- };
104
- } else {
105
- this.zoom = {
106
- min: 0,
107
- max: Infinity
108
- };
109
- }
110
- }
111
- }
112
- urlFromExtent(tile) {
113
- return URLBuilder.xyz(tile, this);
114
- }
115
- onLayerAdded(options) {
116
- super.onLayerAdded(options);
117
- // Build extents of the set of identical zoom tiles.
118
- const parent = options.out.parent;
119
- // The extents crs is chosen to facilitate in raster tile process.
120
- const crs = parent ? parent.extent.crs : options.out.crs;
121
- if (this.tileMatrixSetLimits && !this.extentSetlimits[crs]) {
122
- this.extentSetlimits[crs] = {};
123
- _tile.crs = this.crs;
124
- for (let i = this.zoom.max; i >= this.zoom.min; i--) {
125
- const tmsl = this.tileMatrixSetLimits[i];
126
- const {
127
- west,
128
- north
129
- } = _tile.set(i, tmsl.minTileRow, tmsl.minTileCol).toExtent(crs);
130
- const {
131
- east,
132
- south
133
- } = _tile.set(i, tmsl.maxTileRow, tmsl.maxTileCol).toExtent(crs);
134
- this.extentSetlimits[crs][i] = new Extent(crs, west, east, south, north);
135
- }
136
- }
137
- }
138
- extentInsideLimit(extent, zoom) {
139
- // This layer provides data starting at level = layer.source.zoom.min
140
- // (the zoom.max property is used when building the url to make
141
- // sure we don't use invalid levels)
142
- return zoom >= this.zoom.min && zoom <= this.zoom.max && (this.extentSetlimits[extent.crs] == undefined || this.extentSetlimits[extent.crs][zoom].intersectsExtent(extent));
143
- }
144
- }
145
- export default TMSSource;