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

Commit

Permalink
working surface-meta driver
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavblazek committed Nov 27, 2019
1 parent b9279bd commit 1ccc0e5
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 39 deletions.
2 changes: 1 addition & 1 deletion externals/libgeo
19 changes: 14 additions & 5 deletions mapproxy/src/mapproxy/generator/metatile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal
, const boost::optional<std::string> &geoidGrid
, const MaskTree &maskTree
, const boost::optional<int> &displaySize
, const HeightFunction::pointer &heightFunction)
, const HeightFunction::pointer &heightFunction
, vts::SubMesh::TextureMode textureMode)
{
auto blocks(metatileBlocks(resource, tileId));

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -464,12 +471,13 @@ metatileFromDem(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal
, const boost::optional<std::string> &geoidGrid
, const MaskTree &maskTree
, const boost::optional<int> &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);
}


Expand All @@ -481,10 +489,11 @@ metatileFromDem(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal
, const boost::optional<std::string> &geoidGrid
, const MaskTree &maskTree
, const boost::optional<int> &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);

}
8 changes: 6 additions & 2 deletions mapproxy/src/mapproxy/generator/metatile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink
, const boost::optional<int> &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
Expand All @@ -59,6 +61,8 @@ vts::MetaTile metatileFromDem(const vts::TileId &tileId, Sink &sink
, const boost::optional<int> &displaySize
= boost::none
, const HeightFunction::pointer &heightFunction
= HeightFunction::pointer());
= HeightFunction::pointer()
, vts::SubMesh::TextureMode textureMode
= vts::SubMesh::external);

#endif // mapproxy_metatile_hpp_included_
31 changes: 25 additions & 6 deletions mapproxy/src/mapproxy/generator/providers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -107,15 +117,24 @@ 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
{
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
{
Expand Down
13 changes: 8 additions & 5 deletions mapproxy/src/mapproxy/generator/surface-dem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
Expand All @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions mapproxy/src/mapproxy/generator/surface-dem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();

Expand Down
7 changes: 5 additions & 2 deletions mapproxy/src/mapproxy/generator/surface-meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion mapproxy/src/mapproxy/generator/surface-spheroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion mapproxy/src/mapproxy/generator/surface-spheroid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 44 additions & 10 deletions mapproxy/src/mapproxy/generator/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);
};

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
};

Expand Down
Loading

0 comments on commit 1ccc0e5

Please sign in to comment.