Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Check for existence of cached alpha when merging rasters (#1836)
Browse files Browse the repository at this point in the history
  • Loading branch information
tst-lsavoie authored Sep 9, 2020
1 parent 88e203a commit 0fc1e72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
23 changes: 2 additions & 21 deletions earth_enterprise/src/fusion/autoingest/plugins.src/PacketGen.src
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,9 @@ void PacketGenAssetVersionImplD::UpdateChildren(
// In these cases we pull directly from the product. It
// will also happen for the last thing on the stack who
// hasn't had his blendvers filled in yet.

// Note: Before creating a merge inset, we check if the cached alpha
// blend directory exists for the asset since in GEE-5.x we need to
// pick up the GEE-4.x Imagery/Terrain Projects (the PacketLevel
// assets) that have no alpha blend cached.
levInputs[inputs_idx+1] = blendVer.Ref();
levInputVers[inputs_idx+1] = blendVer;
const std::string cache_alpha_path =
blendVer->GetOutputFilename(0) + "/cache_alpha.pack";
if (khExists(cache_alpha_path)) {
cached_blend_alpha = blendVer.Ref();
}
cached_blend_alpha = blendVer.Ref();
cached_blend = blendVer.Ref();
}
packetLevelConfig.insets[merge_idx] =
Expand All @@ -283,22 +274,12 @@ void PacketGenAssetVersionImplD::UpdateChildren(
levInputs.back() = prevLevelVer.Ref();
levInputVers.back() = prevLevelVer;


// Note: Before creating a merge inset, we check if the cached alpha
// blend directory exists for the asset since in GEE-5.x we need to
// pick up the GEE-4.x Imagery/Terrain Projects (the PacketLevel
// assets) that have no alpha blend cached.
const std::string cache_alpha_path =
prevLevelVer->GetOutputFilename(0) + "/cache_alpha.pack";
const bool cache_alpha_exist = khExists(cache_alpha_path);

packetLevelConfig.insets.push_back
(PacketLevelConfig::Inset(
std::string() /* dataRP */,
std::string() /* alphaRP */,
prevLevelVer.Ref(), /* cached blend */
cache_alpha_exist ?
prevLevelVer.Ref() : SharedString() /* cached blend alpha */));
prevLevelVer.Ref() /* cached blend alpha */));
}

levInputs.erase(std::remove(levInputs.begin(), levInputs.end(), ""), levInputs.end());
Expand Down
14 changes: 11 additions & 3 deletions earth_enterprise/src/fusion/rasterfuse/RasterMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,18 @@ void MergeInset<DataTile>::InitCachedBlendReaders(

magnifyCoverage = cached_blend_reader->levelCoverage(magnify_level);

// Initialize cached alpha reader
// Initialize cached alpha reader.
if (cached_blend_alpha_file.size()) {
cached_blend_alpha_reader = TransferOwnership(
new ffio::raster::Reader<AlphaProductTile>(cached_blend_alpha_file));
// Note: we check if the cached alpha blend directory exists for the
// asset since in GEE-5.x we need to pick up the GEE-4.x Imagery/Terrain
// Projects (the PacketLevel assets) that have no alpha blend cached.
if (khExists(cached_blend_alpha_file)) {
cached_blend_alpha_reader = TransferOwnership(
new ffio::raster::Reader<AlphaProductTile>(cached_blend_alpha_file));
}
else {
notify(NFY_INFO, "Cached blend alpha file %s does not exist.", cached_blend_alpha_file.c_str());
}
}
}
}
Expand Down

0 comments on commit 0fc1e72

Please sign in to comment.