Skip to content

Commit

Permalink
refacto: split Extent between geographic/tiled
Browse files Browse the repository at this point in the history
  • Loading branch information
Desplandis committed Oct 3, 2024
1 parent 8ba1376 commit 4b57498
Show file tree
Hide file tree
Showing 23 changed files with 493 additions and 401 deletions.
11 changes: 9 additions & 2 deletions src/Converter/Feature2Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ class FeatureMesh extends THREE.Group {
// calculate the scale transformation to transform the feature.extent
// to feature.extent.as(crs)
coord.crs = Crs.formatToEPSG(this.#originalCrs);
extent.copy(this.extent).applyMatrix4(this.#collection.matrix);
extent.as(coord.crs, extent);
// TODO: An extent here could be either a geographic extent (for
// features from WFS) or a tiled extent (for features from MVT).
// Unify both behavior.
if (this.extent.isExtent) {
extent.copy(this.extent).applyMatrix4(this.#collection.matrix);
extent.as(coord.crs, extent);
} else {
this.extent.toExtent(coord.crs, extent);
}
extent.spatialEuclideanDimensions(dim_ref);
extent.planarDimensions(dim);
if (dim.x && dim.y) {
Expand Down
6 changes: 3 additions & 3 deletions src/Converter/textureConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ function textureColorLayer(texture, layer) {
}

export default {
convert(data, extentDestination, layer) {
convert(data, destinationTile, layer) {
let texture;
if (data.isFeatureCollection) {
const backgroundLayer = layer.source.backgroundLayer;
const backgroundColor = (backgroundLayer && backgroundLayer.paint) ?
new THREE.Color(backgroundLayer.paint['background-color']) :
undefined;

extentDestination.as(CRS.formatToEPSG(layer.crs), extentTexture);
destinationTile.toExtent(CRS.formatToEPSG(layer.crs), extentTexture);
texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
texture.features = data;
texture.extent = extentDestination;
texture.extent = destinationTile;
} else if (data.isTexture) {
texture = data;
} else {
Expand Down
Loading

0 comments on commit 4b57498

Please sign in to comment.