Skip to content

Commit

Permalink
CoverageLayer: add additional checks on data extents to prevent unnec…
Browse files Browse the repository at this point in the history
…essary querying of source layers during fallback
  • Loading branch information
gwaldron committed Oct 23, 2023
1 parent ad1117d commit 9b7743f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/osgEarth/CoverageLayer
Original file line number Diff line number Diff line change
Expand Up @@ -249,26 +249,27 @@ namespace osgEarth

if (fallback)
{
// this path is taken when we already have a partial tile from
// This path runs when we already have a partial tile from
// a higher priority layer, and need to fill in the empty samples
// from other lower priority layers.

// NB: do not call mayHaveData() on the key, since we want to be sure
// to fail and fall back until we get data.
while (
input.valid() == false &&
inputKey.valid() &&
imageLayer->isKeyInLegalRange(inputKey))
// NB: layer->mayHaveData() is insufficient here. We want to be sure
// to fail and fall back until we get data, and mayHaveData() will return
// false if our LOD exceeds that of the source layer. Instead we just query
// the "best available" key and start the search from there if that
// key is valid. (It will be invalid, for example, if the extents don't intersect.)
inputKey = imageLayer->getBestAvailableTileKey(inputKey);

while (inputKey.valid() && !input.valid() && imageLayer->isKeyInLegalRange(inputKey))
{
input = createCoverage(inputKey, imageLayer, progress);

if (!input.valid())
inputKey.makeParent();
}
}
else
else if (imageLayer->mayHaveData(inputKey))
{
// this path is taken when we have no data at all yet.
// This path runs when we have no data at all yet.
input = createCoverage(inputKey, imageLayer, progress);
}

Expand Down

0 comments on commit 9b7743f

Please sign in to comment.