diff --git a/mapproxy/src/mapproxy/generator/metatile.cpp b/mapproxy/src/mapproxy/generator/metatile.cpp index 767cca3..d33ea1d 100644 --- a/mapproxy/src/mapproxy/generator/metatile.cpp +++ b/mapproxy/src/mapproxy/generator/metatile.cpp @@ -180,7 +180,7 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal , const MaskTree &maskTree , const boost::optional &displaySize , const HeightFunction::pointer &heightFunction - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) { auto blocks(metatileBlocks(resource, tileId)); @@ -194,7 +194,9 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal vts::MetaTile metatile(tileId, rf.metaBinaryOrder); const std::size_t internalTextureCount - (textureMode == vts::SubMesh::internal); + (overrides.textureMode == vts::SubMesh::internal); + + const auto credits(overrides.mergedCredits(resource.credits)); auto setChildren([&](const MetatileBlock &block , const vts::TileId &nodeId, vts::MetaNode &node) @@ -414,7 +416,7 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal // calculate texel size and surrogate if (geometry) { // set credits - node.updateCredits(resource.credits); + node.updateCredits(credits); // texturing node.internalTextureCount(internalTextureCount); @@ -472,12 +474,12 @@ metatileFromDem(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal , const MaskTree &maskTree , const boost::optional &displaySize , const HeightFunction::pointer &heightFunction - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) { return metatileFromDemImpl(tileId, sink, arsenal, resource, tileIndex , demDataset, geoidGrid, maskTree, displaySize - , heightFunction, textureMode); + , heightFunction, overrides); } @@ -490,10 +492,10 @@ metatileFromDem(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal , const MaskTree &maskTree , const boost::optional &displaySize , const HeightFunction::pointer &heightFunction - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) { return metatileFromDemImpl(tileId, sink, arsenal, resource, tileIndex , demDataset, geoidGrid, maskTree, displaySize - , heightFunction, textureMode); + , heightFunction, overrides); } diff --git a/mapproxy/src/mapproxy/generator/metatile.hpp b/mapproxy/src/mapproxy/generator/metatile.hpp index b8226c9..5dabfaf 100644 --- a/mapproxy/src/mapproxy/generator/metatile.hpp +++ b/mapproxy/src/mapproxy/generator/metatile.hpp @@ -37,6 +37,31 @@ #include "../heightfunction.hpp" +struct MetatileOverrides { + enum class CreditsMode { replace, add }; + + vts::SubMesh::TextureMode textureMode; + DualId::set credits; + CreditsMode creditsMode; + + MetatileOverrides() + : textureMode(vts::SubMesh::external) + , creditsMode(CreditsMode::add) + {} + + MetatileOverrides(vts::SubMesh::TextureMode textureMode) + : textureMode(textureMode) + , creditsMode(CreditsMode::add) + + {} + + void addCredits(const DualId::set &addition); + + DualId::set mergedCredits(const DualId::set &original) const; + + vr::IdSet mergedCredits(const vr::IdSet &original) const; +}; + vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink , Arsenal &arsenal , const Resource &resource @@ -48,8 +73,8 @@ vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink = boost::none , const HeightFunction::pointer &heightFunction = HeightFunction::pointer() - , vts::SubMesh::TextureMode textureMode - = vts::SubMesh::external); + , const MetatileOverrides &overrides + = MetatileOverrides()); vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink , Arsenal &arsenal @@ -62,7 +87,39 @@ vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink = boost::none , const HeightFunction::pointer &heightFunction = HeightFunction::pointer() - , vts::SubMesh::TextureMode textureMode - = vts::SubMesh::external); + , const MetatileOverrides &overrides + = MetatileOverrides()); + +// inines + +inline DualId::set +MetatileOverrides::mergedCredits(const DualId::set &original) const +{ + // just send configured credits + if (creditsMode == CreditsMode::replace) { return credits; } + + // merge original with configured credits + auto c(original); + c.insert(credits.begin(), credits.end()); + return c; +} + +inline vr::IdSet +MetatileOverrides::mergedCredits(const vr::IdSet &original) const +{ + const auto thisCredits(asIntSet(credits)); + // just send configured credits + if (creditsMode == CreditsMode::replace) { return thisCredits; } + + // merge original with configured credits + auto c(original); + c.insert(thisCredits.begin(), thisCredits.end()); + return c; +} + +inline void MetatileOverrides::addCredits(const DualId::set &addition) +{ + credits.insert(addition.begin(), addition.end()); +} #endif // mapproxy_metatile_hpp_included_ diff --git a/mapproxy/src/mapproxy/generator/providers.hpp b/mapproxy/src/mapproxy/generator/providers.hpp index 48565e8..321ca0c 100644 --- a/mapproxy/src/mapproxy/generator/providers.hpp +++ b/mapproxy/src/mapproxy/generator/providers.hpp @@ -39,6 +39,8 @@ #include "../generator.hpp" #include "../definition.hpp" +#include "metatile.hpp" + namespace vts = vtslibs::vts; namespace vre = vtslibs::registry::extensions; @@ -50,22 +52,21 @@ class VtsTilesetProvider { /** Generates mesh and sends it to the output. */ - Generator::Task generateMesh(const vts::TileId &tileId - , Sink &sink - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode - = vts::SubMesh::external) const; + Generator::Task mesh(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , vts::SubMesh::TextureMode textureMode + = vts::SubMesh::external) const; /** Generates metatile/debug node and sends it to the output. */ - Generator::Task generateMetatile(const vts::TileId &tileId, Sink &sink - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode - = vts::SubMesh::external) const; + Generator::Task metatile(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , const MetatileOverrides &overrides + = MetatileOverrides()) const; /** Alias for surface file generation. */ - Generator::Task generateFile(const FileInfo &fileInfo, Sink sink) const; + Generator::Task file(const FileInfo &fileInfo, Sink sink) const; /** Returns path to VTS file if supported. */ @@ -77,17 +78,17 @@ class VtsTilesetProvider { private: virtual Generator::Task - generateMesh_impl(const vts::TileId &tileId, Sink &sink - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode) const = 0; + mesh_impl(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , vts::SubMesh::TextureMode textureMode) const = 0; virtual Generator::Task - generateMetatile_impl(const vts::TileId &tileId, Sink &sink - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode) const = 0; + metatile_impl(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , const MetatileOverrides &overrides) const = 0; virtual Generator::Task - generateFile_impl(const FileInfo &fileInfo, Sink sink) const = 0; + file_impl(const FileInfo &fileInfo, Sink sink) const = 0; virtual boost::optional path_impl(vts::File file) const = 0; @@ -101,44 +102,43 @@ class VtsAtlasProvider { /** Generates image/atlas and sends it to the output. */ - Generator::Task generateAtlas(const vts::TileId &tileId, Sink &sink - , const Sink::FileInfo &sfi - , bool atlas = false) const; + Generator::Task atlas(const vts::TileId &tileId, Sink &sink + , const Sink::FileInfo &sfi + , bool atlas = false) const; private: /** Generates image/atlas and sends it to the output. */ virtual Generator::Task - generateAtlas_impl(const vts::TileId &tileId, Sink &sink - , const Sink::FileInfo &sfi - , bool atlas = false) const = 0; + atlas_impl(const vts::TileId &tileId, Sink &sink + , const Sink::FileInfo &sfi + , bool atlas = false) const = 0; }; // inlines inline Generator::Task -VtsTilesetProvider::generateMesh(const vts::TileId &tileId, Sink &sink - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode) +VtsTilesetProvider::mesh(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , vts::SubMesh::TextureMode textureMode) const { - return generateMesh_impl(tileId, sink, fileInfo, textureMode); + return mesh_impl(tileId, sink, fileInfo, textureMode); } inline Generator::Task -VtsTilesetProvider::generateMetatile(const vts::TileId &tileId, Sink &sink - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode - textureMode) +VtsTilesetProvider::metatile(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , const MetatileOverrides &overrides) const { - return generateMetatile_impl(tileId, sink, fileInfo, textureMode); + return metatile_impl(tileId, sink, fileInfo, overrides); } inline Generator::Task -VtsTilesetProvider::generateFile(const FileInfo &fileInfo, Sink sink) const +VtsTilesetProvider::file(const FileInfo &fileInfo, Sink sink) const { - return generateFile_impl(fileInfo, sink); + return file_impl(fileInfo, sink); } inline boost::optional @@ -153,11 +153,11 @@ inline vts::FullTileSetProperties VtsTilesetProvider::properties() const } inline Generator::Task -VtsAtlasProvider::generateAtlas(const vts::TileId &tileId, Sink &sink - , const Sink::FileInfo &sfi - , bool atlas) const +VtsAtlasProvider::atlas(const vts::TileId &tileId, Sink &sink + , const Sink::FileInfo &sfi + , bool atlas) const { - return generateAtlas_impl(tileId, sink, sfi, atlas); + return atlas_impl(tileId, sink, sfi, atlas); } } // namespace generator diff --git a/mapproxy/src/mapproxy/generator/surface-dem.cpp b/mapproxy/src/mapproxy/generator/surface-dem.cpp index b7f4035..c4d4782 100644 --- a/mapproxy/src/mapproxy/generator/surface-dem.cpp +++ b/mapproxy/src/mapproxy/generator/surface-dem.cpp @@ -229,7 +229,7 @@ void SurfaceDem::generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fi , Arsenal &arsenal - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) const { sink.checkAborted(); @@ -239,7 +239,7 @@ void SurfaceDem::generateMetatile(const vts::TileId &tileId return; } - auto metatile(generateMetatileImpl(tileId, sink, arsenal, textureMode)); + auto metatile(generateMetatileImpl(tileId, sink, arsenal, overrides)); // write metatile to stream std::ostringstream os; @@ -250,13 +250,13 @@ void SurfaceDem::generateMetatile(const vts::TileId &tileId vts::MetaTile SurfaceDem::generateMetatileImpl(const vts::TileId &tileId , Sink &sink, Arsenal &arsenal - , vts::SubMesh::TextureMode textureMode) const + , const MetatileOverrides &overrides) const { return metatileFromDem(tileId, sink, arsenal, resource() , index_->tileIndex, dem_.dataset , dem_.geoidGrid, maskTree_, boost::none , definition_.heightFunction - , textureMode); + , overrides); } namespace { diff --git a/mapproxy/src/mapproxy/generator/surface-dem.hpp b/mapproxy/src/mapproxy/generator/surface-dem.hpp index 269de62..6f9d570 100644 --- a/mapproxy/src/mapproxy/generator/surface-dem.hpp +++ b/mapproxy/src/mapproxy/generator/surface-dem.hpp @@ -55,7 +55,7 @@ class SurfaceDem : public SurfaceBase { , Sink &sink , const SurfaceFileInfo &fileInfo , Arsenal &arsenal - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) const; virtual AugmentedMesh @@ -69,8 +69,8 @@ class SurfaceDem : public SurfaceBase { vts::MetaTile generateMetatileImpl(const vts::TileId &tileId , Sink &sink, Arsenal &arsenal - , vts::SubMesh::TextureMode textureMode - = vts::SubMesh::external) + , const MetatileOverrides &overrides + = MetatileOverrides()) const; void addToRegistry(); diff --git a/mapproxy/src/mapproxy/generator/surface-meta.cpp b/mapproxy/src/mapproxy/generator/surface-meta.cpp index d1ed1a1..242c7d7 100644 --- a/mapproxy/src/mapproxy/generator/surface-meta.cpp +++ b/mapproxy/src/mapproxy/generator/surface-meta.cpp @@ -101,6 +101,7 @@ utility::PreMain Factory::register_([]() SurfaceMeta::SurfaceMeta(const Params ¶ms) : Generator(params) , definition_(resource().definition()) + , metatileOverrides_(vts::SubMesh::internal) {} SurfaceMeta::~SurfaceMeta() {} @@ -138,12 +139,17 @@ void SurfaceMeta::prepare_impl(Arsenal&) // reflect revision changes in the underlying resources updateRevision(surface_->resource().revision); updateRevision(tms_->resource().revision); + + // join this resource's credits with tms credits + metatileOverrides_.addCredits(resource().credits); + metatileOverrides_.addCredits(tms_->resource().credits); } vts::FullTileSetProperties SurfaceMeta::properties() const { auto properties(ts_->properties()); properties.revision = resource().revision; + properties.credits = metatileOverrides_.mergedCredits(properties.credits); return properties; } @@ -193,7 +199,7 @@ Generator::Task SurfaceMeta ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const { if (fileInfo.interface.interface != GeneratorInterface::Interface::vts) { - return ts_->generateFile(fileInfo, sink); + return ts_->file(fileInfo, sink); } SurfaceFileInfo fi(fileInfo); @@ -245,15 +251,13 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const switch (fi.tileType) { case vts::TileFile::meta: - return ts_->generateMetatile(fi.tileId, sink, fi - , vts::SubMesh::internal); + return ts_->metatile(fi.tileId, sink, fi, metatileOverrides_); case vts::TileFile::mesh: - return ts_->generateMesh(fi.tileId, sink, fi - , vts::SubMesh::internal); + return ts_->mesh(fi.tileId, sink, fi, vts::SubMesh::internal); case vts::TileFile::atlas: - return atlas_->generateAtlas + return atlas_->atlas (fi.tileId, sink, fi.sinkFileInfo() , (fi.flavor == vts::FileFlavor::raw)); @@ -277,7 +281,7 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const default: break; } - return ts_->generateFile(fileInfo, sink); + return ts_->file(fileInfo, sink); } } // namespace generator diff --git a/mapproxy/src/mapproxy/generator/surface-meta.hpp b/mapproxy/src/mapproxy/generator/surface-meta.hpp index 0e902f7..338c061 100644 --- a/mapproxy/src/mapproxy/generator/surface-meta.hpp +++ b/mapproxy/src/mapproxy/generator/surface-meta.hpp @@ -69,6 +69,8 @@ class SurfaceMeta : public Generator { /** Pointer owned by tms. */ VtsAtlasProvider *atlas_; + + MetatileOverrides metatileOverrides_; }; } // namespace generator diff --git a/mapproxy/src/mapproxy/generator/surface-spheroid.cpp b/mapproxy/src/mapproxy/generator/surface-spheroid.cpp index 6733cce..cca3afb 100644 --- a/mapproxy/src/mapproxy/generator/surface-spheroid.cpp +++ b/mapproxy/src/mapproxy/generator/surface-spheroid.cpp @@ -242,7 +242,7 @@ void SurfaceSpheroid::generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fi , Arsenal& - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) const { sink.checkAborted(); @@ -297,7 +297,8 @@ void SurfaceSpheroid::generateMetatile(const vts::TileId &tileId // set internal texture count to 1 if we are generating internal textures const std::size_t internalTextureCount - (textureMode == vts::SubMesh::internal); + (overrides.textureMode == vts::SubMesh::internal); + const auto credits(overrides.mergedCredits(resource().credits)); for (const auto &block : blocks) { const auto &view(block.view); @@ -430,7 +431,7 @@ void SurfaceSpheroid::generateMetatile(const vts::TileId &tileId node.heightRange.max = std::ceil(heightRange.max); // set credits - node.updateCredits(resource().credits); + node.updateCredits(credits); // texturing node.internalTextureCount(internalTextureCount); diff --git a/mapproxy/src/mapproxy/generator/surface-spheroid.hpp b/mapproxy/src/mapproxy/generator/surface-spheroid.hpp index 81dee0a..1b16b36 100644 --- a/mapproxy/src/mapproxy/generator/surface-spheroid.hpp +++ b/mapproxy/src/mapproxy/generator/surface-spheroid.hpp @@ -50,7 +50,7 @@ class SurfaceSpheroid : public SurfaceBase { , Sink &sink , const SurfaceFileInfo &fileInfo , Arsenal &arsenal - , vts::SubMesh::TextureMode textureMode) + , const MetatileOverrides &overrides) const; virtual AugmentedMesh generateMeshImpl(const vts::NodeInfo &nodeInfo diff --git a/mapproxy/src/mapproxy/generator/surface.cpp b/mapproxy/src/mapproxy/generator/surface.cpp index 7d0bce1..b3a570f 100644 --- a/mapproxy/src/mapproxy/generator/surface.cpp +++ b/mapproxy/src/mapproxy/generator/surface.cpp @@ -106,9 +106,9 @@ class SurfaceProvider {} private: - Generator::Task generateMesh_impl(const vts::TileId &tileId, Sink& - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode) + Generator::Task mesh_impl(const vts::TileId &tileId, Sink& + , const SurfaceFileInfo &fileInfo + , vts::SubMesh::TextureMode textureMode) const override { return [=](Sink &sink, Arsenal &arsenal) { @@ -117,26 +117,25 @@ class SurfaceProvider }; } - Generator::Task generateMetatile_impl(const vts::TileId &tileId, Sink& - , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode - textureMode) + Generator::Task metatile_impl(const vts::TileId &tileId, Sink& + , const SurfaceFileInfo &fileInfo + , const MetatileOverrides &overrides) const override { return [=](Sink &sink, Arsenal &arsenal) { if (fileInfo.flavor == vts::FileFlavor::debug) { // debug metanode surface_.generateDebugNode - (tileId, sink, fileInfo, arsenal, textureMode); + (tileId, sink, fileInfo, arsenal, overrides.textureMode); } else { // real metatile surface_.generateMetatile - (tileId, sink, fileInfo, arsenal, textureMode); + (tileId, sink, fileInfo, arsenal, overrides); } }; } - Generator::Task generateFile_impl(const FileInfo &fileInfo, Sink sink) + Generator::Task file_impl(const FileInfo &fileInfo, Sink sink) const override { return surface_.generateFile(fileInfo, sink); diff --git a/mapproxy/src/mapproxy/generator/surface.hpp b/mapproxy/src/mapproxy/generator/surface.hpp index 7d43e14..71a11e3 100644 --- a/mapproxy/src/mapproxy/generator/surface.hpp +++ b/mapproxy/src/mapproxy/generator/surface.hpp @@ -38,6 +38,7 @@ #include "../support/mmapped/tilesetindex.hpp" #include "../generator.hpp" #include "../definition.hpp" +#include "metatile.hpp" namespace vts = vtslibs::vts; namespace vre = vtslibs::registry::extensions; @@ -72,8 +73,8 @@ class SurfaceBase : public Generator { , Sink &sink , const SurfaceFileInfo &fileInfo , Arsenal &arsenal - , vts::SubMesh::TextureMode textureMode - = vts::SubMesh::external) const = 0; + , const MetatileOverrides &overrides + = MetatileOverrides()) const = 0; void generateMesh(const vts::TileId &tileId , Sink &sink diff --git a/mapproxy/src/mapproxy/generator/tms-raster-base.cpp b/mapproxy/src/mapproxy/generator/tms-raster-base.cpp index ed381fb..c8a2db6 100644 --- a/mapproxy/src/mapproxy/generator/tms-raster-base.cpp +++ b/mapproxy/src/mapproxy/generator/tms-raster-base.cpp @@ -64,9 +64,9 @@ class AtlasProvider {} private: - Generator::Task generateAtlas_impl(const vts::TileId &tileId, Sink& - , const Sink::FileInfo &sfi - , bool atlas) const override + Generator::Task atlas_impl(const vts::TileId &tileId, Sink& + , const Sink::FileInfo &sfi + , bool atlas) const override { TmsRasterBase::ImageFlags imageFlags; imageFlags.forceFormat = true;