itowns 2.44.3-next.4 → 2.44.3-next.6
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/CODING.md +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/lib/Converter/Feature2Mesh.js +9 -2
- package/lib/Converter/textureConverter.js +3 -3
- package/lib/Core/Geographic/Extent.js +74 -266
- package/lib/Core/Prefab/Globe/GlobeLayer.js +1 -1
- package/lib/Core/Prefab/Planar/PlanarLayer.js +1 -1
- package/lib/Core/Tile/Tile.js +219 -0
- package/lib/Core/Tile/TileGrid.js +46 -0
- package/lib/Core/TileMesh.js +2 -1
- package/lib/Layer/LabelLayer.js +8 -4
- package/lib/Parser/GeoJsonParser.js +1 -1
- package/lib/Parser/VectorTileParser.js +1 -1
- package/lib/Provider/URLBuilder.js +22 -11
- package/lib/Source/TMSSource.js +9 -7
- package/lib/Source/VectorTilesSource.js +2 -2
- package/lib/Source/WFSSource.js +4 -1
- package/lib/Source/WMSSource.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import Coordinates from "../Geographic/Coordinates.js";
|
|
3
|
+
import CRS from "../Geographic/Crs.js";
|
|
4
|
+
import Extent from "../Geographic/Extent.js";
|
|
5
|
+
import { getInfoTms, getCountTiles } from "./TileGrid.js";
|
|
6
|
+
const _tmsCoord = new THREE.Vector2();
|
|
7
|
+
const _dimensionTile = new THREE.Vector2();
|
|
8
|
+
const r = {
|
|
9
|
+
row: 0,
|
|
10
|
+
col: 0,
|
|
11
|
+
invDiff: 0
|
|
12
|
+
};
|
|
13
|
+
function _rowColfromParent(/** @type {Tile} */tile, /** @type {number} */zoom) {
|
|
14
|
+
const diffLevel = tile.zoom - zoom;
|
|
15
|
+
const diff = 2 ** diffLevel;
|
|
16
|
+
r.invDiff = 1 / diff;
|
|
17
|
+
r.row = (tile.row - tile.row % diff) * r.invDiff;
|
|
18
|
+
r.col = (tile.col - tile.col % diff) * r.invDiff;
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
22
|
+
const _extent2 = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
23
|
+
const _c = new Coordinates('EPSG:4326', 0, 0);
|
|
24
|
+
class Tile {
|
|
25
|
+
/**
|
|
26
|
+
* Tile is a geographical bounding rectangle defined by zoom, row and column.
|
|
27
|
+
*
|
|
28
|
+
* @param {String} crs projection of limit values.
|
|
29
|
+
* @param {number} [zoom=0] zoom value
|
|
30
|
+
* @param {number} [row=0] row value
|
|
31
|
+
* @param {number} [col=0] column value
|
|
32
|
+
*/
|
|
33
|
+
constructor(crs) {
|
|
34
|
+
let zoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
35
|
+
let row = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
36
|
+
let col = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
37
|
+
this.isTile = true;
|
|
38
|
+
this.crs = crs;
|
|
39
|
+
this.zoom = zoom;
|
|
40
|
+
this.row = row;
|
|
41
|
+
this.col = col;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Clone this tile
|
|
46
|
+
* @return {Tile} cloned tile
|
|
47
|
+
*/
|
|
48
|
+
clone() {
|
|
49
|
+
return new Tile(this.crs, this.zoom, this.row, this.col);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Convert tile to the specified extent.
|
|
54
|
+
* @param {string} crs the projection of destination.
|
|
55
|
+
* @param {Extent} target copy the destination to target.
|
|
56
|
+
* @return {Extent}
|
|
57
|
+
*/
|
|
58
|
+
toExtent(crs, target) {
|
|
59
|
+
CRS.isValid(crs);
|
|
60
|
+
target = target || new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
61
|
+
const {
|
|
62
|
+
epsg,
|
|
63
|
+
globalExtent,
|
|
64
|
+
globalDimension
|
|
65
|
+
} = getInfoTms(this.crs);
|
|
66
|
+
const countTiles = getCountTiles(this.crs, this.zoom);
|
|
67
|
+
_dimensionTile.set(1, 1).divide(countTiles).multiply(globalDimension);
|
|
68
|
+
target.west = globalExtent.west + (globalDimension.x - _dimensionTile.x * (countTiles.x - this.col));
|
|
69
|
+
target.east = target.west + _dimensionTile.x;
|
|
70
|
+
target.south = globalExtent.south + _dimensionTile.y * (countTiles.y - this.row - 1);
|
|
71
|
+
target.north = target.south + _dimensionTile.y;
|
|
72
|
+
target.crs = epsg;
|
|
73
|
+
target.zoom = this.zoom;
|
|
74
|
+
return crs == epsg ? target : target.as(crs, target);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Return true if `tile` is inside this tile.
|
|
79
|
+
*
|
|
80
|
+
* @param {Tile} tile the tile to check
|
|
81
|
+
*
|
|
82
|
+
* @return {boolean}
|
|
83
|
+
*/
|
|
84
|
+
isInside(tile) {
|
|
85
|
+
if (this.zoom == tile.zoom) {
|
|
86
|
+
return this.row == tile.row && this.col == tile.col;
|
|
87
|
+
} else if (this.zoom < tile.zoom) {
|
|
88
|
+
return false;
|
|
89
|
+
} else {
|
|
90
|
+
_rowColfromParent(this, tile.zoom);
|
|
91
|
+
return r.row == tile.row && r.col == tile.col;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Return the translation and scale to transform this tile to input tile.
|
|
97
|
+
*
|
|
98
|
+
* @param {Tile} tile input tile
|
|
99
|
+
* @param {THREE.Vector4} target copy the result to target.
|
|
100
|
+
* @return {THREE.Vector4} {x: translation on west-east, y: translation on south-north, z: scale on west-east, w: scale on south-north}
|
|
101
|
+
*/
|
|
102
|
+
offsetToParent(tile) {
|
|
103
|
+
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
|
|
104
|
+
if (this.crs != tile.crs) {
|
|
105
|
+
throw new Error('unsupported mix');
|
|
106
|
+
}
|
|
107
|
+
_rowColfromParent(this, tile.zoom);
|
|
108
|
+
return target.set(this.col * r.invDiff - r.col, this.row * r.invDiff - r.row, r.invDiff, r.invDiff);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Return parent tile with input level
|
|
113
|
+
*
|
|
114
|
+
* @param {number} levelParent level of parent.
|
|
115
|
+
* @return {Tile}
|
|
116
|
+
*/
|
|
117
|
+
tiledExtentParent(levelParent) {
|
|
118
|
+
if (levelParent && levelParent < this.zoom) {
|
|
119
|
+
_rowColfromParent(this, levelParent);
|
|
120
|
+
return new Tile(this.crs, levelParent, r.row, r.col);
|
|
121
|
+
} else {
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Set zoom, row and column values
|
|
128
|
+
*
|
|
129
|
+
* @param {number} [zoom=0] zoom value
|
|
130
|
+
* @param {number} [row=0] row value
|
|
131
|
+
* @param {number} [col=0] column value
|
|
132
|
+
*
|
|
133
|
+
* @return {Tile}
|
|
134
|
+
*/
|
|
135
|
+
set() {
|
|
136
|
+
let zoom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
137
|
+
let row = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
138
|
+
let col = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
139
|
+
this.zoom = zoom;
|
|
140
|
+
this.row = row;
|
|
141
|
+
this.col = col;
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Copy to this tile to input tile.
|
|
147
|
+
* @param {Tile} tile
|
|
148
|
+
* @return {Tile} copied extent
|
|
149
|
+
*/
|
|
150
|
+
copy(tile) {
|
|
151
|
+
this.crs = tile.crs;
|
|
152
|
+
return this.set(tile.zoom, tile.row, tile.col);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Return values of tile in string, separated by the separator input.
|
|
157
|
+
* @param {string} separator
|
|
158
|
+
* @return {string}
|
|
159
|
+
*/
|
|
160
|
+
toString() {
|
|
161
|
+
let separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
162
|
+
return `${this.zoom}${separator}${this.row}${separator}${this.col}`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {Extent} e
|
|
168
|
+
* @param {string} tms
|
|
169
|
+
* @returns {Tile[]}
|
|
170
|
+
*/
|
|
171
|
+
export function tiledCovering(e, tms) {
|
|
172
|
+
if (e.crs == 'EPSG:4326' && tms == CRS.tms_3857) {
|
|
173
|
+
const WMTS_PM = [];
|
|
174
|
+
const extent = _extent.copy(e).as(CRS.formatToEPSG(tms), _extent2);
|
|
175
|
+
const {
|
|
176
|
+
globalExtent,
|
|
177
|
+
globalDimension,
|
|
178
|
+
sTs
|
|
179
|
+
} = getInfoTms(CRS.formatToEPSG(tms));
|
|
180
|
+
extent.clampByExtent(globalExtent);
|
|
181
|
+
extent.planarDimensions(_dimensionTile);
|
|
182
|
+
const zoom = e.zoom + 1 || Math.floor(Math.log2(Math.round(globalDimension.x / (_dimensionTile.x * sTs.x))));
|
|
183
|
+
const countTiles = getCountTiles(tms, zoom);
|
|
184
|
+
const center = extent.center(_c);
|
|
185
|
+
_tmsCoord.x = center.x - globalExtent.west;
|
|
186
|
+
_tmsCoord.y = globalExtent.north - extent.north;
|
|
187
|
+
_tmsCoord.divide(globalDimension).multiply(countTiles).floor();
|
|
188
|
+
|
|
189
|
+
// ]N; N+1] => N
|
|
190
|
+
const maxRow = Math.ceil((globalExtent.north - extent.south) / globalDimension.x * countTiles.y) - 1;
|
|
191
|
+
for (let r = maxRow; r >= _tmsCoord.y; r--) {
|
|
192
|
+
WMTS_PM.push(new Tile(tms, zoom, r, _tmsCoord.x));
|
|
193
|
+
}
|
|
194
|
+
return WMTS_PM;
|
|
195
|
+
} else {
|
|
196
|
+
const target = new Tile(tms, 0, 0, 0);
|
|
197
|
+
const {
|
|
198
|
+
globalExtent,
|
|
199
|
+
globalDimension,
|
|
200
|
+
sTs,
|
|
201
|
+
isInverted
|
|
202
|
+
} = getInfoTms(e.crs);
|
|
203
|
+
const center = e.center(_c);
|
|
204
|
+
e.planarDimensions(_dimensionTile);
|
|
205
|
+
// Each level has 2^n * 2^n tiles...
|
|
206
|
+
// ... so we count how many tiles of the same width as tile we can fit in the layer
|
|
207
|
+
// ... 2^zoom = tilecount => zoom = log2(tilecount)
|
|
208
|
+
const zoom = Math.floor(Math.log2(Math.round(globalDimension.x / (_dimensionTile.x * sTs.x))));
|
|
209
|
+
const countTiles = getCountTiles(tms, zoom);
|
|
210
|
+
|
|
211
|
+
// Now that we have computed zoom, we can deduce x and y (or row / column)
|
|
212
|
+
_tmsCoord.x = center.x - globalExtent.west;
|
|
213
|
+
_tmsCoord.y = isInverted ? globalExtent.north - center.y : center.y - globalExtent.south;
|
|
214
|
+
_tmsCoord.divide(globalDimension).multiply(countTiles).floor();
|
|
215
|
+
target.set(zoom, _tmsCoord.y, _tmsCoord.x);
|
|
216
|
+
return [target];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
export default Tile;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import CRS from "../Geographic/Crs.js";
|
|
3
|
+
import Extent from "../Geographic/Extent.js";
|
|
4
|
+
const _countTiles = new THREE.Vector2();
|
|
5
|
+
const _dim = new THREE.Vector2();
|
|
6
|
+
export const globalExtentTMS = new Map();
|
|
7
|
+
export const schemeTiles = new Map();
|
|
8
|
+
const extent4326 = new Extent('EPSG:4326', -180, 180, -90, 90);
|
|
9
|
+
globalExtentTMS.set('EPSG:4326', extent4326);
|
|
10
|
+
|
|
11
|
+
// Compute global extent of TMS in EPSG:3857
|
|
12
|
+
// It's square whose a side is between -180° to 180°.
|
|
13
|
+
// So, west extent, it's 180 convert in EPSG:3857
|
|
14
|
+
const extent3857 = extent4326.as('EPSG:3857');
|
|
15
|
+
extent3857.clampSouthNorth(extent3857.west, extent3857.east);
|
|
16
|
+
globalExtentTMS.set('EPSG:3857', extent3857);
|
|
17
|
+
schemeTiles.set('default', new THREE.Vector2(1, 1));
|
|
18
|
+
schemeTiles.set(CRS.tms_3857, schemeTiles.get('default'));
|
|
19
|
+
schemeTiles.set(CRS.tms_4326, new THREE.Vector2(2, 1));
|
|
20
|
+
export function getInfoTms(/** @type {string} */crs) {
|
|
21
|
+
const epsg = CRS.formatToEPSG(crs);
|
|
22
|
+
const globalExtent = globalExtentTMS.get(epsg);
|
|
23
|
+
const globalDimension = globalExtent.planarDimensions(_dim);
|
|
24
|
+
const tms = CRS.formatToTms(crs);
|
|
25
|
+
const sTs = schemeTiles.get(tms) || schemeTiles.get('default');
|
|
26
|
+
// The isInverted parameter is to be set to the correct value, true or false
|
|
27
|
+
// (default being false) if the computation of the coordinates needs to be
|
|
28
|
+
// inverted to match the same scheme as OSM, Google Maps or other system.
|
|
29
|
+
// See link below for more information
|
|
30
|
+
// https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
|
|
31
|
+
// in crs includes ':NI' => tms isn't inverted (NOT INVERTED)
|
|
32
|
+
const isInverted = !tms.includes(':NI');
|
|
33
|
+
return {
|
|
34
|
+
epsg,
|
|
35
|
+
globalExtent,
|
|
36
|
+
globalDimension,
|
|
37
|
+
sTs,
|
|
38
|
+
isInverted
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function getCountTiles(/** @type {string} */crs, /** @type {number} */zoom) {
|
|
42
|
+
const sTs = schemeTiles.get(CRS.formatToTms(crs)) || schemeTiles.get('default');
|
|
43
|
+
const count = 2 ** zoom;
|
|
44
|
+
_countTiles.set(count, count).multiply(sTs);
|
|
45
|
+
return _countTiles;
|
|
46
|
+
}
|
package/lib/Core/TileMesh.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import CRS from "./Geographic/Crs.js";
|
|
3
3
|
import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
|
|
4
|
+
import { tiledCovering } from "./Tile/Tile.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A TileMesh is a THREE.Mesh with a geometricError and an OBB
|
|
@@ -29,7 +30,7 @@ class TileMesh extends THREE.Mesh {
|
|
|
29
30
|
this.boundingSphere = new THREE.Sphere();
|
|
30
31
|
this.obb.box3D.getBoundingSphere(this.boundingSphere);
|
|
31
32
|
for (const tms of layer.tileMatrixSets) {
|
|
32
|
-
this.#_tms.set(tms, this.extent
|
|
33
|
+
this.#_tms.set(tms, tiledCovering(this.extent, tms));
|
|
33
34
|
}
|
|
34
35
|
this.frustumCulled = false;
|
|
35
36
|
this.matrixAutoUpdate = false;
|
package/lib/Layer/LabelLayer.js
CHANGED
|
@@ -216,17 +216,21 @@ class LabelLayer extends GeometryLayer {
|
|
|
216
216
|
*
|
|
217
217
|
* @param {FeatureCollection} data - The FeatureCollection to read the
|
|
218
218
|
* labels from.
|
|
219
|
-
* @param {Extent}
|
|
219
|
+
* @param {Extent|Tile} extentOrTile
|
|
220
220
|
*
|
|
221
221
|
* @return {Label[]} An array containing all the created labels.
|
|
222
222
|
*/
|
|
223
|
-
convert(data,
|
|
223
|
+
convert(data, extentOrTile) {
|
|
224
224
|
const labels = [];
|
|
225
225
|
|
|
226
226
|
// Converting the extent now is faster for further operation
|
|
227
|
-
|
|
227
|
+
if (extentOrTile.isExtent) {
|
|
228
|
+
extentOrTile.as(data.crs, _extent);
|
|
229
|
+
} else {
|
|
230
|
+
extentOrTile.toExtent(data.crs, _extent);
|
|
231
|
+
}
|
|
228
232
|
coord.crs = data.crs;
|
|
229
|
-
context.setZoom(
|
|
233
|
+
context.setZoom(extentOrTile.zoom);
|
|
230
234
|
data.features.forEach(f => {
|
|
231
235
|
// TODO: add support for LINE and POLYGON
|
|
232
236
|
if (f.type !== FEATURE_TYPES.POINT) {
|
|
@@ -195,7 +195,7 @@ export default {
|
|
|
195
195
|
_in.crs = _in.crs || readCRS(json);
|
|
196
196
|
if (out.filteringExtent) {
|
|
197
197
|
if (typeof out.filteringExtent == 'boolean') {
|
|
198
|
-
out.filterExtent = options.extent.as(_in.crs);
|
|
198
|
+
out.filterExtent = options.extent.isExtent ? options.extent.as(_in.crs) : options.extent.toExtent(_in.crs);
|
|
199
199
|
} else if (out.filteringExtent.isExtent) {
|
|
200
200
|
out.filterExtent = out.filteringExtent;
|
|
201
201
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector2, Vector3 } from 'three';
|
|
2
2
|
import Protobuf from 'pbf';
|
|
3
3
|
import { VectorTile } from '@mapbox/vector-tile';
|
|
4
|
-
import { globalExtentTMS } from "../Core/
|
|
4
|
+
import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
|
|
5
5
|
import { FeatureCollection, FEATURE_TYPES } from "../Core/Feature.js";
|
|
6
6
|
import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
|
|
7
7
|
import Coordinates from "../Core/Geographic/Coordinates.js";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import Extent from "../Core/Geographic/Extent.js";
|
|
2
|
-
const extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
3
1
|
let subDomainsCount = 0;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} url
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
4
7
|
function subDomains(url) {
|
|
5
8
|
const subDomainsPtrn = /\$\{u:([\w-_.|]+)\}/.exec(url);
|
|
6
9
|
if (!subDomainsPtrn) {
|
|
@@ -51,8 +54,13 @@ export default {
|
|
|
51
54
|
* // The resulting url is:
|
|
52
55
|
* // http://server.geo/tms/15/2142/3412.jpg;
|
|
53
56
|
*
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
57
|
+
* @param {Object} coords - tile coordinates
|
|
58
|
+
* @param {number} coords.row - tile row
|
|
59
|
+
* @param {number} coords.col - tile column
|
|
60
|
+
* @param {number} coords.zoom - tile zoom
|
|
61
|
+
* @param {Object} source
|
|
62
|
+
* @param {string} source.url
|
|
63
|
+
* @param {Function} source.tileMatrixCallback
|
|
56
64
|
*
|
|
57
65
|
* @return {string} the formed url
|
|
58
66
|
*/
|
|
@@ -79,8 +87,12 @@ export default {
|
|
|
79
87
|
* // The resulting url is:
|
|
80
88
|
* // http://server.geo/wms/BBOX=12,35,14,46&FORMAT=jpg&SERVICE=WMS
|
|
81
89
|
*
|
|
82
|
-
* @param {
|
|
83
|
-
* @param {
|
|
90
|
+
* @param {Object} bbox - the bounding box
|
|
91
|
+
* @param {number} bbox.west
|
|
92
|
+
* @param {number} bbox.south
|
|
93
|
+
* @param {number} bbox.east
|
|
94
|
+
* @param {number} bbox.north
|
|
95
|
+
* @param {Object} source - the source of data
|
|
84
96
|
* @param {string} source.crs
|
|
85
97
|
* @param {number} source.bboxDigits
|
|
86
98
|
* @param {string} source.url
|
|
@@ -93,11 +105,10 @@ export default {
|
|
|
93
105
|
if (source.bboxDigits !== undefined) {
|
|
94
106
|
precision = source.bboxDigits;
|
|
95
107
|
}
|
|
96
|
-
bbox.
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const n = extent.north.toFixed(precision);
|
|
108
|
+
const w = bbox.west.toFixed(precision);
|
|
109
|
+
const s = bbox.south.toFixed(precision);
|
|
110
|
+
const e = bbox.east.toFixed(precision);
|
|
111
|
+
const n = bbox.north.toFixed(precision);
|
|
101
112
|
let bboxInUnit = source.axisOrder || 'wsen';
|
|
102
113
|
bboxInUnit = bboxInUnit.replace('w', `${w},`).replace('s', `${s},`).replace('e', `${e},`).replace('n', `${n},`).slice(0, -1);
|
|
103
114
|
return subDomains(source.url.replace('%bbox', bboxInUnit));
|
package/lib/Source/TMSSource.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import Source from "./Source.js";
|
|
2
2
|
import URLBuilder from "../Provider/URLBuilder.js";
|
|
3
|
-
import Extent
|
|
3
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
4
|
+
import Tile from "../Core/Tile/Tile.js";
|
|
5
|
+
import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
|
|
4
6
|
import CRS from "../Core/Geographic/Crs.js";
|
|
5
|
-
const
|
|
7
|
+
const _tile = new Tile(CRS.tms_4326, 0, 0, 0);
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* An object defining the source of resources to get from a
|
|
@@ -107,8 +109,8 @@ class TMSSource extends Source {
|
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
|
-
urlFromExtent(
|
|
111
|
-
return URLBuilder.xyz(
|
|
112
|
+
urlFromExtent(tile) {
|
|
113
|
+
return URLBuilder.xyz(tile, this);
|
|
112
114
|
}
|
|
113
115
|
onLayerAdded(options) {
|
|
114
116
|
super.onLayerAdded(options);
|
|
@@ -118,17 +120,17 @@ class TMSSource extends Source {
|
|
|
118
120
|
const crs = parent ? parent.extent.crs : options.out.crs;
|
|
119
121
|
if (this.tileMatrixSetLimits && !this.extentSetlimits[crs]) {
|
|
120
122
|
this.extentSetlimits[crs] = {};
|
|
121
|
-
|
|
123
|
+
_tile.crs = this.crs;
|
|
122
124
|
for (let i = this.zoom.max; i >= this.zoom.min; i--) {
|
|
123
125
|
const tmsl = this.tileMatrixSetLimits[i];
|
|
124
126
|
const {
|
|
125
127
|
west,
|
|
126
128
|
north
|
|
127
|
-
} =
|
|
129
|
+
} = _tile.set(i, tmsl.minTileRow, tmsl.minTileCol).toExtent(crs);
|
|
128
130
|
const {
|
|
129
131
|
east,
|
|
130
132
|
south
|
|
131
|
-
} =
|
|
133
|
+
} = _tile.set(i, tmsl.maxTileRow, tmsl.maxTileCol).toExtent(crs);
|
|
132
134
|
this.extentSetlimits[crs][i] = new Extent(crs, west, east, south, north);
|
|
133
135
|
}
|
|
134
136
|
}
|
|
@@ -135,8 +135,8 @@ class VectorTilesSource extends TMSSource {
|
|
|
135
135
|
this.urls = Array.from(new Set(TMSUrlList));
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
urlFromExtent(
|
|
139
|
-
return URLBuilder.xyz(
|
|
138
|
+
urlFromExtent(tile, url) {
|
|
139
|
+
return URLBuilder.xyz(tile, {
|
|
140
140
|
tileMatrixCallback: this.tileMatrixCallback,
|
|
141
141
|
url
|
|
142
142
|
});
|
package/lib/Source/WFSSource.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Source from "./Source.js";
|
|
2
2
|
import URLBuilder from "../Provider/URLBuilder.js";
|
|
3
3
|
import CRS from "../Core/Geographic/Crs.js";
|
|
4
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
5
|
+
const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* An object defining the source of resources to get from a
|
|
@@ -155,7 +157,8 @@ class WFSSource extends Source {
|
|
|
155
157
|
return [extent.zoom, extent.south, extent.west];
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
urlFromExtent(
|
|
160
|
+
urlFromExtent(extentOrTile) {
|
|
161
|
+
const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
|
|
159
162
|
return URLBuilder.bbox(extent, this);
|
|
160
163
|
}
|
|
161
164
|
extentInsideLimit(extent) {
|
package/lib/Source/WMSSource.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Source from "./Source.js";
|
|
2
2
|
import URLBuilder from "../Provider/URLBuilder.js";
|
|
3
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
4
|
+
const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* An object defining the source of images to get from a
|
|
@@ -120,7 +122,8 @@ class WMSSource extends Source {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
|
-
urlFromExtent(
|
|
125
|
+
urlFromExtent(extentOrTile) {
|
|
126
|
+
const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
|
|
124
127
|
return URLBuilder.bbox(extent, this);
|
|
125
128
|
}
|
|
126
129
|
extentInsideLimit(extent) {
|