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

Commit

Permalink
surface-meta: better properties handling (using max revision)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavblazek committed Nov 27, 2019
1 parent 2ff12ce commit c05d709
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
5 changes: 5 additions & 0 deletions mapproxy/src/mapproxy/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ class Generator : boost::noncopyable {
*/
void setProvider(std::unique_ptr<Provider> &&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;
Expand Down
5 changes: 5 additions & 0 deletions mapproxy/src/mapproxy/generator/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
58 changes: 56 additions & 2 deletions mapproxy/src/mapproxy/generator/surface-meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<NotFound>
("Unsupported file flavor %s.", fi.flavor));
break;
}
} break;

case vts::File::tileIndex:
return tileindex(fi, sink);
default: break;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions mapproxy/src/mapproxy/generator/surface-meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down

0 comments on commit c05d709

Please sign in to comment.