From 589fd85117d1fd849975bd6ac5059f5e86cea182 Mon Sep 17 00:00:00 2001 From: ftoromanoff Date: Thu, 21 Nov 2024 15:47:46 +0100 Subject: [PATCH] to reset --- src/Core/Style.js | 2 +- src/Parser/VectorTileParser.js | 38 ++++++++++++++++++++------------- src/Source/VectorTilesSource.js | 1 + 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Core/Style.js b/src/Core/Style.js index 09ae71a779..aabb5e8f5a 100644 --- a/src/Core/Style.js +++ b/src/Core/Style.js @@ -111,7 +111,7 @@ function replaceWhitePxl(imgd, color, id) { const newColor = new Color(color); const colorToChange = new Color('white'); for (let i = 0, n = pix.length; i < n; i += 4) { - const d = deltaE(pix.slice(i, i + 3), colorToChange) / 100; + const d = deltaE(Array.prototype.slice.call(pix, i, i + 3), colorToChange) / 100; pix[i] = (pix[i] * d + newColor.r * 255 * (1 - d)); pix[i + 1] = (pix[i + 1] * d + newColor.g * 255 * (1 - d)); pix[i + 2] = (pix[i + 2] * d + newColor.b * 255 * (1 - d)); diff --git a/src/Parser/VectorTileParser.js b/src/Parser/VectorTileParser.js index adf5d93f45..5a1f780463 100644 --- a/src/Parser/VectorTileParser.js +++ b/src/Parser/VectorTileParser.js @@ -175,20 +175,28 @@ function readPBF(file, options) { feature.order = layer.layerOrder; }); - let _feature; + // let _feature; + // for (const layer of layers) { + // if (!_feature) { + // _feature = _collection.requestFeatureById(layer.id, vtFeature.type - 1); + // _feature.id = layer.id; + // _feature.order = layer.order; + // _feature.style = options.in.styles[_feature.id]; + // vtFeatureToFeatureGeometry(vtFeature, _feature); + // } else if (!_collection.features.find(f => f.id === layer.id)) { + // _feature = _collection.newFeatureByReference(_feature); + // _feature.id = layer.id; + // _feature.order = layer.order; + // _feature.style = options.in.styles[_feature.id]; + // } + // } + for (const layer of layers) { - if (!_feature) { - _feature = _collection.requestFeatureById(layer.id, vtFeature.type - 1); - _feature.id = layer.id; - _feature.order = layer.order; - _feature.style = options.in.styles[_feature.id]; - vtFeatureToFeatureGeometry(vtFeature, _feature); - } else if (!_collection.features.find(f => f.id === layer.id)) { - _feature = _collection.newFeatureByReference(_feature); - _feature.id = layer.id; - _feature.order = layer.order; - _feature.style = options.in.styles[_feature.id]; - } + const _feature = _collection.requestFeatureById(layer.id, vtFeature.type - 1); + _feature.id = layer.id; + _feature.order = layer.order; + _feature.style = options.in.styles[_feature.id]; + vtFeatureToFeatureGeometry(vtFeature, _feature); } } }); @@ -209,10 +217,10 @@ function readPBF(file, options) { // console.log(collection.features); // console.log(collection.features.map(f => f.type)); - // console.log(_collection.features); + // console.log('zoom', z, _collection.features); // console.log(_collection.features.map(f => f.type)); - return Promise.resolve(collection); + return Promise.resolve(_collection); } /** diff --git a/src/Source/VectorTilesSource.js b/src/Source/VectorTilesSource.js index 2f9007616b..9e29985c4d 100644 --- a/src/Source/VectorTilesSource.js +++ b/src/Source/VectorTilesSource.js @@ -126,6 +126,7 @@ class VectorTilesSource extends TMSSource { order, layerOrder, filterExpression: featureFilter(layer.filter, layer.type), + style: layer, }); } });