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,534 +0,0 @@
1
- import * as THREE from 'three';
2
- import Coordinates from "./Coordinates.js";
3
- import CRS from "./Crs.js";
4
-
5
- /**
6
- * Extent is a SIG-area (so 2D)
7
- * It can use explicit coordinates (e.g: lon/lat) or implicit (WMTS coordinates)
8
- */
9
-
10
- const _dim = new THREE.Vector2();
11
- const _dim2 = new THREE.Vector2();
12
- const _box = new THREE.Box3();
13
- const defaultScheme = new THREE.Vector2(2, 2);
14
- const cNorthWest = new Coordinates('EPSG:4326', 0, 0, 0);
15
- const cSouthWest = new Coordinates('EPSG:4326', 0, 0, 0);
16
- const cNorthEast = new Coordinates('EPSG:4326', 0, 0, 0);
17
- const southWest = new THREE.Vector3();
18
- const northEast = new THREE.Vector3();
19
-
20
- /** @type {Extent} */
21
- let _extent;
22
- const cardinals = new Array(8);
23
- for (let i = cardinals.length - 1; i >= 0; i--) {
24
- cardinals[i] = new Coordinates('EPSG:4326', 0, 0, 0);
25
- }
26
- const _c = new Coordinates('EPSG:4326', 0, 0);
27
- class Extent {
28
- /**
29
- * Extent is geographical bounding rectangle defined by 4 limits: west, east, south and north.
30
- *
31
- * Warning, using geocentric projection isn't consistent with geographical extent.
32
- *
33
- * @param {String} crs projection of limit values.
34
- * @param {number|Array.<number>|Coordinates|Object} v0 west value, Array
35
- * of values [west, east, south and north], Coordinates of west-south
36
- * corner or object {west, east, south and north}
37
- * @param {number|Coordinates} [v1] east value or Coordinates of
38
- * east-north corner
39
- * @param {number} [v2] south value
40
- * @param {number} [v3] north value
41
- */
42
- constructor(crs, v0, v1, v2, v3) {
43
- if (CRS.isGeocentric(crs)) {
44
- throw new Error(`${crs} is a geocentric projection, it doesn't make sense with a geographical extent`);
45
- }
46
- if (CRS.isTms(crs)) {
47
- throw new Error(`${crs} is a tiled projection, use Tile instead`);
48
- }
49
- this.isExtent = true;
50
- this.crs = crs;
51
- this.west = 0;
52
- this.east = 0;
53
- this.south = 0;
54
- this.north = 0;
55
- this.set(v0, v1, v2, v3);
56
- }
57
-
58
- /**
59
- * Clone this extent
60
- * @return {Extent} cloned extent
61
- */
62
- clone() {
63
- return new Extent(this.crs, this.west, this.east, this.south, this.north);
64
- }
65
-
66
- /**
67
- * Convert Extent to the specified projection.
68
- * @param {string} crs the projection of destination.
69
- * @param {Extent} [target] copy the destination to target.
70
- * @return {Extent}
71
- */
72
- as(crs, target) {
73
- CRS.isValid(crs);
74
- target = target || new Extent('EPSG:4326', [0, 0, 0, 0]);
75
- if (this.crs != crs) {
76
- // Compute min/max in x/y by projecting 8 cardinal points,
77
- // and then taking the min/max of each coordinates.
78
- const center = this.center(_c);
79
- cardinals[0].setFromValues(this.west, this.north);
80
- cardinals[1].setFromValues(center.x, this.north);
81
- cardinals[2].setFromValues(this.east, this.north);
82
- cardinals[3].setFromValues(this.east, center.y);
83
- cardinals[4].setFromValues(this.east, this.south);
84
- cardinals[5].setFromValues(center.x, this.south);
85
- cardinals[6].setFromValues(this.west, this.south);
86
- cardinals[7].setFromValues(this.west, center.y);
87
- target.set(Infinity, -Infinity, Infinity, -Infinity);
88
-
89
- // loop over the coordinates
90
- for (let i = 0; i < cardinals.length; i++) {
91
- // convert the coordinate.
92
- cardinals[i].crs = this.crs;
93
- cardinals[i].as(crs, _c);
94
- target.north = Math.max(target.north, _c.y);
95
- target.south = Math.min(target.south, _c.y);
96
- target.east = Math.max(target.east, _c.x);
97
- target.west = Math.min(target.west, _c.x);
98
- }
99
- target.crs = crs;
100
- return target;
101
- }
102
- target.crs = crs;
103
- target.set(this.west, this.east, this.south, this.north);
104
- return target;
105
- }
106
-
107
- /**
108
- * Return the center of Extent
109
- * @param {Coordinates} target copy the center to the target.
110
- * @return {Coordinates}
111
- */
112
- center() {
113
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Coordinates(this.crs);
114
- this.planarDimensions(_dim);
115
- target.crs = this.crs;
116
- target.setFromValues(this.west + _dim.x * 0.5, this.south + _dim.y * 0.5);
117
- return target;
118
- }
119
-
120
- /**
121
- * Returns the dimension of the extent, in a `THREE.Vector2`.
122
- *
123
- * @param {THREE.Vector2} [target] - The target to assign the result in.
124
- *
125
- * @return {THREE.Vector2}
126
- */
127
- dimensions() {
128
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
129
- console.warn('Extent.dimensions is deprecated, use planarDimensions, geodeticDimensions or spatialEuclideanDimensions');
130
- target.x = Math.abs(this.east - this.west);
131
- target.y = Math.abs(this.north - this.south);
132
- return target;
133
- }
134
-
135
- /**
136
- * Planar dimensions are two planar distances west/east and south/north.
137
- * Planar distance straight-line Euclidean distance calculated in a 2D Cartesian coordinate system.
138
- *
139
- * @param {THREE.Vector2} [target=new THREE.Vector2()] The target
140
- * @return {THREE.Vector2} Planar dimensions
141
- */
142
- planarDimensions() {
143
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
144
- // Calculte the dimensions for x and y
145
- return target.set(Math.abs(this.east - this.west), Math.abs(this.north - this.south));
146
- }
147
-
148
- /**
149
- * Geodetic dimensions are two planar distances west/east and south/north.
150
- * Geodetic distance is calculated in an ellispoid space as the distance
151
- * across the curved surface of the world.
152
- *
153
- * @param {THREE.Vector2} [target=new THREE.Vector2()] The target
154
- * @return {THREE.Vector2} geodetic dimensions
155
- */
156
- geodeticDimensions() {
157
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
158
- // set 3 corners extent
159
- cNorthWest.crs = this.crs;
160
- cSouthWest.crs = this.crs;
161
- cNorthEast.crs = this.crs;
162
- cNorthWest.setFromValues(this.west, this.north, 0);
163
- cSouthWest.setFromValues(this.west, this.south, 0);
164
- cNorthEast.setFromValues(this.east, this.north, 0);
165
-
166
- // calcul geodetic distance northWest/northEast and northWest/southWest
167
- return target.set(cNorthWest.geodeticDistanceTo(cNorthEast), cNorthWest.geodeticDistanceTo(cSouthWest));
168
- }
169
-
170
- /**
171
- * Spatial euclidean dimensions are two spatial euclidean distances between west/east corner and south/north corner.
172
- * Spatial euclidean distance chord is calculated in a ellispoid space.
173
- *
174
- * @param {THREE.Vector2} [target=new THREE.Vector2()] The target
175
- * @return {THREE.Vector2} spatial euclidean dimensions
176
- */
177
- spatialEuclideanDimensions() {
178
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
179
- // set 3 corners extent
180
- cNorthWest.crs = this.crs;
181
- cSouthWest.crs = this.crs;
182
- cNorthEast.crs = this.crs;
183
- cNorthWest.setFromValues(this.west, this.north, 0);
184
- cSouthWest.setFromValues(this.west, this.south, 0);
185
- cNorthEast.setFromValues(this.east, this.north, 0);
186
-
187
- // calcul chord distance northWest/northEast and northWest/southWest
188
- return target.set(cNorthWest.spatialEuclideanDistanceTo(cNorthEast), cNorthWest.spatialEuclideanDistanceTo(cSouthWest));
189
- }
190
-
191
- /**
192
- * Return true if `coord` is inside the bounding box.
193
- *
194
- * @param {Coordinates} coord
195
- * @param {number} [epsilon=0] - to take into account when comparing to the
196
- * point.
197
- *
198
- * @return {boolean}
199
- */
200
- isPointInside(coord) {
201
- let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
202
- if (this.crs == coord.crs) {
203
- _c.copy(coord);
204
- } else {
205
- coord.as(this.crs, _c);
206
- }
207
-
208
- // TODO this ignores altitude
209
- return _c.x <= this.east + epsilon && _c.x >= this.west - epsilon && _c.y <= this.north + epsilon && _c.y >= this.south - epsilon;
210
- }
211
-
212
- /**
213
- * Return true if `extent` is inside this extent.
214
- *
215
- * @param {Extent} extent the extent to check
216
- * @param {number} epsilon to take into account when comparing to the
217
- * point.
218
- *
219
- * @return {boolean}
220
- */
221
- isInside(extent, epsilon) {
222
- extent.as(this.crs, _extent);
223
- epsilon = epsilon == undefined ? CRS.reasonnableEpsilon(this.crs) : epsilon;
224
- return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
225
- }
226
-
227
- /**
228
- * Return the translation and scale to transform this extent to input extent.
229
- *
230
- * @param {Extent} extent input extent
231
- * @param {THREE.Vector4} target copy the result to target.
232
- * @return {THREE.Vector4} {x: translation on west-east, y: translation on south-north, z: scale on west-east, w: scale on south-north}
233
- */
234
- offsetToParent(extent) {
235
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
236
- if (this.crs != extent.crs) {
237
- throw new Error('unsupported mix');
238
- }
239
- extent.planarDimensions(_dim);
240
- this.planarDimensions(_dim2);
241
- const originX = (this.west - extent.west) / _dim.x;
242
- const originY = (extent.north - this.north) / _dim.y;
243
- const scaleX = _dim2.x / _dim.x;
244
- const scaleY = _dim2.y / _dim.y;
245
- return target.set(originX, originY, scaleX, scaleY);
246
- }
247
-
248
- /**
249
- * Return true if this bounding box intersect with the bouding box parameter
250
- * @param {Extent} extent
251
- * @returns {Boolean}
252
- */
253
- intersectsExtent(extent) {
254
- return Extent.intersectsExtent(this, extent);
255
- }
256
- static intersectsExtent(/** @type {Extent} */extentA, /** @type {Extent} */extentB) {
257
- // TODO don't work when is on limit
258
- const other = extentB.crs == extentA.crs ? extentB : extentB.as(extentA.crs, _extent);
259
- return !(extentA.west >= other.east || extentA.east <= other.west || extentA.south >= other.north || extentA.north <= other.south);
260
- }
261
-
262
- /**
263
- * Return the intersection of this extent with another one
264
- * @param {Extent} extent
265
- * @returns {Extent}
266
- */
267
- intersect(extent) {
268
- if (!this.intersectsExtent(extent)) {
269
- return new Extent(this.crs, 0, 0, 0, 0);
270
- }
271
- if (extent.crs != this.crs) {
272
- extent = extent.as(this.crs, _extent);
273
- }
274
- 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));
275
- }
276
-
277
- /**
278
- * Set west, east, south and north values.
279
- *
280
- * @param {number|Array.<number>|Coordinates|Object|Extent} v0 west value,
281
- * Array of values [west, east, south and north], Extent of same type (tiled
282
- * or not), Coordinates of west-south corner or object {west, east, south
283
- * and north}
284
- * @param {number|Coordinates} [v1] east value, row value or Coordinates of
285
- * east-north corner
286
- * @param {number} [v2] south value or column value
287
- * @param {number} [v3] north value
288
- *
289
- * @return {Extent}
290
- */
291
- set(v0, v1, v2, v3) {
292
- if (v0 == undefined) {
293
- throw new Error('No values to set in the extent');
294
- }
295
- if (v0.isExtent) {
296
- v1 = v0.east;
297
- v2 = v0.south;
298
- v3 = v0.north;
299
- v0 = v0.west;
300
- }
301
- if (v0.isCoordinates) {
302
- // seem never used
303
- this.west = v0.x;
304
- this.east = v1.x;
305
- this.south = v0.y;
306
- this.north = v1.y;
307
- } else if (v0.west !== undefined) {
308
- this.west = v0.west;
309
- this.east = v0.east;
310
- this.south = v0.south;
311
- this.north = v0.north;
312
- } else if (v0.length == 4) {
313
- this.west = v0[0];
314
- this.east = v0[1];
315
- this.south = v0[2];
316
- this.north = v0[3];
317
- } else if (v3 !== undefined) {
318
- this.west = v0;
319
- this.east = v1;
320
- this.south = v2;
321
- this.north = v3;
322
- }
323
- return this;
324
- }
325
-
326
- /**
327
- * Copy to this extent to input extent.
328
- * @param {Extent} extent
329
- * @return {Extent} copied extent
330
- */
331
- copy(extent) {
332
- this.crs = extent.crs;
333
- return this.set(extent);
334
- }
335
-
336
- /**
337
- * Union this extent with the input extent.
338
- * @param {Extent} extent the extent to union.
339
- */
340
- union(extent) {
341
- if (extent.crs != this.crs) {
342
- throw new Error('unsupported union between 2 diff crs');
343
- }
344
- if (this.west === Infinity) {
345
- this.copy(extent);
346
- } else {
347
- const west = extent.west;
348
- if (west < this.west) {
349
- this.west = west;
350
- }
351
- const east = extent.east;
352
- if (east > this.east) {
353
- this.east = east;
354
- }
355
- const south = extent.south;
356
- if (south < this.south) {
357
- this.south = south;
358
- }
359
- const north = extent.north;
360
- if (north > this.north) {
361
- this.north = north;
362
- }
363
- }
364
- }
365
-
366
- /**
367
- * expandByCoordinates perfoms the minimal extension
368
- * for the coordinates to belong to this Extent object
369
- * @param {Coordinates} coordinates The coordinates to belong
370
- */
371
- expandByCoordinates(coordinates) {
372
- const coords = coordinates.crs == this.crs ? coordinates : coordinates.as(this.crs, _c);
373
- this.expandByValuesCoordinates(coords.x, coords.y);
374
- }
375
-
376
- /**
377
- * expandByValuesCoordinates perfoms the minimal extension
378
- * for the coordinates values to belong to this Extent object
379
- * @param {number} we The coordinate on west-east
380
- * @param {number} sn The coordinate on south-north
381
- *
382
- */
383
- expandByValuesCoordinates(we, sn) {
384
- if (we < this.west) {
385
- this.west = we;
386
- }
387
- if (we > this.east) {
388
- this.east = we;
389
- }
390
- if (sn < this.south) {
391
- this.south = sn;
392
- }
393
- if (sn > this.north) {
394
- this.north = sn;
395
- }
396
- }
397
-
398
- /**
399
- * Instance Extent with THREE.Box3.
400
- *
401
- * If crs is a geocentric projection, the `box3.min` and `box3.max`
402
- * should be the geocentric coordinates of `min` and `max` of a `box3`
403
- * in local tangent plane.
404
- *
405
- * @param {string} crs Projection of extent to instancied.
406
- * @param {THREE.Box3} box
407
- * @return {Extent}
408
- */
409
- static fromBox3(crs, box) {
410
- if (CRS.isGeocentric(crs)) {
411
- // if geocentric reproject box on 'EPSG:4326'
412
- crs = 'EPSG:4326';
413
- box = _box.copy(box);
414
- cSouthWest.crs = crs;
415
- cSouthWest.setFromVector3(box.min).as(crs, cSouthWest).toVector3(box.min);
416
- cNorthEast.crs = crs;
417
- cNorthEast.setFromVector3(box.max).as(crs, cNorthEast).toVector3(box.max);
418
- }
419
- return new Extent(crs, {
420
- west: box.min.x,
421
- east: box.max.x,
422
- south: box.min.y,
423
- north: box.max.y
424
- });
425
- }
426
-
427
- /**
428
- * Return values of extent in string, separated by the separator input.
429
- * @param {string} separator
430
- * @return {string}
431
- */
432
- toString() {
433
- let separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
434
- return `${this.east}${separator}${this.north}${separator}${this.west}${separator}${this.south}`;
435
- }
436
-
437
- /**
438
- * Subdivide equally an extent from its center to return four extents:
439
- * north-west, north-east, south-west and south-east.
440
- *
441
- * @returns {Extent[]} An array containing the four sections of the extent. The
442
- * order of the sections is [NW, NE, SW, SE].
443
- */
444
- subdivision() {
445
- return this.subdivisionByScheme();
446
- }
447
- /**
448
- * subdivise extent by scheme.x on west-east and scheme.y on south-north.
449
- *
450
- * @param {THREE.Vector2} [scheme=Vector2(2,2)] The scheme to subdivise.
451
- * @return {Array<Extent>} subdivised extents.
452
- */
453
- subdivisionByScheme() {
454
- let scheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultScheme;
455
- const subdivisedExtents = [];
456
- const dimSub = this.planarDimensions(_dim).divide(scheme);
457
- for (let x = scheme.x - 1; x >= 0; x--) {
458
- for (let y = scheme.y - 1; y >= 0; y--) {
459
- const west = this.west + x * dimSub.x;
460
- const south = this.south + y * dimSub.y;
461
- subdivisedExtents.push(new Extent(this.crs, west, west + dimSub.x, south, south + dimSub.y));
462
- }
463
- }
464
- return subdivisedExtents;
465
- }
466
-
467
- /**
468
- * Multiplies all extent `coordinates` (with an implicit 1 in the 4th dimension) and `matrix`.
469
- *
470
- * @param {THREE.Matrix4} matrix The matrix
471
- * @return {Extent} return this extent instance.
472
- */
473
- applyMatrix4(matrix) {
474
- southWest.set(this.west, this.south, 0).applyMatrix4(matrix);
475
- northEast.set(this.east, this.north, 0).applyMatrix4(matrix);
476
- this.west = southWest.x;
477
- this.east = northEast.x;
478
- this.south = southWest.y;
479
- this.north = northEast.y;
480
- if (this.west > this.east) {
481
- const temp = this.west;
482
- this.west = this.east;
483
- this.east = temp;
484
- }
485
- if (this.south > this.north) {
486
- const temp = this.south;
487
- this.south = this.north;
488
- this.north = temp;
489
- }
490
- return this;
491
- }
492
-
493
- /**
494
- * clamp south and north values
495
- *
496
- * @param {number} [south=this.south] The min south
497
- * @param {number} [north=this.north] The max north
498
- * @return {Extent} this extent
499
- */
500
- clampSouthNorth() {
501
- let south = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.south;
502
- let north = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.north;
503
- this.south = Math.max(this.south, south);
504
- this.north = Math.min(this.north, north);
505
- return this;
506
- }
507
-
508
- /**
509
- * clamp west and east values
510
- *
511
- * @param {number} [west=this.west] The min west
512
- * @param {number} [east=this.east] The max east
513
- * @return {Extent} this extent
514
- */
515
- clampWestEast() {
516
- let west = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.west;
517
- let east = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.east;
518
- this.west = Math.max(this.west, west);
519
- this.east = Math.min(this.east, east);
520
- return this;
521
- }
522
- /**
523
- * clamp this extent by passed extent
524
- *
525
- * @param {Extent} extent The maximum extent.
526
- * @return {Extent} this extent.
527
- */
528
- clampByExtent(extent) {
529
- this.clampSouthNorth(extent.south, extent.north);
530
- return this.clampWestEast(extent.west, extent.east);
531
- }
532
- }
533
- _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
534
- export default Extent;
@@ -1,109 +0,0 @@
1
- import * as THREE from 'three';
2
- import Coordinates from "./Coordinates.js";
3
- import CRS from "./Crs.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;