Fix panoramax non existing inaccurate sequence (#10375)

fixes #10365
This commit is contained in:
Mattia Pezzotti
2024-08-03 21:08:57 +02:00
committed by GitHub
parent dd7de08a35
commit ebb68d610e
3 changed files with 16 additions and 11 deletions

View File

@@ -74,18 +74,18 @@ function searchLimited(limit, projection, rtree) {
}
// Load all data for the specified type from Panoramax vector tiles
function loadTiles(which, url, maxZoom, projection) {
function loadTiles(which, url, maxZoom, projection, zoom) {
const tiler = utilTiler().zoomExtent([minZoom, maxZoom]).skipNullIsland(true);
const tiles = tiler.getTiles(projection);
tiles.forEach(function(tile) {
loadTile(which, url, tile);
loadTile(which, url, tile, zoom);
});
}
// Load all data for the specified type from one vector tile
function loadTile(which, url, tile) {
function loadTile(which, url, tile, zoom) {
const cache = _cache.requests;
const tileId = `${tile.id}-${which}`;
if (cache.loaded[tileId] || cache.inflight[tileId]) return;
@@ -109,7 +109,7 @@ function loadTile(which, url, tile) {
throw new Error('No Data');
}
loadTileDataToCache(data, tile, which);
loadTileDataToCache(data, tile, zoom);
if (which === 'images') {
dispatch.call('loadedImages');
@@ -126,7 +126,7 @@ function loadTile(which, url, tile) {
});
}
function loadTileDataToCache(data, tile) {
function loadTileDataToCache(data, tile, zoom) {
const vectorTile = new VectorTile(new Protobuf(data));
let features,
@@ -177,7 +177,11 @@ function loadTileDataToCache(data, tile) {
}
if (vectorTile.layers.hasOwnProperty(sequenceLayer)) {
cache = _cache.sequences;
if (zoom >= lineMinZoom && zoom < imageMinZoom) cache = _cache.mockSequences;
layer = vectorTile.layers[sequenceLayer];
for (i = 0; i < layer.length; i++) {
@@ -238,6 +242,7 @@ export default {
_cache = {
images: { rtree: new RBush(), forImageId: {} },
sequences: { rtree: new RBush(), lineString: {} },
mockSequences: { rtree: new RBush(), lineString: {} },
requests: { loaded: {}, inflight: {} }
};
@@ -261,8 +266,8 @@ export default {
},
// Load line in the visible area
loadLines: function(projection) {
loadTiles('line', tileUrl, lineMinZoom, projection);
loadLines: function(projection, zoom) {
loadTiles('line', tileUrl, lineMinZoom, projection, zoom);
},
getUserIds: async function(usernames) {
@@ -308,8 +313,8 @@ export default {
return lineStrings;
}
if (zoom >= lineMinZoom){
Object.keys(_cache.sequences.lineString).forEach(function(sequenceId) {
lineStrings = lineStrings.concat(_cache.sequences.lineString[sequenceId]);
Object.keys(_cache.mockSequences.lineString).forEach(function(sequenceId) {
lineStrings = lineStrings.concat(_cache.mockSequences.lineString[sequenceId]);
});
}
return lineStrings;

View File

@@ -345,7 +345,7 @@ export function svgPanoramaxImages(projection, context, dispatch) {
} else if (zoom >= lineMinZoom) {
editOn();
update();
service.loadLines(projection);
service.loadLines(projection, zoom);
} else {
editOff();
}

View File

@@ -96,7 +96,7 @@ describe('iD.servicePanoramax', function() {
panoramax.cache().images.rtree.load(features);
panoramax.cache().sequences.lineString['100'] = { rotation: 0, images: [ features[0].data, features[1].data, features[2].data ] };
var res = panoramax.sequences(context.projection, 14);
var res = panoramax.sequences(context.projection, 15);
expect(res).to.deep.eql([{
rotation: 0, images: [features[0].data, features[1].data, features[2].data]
}]);