itowns 2.44.3-next.40 → 2.44.3-next.41

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,550 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as CRS from "./Crs.js";
3
- import Coordinates from "./Coordinates.js";
4
- const _dim = new THREE.Vector2();
5
- const _dim2 = new THREE.Vector2();
6
- const _box = new THREE.Box3();
7
- const defaultScheme = new THREE.Vector2(2, 2);
8
- const cNorthWest = new Coordinates('EPSG:4326', 0, 0, 0);
9
- const cSouthWest = new Coordinates('EPSG:4326', 0, 0, 0);
10
- const cNorthEast = new Coordinates('EPSG:4326', 0, 0, 0);
11
- const southWest = new THREE.Vector3();
12
- const northEast = new THREE.Vector3();
13
- let _extent;
14
- const cardinals = new Array(8);
15
- for (let i = cardinals.length - 1; i >= 0; i--) {
16
- cardinals[i] = new Coordinates('EPSG:4326', 0, 0, 0);
17
- }
18
- const _c = new Coordinates('EPSG:4326', 0, 0);
19
- /**
20
- * A class representing a geographical extent.
21
- *
22
- * An extent is a geographical bounding rectangle defined by 4 limits: west,
23
- * east, south and north.
24
- *
25
- * **Warning**: Using a geocentric projection is not suitable for representing a
26
- * geographical extent. Please use a geographic projection.
27
- */
28
- class Extent {
29
- /**
30
- * Read-only flag to check if a given object is of type `Extent`.
31
- */
32
-
33
- /**
34
- * A default or user-defined CRS (see {@link ProjectionLike}).
35
- */
36
-
37
- /**
38
- * West longitude bound of this extent.
39
- */
40
-
41
- /**
42
- * East longitude bound of this extent.
43
- */
44
-
45
- /**
46
- * South latitude bound of this extent.
47
- */
48
-
49
- /**
50
- * North latitude bound of this extent.
51
- */
52
-
53
- /**
54
- * @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
55
- * @param west - the `west` value of this extent. Default is 0.
56
- * @param east - the `east` value of this extent. Default is 0.
57
- * @param south - the `south` value of this extent. Default is 0.
58
- * @param north - the `north` value of this extent. Default is 0.
59
- */
60
- constructor(crs) {
61
- let west = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
62
- let east = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
63
- let south = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
64
- let north = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
65
- if (CRS.isGeocentric(crs)) {
66
- throw new Error(`Non-compatible geocentric projection ${crs} to build a geographical extent`);
67
- }
68
- this.isExtent = true;
69
- this.crs = crs;
70
- this.west = 0;
71
- this.east = 0;
72
- this.south = 0;
73
- this.north = 0;
74
- this.set(west, east, south, north);
75
- }
76
-
77
- /**
78
- * Returns a new extent with the same bounds and crs as this one.
79
- */
80
- clone() {
81
- return new Extent(this.crs, this.west, this.east, this.south, this.north);
82
- }
83
-
84
- /**
85
- * Projects this extent to the specified projection.
86
- *
87
- * @param crs - target's projection.
88
- * @param target - The target to store the projected extent. If this not
89
- * provided a new extent will be created.
90
- */
91
- as(crs) {
92
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Extent('EPSG:4326');
93
- CRS.isValid(crs);
94
- if (this.crs != crs) {
95
- // Compute min/max in x/y by projecting 8 cardinal points,
96
- // and then taking the min/max of each coordinates.
97
- const center = this.center(_c);
98
- cardinals[0].setFromValues(this.west, this.north);
99
- cardinals[1].setFromValues(center.x, this.north);
100
- cardinals[2].setFromValues(this.east, this.north);
101
- cardinals[3].setFromValues(this.east, center.y);
102
- cardinals[4].setFromValues(this.east, this.south);
103
- cardinals[5].setFromValues(center.x, this.south);
104
- cardinals[6].setFromValues(this.west, this.south);
105
- cardinals[7].setFromValues(this.west, center.y);
106
- target.set(Infinity, -Infinity, Infinity, -Infinity);
107
-
108
- // loop over the coordinates
109
- for (let i = 0; i < cardinals.length; i++) {
110
- // convert the coordinate.
111
- cardinals[i].crs = this.crs;
112
- cardinals[i].as(crs, _c);
113
- target.north = Math.max(target.north, _c.y);
114
- target.south = Math.min(target.south, _c.y);
115
- target.east = Math.max(target.east, _c.x);
116
- target.west = Math.min(target.west, _c.x);
117
- }
118
- target.crs = crs;
119
- return target;
120
- }
121
- target.crs = crs;
122
- target.set(this.west, this.east, this.south, this.north);
123
- return target;
124
- }
125
-
126
- /**
127
- * Returns the center of the extent.
128
- *
129
- * @param target - The target to store the center coordinate. If this not
130
- * provided a new coordinate will be created.
131
- */
132
- center() {
133
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Coordinates(this.crs);
134
- this.planarDimensions(_dim);
135
- target.crs = this.crs;
136
- target.setFromValues(this.west + _dim.x * 0.5, this.south + _dim.y * 0.5);
137
- return target;
138
- }
139
-
140
- /**
141
- * Returns the planar dimensions as two-vector planar distances west/east
142
- * and south/north.
143
- * The planar distance is a straight-line Euclidean distance calculated in a
144
- * 2D Cartesian coordinate system.
145
- *
146
- * @param target - optional target
147
- */
148
- planarDimensions() {
149
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
150
- // Calculte the dimensions for x and y
151
- return target.set(Math.abs(this.east - this.west), Math.abs(this.north - this.south));
152
- }
153
-
154
- /**
155
- * Returns the geodetic dimensions as two-vector planar distances west/east
156
- * and south/north.
157
- * Geodetic distance is calculated in an ellispoid space as the distance
158
- * across the curved surface of the ellipsoid.
159
- *
160
- * @param target - optional target
161
- */
162
- geodeticDimensions() {
163
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
164
- // set 3 corners extent
165
- cNorthWest.crs = this.crs;
166
- cSouthWest.crs = this.crs;
167
- cNorthEast.crs = this.crs;
168
- cNorthWest.setFromValues(this.west, this.north, 0);
169
- cSouthWest.setFromValues(this.west, this.south, 0);
170
- cNorthEast.setFromValues(this.east, this.north, 0);
171
-
172
- // calcul geodetic distance northWest/northEast and northWest/southWest
173
- return target.set(cNorthWest.geodeticDistanceTo(cNorthEast), cNorthWest.geodeticDistanceTo(cSouthWest));
174
- }
175
-
176
- /**
177
- * Returns the spatial euclidean dimensions as a two-vector spatial
178
- * euclidean distances between west/east corner and south/north corner.
179
- * Spatial euclidean distance chord is calculated in an ellispoid space.
180
- *
181
- * @param target - optional target
182
- */
183
- spatialEuclideanDimensions() {
184
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
185
- // set 3 corners extent
186
- cNorthWest.crs = this.crs;
187
- cSouthWest.crs = this.crs;
188
- cNorthEast.crs = this.crs;
189
- cNorthWest.setFromValues(this.west, this.north, 0);
190
- cSouthWest.setFromValues(this.west, this.south, 0);
191
- cNorthEast.setFromValues(this.east, this.north, 0);
192
-
193
- // calcul chord distance northWest/northEast and northWest/southWest
194
- return target.set(cNorthWest.spatialEuclideanDistanceTo(cNorthEast), cNorthWest.spatialEuclideanDistanceTo(cSouthWest));
195
- }
196
-
197
- /**
198
- * Checks whether a coordinates is inside the extent.
199
- *
200
- * @param coord - the given coordinates.
201
- * @param epsilon - error margin when comparing to the coordinates.
202
- * Default is 0.
203
- */
204
- isPointInside(coord) {
205
- let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
206
- if (this.crs == coord.crs) {
207
- _c.copy(coord);
208
- } else {
209
- coord.as(this.crs, _c);
210
- }
211
-
212
- // TODO this ignores altitude
213
- return _c.x <= this.east + epsilon && _c.x >= this.west - epsilon && _c.y <= this.north + epsilon && _c.y >= this.south - epsilon;
214
- }
215
-
216
- /**
217
- * Checks whether another extent is inside the extent.
218
- *
219
- * @param extent - the extent to check
220
- * @param epsilon - error margin when comparing the extent bounds.
221
- */
222
- isInside(extent) {
223
- let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CRS.reasonableEpsilon(this.crs);
224
- extent.as(this.crs, _extent);
225
- return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
226
- }
227
-
228
- /**
229
- * Return the translation and scale to transform this extent to the input
230
- * extent.
231
- *
232
- * @param extent - input extent
233
- * @param target - copy the result to target.
234
- * @returns A {@link THREE.Vector4} where the `x` property encodes the
235
- * translation on west-east, the `y` property the translation on
236
- * south-north, the `z` property the scale on west-east, the `w` property
237
- * the scale on south-north.
238
- */
239
- offsetToParent(extent) {
240
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
241
- if (this.crs != extent.crs) {
242
- throw new Error('unsupported mix');
243
- }
244
- extent.planarDimensions(_dim);
245
- this.planarDimensions(_dim2);
246
- const originX = (this.west - extent.west) / _dim.x;
247
- const originY = (extent.north - this.north) / _dim.y;
248
- const scaleX = _dim2.x / _dim.x;
249
- const scaleY = _dim2.y / _dim.y;
250
- return target.set(originX, originY, scaleX, scaleY);
251
- }
252
-
253
- /**
254
- * Checks wheter this bounding box intersects with the given extent
255
- * parameter.
256
- * @param extent - the provided extent
257
- */
258
- intersectsExtent(extent) {
259
- return Extent.intersectsExtent(this, extent);
260
- }
261
- static intersectsExtent(extentA, extentB) {
262
- // TODO don't work when is on limit
263
- const other = extentB.crs == extentA.crs ? extentB : extentB.as(extentA.crs, _extent);
264
- return !(extentA.west >= other.east || extentA.east <= other.west || extentA.south >= other.north || extentA.north <= other.south);
265
- }
266
-
267
- /**
268
- * Returns the intersection of this extent with another one.
269
- * @param extent - extent to intersect
270
- */
271
- intersect(extent) {
272
- if (!this.intersectsExtent(extent)) {
273
- return new Extent(this.crs);
274
- }
275
- if (extent.crs != this.crs) {
276
- extent = extent.as(this.crs, _extent);
277
- }
278
- return new Extent(this.crs, Math.max(this.west, extent.west), Math.min(this.east, extent.east), Math.max(this.south, extent.south), Math.min(this.north, extent.north));
279
- }
280
-
281
- /**
282
- * Set west, east, south and north values.
283
- *
284
- * @param v0 - the `west` value of this extent. Default is 0.
285
- * @param v1 - the `east` value of this extent. Default is 0.
286
- * @param v2 - the `south` value of this extent. Default is 0.
287
- * @param v3 - the `north` value of this extent. Default is 0.
288
- */
289
- set(v0, v1, v2, v3) {
290
- if (v0 == undefined) {
291
- throw new Error('No values to set in the extent');
292
- }
293
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
294
- if (v0.west !== undefined) {
295
- console.warn('Deprecated Extent#constructor(string, Extent) and Extent#set(Extent),', 'use new Extent(string).setFromExtent(Extent) instead.');
296
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
297
- this.setFromExtent(v0);
298
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
- } else if (v0.length == 4) {
300
- // deepscan-disable-line
301
- console.warn('Deprecated Extent#constructor(string, number[]) and Extent#set(number[]),', 'use new Extent(string).setFromArray(number[]) instead.');
302
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
303
- this.setFromArray(v0);
304
- } else if (v3 !== undefined) {
305
- this.west = v0;
306
- this.east = v1;
307
- this.south = v2;
308
- this.north = v3;
309
- }
310
- return this;
311
- }
312
-
313
- /**
314
- * Sets this extent `west` property to `array[offset + 0]`, `east` property
315
- * to `array[offset + 1]`, `south` property to `array[offset + 2]` and
316
- * `north` property to `array[offset + 3]`.
317
- * @param array - the source array
318
- * @param offset - offset into the array. Default is 0.
319
- */
320
- setFromArray(array) {
321
- let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
322
- this.west = array[offset];
323
- this.east = array[offset + 1];
324
- this.south = array[offset + 2];
325
- this.north = array[offset + 3];
326
- return this;
327
- }
328
-
329
- /**
330
- * Sets this extent `west`, `east`, `south` and `north` properties from an
331
- * `extent` bounds.
332
- * @param extent - the source extent
333
- */
334
- setFromExtent(extent) {
335
- this.west = extent.west;
336
- this.east = extent.east;
337
- this.south = extent.south;
338
- this.north = extent.north;
339
- return this;
340
- }
341
-
342
- /**
343
- * Copies the passed extent to this extent.
344
- * @param extent - extent to copy.
345
- */
346
- copy(extent) {
347
- this.crs = extent.crs;
348
- return this.setFromExtent(extent);
349
- }
350
-
351
- /**
352
- * Union this extent with the input extent.
353
- * @param extent - the extent to union.
354
- */
355
- union(extent) {
356
- if (extent.crs != this.crs) {
357
- throw new Error('unsupported union between 2 diff crs');
358
- }
359
- if (this.west === Infinity) {
360
- this.copy(extent);
361
- } else {
362
- const west = extent.west;
363
- if (west < this.west) {
364
- this.west = west;
365
- }
366
- const east = extent.east;
367
- if (east > this.east) {
368
- this.east = east;
369
- }
370
- const south = extent.south;
371
- if (south < this.south) {
372
- this.south = south;
373
- }
374
- const north = extent.north;
375
- if (north > this.north) {
376
- this.north = north;
377
- }
378
- }
379
- }
380
-
381
- /**
382
- * expandByCoordinates perfoms the minimal extension
383
- * for the coordinates to belong to this Extent object
384
- * @param coordinates - The coordinates to belong
385
- */
386
- expandByCoordinates(coordinates) {
387
- const coords = coordinates.crs == this.crs ? coordinates : coordinates.as(this.crs, _c);
388
- this.expandByValuesCoordinates(coords.x, coords.y);
389
- }
390
-
391
- /**
392
- * expandByValuesCoordinates perfoms the minimal extension
393
- * for the coordinates values to belong to this Extent object
394
- * @param we - The coordinate on west-east
395
- * @param sn - The coordinate on south-north
396
- *
397
- */
398
- expandByValuesCoordinates(we, sn) {
399
- if (we < this.west) {
400
- this.west = we;
401
- }
402
- if (we > this.east) {
403
- this.east = we;
404
- }
405
- if (sn < this.south) {
406
- this.south = sn;
407
- }
408
- if (sn > this.north) {
409
- this.north = sn;
410
- }
411
- }
412
-
413
- /**
414
- * Instance Extent with THREE.Box3.
415
- *
416
- * If crs is a geocentric projection, the `box3.min` and `box3.max`
417
- * should be the geocentric coordinates of `min` and `max` of a `box3`
418
- * in local tangent plane.
419
- *
420
- * @param crs - Projection of extent to instancied.
421
- * @param box - Bounding-box
422
- */
423
- static fromBox3(crs, box) {
424
- if (CRS.isGeocentric(crs)) {
425
- // if geocentric reproject box on 'EPSG:4326'
426
- crs = 'EPSG:4326';
427
- box = _box.copy(box);
428
- cSouthWest.crs = crs;
429
- cSouthWest.setFromVector3(box.min).as(crs, cSouthWest).toVector3(box.min);
430
- cNorthEast.crs = crs;
431
- cNorthEast.setFromVector3(box.max).as(crs, cNorthEast).toVector3(box.max);
432
- }
433
- return new Extent(crs).setFromExtent({
434
- west: box.min.x,
435
- east: box.max.x,
436
- south: box.min.y,
437
- north: box.max.y
438
- });
439
- }
440
-
441
- /**
442
- * Return values of extent in string, separated by the separator input.
443
- * @param sep - string separator
444
- */
445
- toString() {
446
- let sep = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
447
- return `${this.east}${sep}${this.north}${sep}${this.west}${sep}${this.south}`;
448
- }
449
-
450
- /**
451
- * Subdivide equally an extent from its center to return four extents:
452
- * north-west, north-east, south-west and south-east.
453
- *
454
- * @returns An array containing the four sections of the extent. The order
455
- * of the sections is [NW, NE, SW, SE].
456
- */
457
- subdivision() {
458
- return this.subdivisionByScheme();
459
- }
460
-
461
- /**
462
- * subdivise extent by scheme.x on west-east and scheme.y on south-north.
463
- *
464
- * @param scheme - The scheme to subdivise.
465
- * @returns subdivised extents.
466
- */
467
- subdivisionByScheme() {
468
- let scheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultScheme;
469
- const subdivisedExtents = [];
470
- const dimSub = this.planarDimensions(_dim).divide(scheme);
471
- for (let x = scheme.x - 1; x >= 0; x--) {
472
- for (let y = scheme.y - 1; y >= 0; y--) {
473
- const west = this.west + x * dimSub.x;
474
- const south = this.south + y * dimSub.y;
475
- subdivisedExtents.push(new Extent(this.crs, west, west + dimSub.x, south, south + dimSub.y));
476
- }
477
- }
478
- return subdivisedExtents;
479
- }
480
-
481
- /**
482
- * Multiplies all extent `coordinates` (with an implicit 1 in the 4th
483
- * dimension) and `matrix`.
484
- *
485
- * @param matrix - The matrix
486
- * @returns return this extent instance.
487
- */
488
- applyMatrix4(matrix) {
489
- southWest.set(this.west, this.south, 0).applyMatrix4(matrix);
490
- northEast.set(this.east, this.north, 0).applyMatrix4(matrix);
491
- this.west = southWest.x;
492
- this.east = northEast.x;
493
- this.south = southWest.y;
494
- this.north = northEast.y;
495
- if (this.west > this.east) {
496
- const temp = this.west;
497
- this.west = this.east;
498
- this.east = temp;
499
- }
500
- if (this.south > this.north) {
501
- const temp = this.south;
502
- this.south = this.north;
503
- this.north = temp;
504
- }
505
- return this;
506
- }
507
-
508
- /**
509
- * clamp south and north values
510
- *
511
- * @param south - The min south
512
- * @param north - The max north
513
- * @returns this extent
514
- */
515
- clampSouthNorth() {
516
- let south = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.south;
517
- let north = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.north;
518
- this.south = Math.max(this.south, south);
519
- this.north = Math.min(this.north, north);
520
- return this;
521
- }
522
-
523
- /**
524
- * clamp west and east values
525
- *
526
- * @param west - The min west
527
- * @param east - The max east
528
- * @returns this extent
529
- */
530
- clampWestEast() {
531
- let west = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.west;
532
- let east = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.east;
533
- this.west = Math.max(this.west, west);
534
- this.east = Math.min(this.east, east);
535
- return this;
536
- }
537
-
538
- /**
539
- * clamp this extent by passed extent
540
- *
541
- * @param extent - The maximum extent.
542
- * @returns this extent.
543
- */
544
- clampByExtent(extent) {
545
- this.clampSouthNorth(extent.south, extent.north);
546
- return this.clampWestEast(extent.west, extent.east);
547
- }
548
- }
549
- _extent = new Extent('EPSG:4326');
550
- export default Extent;
@@ -1,109 +0,0 @@
1
- import * as THREE from 'three';
2
- import * as CRS from "./Crs.js";
3
- import Coordinates from "./Coordinates.js";
4
- const coord = new Coordinates('EPSG:4326');
5
- const indexes = new THREE.Vector2();
6
- function biLinearInterpolation(indexes, getData) {
7
- const j = Math.floor(indexes.x);
8
- const i = Math.floor(indexes.y);
9
- const u = indexes.x - j;
10
- const v = indexes.y - i;
11
- return (1 - u) * ((1 - v) * getData(i, j) + v * getData(i + 1, j)) + u * ((1 - v) * getData(i, j + 1) + v * getData(i + 1, j + 1));
12
- }
13
-
14
- /**
15
- * An instance of `GeoidGrid` allows accessing some geoid height grid data from geographic instances (like some
16
- * {@link Coordinates}). The geoid height grid data must contain geoid height values for a set of geographic points
17
- * regularly dispatched on a planar surface.
18
- *
19
- * @property {Extent} extent The geographic extent of the geoid height grid data.
20
- * @property {THREE.Vector2} step The distance between two consecutive points of the geoid height grid. The
21
- * `x` value stands for the distance along the West-East direction, and the
22
- * `y` value stands for the distance along the South-North direction.
23
- * @property {THREE.Vector2} dimensions The planar dimensions of the geoid height grid data extent.
24
- * @property {THREE.Vector2} dataSize The number of values in the gridded data along the West-East direction (`x`
25
- * axis) and the South-North direction (`y` axis).
26
- *
27
- * @example
28
- * // Create a set of gridded data.
29
- * const data = [
30
- * [1, 2, 3],
31
- * [2, 3, 4],
32
- * [3, 4, 5],
33
- * ];
34
- * // This set of data presents the following spatial distribution of geoid heights values :
35
- * //
36
- * // Latitudes ^
37
- * // |
38
- * // 41.0 | 3 4 5
39
- * // 40.5 | 2 3 4
40
- * // 40.0 | 1 2 3
41
- * // |------------->
42
- * // 1 2 3 Longitudes
43
- *
44
- * // Create a GeoidGrid allowing to access the gridded data.
45
- * const geoidGrid = new GeoidGrid(
46
- * new Extent('EPSG:4326', 1, 3, 40, 41),
47
- * new THREE.Vector2(1, 0.5),
48
- * (verticalIndex, horizontalIndex) => data[verticalIndex][horizontalIndex],
49
- * );
50
- *
51
- * // Access a value of geoid height at some geographic coordinates.
52
- * // The value is interpolated from the gridded data.
53
- * const value = geoidGrid.getHeightAtCoordinates(
54
- * new Coordinates('EPSG:4326', 1.5, 40.25)
55
- * );
56
- * // This should return 2.0, which is the result from the bi-linear
57
- * // interpolation at the center of the `[[1, 2], [2, 3]]` subsection
58
- * // of the grid data.
59
- */
60
- class GeoidGrid {
61
- /**
62
- * @param {Extent} extent The geographic extent of the geoid height grid data.
63
- * @param {THREE.Vector2} step The distance between two consecutive points of the geoid height grid. The
64
- * `x` value stands for the distance along the West-East direction, and the
65
- * `y` value stands for the distance along the South-North direction.
66
- * @param {function} getData A method that allows reading a value in the geoid height grid from its
67
- * vertical and horizontal indexes. The lower an index, the lower the
68
- * coordinate on the corresponding axis - 0 being the index of the minimal
69
- * coordinate of the gridded data on a given axis. In other words :
70
- * - `getData(0, 0)` must return the geoid height value at the SOUTH-WEST
71
- * corner of your data extent.
72
- * - `getData(0, j)` must return a geoid height on the southern limit of your
73
- * data extent.
74
- * - `getData(i, 0)` must return a geoid height on the western limit of your
75
- * data extent.
76
- * - if your gridded data has dimensions (rowNumber, colNumber),
77
- * `getData(rowNumber - 1, colNumber - 1)` must return the geoid height at
78
- * the NORTH-EAST corner of your data extent.
79
- */
80
- constructor(extent, step, getData) {
81
- CRS.isGeographic(extent.crs);
82
- this.extent = extent;
83
- this.step = new THREE.Vector2(step.x, step.y || step.x);
84
- this.dimensions = this.extent.planarDimensions();
85
- this.dataSize = new THREE.Vector2().addVectors(this.step, this.dimensions).divide(this.step).round();
86
- this.getData = getData;
87
- }
88
-
89
- /**
90
- * Get the value of the geoid height at given geographic {@link Coordinates}. The geoid height value is
91
- * bi-linearly interpolated from the gridded data accessed by the `GeoidGrid` instance.
92
- *
93
- * @param {Coordinates} coordinates Geographic coordinates to get the geoid height value at.
94
- *
95
- * @returns {number} The geoid height value at the given {@link Coordinates}, bi-interpolated from the gridded
96
- * data accessed by the `GeoidGrid` instance.
97
- */
98
- getHeightAtCoordinates(coordinates) {
99
- coordinates.as(this.extent.crs, coord);
100
- indexes.set((this.dataSize.x - 1) * (coord.x - this.extent.west) / this.dimensions.x, (this.dataSize.y - 1) * (coord.y - this.extent.south) / this.dimensions.y);
101
-
102
- // TODO : add management for global GeoidGrid.
103
- if (indexes.x < 0 || indexes.x >= this.dataSize.x - 1 || indexes.y < 0 || indexes.y >= this.dataSize.y - 1) {
104
- return 0;
105
- }
106
- return biLinearInterpolation(indexes, this.getData);
107
- }
108
- }
109
- export default GeoidGrid;