diff --git a/mapproxy/src/mapproxy/generator.hpp b/mapproxy/src/mapproxy/generator.hpp index 187833c..8317212 100644 --- a/mapproxy/src/mapproxy/generator.hpp +++ b/mapproxy/src/mapproxy/generator.hpp @@ -298,6 +298,11 @@ class Generator : boost::noncopyable { */ void setProvider(std::unique_ptr &&provider); + /** Updates revision in this resource. Revision is updated only if more + * recent revision is used. + */ + void updateRevision(unsigned int revision); + private: virtual void prepare_impl(Arsenal &arsenal) = 0; virtual vts::MapConfig mapConfig_impl(ResourceRoot root) const = 0; diff --git a/mapproxy/src/mapproxy/generator/generator.cpp b/mapproxy/src/mapproxy/generator/generator.cpp index 1fb25fd..22819ce 100644 --- a/mapproxy/src/mapproxy/generator/generator.cpp +++ b/mapproxy/src/mapproxy/generator/generator.cpp @@ -308,3 +308,8 @@ Generator::Task Generator::generateFile(const FileInfo &fileInfo, Sink sink) return generateFile_impl(fileInfo, sink); } + +void Generator::updateRevision(unsigned int revision) +{ + resource_.revision = std::max(resource_.revision, revision); +} diff --git a/mapproxy/src/mapproxy/generator/surface-meta.cpp b/mapproxy/src/mapproxy/generator/surface-meta.cpp index 06735c2..d1ed1a1 100644 --- a/mapproxy/src/mapproxy/generator/surface-meta.cpp +++ b/mapproxy/src/mapproxy/generator/surface-meta.cpp @@ -58,6 +58,7 @@ #include "vts-libs/vts/opencv/navtile.hpp" #include "vts-libs/vts/service.hpp" #include "vts-libs/vts/tileset/tilesetindex.hpp" +#include "vts-libs/vts/tileset/config.hpp" #include "../error.hpp" #include "../support/metatile.hpp" @@ -133,14 +134,24 @@ void SurfaceMeta::prepare_impl(Arsenal&) << Resource::Id(referenceFrameId(), definition_.surface) << "> doesn't provide VTS atlas support."; } + + // reflect revision changes in the underlying resources + updateRevision(surface_->resource().revision); + updateRevision(tms_->resource().revision); +} + +vts::FullTileSetProperties SurfaceMeta::properties() const +{ + auto properties(ts_->properties()); + properties.revision = resource().revision; + return properties; } vts::MapConfig SurfaceMeta::mapConfig_impl(ResourceRoot root) const { const auto path(prependRoot(fs::path(), resource(), root)); - auto mc(vts::mapConfig - (ts_->properties(), resource().registry, {}, path)); + auto mc(vts::mapConfig(properties(), resource().registry, {}, path)); // force 2d interface existence mc.surfaces.front().has2dInterface = true; @@ -192,6 +203,37 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const case SurfaceFileInfo::Type::file: { switch (fi.fileType) { + case vts::File::config: { + switch (fi.flavor) { + // handled by mapconfig machinery + case vts::FileFlavor::regular: break; + + case vts::FileFlavor::raw: { + std::ostringstream os; + vts::tileset::saveConfig(os, properties()); + sink.content(os.str(), fi.sinkFileInfo() + .setFileClass(FileClass::unknown)); + } return {}; + + case vts::FileFlavor::debug: { + std::ostringstream os; + const auto debug + (vts::debugConfig + (vts::meshTilesConfig + (properties(), vts::ExtraTileSetProperties() + , prependRoot(fs::path(), resource() + , ResourceRoot::none)))); + vts::saveDebug(os, debug); + sink.content(os.str(), fi.sinkFileInfo()); + } return {}; + + default: + sink.error(utility::makeError + ("Unsupported file flavor %s.", fi.flavor)); + break; + } + } break; + case vts::File::tileIndex: return tileindex(fi, sink); default: break; @@ -220,6 +262,18 @@ ::generateFile_impl(const FileInfo &fileInfo, Sink &sink) const } break; + case SurfaceFileInfo::Type::definition: { + auto fl(vts::freeLayer + (vts::meshTilesConfig + (properties(), vts::ExtraTileSetProperties() + , prependRoot(fs::path(), resource(), ResourceRoot::none)))); + + std::ostringstream os; + vr::saveFreeLayer(os, fl); + sink.content(os.str(), fi.sinkFileInfo()); + return {}; + } + default: break; } diff --git a/mapproxy/src/mapproxy/generator/surface-meta.hpp b/mapproxy/src/mapproxy/generator/surface-meta.hpp index 0a9c485..0e902f7 100644 --- a/mapproxy/src/mapproxy/generator/surface-meta.hpp +++ b/mapproxy/src/mapproxy/generator/surface-meta.hpp @@ -55,6 +55,8 @@ class SurfaceMeta : public Generator { Generator::Task tileindex(const SurfaceFileInfo &fileInfo, Sink &sink) const; + vts::FullTileSetProperties properties() const; + const Definition &definition_; pointer surface_;