diff --git a/externals/libgeo b/externals/libgeo index d3e63de..f5822f0 160000 --- a/externals/libgeo +++ b/externals/libgeo @@ -1 +1 @@ -Subproject commit d3e63ded73e4b175f4e34c0cbbadb95edeedb92e +Subproject commit f5822f052d0c634a38465115d0c3fc9184ba6ea7 diff --git a/externals/vts-libs b/externals/vts-libs index fd677d6..0e0bd09 160000 --- a/externals/vts-libs +++ b/externals/vts-libs @@ -1 +1 @@ -Subproject commit fd677d6180a06da72bc2a4a68bb8e8364ff79684 +Subproject commit 0e0bd095dc44698e682c485136924e36b7fcc45f diff --git a/mapproxy/src/mapproxy/generator/metatile.cpp b/mapproxy/src/mapproxy/generator/metatile.cpp index 4cf5f28..767cca3 100644 --- a/mapproxy/src/mapproxy/generator/metatile.cpp +++ b/mapproxy/src/mapproxy/generator/metatile.cpp @@ -179,7 +179,8 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal , const boost::optional &geoidGrid , const MaskTree &maskTree , const boost::optional &displaySize - , const HeightFunction::pointer &heightFunction) + , const HeightFunction::pointer &heightFunction + , vts::SubMesh::TextureMode textureMode) { auto blocks(metatileBlocks(resource, tileId)); @@ -192,6 +193,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); + auto setChildren([&](const MetatileBlock &block , const vts::TileId &nodeId, vts::MetaNode &node) -> void @@ -412,6 +416,9 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal // set credits node.updateCredits(resource.credits); + // texturing + node.internalTextureCount(internalTextureCount); + if (displaySize) { // use display size node.applyDisplaySize(true); @@ -464,12 +471,13 @@ metatileFromDem(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal , const boost::optional &geoidGrid , const MaskTree &maskTree , const boost::optional &displaySize - , const HeightFunction::pointer &heightFunction) + , const HeightFunction::pointer &heightFunction + , vts::SubMesh::TextureMode textureMode) { return metatileFromDemImpl(tileId, sink, arsenal, resource, tileIndex , demDataset, geoidGrid, maskTree, displaySize - , heightFunction); + , heightFunction, textureMode); } @@ -481,10 +489,11 @@ metatileFromDem(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal , const boost::optional &geoidGrid , const MaskTree &maskTree , const boost::optional &displaySize - , const HeightFunction::pointer &heightFunction) + , const HeightFunction::pointer &heightFunction + , vts::SubMesh::TextureMode textureMode) { return metatileFromDemImpl(tileId, sink, arsenal, resource, tileIndex , demDataset, geoidGrid, maskTree, displaySize - , heightFunction); + , heightFunction, textureMode); } diff --git a/mapproxy/src/mapproxy/generator/metatile.hpp b/mapproxy/src/mapproxy/generator/metatile.hpp index 9e3c172..b8226c9 100644 --- a/mapproxy/src/mapproxy/generator/metatile.hpp +++ b/mapproxy/src/mapproxy/generator/metatile.hpp @@ -47,7 +47,9 @@ vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink , const boost::optional &displaySize = boost::none , const HeightFunction::pointer &heightFunction - = HeightFunction::pointer()); + = HeightFunction::pointer() + , vts::SubMesh::TextureMode textureMode + = vts::SubMesh::external); vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink , Arsenal &arsenal @@ -59,6 +61,8 @@ vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink , const boost::optional &displaySize = boost::none , const HeightFunction::pointer &heightFunction - = HeightFunction::pointer()); + = HeightFunction::pointer() + , vts::SubMesh::TextureMode textureMode + = vts::SubMesh::external); #endif // mapproxy_metatile_hpp_included_ diff --git a/mapproxy/src/mapproxy/generator/providers.hpp b/mapproxy/src/mapproxy/generator/providers.hpp index 067e6cb..48565e8 100644 --- a/mapproxy/src/mapproxy/generator/providers.hpp +++ b/mapproxy/src/mapproxy/generator/providers.hpp @@ -56,6 +56,13 @@ class VtsTilesetProvider { , 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; + /** Alias for surface file generation. */ Generator::Task generateFile(const FileInfo &fileInfo, Sink sink) const; @@ -70,11 +77,14 @@ class VtsTilesetProvider { private: virtual Generator::Task - generateMesh_impl(const vts::TileId &tileId - , Sink &sink + generateMesh_impl(const vts::TileId &tileId, Sink &sink , const SurfaceFileInfo &fileInfo - , vts::SubMesh::TextureMode textureMode) - const = 0; + , 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; virtual Generator::Task generateFile_impl(const FileInfo &fileInfo, Sink sink) const = 0; @@ -107,8 +117,7 @@ class VtsAtlasProvider { // inlines inline Generator::Task -VtsTilesetProvider::generateMesh(const vts::TileId &tileId - , Sink &sink +VtsTilesetProvider::generateMesh(const vts::TileId &tileId, Sink &sink , const SurfaceFileInfo &fileInfo , vts::SubMesh::TextureMode textureMode) const @@ -116,6 +125,16 @@ VtsTilesetProvider::generateMesh(const vts::TileId &tileId return generateMesh_impl(tileId, sink, fileInfo, textureMode); } +inline Generator::Task +VtsTilesetProvider::generateMetatile(const vts::TileId &tileId, Sink &sink + , const SurfaceFileInfo &fileInfo + , vts::SubMesh::TextureMode + textureMode) + const +{ + return generateMetatile_impl(tileId, sink, fileInfo, textureMode); +} + inline Generator::Task VtsTilesetProvider::generateFile(const FileInfo &fileInfo, Sink sink) const { diff --git a/mapproxy/src/mapproxy/generator/surface-dem.cpp b/mapproxy/src/mapproxy/generator/surface-dem.cpp index 05eeec5..b7f4035 100644 --- a/mapproxy/src/mapproxy/generator/surface-dem.cpp +++ b/mapproxy/src/mapproxy/generator/surface-dem.cpp @@ -228,7 +228,9 @@ vts::MapConfig SurfaceDem::mapConfig_impl(ResourceRoot root) const void SurfaceDem::generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fi - , Arsenal &arsenal) const + , Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode) + const { sink.checkAborted(); @@ -237,7 +239,7 @@ void SurfaceDem::generateMetatile(const vts::TileId &tileId return; } - auto metatile(generateMetatileImpl(tileId, sink, arsenal)); + auto metatile(generateMetatileImpl(tileId, sink, arsenal, textureMode)); // write metatile to stream std::ostringstream os; @@ -247,13 +249,14 @@ void SurfaceDem::generateMetatile(const vts::TileId &tileId vts::MetaTile SurfaceDem::generateMetatileImpl(const vts::TileId &tileId - , Sink &sink - , Arsenal &arsenal) const + , Sink &sink, Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode) const { return metatileFromDem(tileId, sink, arsenal, resource() , index_->tileIndex, dem_.dataset , dem_.geoidGrid, maskTree_, boost::none - , definition_.heightFunction); + , definition_.heightFunction + , textureMode); } namespace { diff --git a/mapproxy/src/mapproxy/generator/surface-dem.hpp b/mapproxy/src/mapproxy/generator/surface-dem.hpp index 806f5d0..269de62 100644 --- a/mapproxy/src/mapproxy/generator/surface-dem.hpp +++ b/mapproxy/src/mapproxy/generator/surface-dem.hpp @@ -54,7 +54,9 @@ class SurfaceDem : public SurfaceBase { virtual void generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fileInfo - , Arsenal &arsenal) const; + , Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode) + const; virtual AugmentedMesh generateMeshImpl(const vts::NodeInfo &nodeInfo, Sink &sink @@ -66,8 +68,10 @@ class SurfaceDem : public SurfaceBase { , Arsenal &arsenal) const; vts::MetaTile generateMetatileImpl(const vts::TileId &tileId - , Sink &sink - , Arsenal &arsenal) const; + , Sink &sink, Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode + = vts::SubMesh::external) + const; void addToRegistry(); diff --git a/mapproxy/src/mapproxy/generator/surface-meta.cpp b/mapproxy/src/mapproxy/generator/surface-meta.cpp index 3cad8ef..b9fdb7e 100644 --- a/mapproxy/src/mapproxy/generator/surface-meta.cpp +++ b/mapproxy/src/mapproxy/generator/surface-meta.cpp @@ -207,15 +207,18 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const case SurfaceFileInfo::Type::tile: { switch (fi.tileType) { + case vts::TileFile::meta: + return ts_->generateMetatile(fi.tileId, sink, fi + , vts::SubMesh::internal); + case vts::TileFile::mesh: return ts_->generateMesh(fi.tileId, sink, fi , vts::SubMesh::internal); - case vts::TileFile::atlas: { + case vts::TileFile::atlas: return atlas_->generateAtlas (fi.tileId, sink, fi.sinkFileInfo() , (fi.flavor == vts::FileFlavor::raw)); - } break; default: break; } break; diff --git a/mapproxy/src/mapproxy/generator/surface-spheroid.cpp b/mapproxy/src/mapproxy/generator/surface-spheroid.cpp index 5fdea41..6733cce 100644 --- a/mapproxy/src/mapproxy/generator/surface-spheroid.cpp +++ b/mapproxy/src/mapproxy/generator/surface-spheroid.cpp @@ -241,7 +241,9 @@ const int metatileSamplesPerTile(8); void SurfaceSpheroid::generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fi - , Arsenal&) const + , Arsenal& + , vts::SubMesh::TextureMode textureMode) + const { sink.checkAborted(); @@ -293,6 +295,10 @@ 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); + for (const auto &block : blocks) { const auto &view(block.view); const auto &extents(block.extents); @@ -426,6 +432,9 @@ void SurfaceSpheroid::generateMetatile(const vts::TileId &tileId // set credits node.updateCredits(resource().credits); + // texturing + node.internalTextureCount(internalTextureCount); + // mesh is (almost) flat -> use tile area if (geometry) { node.applyTexelSize(true); diff --git a/mapproxy/src/mapproxy/generator/surface-spheroid.hpp b/mapproxy/src/mapproxy/generator/surface-spheroid.hpp index b15d263..81dee0a 100644 --- a/mapproxy/src/mapproxy/generator/surface-spheroid.hpp +++ b/mapproxy/src/mapproxy/generator/surface-spheroid.hpp @@ -49,7 +49,9 @@ class SurfaceSpheroid : public SurfaceBase { virtual void generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fileInfo - , Arsenal &arsenal) const; + , Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode) + const; virtual AugmentedMesh generateMeshImpl(const vts::NodeInfo &nodeInfo , Sink &sink diff --git a/mapproxy/src/mapproxy/generator/surface.cpp b/mapproxy/src/mapproxy/generator/surface.cpp index 6c1980e..7d0bce1 100644 --- a/mapproxy/src/mapproxy/generator/surface.cpp +++ b/mapproxy/src/mapproxy/generator/surface.cpp @@ -111,12 +111,31 @@ class SurfaceProvider , vts::SubMesh::TextureMode textureMode) const override { - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { surface_.generateMesh (tileId, sink, fileInfo, arsenal, textureMode); }; } + Generator::Task generateMetatile_impl(const vts::TileId &tileId, Sink& + , const SurfaceFileInfo &fileInfo + , vts::SubMesh::TextureMode + textureMode) + const override + { + return [=](Sink &sink, Arsenal &arsenal) { + if (fileInfo.flavor == vts::FileFlavor::debug) { + // debug metanode + surface_.generateDebugNode + (tileId, sink, fileInfo, arsenal, textureMode); + } else { + // real metatile + surface_.generateMetatile + (tileId, sink, fileInfo, arsenal, textureMode); + } + }; + } + Generator::Task generateFile_impl(const FileInfo &fileInfo, Sink sink) const override { @@ -335,7 +354,7 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const case SurfaceFileInfo::Type::tile: { switch (fi.tileType) { case vts::TileFile::meta: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { if (fi.flavor == vts::FileFlavor::debug) { // debug metanode generateDebugNode(fi.tileId, sink, fi, arsenal); @@ -346,7 +365,7 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const }; case vts::TileFile::mesh: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { generateMesh(fi.tileId, sink, fi, arsenal); }; @@ -356,19 +375,19 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const break; case vts::TileFile::navtile: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { generateNavtile(fi.tileId, sink, fi, arsenal); }; break; case vts::TileFile::meta2d: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { generate2dMetatile(fi.tileId, sink, fi, arsenal); }; break; case vts::TileFile::mask: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { generate2dMask(fi.tileId, sink, fi, arsenal); }; break; @@ -379,7 +398,7 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const break; case vts::TileFile::credits: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { generateCredits(fi.tileId, sink, fi, arsenal); }; break; @@ -544,10 +563,25 @@ void SurfaceBase::generateCredits(const vts::TileId& void SurfaceBase::generateDebugNode(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fi - , Arsenal &) const + , Arsenal & + , vts::SubMesh::TextureMode textureMode) + const { // generate debug metanode - const auto debugNode(vts::getNodeDebugInfo(index_->tileIndex, tileId)); + const auto debugNode([&]() + { + if (textureMode == vts::SubMesh::external) { + return vts::getNodeDebugInfo(index_->tileIndex, tileId); + } + + // internal texture -> add atlas flag + return vts::getNodeDebugInfo + (index_->tileIndex, tileId + , [](vts::TileIndex::Flag::value_type f) { + return (vts::TileIndex::Flag::isReal(f) + ? (f | vts::TileIndex::Flag::atlas) : f); + }); + }()); std::ostringstream os; vts::saveDebug(os, debugNode); @@ -620,7 +654,7 @@ ::terrainInterface(const FileInfo &fileInfo, Sink &sink) const break; case TerrainFileInfo::Type::tile: - return[=](Sink &sink, Arsenal &arsenal) { + return [=](Sink &sink, Arsenal &arsenal) { generateTerrain(fi.tileId, sink, fi, arsenal, tms); }; diff --git a/mapproxy/src/mapproxy/generator/surface.hpp b/mapproxy/src/mapproxy/generator/surface.hpp index 2cd1aff..7d43e14 100644 --- a/mapproxy/src/mapproxy/generator/surface.hpp +++ b/mapproxy/src/mapproxy/generator/surface.hpp @@ -71,7 +71,9 @@ class SurfaceBase : public Generator { virtual void generateMetatile(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fileInfo - , Arsenal &arsenal) const = 0; + , Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode + = vts::SubMesh::external) const = 0; void generateMesh(const vts::TileId &tileId , Sink &sink @@ -103,7 +105,9 @@ class SurfaceBase : public Generator { void generateDebugNode(const vts::TileId &tileId , Sink &sink , const SurfaceFileInfo &fileInfo - , Arsenal &arsenal) const; + , Arsenal &arsenal + , vts::SubMesh::TextureMode textureMode + = vts::SubMesh::external) const; /** Generic mesh generation, used by both surface and terrain interface. */