itowns 2.44.3-next.4 → 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.
- package/README.md +3 -129
- package/examples/3dtiles_loader.html +123 -48
- package/examples/config.json +3 -10
- package/examples/copc_simple_loader.html +15 -5
- package/examples/effects_stereo.html +2 -2
- package/examples/entwine_3d_loader.html +3 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/examples/images/itowns_logo.svg +123 -0
- package/examples/js/plugins/COGParser.js +1 -1
- package/examples/jsm/OGC3DTilesHelper.js +6 -1
- package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
- package/examples/misc_collada.html +2 -2
- package/examples/source_file_geojson_3d.html +0 -1
- package/examples/source_file_kml_raster_usgs.html +0 -1
- package/examples/source_stream_wfs_raster.html +0 -7
- package/examples/vector_tile_mapbox_raster.html +91 -0
- package/examples/view_3d_map_webxr.html +3 -1
- package/examples/view_multi_25d.html +2 -2
- package/package.json +21 -75
- package/CODING.md +0 -120
- package/CONTRIBUTING.md +0 -150
- package/CONTRIBUTORS.md +0 -55
- package/LICENSE.md +0 -44
- package/changelog.md +0 -1361
- package/dist/455.js +0 -2
- package/dist/455.js.map +0 -1
- package/dist/debug.js +0 -3
- package/dist/debug.js.LICENSE.txt +0 -13
- package/dist/debug.js.map +0 -1
- package/dist/itowns.js +0 -3
- package/dist/itowns.js.LICENSE.txt +0 -7
- package/dist/itowns.js.map +0 -1
- package/dist/itowns_lasparser.js +0 -2
- package/dist/itowns_lasparser.js.map +0 -1
- package/dist/itowns_lasworker.js +0 -2
- package/dist/itowns_lasworker.js.map +0 -1
- package/dist/itowns_potree2worker.js +0 -2
- package/dist/itowns_potree2worker.js.map +0 -1
- package/dist/itowns_widgets.js +0 -2
- package/dist/itowns_widgets.js.map +0 -1
- package/examples/.eslintrc.cjs +0 -35
- package/examples/3dtiles_25d.html +0 -120
- package/examples/3dtiles_basic.html +0 -94
- package/examples/3dtiles_batch_table.html +0 -86
- package/examples/3dtiles_ion.html +0 -126
- package/examples/3dtiles_pointcloud.html +0 -95
- package/examples/jsm/.eslintrc.cjs +0 -38
- package/lib/Controls/FirstPersonControls.js +0 -308
- package/lib/Controls/FlyControls.js +0 -175
- package/lib/Controls/GlobeControls.js +0 -1162
- package/lib/Controls/PlanarControls.js +0 -1025
- package/lib/Controls/StateControl.js +0 -429
- package/lib/Controls/StreetControls.js +0 -392
- package/lib/Converter/Feature2Mesh.js +0 -608
- package/lib/Converter/Feature2Texture.js +0 -170
- package/lib/Converter/convertToTile.js +0 -75
- package/lib/Converter/textureConverter.js +0 -44
- package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
- package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
- package/lib/Core/3DTiles/C3DTFeature.js +0 -110
- package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
- package/lib/Core/3DTiles/C3DTileset.js +0 -99
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
- package/lib/Core/AnimationPlayer.js +0 -142
- package/lib/Core/CopcNode.js +0 -174
- package/lib/Core/Deprecated/Undeprecator.js +0 -75
- package/lib/Core/EntwinePointTileNode.js +0 -126
- package/lib/Core/Feature.js +0 -490
- package/lib/Core/Geographic/CoordStars.js +0 -80
- package/lib/Core/Geographic/Coordinates.js +0 -320
- package/lib/Core/Geographic/Crs.js +0 -175
- package/lib/Core/Geographic/Extent.js +0 -726
- package/lib/Core/Geographic/GeoidGrid.js +0 -109
- package/lib/Core/Label.js +0 -222
- package/lib/Core/MainLoop.js +0 -211
- package/lib/Core/Math/Ellipsoid.js +0 -144
- package/lib/Core/Picking.js +0 -255
- package/lib/Core/PointCloudNode.js +0 -42
- package/lib/Core/Potree2Node.js +0 -206
- package/lib/Core/Potree2PointAttributes.js +0 -139
- package/lib/Core/PotreeNode.js +0 -101
- package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
- package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
- package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
- package/lib/Core/Prefab/GlobeView.js +0 -161
- package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
- package/lib/Core/Prefab/PlanarView.js +0 -62
- package/lib/Core/Prefab/TileBuilder.js +0 -80
- package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
- package/lib/Core/Scheduler/Cache.js +0 -256
- package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
- package/lib/Core/Scheduler/Scheduler.js +0 -294
- package/lib/Core/Style.js +0 -1121
- package/lib/Core/System/Capabilities.js +0 -63
- package/lib/Core/TileGeometry.js +0 -40
- package/lib/Core/TileMesh.js +0 -108
- package/lib/Core/View.js +0 -1109
- package/lib/Layer/C3DTilesLayer.js +0 -455
- package/lib/Layer/ColorLayer.js +0 -128
- package/lib/Layer/CopcLayer.js +0 -58
- package/lib/Layer/ElevationLayer.js +0 -107
- package/lib/Layer/EntwinePointTileLayer.js +0 -64
- package/lib/Layer/FeatureGeometryLayer.js +0 -63
- package/lib/Layer/GeoidLayer.js +0 -80
- package/lib/Layer/GeometryLayer.js +0 -202
- package/lib/Layer/InfoLayer.js +0 -64
- package/lib/Layer/LabelLayer.js +0 -452
- package/lib/Layer/Layer.js +0 -304
- package/lib/Layer/LayerUpdateState.js +0 -89
- package/lib/Layer/LayerUpdateStrategy.js +0 -80
- package/lib/Layer/OGC3DTilesLayer.js +0 -387
- package/lib/Layer/OrientedImageLayer.js +0 -222
- package/lib/Layer/PointCloudLayer.js +0 -359
- package/lib/Layer/Potree2Layer.js +0 -164
- package/lib/Layer/PotreeLayer.js +0 -65
- package/lib/Layer/RasterLayer.js +0 -27
- package/lib/Layer/ReferencingLayerProperties.js +0 -62
- package/lib/Layer/TiledGeometryLayer.js +0 -403
- package/lib/Loader/LASLoader.js +0 -193
- package/lib/Loader/Potree2BrotliLoader.js +0 -261
- package/lib/Loader/Potree2Loader.js +0 -207
- package/lib/Main.js +0 -115
- package/lib/MainBundle.js +0 -4
- package/lib/Parser/B3dmParser.js +0 -174
- package/lib/Parser/CameraCalibrationParser.js +0 -94
- package/lib/Parser/GDFParser.js +0 -72
- package/lib/Parser/GTXParser.js +0 -75
- package/lib/Parser/GeoJsonParser.js +0 -212
- package/lib/Parser/GpxParser.js +0 -25
- package/lib/Parser/ISGParser.js +0 -71
- package/lib/Parser/KMLParser.js +0 -25
- package/lib/Parser/LASParser.js +0 -137
- package/lib/Parser/MapBoxUrlParser.js +0 -83
- package/lib/Parser/PntsParser.js +0 -131
- package/lib/Parser/Potree2BinParser.js +0 -92
- package/lib/Parser/PotreeBinParser.js +0 -106
- package/lib/Parser/PotreeCinParser.js +0 -29
- package/lib/Parser/ShapefileParser.js +0 -78
- package/lib/Parser/VectorTileParser.js +0 -202
- package/lib/Parser/XbilParser.js +0 -108
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
- package/lib/Parser/iGLTFLoader.js +0 -168
- package/lib/Process/3dTilesProcessing.js +0 -304
- package/lib/Process/FeatureProcessing.js +0 -76
- package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
- package/lib/Process/ObjectRemovalHelper.js +0 -97
- package/lib/Process/handlerNodeError.js +0 -23
- package/lib/Provider/3dTilesProvider.js +0 -149
- package/lib/Provider/DataSourceProvider.js +0 -8
- package/lib/Provider/Fetcher.js +0 -229
- package/lib/Provider/PointCloudProvider.js +0 -45
- package/lib/Provider/TileProvider.js +0 -16
- package/lib/Provider/URLBuilder.js +0 -105
- package/lib/Renderer/Camera.js +0 -281
- package/lib/Renderer/Color.js +0 -56
- package/lib/Renderer/ColorLayersOrdering.js +0 -115
- package/lib/Renderer/CommonMaterial.js +0 -31
- package/lib/Renderer/Label2DRenderer.js +0 -190
- package/lib/Renderer/LayeredMaterial.js +0 -243
- package/lib/Renderer/OBB.js +0 -153
- package/lib/Renderer/OrientedImageCamera.js +0 -118
- package/lib/Renderer/OrientedImageMaterial.js +0 -167
- package/lib/Renderer/PointsMaterial.js +0 -485
- package/lib/Renderer/RasterTile.js +0 -209
- package/lib/Renderer/RenderMode.js +0 -31
- package/lib/Renderer/Shader/ShaderChunk.js +0 -160
- package/lib/Renderer/Shader/ShaderUtils.js +0 -47
- package/lib/Renderer/SphereHelper.js +0 -23
- package/lib/Renderer/WebXR.js +0 -51
- package/lib/Renderer/c3DEngine.js +0 -214
- package/lib/Source/C3DTilesGoogleSource.js +0 -74
- package/lib/Source/C3DTilesIonSource.js +0 -54
- package/lib/Source/C3DTilesSource.js +0 -30
- package/lib/Source/CopcSource.js +0 -115
- package/lib/Source/EntwinePointTileSource.js +0 -62
- package/lib/Source/FileSource.js +0 -189
- package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
- package/lib/Source/OGC3DTilesIonSource.js +0 -34
- package/lib/Source/OGC3DTilesSource.js +0 -21
- package/lib/Source/OrientedImageSource.js +0 -59
- package/lib/Source/Potree2Source.js +0 -167
- package/lib/Source/PotreeSource.js +0 -82
- package/lib/Source/Source.js +0 -223
- package/lib/Source/TMSSource.js +0 -143
- package/lib/Source/VectorTilesSource.js +0 -178
- package/lib/Source/WFSSource.js +0 -165
- package/lib/Source/WMSSource.js +0 -130
- package/lib/Source/WMTSSource.js +0 -86
- package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
- package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
- package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
- package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
- package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
- package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
- package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
- package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
- package/lib/Utils/CameraUtils.js +0 -555
- package/lib/Utils/DEMUtils.js +0 -350
- package/lib/Utils/FeaturesUtils.js +0 -156
- package/lib/Utils/Gradients.js +0 -16
- package/lib/Utils/OrientationUtils.js +0 -457
- package/lib/Utils/ThreeUtils.js +0 -115
- package/lib/Utils/gui/C3DTilesStyle.js +0 -216
- package/lib/Utils/gui/Main.js +0 -7
- package/lib/Utils/gui/Minimap.js +0 -154
- package/lib/Utils/gui/Navigation.js +0 -245
- package/lib/Utils/gui/Scale.js +0 -107
- package/lib/Utils/gui/Searchbar.js +0 -234
- package/lib/Utils/gui/Widget.js +0 -80
- package/lib/Utils/placeObjectOnGround.js +0 -137
- package/lib/Worker/LASLoaderWorker.js +0 -19
- package/lib/Worker/Potree2Worker.js +0 -21
|
@@ -1,726 +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 _countTiles = new THREE.Vector2();
|
|
13
|
-
const _box = new THREE.Box3();
|
|
14
|
-
const tmsCoord = new THREE.Vector2();
|
|
15
|
-
const dimensionTile = new THREE.Vector2();
|
|
16
|
-
const defaultScheme = new THREE.Vector2(2, 2);
|
|
17
|
-
const r = {
|
|
18
|
-
row: 0,
|
|
19
|
-
col: 0,
|
|
20
|
-
invDiff: 0
|
|
21
|
-
};
|
|
22
|
-
const cNorthWest = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
23
|
-
const cSouthWest = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
24
|
-
const cNorthEast = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
25
|
-
const southWest = new THREE.Vector3();
|
|
26
|
-
const northEast = new THREE.Vector3();
|
|
27
|
-
function _rowColfromParent(extent, zoom) {
|
|
28
|
-
const diffLevel = extent.zoom - zoom;
|
|
29
|
-
const diff = 2 ** diffLevel;
|
|
30
|
-
r.invDiff = 1 / diff;
|
|
31
|
-
r.row = (extent.row - extent.row % diff) * r.invDiff;
|
|
32
|
-
r.col = (extent.col - extent.col % diff) * r.invDiff;
|
|
33
|
-
return r;
|
|
34
|
-
}
|
|
35
|
-
let _extent;
|
|
36
|
-
let _extent2;
|
|
37
|
-
const cardinals = new Array(8);
|
|
38
|
-
for (let i = cardinals.length - 1; i >= 0; i--) {
|
|
39
|
-
cardinals[i] = new Coordinates('EPSG:4326', 0, 0, 0, 0);
|
|
40
|
-
}
|
|
41
|
-
const _c = new Coordinates('EPSG:4326', 0, 0);
|
|
42
|
-
|
|
43
|
-
/** @private */
|
|
44
|
-
export const globalExtentTMS = new Map();
|
|
45
|
-
/** @private */
|
|
46
|
-
export const schemeTiles = new Map();
|
|
47
|
-
function getInfoTms(crs) {
|
|
48
|
-
const epsg = CRS.formatToEPSG(crs);
|
|
49
|
-
const globalExtent = globalExtentTMS.get(epsg);
|
|
50
|
-
const globalDimension = globalExtent.planarDimensions(_dim2);
|
|
51
|
-
const tms = CRS.formatToTms(crs);
|
|
52
|
-
const sTs = schemeTiles.get(tms) || schemeTiles.get('default');
|
|
53
|
-
// The isInverted parameter is to be set to the correct value, true or false
|
|
54
|
-
// (default being false) if the computation of the coordinates needs to be
|
|
55
|
-
// inverted to match the same scheme as OSM, Google Maps or other system.
|
|
56
|
-
// See link below for more information
|
|
57
|
-
// https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
|
|
58
|
-
// in crs includes ':NI' => tms isn't inverted (NOT INVERTED)
|
|
59
|
-
const isInverted = !tms.includes(':NI');
|
|
60
|
-
return {
|
|
61
|
-
epsg,
|
|
62
|
-
globalExtent,
|
|
63
|
-
globalDimension,
|
|
64
|
-
sTs,
|
|
65
|
-
isInverted
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function getCountTiles(crs, zoom) {
|
|
69
|
-
const sTs = schemeTiles.get(CRS.formatToTms(crs)) || schemeTiles.get('default');
|
|
70
|
-
const count = 2 ** zoom;
|
|
71
|
-
_countTiles.set(count, count).multiply(sTs);
|
|
72
|
-
return _countTiles;
|
|
73
|
-
}
|
|
74
|
-
class Extent {
|
|
75
|
-
/**
|
|
76
|
-
* Extent is geographical bounding rectangle defined by 4 limits: west, east, south and north.
|
|
77
|
-
* If crs is tiled projection (WMTS or TMS), the extent is defined by zoom, row and column.
|
|
78
|
-
*
|
|
79
|
-
* Warning, using geocentric projection isn't consistent with geographical extent.
|
|
80
|
-
*
|
|
81
|
-
* @param {String} crs projection of limit values.
|
|
82
|
-
* @param {number|Array.<number>|Coordinates|Object} v0 west value, zoom
|
|
83
|
-
* value, Array of values [west, east, south and north], Coordinates of
|
|
84
|
-
* west-south corner or object {west, east, south and north}
|
|
85
|
-
* @param {number|Coordinates} [v1] east value, row value or Coordinates of
|
|
86
|
-
* east-north corner
|
|
87
|
-
* @param {number} [v2] south value or column value
|
|
88
|
-
* @param {number} [v3] north value
|
|
89
|
-
*/
|
|
90
|
-
constructor(crs, v0, v1, v2, v3) {
|
|
91
|
-
if (CRS.isGeocentric(crs)) {
|
|
92
|
-
throw new Error(`${crs} is a geocentric projection, it doesn't make sense with a geographical extent`);
|
|
93
|
-
}
|
|
94
|
-
this.isExtent = true;
|
|
95
|
-
this.crs = crs;
|
|
96
|
-
// Scale/zoom
|
|
97
|
-
this.zoom = 0;
|
|
98
|
-
if (CRS.isTms(this.crs)) {
|
|
99
|
-
this.row = 0;
|
|
100
|
-
this.col = 0;
|
|
101
|
-
} else {
|
|
102
|
-
this.west = 0;
|
|
103
|
-
this.east = 0;
|
|
104
|
-
this.south = 0;
|
|
105
|
-
this.north = 0;
|
|
106
|
-
}
|
|
107
|
-
this.set(v0, v1, v2, v3);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Clone this extent
|
|
112
|
-
* @return {Extent} cloned extent
|
|
113
|
-
*/
|
|
114
|
-
clone() {
|
|
115
|
-
if (CRS.isTms(this.crs)) {
|
|
116
|
-
return new Extent(this.crs, this.zoom, this.row, this.col);
|
|
117
|
-
} else {
|
|
118
|
-
return new Extent(this.crs, this.west, this.east, this.south, this.north);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* get tiled extents convering this extent
|
|
124
|
-
*
|
|
125
|
-
* @param {string} crs WMTS, TMS crs
|
|
126
|
-
* @return {Array<Extent>} array of extents covering
|
|
127
|
-
*/
|
|
128
|
-
tiledCovering(crs) {
|
|
129
|
-
if (this.crs == 'EPSG:4326' && crs == CRS.tms_3857) {
|
|
130
|
-
const extents_WMTS_PM = [];
|
|
131
|
-
const extent = _extent.copy(this).as(CRS.formatToEPSG(crs), _extent2);
|
|
132
|
-
const {
|
|
133
|
-
globalExtent,
|
|
134
|
-
globalDimension,
|
|
135
|
-
sTs
|
|
136
|
-
} = getInfoTms(CRS.formatToEPSG(crs));
|
|
137
|
-
extent.clampByExtent(globalExtent);
|
|
138
|
-
extent.planarDimensions(dimensionTile);
|
|
139
|
-
const zoom = this.zoom + 1 || Math.floor(Math.log2(Math.round(globalDimension.x / (dimensionTile.x * sTs.x))));
|
|
140
|
-
const countTiles = getCountTiles(crs, zoom);
|
|
141
|
-
const center = extent.center(_c);
|
|
142
|
-
tmsCoord.x = center.x - globalExtent.west;
|
|
143
|
-
tmsCoord.y = globalExtent.north - extent.north;
|
|
144
|
-
tmsCoord.divide(globalDimension).multiply(countTiles).floor();
|
|
145
|
-
|
|
146
|
-
// ]N; N+1] => N
|
|
147
|
-
const maxRow = Math.ceil((globalExtent.north - extent.south) / globalDimension.x * countTiles.y) - 1;
|
|
148
|
-
for (let r = maxRow; r >= tmsCoord.y; r--) {
|
|
149
|
-
extents_WMTS_PM.push(new Extent(crs, zoom, r, tmsCoord.x));
|
|
150
|
-
}
|
|
151
|
-
return extents_WMTS_PM;
|
|
152
|
-
} else {
|
|
153
|
-
const target = new Extent(crs, 0, 0, 0);
|
|
154
|
-
const {
|
|
155
|
-
globalExtent,
|
|
156
|
-
globalDimension,
|
|
157
|
-
sTs,
|
|
158
|
-
isInverted
|
|
159
|
-
} = getInfoTms(this.crs);
|
|
160
|
-
const center = this.center(_c);
|
|
161
|
-
this.planarDimensions(dimensionTile);
|
|
162
|
-
// Each level has 2^n * 2^n tiles...
|
|
163
|
-
// ... so we count how many tiles of the same width as tile we can fit in the layer
|
|
164
|
-
// ... 2^zoom = tilecount => zoom = log2(tilecount)
|
|
165
|
-
const zoom = Math.floor(Math.log2(Math.round(globalDimension.x / (dimensionTile.x * sTs.x))));
|
|
166
|
-
const countTiles = getCountTiles(crs, zoom);
|
|
167
|
-
|
|
168
|
-
// Now that we have computed zoom, we can deduce x and y (or row / column)
|
|
169
|
-
tmsCoord.x = center.x - globalExtent.west;
|
|
170
|
-
tmsCoord.y = isInverted ? globalExtent.north - center.y : center.y - globalExtent.south;
|
|
171
|
-
tmsCoord.divide(globalDimension).multiply(countTiles).floor();
|
|
172
|
-
target.set(zoom, tmsCoord.y, tmsCoord.x);
|
|
173
|
-
return [target];
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Convert Extent to the specified projection.
|
|
179
|
-
* @param {string} crs the projection of destination.
|
|
180
|
-
* @param {Extent} target copy the destination to target.
|
|
181
|
-
* @return {Extent}
|
|
182
|
-
*/
|
|
183
|
-
as(crs, target) {
|
|
184
|
-
CRS.isValid(crs);
|
|
185
|
-
target = target || new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
186
|
-
if (CRS.isTms(this.crs)) {
|
|
187
|
-
const {
|
|
188
|
-
epsg,
|
|
189
|
-
globalExtent,
|
|
190
|
-
globalDimension
|
|
191
|
-
} = getInfoTms(this.crs);
|
|
192
|
-
const countTiles = getCountTiles(this.crs, this.zoom);
|
|
193
|
-
dimensionTile.set(1, 1).divide(countTiles).multiply(globalDimension);
|
|
194
|
-
target.west = globalExtent.west + (globalDimension.x - dimensionTile.x * (countTiles.x - this.col));
|
|
195
|
-
target.east = target.west + dimensionTile.x;
|
|
196
|
-
target.south = globalExtent.south + dimensionTile.y * (countTiles.y - this.row - 1);
|
|
197
|
-
target.north = target.south + dimensionTile.y;
|
|
198
|
-
target.crs = epsg;
|
|
199
|
-
target.zoom = this.zoom;
|
|
200
|
-
return crs == epsg ? target : target.as(crs, target);
|
|
201
|
-
} else if (CRS.isEpsg(crs)) {
|
|
202
|
-
if (this.crs != crs) {
|
|
203
|
-
// Compute min/max in x/y by projecting 8 cardinal points,
|
|
204
|
-
// and then taking the min/max of each coordinates.
|
|
205
|
-
const center = this.center(_c);
|
|
206
|
-
cardinals[0].setFromValues(this.west, this.north);
|
|
207
|
-
cardinals[1].setFromValues(center.x, this.north);
|
|
208
|
-
cardinals[2].setFromValues(this.east, this.north);
|
|
209
|
-
cardinals[3].setFromValues(this.east, center.y);
|
|
210
|
-
cardinals[4].setFromValues(this.east, this.south);
|
|
211
|
-
cardinals[5].setFromValues(center.x, this.south);
|
|
212
|
-
cardinals[6].setFromValues(this.west, this.south);
|
|
213
|
-
cardinals[7].setFromValues(this.west, center.y);
|
|
214
|
-
target.set(Infinity, -Infinity, Infinity, -Infinity);
|
|
215
|
-
|
|
216
|
-
// loop over the coordinates
|
|
217
|
-
for (let i = 0; i < cardinals.length; i++) {
|
|
218
|
-
// convert the coordinate.
|
|
219
|
-
cardinals[i].crs = this.crs;
|
|
220
|
-
cardinals[i].as(crs, _c);
|
|
221
|
-
target.north = Math.max(target.north, _c.y);
|
|
222
|
-
target.south = Math.min(target.south, _c.y);
|
|
223
|
-
target.east = Math.max(target.east, _c.x);
|
|
224
|
-
target.west = Math.min(target.west, _c.x);
|
|
225
|
-
}
|
|
226
|
-
target.zoom = this.zoom;
|
|
227
|
-
target.crs = crs;
|
|
228
|
-
return target;
|
|
229
|
-
}
|
|
230
|
-
target.crs = crs;
|
|
231
|
-
target.zoom = this.zoom;
|
|
232
|
-
target.set(this.west, this.east, this.south, this.north);
|
|
233
|
-
return target;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Return the center of Extent
|
|
239
|
-
* @param {Coordinates} target copy the center to the target.
|
|
240
|
-
* @return {Coordinates}
|
|
241
|
-
*/
|
|
242
|
-
center() {
|
|
243
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Coordinates(this.crs);
|
|
244
|
-
if (CRS.isTms(this.crs)) {
|
|
245
|
-
throw new Error('Invalid operation for WMTS bbox');
|
|
246
|
-
}
|
|
247
|
-
this.planarDimensions(_dim);
|
|
248
|
-
target.crs = this.crs;
|
|
249
|
-
target.setFromValues(this.west + _dim.x * 0.5, this.south + _dim.y * 0.5);
|
|
250
|
-
return target;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Returns the dimension of the extent, in a `THREE.Vector2`.
|
|
255
|
-
*
|
|
256
|
-
* @param {THREE.Vector2} [target] - The target to assign the result in.
|
|
257
|
-
*
|
|
258
|
-
* @return {THREE.Vector2}
|
|
259
|
-
*/
|
|
260
|
-
dimensions() {
|
|
261
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
262
|
-
console.warn('Extent.dimensions is deprecated, use planarDimensions, geodeticDimensions or spatialEuclideanDimensions');
|
|
263
|
-
target.x = Math.abs(this.east - this.west);
|
|
264
|
-
target.y = Math.abs(this.north - this.south);
|
|
265
|
-
return target;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Planar dimensions are two planar distances west/east and south/north.
|
|
270
|
-
* Planar distance straight-line Euclidean distance calculated in a 2D Cartesian coordinate system.
|
|
271
|
-
*
|
|
272
|
-
* @param {THREE.Vector2} [target=new THREE.Vector2()] The target
|
|
273
|
-
* @return {THREE.Vector2} Planar dimensions
|
|
274
|
-
*/
|
|
275
|
-
planarDimensions() {
|
|
276
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
277
|
-
// Calculte the dimensions for x and y
|
|
278
|
-
return target.set(Math.abs(this.east - this.west), Math.abs(this.north - this.south));
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Geodetic dimensions are two planar distances west/east and south/north.
|
|
283
|
-
* Geodetic distance is calculated in an ellispoid space as the distance
|
|
284
|
-
* across the curved surface of the world.
|
|
285
|
-
*
|
|
286
|
-
* @param {THREE.Vector2} [target=new THREE.Vector2()] The target
|
|
287
|
-
* @return {THREE.Vector2} geodetic dimensions
|
|
288
|
-
*/
|
|
289
|
-
geodeticDimensions() {
|
|
290
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
291
|
-
// set 3 corners extent
|
|
292
|
-
cNorthWest.crs = this.crs;
|
|
293
|
-
cSouthWest.crs = this.crs;
|
|
294
|
-
cNorthEast.crs = this.crs;
|
|
295
|
-
cNorthWest.setFromValues(this.west, this.north, 0);
|
|
296
|
-
cSouthWest.setFromValues(this.west, this.south, 0);
|
|
297
|
-
cNorthEast.setFromValues(this.east, this.north, 0);
|
|
298
|
-
|
|
299
|
-
// calcul geodetic distance northWest/northEast and northWest/southWest
|
|
300
|
-
return target.set(cNorthWest.geodeticDistanceTo(cNorthEast), cNorthWest.geodeticDistanceTo(cSouthWest));
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Spatial euclidean dimensions are two spatial euclidean distances between west/east corner and south/north corner.
|
|
305
|
-
* Spatial euclidean distance chord is calculated in a ellispoid space.
|
|
306
|
-
*
|
|
307
|
-
* @param {THREE.Vector2} [target=new THREE.Vector2()] The target
|
|
308
|
-
* @return {THREE.Vector2} spatial euclidean dimensions
|
|
309
|
-
*/
|
|
310
|
-
spatialEuclideanDimensions() {
|
|
311
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
312
|
-
// set 3 corners extent
|
|
313
|
-
cNorthWest.crs = this.crs;
|
|
314
|
-
cSouthWest.crs = this.crs;
|
|
315
|
-
cNorthEast.crs = this.crs;
|
|
316
|
-
cNorthWest.setFromValues(this.west, this.north, 0);
|
|
317
|
-
cSouthWest.setFromValues(this.west, this.south, 0);
|
|
318
|
-
cNorthEast.setFromValues(this.east, this.north, 0);
|
|
319
|
-
|
|
320
|
-
// calcul chord distance northWest/northEast and northWest/southWest
|
|
321
|
-
return target.set(cNorthWest.spatialEuclideanDistanceTo(cNorthEast), cNorthWest.spatialEuclideanDistanceTo(cSouthWest));
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Return true if `coord` is inside the bounding box.
|
|
326
|
-
*
|
|
327
|
-
* @param {Coordinates} coord
|
|
328
|
-
* @param {number} [epsilon=0] - to take into account when comparing to the
|
|
329
|
-
* point.
|
|
330
|
-
*
|
|
331
|
-
* @return {boolean}
|
|
332
|
-
*/
|
|
333
|
-
isPointInside(coord) {
|
|
334
|
-
let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
335
|
-
if (this.crs == coord.crs) {
|
|
336
|
-
_c.copy(coord);
|
|
337
|
-
} else {
|
|
338
|
-
coord.as(this.crs, _c);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// TODO this ignores altitude
|
|
342
|
-
return _c.x <= this.east + epsilon && _c.x >= this.west - epsilon && _c.y <= this.north + epsilon && _c.y >= this.south - epsilon;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Return true if `extent` is inside this extent.
|
|
347
|
-
*
|
|
348
|
-
* @param {Extent} extent the extent to check
|
|
349
|
-
* @param {number} epsilon to take into account when comparing to the
|
|
350
|
-
* point.
|
|
351
|
-
*
|
|
352
|
-
* @return {boolean}
|
|
353
|
-
*/
|
|
354
|
-
isInside(extent, epsilon) {
|
|
355
|
-
if (CRS.isTms(this.crs)) {
|
|
356
|
-
if (this.zoom == extent.zoom) {
|
|
357
|
-
return this.row == extent.row && this.col == extent.col;
|
|
358
|
-
} else if (this.zoom < extent.zoom) {
|
|
359
|
-
return false;
|
|
360
|
-
} else {
|
|
361
|
-
_rowColfromParent(this, extent.zoom);
|
|
362
|
-
return r.row == extent.row && r.col == extent.col;
|
|
363
|
-
}
|
|
364
|
-
} else {
|
|
365
|
-
extent.as(this.crs, _extent);
|
|
366
|
-
epsilon = epsilon == undefined ? CRS.reasonnableEpsilon(this.crs) : epsilon;
|
|
367
|
-
return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Return the translation and scale to transform this extent to input extent.
|
|
373
|
-
*
|
|
374
|
-
* @param {Extent} extent input extent
|
|
375
|
-
* @param {THREE.Vector4} target copy the result to target.
|
|
376
|
-
* @return {THREE.Vector4} {x: translation on west-east, y: translation on south-north, z: scale on west-east, w: scale on south-north}
|
|
377
|
-
*/
|
|
378
|
-
offsetToParent(extent) {
|
|
379
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
|
|
380
|
-
if (this.crs != extent.crs) {
|
|
381
|
-
throw new Error('unsupported mix');
|
|
382
|
-
}
|
|
383
|
-
if (CRS.isTms(this.crs)) {
|
|
384
|
-
_rowColfromParent(this, extent.zoom);
|
|
385
|
-
return target.set(this.col * r.invDiff - r.col, this.row * r.invDiff - r.row, r.invDiff, r.invDiff);
|
|
386
|
-
}
|
|
387
|
-
extent.planarDimensions(_dim);
|
|
388
|
-
this.planarDimensions(_dim2);
|
|
389
|
-
const originX = (this.west - extent.west) / _dim.x;
|
|
390
|
-
const originY = (extent.north - this.north) / _dim.y;
|
|
391
|
-
const scaleX = _dim2.x / _dim.x;
|
|
392
|
-
const scaleY = _dim2.y / _dim.y;
|
|
393
|
-
return target.set(originX, originY, scaleX, scaleY);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Return parent tiled extent with input level
|
|
398
|
-
*
|
|
399
|
-
* @param {number} levelParent level of parent.
|
|
400
|
-
* @return {Extent}
|
|
401
|
-
*/
|
|
402
|
-
tiledExtentParent(levelParent) {
|
|
403
|
-
if (levelParent && levelParent < this.zoom) {
|
|
404
|
-
_rowColfromParent(this, levelParent);
|
|
405
|
-
return new Extent(this.crs, levelParent, r.row, r.col);
|
|
406
|
-
} else {
|
|
407
|
-
return this;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Return true if this bounding box intersect with the bouding box parameter
|
|
413
|
-
* @param {Extent} extent
|
|
414
|
-
* @returns {Boolean}
|
|
415
|
-
*/
|
|
416
|
-
intersectsExtent(extent) {
|
|
417
|
-
return Extent.intersectsExtent(this, extent);
|
|
418
|
-
}
|
|
419
|
-
static intersectsExtent(extentA, extentB) {
|
|
420
|
-
// TODO don't work when is on limit
|
|
421
|
-
const other = extentB.crs == extentA.crs ? extentB : extentB.as(extentA.crs, _extent);
|
|
422
|
-
return !(extentA.west >= other.east || extentA.east <= other.west || extentA.south >= other.north || extentA.north <= other.south);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Return the intersection of this extent with another one
|
|
427
|
-
* @param {Extent} extent
|
|
428
|
-
* @returns {Boolean}
|
|
429
|
-
*/
|
|
430
|
-
intersect(extent) {
|
|
431
|
-
if (!this.intersectsExtent(extent)) {
|
|
432
|
-
return new Extent(this.crs, 0, 0, 0, 0);
|
|
433
|
-
}
|
|
434
|
-
if (extent.crs != this.crs) {
|
|
435
|
-
extent = extent.as(this.crs, _extent);
|
|
436
|
-
}
|
|
437
|
-
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));
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Set west, east, south and north values.
|
|
442
|
-
* Or if tiled extent, set zoom, row and column values
|
|
443
|
-
*
|
|
444
|
-
* @param {number|Array.<number>|Coordinates|Object|Extent} v0 west value,
|
|
445
|
-
* zoom value, Array of values [west, east, south and north], Extent of same
|
|
446
|
-
* type (tiled or not), Coordinates of west-south corner or object {west,
|
|
447
|
-
* east, south and north}
|
|
448
|
-
* @param {number|Coordinates} [v1] east value, row value or Coordinates of
|
|
449
|
-
* east-north corner
|
|
450
|
-
* @param {number} [v2] south value or column value
|
|
451
|
-
* @param {number} [v3] north value
|
|
452
|
-
*
|
|
453
|
-
* @return {Extent}
|
|
454
|
-
*/
|
|
455
|
-
set(v0, v1, v2, v3) {
|
|
456
|
-
if (v0 == undefined) {
|
|
457
|
-
throw new Error('No values to set in the extent');
|
|
458
|
-
}
|
|
459
|
-
if (v0.isExtent) {
|
|
460
|
-
if (CRS.isTms(v0.crs)) {
|
|
461
|
-
v1 = v0.row;
|
|
462
|
-
v2 = v0.col;
|
|
463
|
-
v0 = v0.zoom;
|
|
464
|
-
} else {
|
|
465
|
-
v1 = v0.east;
|
|
466
|
-
v2 = v0.south;
|
|
467
|
-
v3 = v0.north;
|
|
468
|
-
v0 = v0.west;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (CRS.isTms(this.crs)) {
|
|
472
|
-
this.zoom = v0;
|
|
473
|
-
this.row = v1;
|
|
474
|
-
this.col = v2;
|
|
475
|
-
} else if (v0.isCoordinates) {
|
|
476
|
-
// seem never used
|
|
477
|
-
this.west = v0.x;
|
|
478
|
-
this.east = v1.x;
|
|
479
|
-
this.south = v0.y;
|
|
480
|
-
this.north = v1.y;
|
|
481
|
-
} else if (v0.west !== undefined) {
|
|
482
|
-
this.west = v0.west;
|
|
483
|
-
this.east = v0.east;
|
|
484
|
-
this.south = v0.south;
|
|
485
|
-
this.north = v0.north;
|
|
486
|
-
} else if (v0.length == 4) {
|
|
487
|
-
this.west = v0[0];
|
|
488
|
-
this.east = v0[1];
|
|
489
|
-
this.south = v0[2];
|
|
490
|
-
this.north = v0[3];
|
|
491
|
-
} else if (v3 !== undefined) {
|
|
492
|
-
this.west = v0;
|
|
493
|
-
this.east = v1;
|
|
494
|
-
this.south = v2;
|
|
495
|
-
this.north = v3;
|
|
496
|
-
}
|
|
497
|
-
return this;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Copy to this extent to input extent.
|
|
502
|
-
* @param {Extent} extent
|
|
503
|
-
* @return {Extent} copied extent
|
|
504
|
-
*/
|
|
505
|
-
copy(extent) {
|
|
506
|
-
this.crs = extent.crs;
|
|
507
|
-
return this.set(extent);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Union this extent with the input extent.
|
|
512
|
-
* @param {Extent} extent the extent to union.
|
|
513
|
-
*/
|
|
514
|
-
union(extent) {
|
|
515
|
-
if (extent.crs != this.crs) {
|
|
516
|
-
throw new Error('unsupported union between 2 diff crs');
|
|
517
|
-
}
|
|
518
|
-
if (this.west === Infinity) {
|
|
519
|
-
this.copy(extent);
|
|
520
|
-
} else {
|
|
521
|
-
const west = extent.west;
|
|
522
|
-
if (west < this.west) {
|
|
523
|
-
this.west = west;
|
|
524
|
-
}
|
|
525
|
-
const east = extent.east;
|
|
526
|
-
if (east > this.east) {
|
|
527
|
-
this.east = east;
|
|
528
|
-
}
|
|
529
|
-
const south = extent.south;
|
|
530
|
-
if (south < this.south) {
|
|
531
|
-
this.south = south;
|
|
532
|
-
}
|
|
533
|
-
const north = extent.north;
|
|
534
|
-
if (north > this.north) {
|
|
535
|
-
this.north = north;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* expandByCoordinates perfoms the minimal extension
|
|
542
|
-
* for the coordinates to belong to this Extent object
|
|
543
|
-
* @param {Coordinates} coordinates The coordinates to belong
|
|
544
|
-
*/
|
|
545
|
-
expandByCoordinates(coordinates) {
|
|
546
|
-
const coords = coordinates.crs == this.crs ? coordinates : coordinates.as(this.crs, _c);
|
|
547
|
-
this.expandByValuesCoordinates(coords.x, coords.y);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* expandByValuesCoordinates perfoms the minimal extension
|
|
552
|
-
* for the coordinates values to belong to this Extent object
|
|
553
|
-
* @param {number} we The coordinate on west-east
|
|
554
|
-
* @param {number} sn The coordinate on south-north
|
|
555
|
-
*
|
|
556
|
-
*/
|
|
557
|
-
expandByValuesCoordinates(we, sn) {
|
|
558
|
-
if (we < this.west) {
|
|
559
|
-
this.west = we;
|
|
560
|
-
}
|
|
561
|
-
if (we > this.east) {
|
|
562
|
-
this.east = we;
|
|
563
|
-
}
|
|
564
|
-
if (sn < this.south) {
|
|
565
|
-
this.south = sn;
|
|
566
|
-
}
|
|
567
|
-
if (sn > this.north) {
|
|
568
|
-
this.north = sn;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Instance Extent with THREE.Box3.
|
|
574
|
-
*
|
|
575
|
-
* If crs is a geocentric projection, the `box3.min` and `box3.max`
|
|
576
|
-
* should be the geocentric coordinates of `min` and `max` of a `box3`
|
|
577
|
-
* in local tangent plane.
|
|
578
|
-
*
|
|
579
|
-
* @param {string} crs Projection of extent to instancied.
|
|
580
|
-
* @param {THREE.Box3} box
|
|
581
|
-
* @return {Extent}
|
|
582
|
-
*/
|
|
583
|
-
static fromBox3(crs, box) {
|
|
584
|
-
if (CRS.isGeocentric(crs)) {
|
|
585
|
-
// if geocentric reproject box on 'EPSG:4326'
|
|
586
|
-
crs = 'EPSG:4326';
|
|
587
|
-
box = _box.copy(box);
|
|
588
|
-
cSouthWest.crs = crs;
|
|
589
|
-
cSouthWest.setFromVector3(box.min).as(crs, cSouthWest).toVector3(box.min);
|
|
590
|
-
cNorthEast.crs = crs;
|
|
591
|
-
cNorthEast.setFromVector3(box.max).as(crs, cNorthEast).toVector3(box.max);
|
|
592
|
-
}
|
|
593
|
-
return new Extent(crs, {
|
|
594
|
-
west: box.min.x,
|
|
595
|
-
east: box.max.x,
|
|
596
|
-
south: box.min.y,
|
|
597
|
-
north: box.max.y
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Return values of extent in string, separated by the separator input.
|
|
603
|
-
* @param {string} separator
|
|
604
|
-
* @return {string}
|
|
605
|
-
*/
|
|
606
|
-
toString() {
|
|
607
|
-
let separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
608
|
-
if (CRS.isTms(this.crs)) {
|
|
609
|
-
return `${this.zoom}${separator}${this.row}${separator}${this.col}`;
|
|
610
|
-
} else {
|
|
611
|
-
return `${this.east}${separator}${this.north}${separator}${this.west}${separator}${this.south}`;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Subdivide equally an extent from its center to return four extents:
|
|
617
|
-
* north-west, north-east, south-west and south-east.
|
|
618
|
-
*
|
|
619
|
-
* @returns {Extent[]} An array containing the four sections of the extent. The
|
|
620
|
-
* order of the sections is [NW, NE, SW, SE].
|
|
621
|
-
*/
|
|
622
|
-
subdivision() {
|
|
623
|
-
return this.subdivisionByScheme();
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* subdivise extent by scheme.x on west-east and scheme.y on south-north.
|
|
627
|
-
*
|
|
628
|
-
* @param {Vector2} [scheme=Vector2(2,2)] The scheme to subdivise.
|
|
629
|
-
* @return {Array<Extent>} subdivised extents.
|
|
630
|
-
*/
|
|
631
|
-
subdivisionByScheme() {
|
|
632
|
-
let scheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultScheme;
|
|
633
|
-
const subdivisedExtents = [];
|
|
634
|
-
const dimSub = this.planarDimensions(_dim).divide(scheme);
|
|
635
|
-
for (let x = scheme.x - 1; x >= 0; x--) {
|
|
636
|
-
for (let y = scheme.y - 1; y >= 0; y--) {
|
|
637
|
-
const west = this.west + x * dimSub.x;
|
|
638
|
-
const south = this.south + y * dimSub.y;
|
|
639
|
-
subdivisedExtents.push(new Extent(this.crs, west, west + dimSub.x, south, south + dimSub.y));
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
return subdivisedExtents;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Multiplies all extent `coordinates` (with an implicit 1 in the 4th dimension) and `matrix`.
|
|
647
|
-
*
|
|
648
|
-
* @param {THREE.Matrix4} matrix The matrix
|
|
649
|
-
* @return {Extent} return this extent instance.
|
|
650
|
-
*/
|
|
651
|
-
applyMatrix4(matrix) {
|
|
652
|
-
if (!CRS.isTms(this.crs)) {
|
|
653
|
-
southWest.set(this.west, this.south, 0).applyMatrix4(matrix);
|
|
654
|
-
northEast.set(this.east, this.north, 0).applyMatrix4(matrix);
|
|
655
|
-
this.west = southWest.x;
|
|
656
|
-
this.east = northEast.x;
|
|
657
|
-
this.south = southWest.y;
|
|
658
|
-
this.north = northEast.y;
|
|
659
|
-
if (this.west > this.east) {
|
|
660
|
-
const temp = this.west;
|
|
661
|
-
this.west = this.east;
|
|
662
|
-
this.east = temp;
|
|
663
|
-
}
|
|
664
|
-
if (this.south > this.north) {
|
|
665
|
-
const temp = this.south;
|
|
666
|
-
this.south = this.north;
|
|
667
|
-
this.north = temp;
|
|
668
|
-
}
|
|
669
|
-
return this;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* clamp south and north values
|
|
675
|
-
*
|
|
676
|
-
* @param {number} [south=this.south] The min south
|
|
677
|
-
* @param {number} [north=this.north] The max north
|
|
678
|
-
* @return {Extent} this extent
|
|
679
|
-
*/
|
|
680
|
-
clampSouthNorth() {
|
|
681
|
-
let south = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.south;
|
|
682
|
-
let north = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.north;
|
|
683
|
-
this.south = Math.max(this.south, south);
|
|
684
|
-
this.north = Math.min(this.north, north);
|
|
685
|
-
return this;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* clamp west and east values
|
|
690
|
-
*
|
|
691
|
-
* @param {number} [west=this.west] The min west
|
|
692
|
-
* @param {number} [east=this.east] The max east
|
|
693
|
-
* @return {Extent} this extent
|
|
694
|
-
*/
|
|
695
|
-
clampWestEast() {
|
|
696
|
-
let west = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.west;
|
|
697
|
-
let east = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.east;
|
|
698
|
-
this.west = Math.max(this.west, west);
|
|
699
|
-
this.east = Math.min(this.east, east);
|
|
700
|
-
return this;
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* clamp this extent by passed extent
|
|
704
|
-
*
|
|
705
|
-
* @param {Extent} extent The maximum extent.
|
|
706
|
-
* @return {Extent} this extent.
|
|
707
|
-
*/
|
|
708
|
-
clampByExtent(extent) {
|
|
709
|
-
this.clampSouthNorth(extent.south, extent.north);
|
|
710
|
-
return this.clampWestEast(extent.west, extent.east);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
_extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
714
|
-
_extent2 = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
715
|
-
globalExtentTMS.set('EPSG:4326', new Extent('EPSG:4326', -180, 180, -90, 90));
|
|
716
|
-
|
|
717
|
-
// Compute global extent of TMS in EPSG:3857
|
|
718
|
-
// It's square whose a side is between -180° to 180°.
|
|
719
|
-
// So, west extent, it's 180 convert in EPSG:3857
|
|
720
|
-
const extent3857 = globalExtentTMS.get('EPSG:4326').as('EPSG:3857');
|
|
721
|
-
extent3857.clampSouthNorth(extent3857.west, extent3857.east);
|
|
722
|
-
globalExtentTMS.set('EPSG:3857', extent3857);
|
|
723
|
-
schemeTiles.set('default', new THREE.Vector2(1, 1));
|
|
724
|
-
schemeTiles.set(CRS.tms_3857, schemeTiles.get('default'));
|
|
725
|
-
schemeTiles.set(CRS.tms_4326, new THREE.Vector2(2, 1));
|
|
726
|
-
export default Extent;
|