StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
|
|
// Transforms the coordinates of each feature in the given tile from
|
|
// mercator-projected space into (extent x extent) tile space.
|
|
export default function transformTile(tile, extent) {
|
|
if (tile.transformed) return tile;
|
|
|
|
var z2 = 1 << tile.z,
|
|
tx = tile.x,
|
|
ty = tile.y,
|
|
i, j, k;
|
|
|
|
for (i = 0; i < tile.features.length; i++) {
|
|
var feature = tile.features[i],
|
|
geom = feature.geometry,
|
|
type = feature.type;
|
|
|
|
feature.geometry = [];
|
|
|
|
if (type === 1) {
|
|
for (j = 0; j < geom.length; j += 2) {
|
|
feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));
|
|
}
|
|
} else {
|
|
for (j = 0; j < geom.length; j++) {
|
|
var ring = [];
|
|
for (k = 0; k < geom[j].length; k += 2) {
|
|
ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));
|
|
}
|
|
feature.geometry.push(ring);
|
|
}
|
|
}
|
|
}
|
|
|
|
tile.transformed = true;
|
|
|
|
return tile;
|
|
}
|
|
|
|
function transformPoint(x, y, extent, z2, tx, ty) {
|
|
return [
|
|
Math.round(extent * (x * z2 - tx)),
|
|
Math.round(extent * (y * z2 - ty))];
|
|
}
|
|
|