itowns 2.44.3-next.33 → 2.44.3-next.34
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/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/lib/Converter/textureConverter.js +1 -1
- package/lib/Core/Geographic/Extent.js +171 -152
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +1 -1
- package/lib/Core/Tile/Tile.js +39 -51
- package/lib/Core/Tile/TileGrid.js +12 -6
- package/lib/Source/Source.js +1 -1
- package/lib/Source/WFSSource.js +1 -1
- package/lib/Source/WMSSource.js +1 -1
- package/package.json +1 -1
package/lib/Core/Tile/Tile.js
CHANGED
|
@@ -10,7 +10,7 @@ const r = {
|
|
|
10
10
|
col: 0,
|
|
11
11
|
invDiff: 0
|
|
12
12
|
};
|
|
13
|
-
function _rowColfromParent(
|
|
13
|
+
function _rowColfromParent(tile, zoom) {
|
|
14
14
|
const diffLevel = tile.zoom - zoom;
|
|
15
15
|
const diff = 2 ** diffLevel;
|
|
16
16
|
r.invDiff = 1 / diff;
|
|
@@ -18,17 +18,18 @@ function _rowColfromParent(/** @type {Tile} */tile, /** @type {number} */zoom) {
|
|
|
18
18
|
r.col = (tile.col - tile.col % diff) * r.invDiff;
|
|
19
19
|
return r;
|
|
20
20
|
}
|
|
21
|
-
const _extent = new Extent('EPSG:4326'
|
|
22
|
-
const _extent2 = new Extent('EPSG:4326'
|
|
21
|
+
const _extent = new Extent('EPSG:4326');
|
|
22
|
+
const _extent2 = new Extent('EPSG:4326');
|
|
23
23
|
const _c = new Coordinates('EPSG:4326', 0, 0);
|
|
24
24
|
class Tile {
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* A tile is a geographical bounding rectangle uniquely defined by its zoom,
|
|
27
|
+
* row and column.
|
|
27
28
|
*
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
29
|
+
* @param crs - projection of limit values.
|
|
30
|
+
* @param zoom - `zoom` value. Default is 0.
|
|
31
|
+
* @param row - `row` value. Default is 0.
|
|
32
|
+
* @param col - `column` value. Default is 0.
|
|
32
33
|
*/
|
|
33
34
|
constructor(crs) {
|
|
34
35
|
let zoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -42,22 +43,21 @@ class Tile {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @return {Tile} cloned tile
|
|
46
|
+
* Returns a new tile with the same bounds and crs as this one.
|
|
47
47
|
*/
|
|
48
48
|
clone() {
|
|
49
49
|
return new Tile(this.crs, this.zoom, this.row, this.col);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
*
|
|
53
|
+
* Converts this tile to the specified extent.
|
|
54
|
+
* @param crs - target's projection.
|
|
55
|
+
* @param target - The target to store the projected extent. If this not
|
|
56
|
+
* provided a new extent will be created.
|
|
57
57
|
*/
|
|
58
|
-
toExtent(crs
|
|
58
|
+
toExtent(crs) {
|
|
59
|
+
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Extent('EPSG:4326');
|
|
59
60
|
CRS.isValid(crs);
|
|
60
|
-
target = target || new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
61
61
|
const {
|
|
62
62
|
epsg,
|
|
63
63
|
globalExtent,
|
|
@@ -70,16 +70,13 @@ class Tile {
|
|
|
70
70
|
target.south = globalExtent.south + _dimensionTile.y * (countTiles.y - this.row - 1);
|
|
71
71
|
target.north = target.south + _dimensionTile.y;
|
|
72
72
|
target.crs = epsg;
|
|
73
|
-
target.zoom = this.zoom;
|
|
74
73
|
return crs == epsg ? target : target.as(crs, target);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
/**
|
|
78
|
-
*
|
|
77
|
+
* Checks whether another tile is inside this tile.
|
|
79
78
|
*
|
|
80
|
-
* @param
|
|
81
|
-
*
|
|
82
|
-
* @return {boolean}
|
|
79
|
+
* @param extent - the tile to check.
|
|
83
80
|
*/
|
|
84
81
|
isInside(tile) {
|
|
85
82
|
if (this.zoom == tile.zoom) {
|
|
@@ -87,36 +84,35 @@ class Tile {
|
|
|
87
84
|
} else if (this.zoom < tile.zoom) {
|
|
88
85
|
return false;
|
|
89
86
|
} else {
|
|
90
|
-
_rowColfromParent(this, tile.zoom);
|
|
87
|
+
const r = _rowColfromParent(this, tile.zoom);
|
|
91
88
|
return r.row == tile.row && r.col == tile.col;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
/**
|
|
96
|
-
*
|
|
93
|
+
* Returns the translation and scale to transform this tile to the input
|
|
94
|
+
* tile.
|
|
97
95
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @return {THREE.Vector4} {x: translation on west-east, y: translation on south-north, z: scale on west-east, w: scale on south-north}
|
|
96
|
+
* @param tile - the input tile.
|
|
97
|
+
* @param target - copy the result to target.
|
|
101
98
|
*/
|
|
102
99
|
offsetToParent(tile) {
|
|
103
100
|
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
|
|
104
101
|
if (this.crs != tile.crs) {
|
|
105
102
|
throw new Error('unsupported mix');
|
|
106
103
|
}
|
|
107
|
-
_rowColfromParent(this, tile.zoom);
|
|
104
|
+
const r = _rowColfromParent(this, tile.zoom);
|
|
108
105
|
return target.set(this.col * r.invDiff - r.col, this.row * r.invDiff - r.row, r.invDiff, r.invDiff);
|
|
109
106
|
}
|
|
110
107
|
|
|
111
108
|
/**
|
|
112
|
-
*
|
|
109
|
+
* Returns the parent tile at the given level.
|
|
113
110
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @return {Tile}
|
|
111
|
+
* @param levelParent - the level of the parent tile.
|
|
116
112
|
*/
|
|
117
113
|
tiledExtentParent(levelParent) {
|
|
118
114
|
if (levelParent && levelParent < this.zoom) {
|
|
119
|
-
_rowColfromParent(this, levelParent);
|
|
115
|
+
const r = _rowColfromParent(this, levelParent);
|
|
120
116
|
return new Tile(this.crs, levelParent, r.row, r.col);
|
|
121
117
|
} else {
|
|
122
118
|
return this;
|
|
@@ -124,13 +120,11 @@ class Tile {
|
|
|
124
120
|
}
|
|
125
121
|
|
|
126
122
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* @param {number} [zoom=0] zoom value
|
|
130
|
-
* @param {number} [row=0] row value
|
|
131
|
-
* @param {number} [col=0] column value
|
|
123
|
+
* Sets zoom, row and column values.
|
|
132
124
|
*
|
|
133
|
-
* @
|
|
125
|
+
* @param zoom - zoom value.
|
|
126
|
+
* @param row - row value.
|
|
127
|
+
* @param col - column value.
|
|
134
128
|
*/
|
|
135
129
|
set() {
|
|
136
130
|
let zoom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
@@ -143,9 +137,8 @@ class Tile {
|
|
|
143
137
|
}
|
|
144
138
|
|
|
145
139
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
* @return {Tile} copied extent
|
|
140
|
+
* Copies the passed tile to this tile.
|
|
141
|
+
* @param tile - tile to copy.
|
|
149
142
|
*/
|
|
150
143
|
copy(tile) {
|
|
151
144
|
this.crs = tile.crs;
|
|
@@ -154,20 +147,13 @@ class Tile {
|
|
|
154
147
|
|
|
155
148
|
/**
|
|
156
149
|
* Return values of tile in string, separated by the separator input.
|
|
157
|
-
* @param
|
|
158
|
-
* @return {string}
|
|
150
|
+
* @param separator - string separator
|
|
159
151
|
*/
|
|
160
152
|
toString() {
|
|
161
153
|
let separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
162
154
|
return `${this.zoom}${separator}${this.row}${separator}${this.col}`;
|
|
163
155
|
}
|
|
164
156
|
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* @param {Extent} e
|
|
168
|
-
* @param {string} tms
|
|
169
|
-
* @returns {Tile[]}
|
|
170
|
-
*/
|
|
171
157
|
export function tiledCovering(e, tms) {
|
|
172
158
|
if (e.crs == 'EPSG:4326' && tms == 'EPSG:3857') {
|
|
173
159
|
const WMTS_PM = [];
|
|
@@ -179,7 +165,7 @@ export function tiledCovering(e, tms) {
|
|
|
179
165
|
} = getInfoTms(tms);
|
|
180
166
|
extent.clampByExtent(globalExtent);
|
|
181
167
|
extent.planarDimensions(_dimensionTile);
|
|
182
|
-
const zoom =
|
|
168
|
+
const zoom = Math.floor(Math.log2(Math.round(globalDimension.x / (_dimensionTile.x * sTs.x))));
|
|
183
169
|
const countTiles = getCountTiles(tms, zoom);
|
|
184
170
|
const center = extent.center(_c);
|
|
185
171
|
_tmsCoord.x = center.x - globalExtent.west;
|
|
@@ -203,12 +189,14 @@ export function tiledCovering(e, tms) {
|
|
|
203
189
|
const center = e.center(_c);
|
|
204
190
|
e.planarDimensions(_dimensionTile);
|
|
205
191
|
// Each level has 2^n * 2^n tiles...
|
|
206
|
-
// ... so we count how many tiles of the same width as tile we can fit
|
|
192
|
+
// ... so we count how many tiles of the same width as tile we can fit
|
|
193
|
+
// in the layer
|
|
207
194
|
// ... 2^zoom = tilecount => zoom = log2(tilecount)
|
|
208
195
|
const zoom = Math.floor(Math.log2(Math.round(globalDimension.x / (_dimensionTile.x * sTs.x))));
|
|
209
196
|
const countTiles = getCountTiles(tms, zoom);
|
|
210
197
|
|
|
211
|
-
// Now that we have computed zoom, we can deduce x and y (or row /
|
|
198
|
+
// Now that we have computed zoom, we can deduce x and y (or row /
|
|
199
|
+
// column)
|
|
212
200
|
_tmsCoord.x = center.x - globalExtent.west;
|
|
213
201
|
_tmsCoord.y = isInverted ? globalExtent.north - center.y : center.y - globalExtent.south;
|
|
214
202
|
_tmsCoord.divide(globalDimension).multiply(countTiles).floor();
|
|
@@ -13,13 +13,19 @@ globalExtentTMS.set('EPSG:4326', extent4326);
|
|
|
13
13
|
const extent3857 = extent4326.as('EPSG:3857');
|
|
14
14
|
extent3857.clampSouthNorth(extent3857.west, extent3857.east);
|
|
15
15
|
globalExtentTMS.set('EPSG:3857', extent3857);
|
|
16
|
-
|
|
17
|
-
schemeTiles.set('EPSG:3857',
|
|
16
|
+
const defaultScheme = new THREE.Vector2(1, 1);
|
|
17
|
+
schemeTiles.set('EPSG:3857', defaultScheme);
|
|
18
18
|
schemeTiles.set('EPSG:4326', new THREE.Vector2(2, 1));
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
// TODO: For now we can only have a single TMS grid per proj4 identifier.
|
|
21
|
+
// This causes TMS identifier to be proj4 identifier.
|
|
22
|
+
export function getInfoTms(crs) {
|
|
20
23
|
const globalExtent = globalExtentTMS.get(crs);
|
|
24
|
+
if (!globalExtent) {
|
|
25
|
+
throw new Error(`The tile matrix set ${crs} is not defined.`);
|
|
26
|
+
}
|
|
21
27
|
const globalDimension = globalExtent.planarDimensions(_dim);
|
|
22
|
-
const sTs = schemeTiles.get(crs)
|
|
28
|
+
const sTs = schemeTiles.get(crs) ?? defaultScheme;
|
|
23
29
|
// The isInverted parameter is to be set to the correct value, true or false
|
|
24
30
|
// (default being false) if the computation of the coordinates needs to be
|
|
25
31
|
// inverted to match the same scheme as OSM, Google Maps or other system.
|
|
@@ -35,8 +41,8 @@ export function getInfoTms(/** @type {string} */crs) {
|
|
|
35
41
|
isInverted
|
|
36
42
|
};
|
|
37
43
|
}
|
|
38
|
-
export function getCountTiles(
|
|
39
|
-
const sTs = schemeTiles.get(crs) ||
|
|
44
|
+
export function getCountTiles(crs, zoom) {
|
|
45
|
+
const sTs = schemeTiles.get(crs) || defaultScheme;
|
|
40
46
|
const count = 2 ** zoom;
|
|
41
47
|
_countTiles.set(count, count).multiply(sTs);
|
|
42
48
|
return _countTiles;
|
package/lib/Source/Source.js
CHANGED
|
@@ -121,7 +121,7 @@ class Source extends InformationsData {
|
|
|
121
121
|
this.whenReady = Promise.resolve();
|
|
122
122
|
this._featuresCaches = {};
|
|
123
123
|
if (source.extent && !source.extent.isExtent) {
|
|
124
|
-
this.extent = new Extent(this.crs
|
|
124
|
+
this.extent = new Extent(this.crs).setFromExtent(source.extent);
|
|
125
125
|
} else {
|
|
126
126
|
this.extent = source.extent;
|
|
127
127
|
}
|
package/lib/Source/WFSSource.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Source from "./Source.js";
|
|
2
2
|
import URLBuilder from "../Provider/URLBuilder.js";
|
|
3
3
|
import Extent from "../Core/Geographic/Extent.js";
|
|
4
|
-
const _extent = new Extent('EPSG:4326'
|
|
4
|
+
const _extent = new Extent('EPSG:4326');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* An object defining the source of resources to get from a
|
package/lib/Source/WMSSource.js
CHANGED
|
@@ -2,7 +2,7 @@ import Source from "./Source.js";
|
|
|
2
2
|
import URLBuilder from "../Provider/URLBuilder.js";
|
|
3
3
|
import Extent from "../Core/Geographic/Extent.js";
|
|
4
4
|
import * as CRS from "../Core/Geographic/Crs.js";
|
|
5
|
-
const _extent = new Extent('EPSG:4326'
|
|
5
|
+
const _extent = new Extent('EPSG:4326');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Proj provides an optional param to define axis order and orientation for a
|