diff --git a/externals/libsemantic b/externals/libsemantic index fe561a7..3d83870 160000 --- a/externals/libsemantic +++ b/externals/libsemantic @@ -1 +1 @@ -Subproject commit fe561a7c600d1dc0016c261cbcdc3df6ab39ce69 +Subproject commit 3d838709bf5154897fce22bb3b9f46f1a39c3fd1 diff --git a/mapproxy/src/mapproxy/generator/geodata-semantic-tiled.cpp b/mapproxy/src/mapproxy/generator/geodata-semantic-tiled.cpp index 15bf537..36301f4 100644 --- a/mapproxy/src/mapproxy/generator/geodata-semantic-tiled.cpp +++ b/mapproxy/src/mapproxy/generator/geodata-semantic-tiled.cpp @@ -37,15 +37,12 @@ #include "math/transform.hpp" -#include "geo/featurelayers.hpp" -#include "geometry/meshop.hpp" - #include "jsoncpp/as.hpp" #include "jsoncpp/io.hpp" #include "semantic/io.hpp" -#include "semantic/mesh.hpp" #include "semantic/gpkg.hpp" +#include "semantic/featurelayers.hpp" #include "vts-libs/storage/fstreams.hpp" #include "vts-libs/registry/json.hpp" @@ -139,77 +136,6 @@ GeodataSemanticTiled::GeodataSemanticTiled(const Params ¶ms) LOG(info1) << "Generator for <" << id() << "> not ready."; } -namespace { - -class LayerBuilder { -public: - /** TODO: - * * Add clipping - * * Add destination SRS - */ - LayerBuilder(const semantic::World &world, int lod = 2) - : world_(world), fid_() - , materials_(semantic::materials()) - { - semantic::mesh(world, semantic::MeshConfig() - , [this](auto&&... args) { - this->mesh(std::forward(args)...); - } - , lod); - } - - geo::FeatureLayers featureLayers() { - geo::FeatureLayers fl; - for (auto &item : layers_) { - fl.layers.emplace_back(std::move(item.second)); - } - return fl; - } - -private: - using Layer = geo::FeatureLayers::Layer; - using LayerMap = std::map; - using Features = geo::FeatureLayers::Features; - - template - void mesh(const Entity &entity, const geometry::Mesh &mesh) - { - auto &l(layer(entity.cls)); - - for (const auto &sm : geometry::splitById(mesh)) { - // TODO: get more properties from the source - Features::Properties props; - props["material"] = materials_[sm.faces.front().imageId]; - - // add surface - auto &s(l.features.addSurface(++fid_, entity.id, props)); - s.vertices = sm.vertices; - for (const auto &face : sm.faces) { - s.surface.emplace_back(face.a, face.b, face.c); - } - } - } - - Layer& layer(semantic::Class cls) { - auto flayers(layers_.find(cls)); - if (flayers != layers_.end()) { return flayers->second; } - - const auto name(boost::lexical_cast(cls)); - return layers_.emplace - (std::piecewise_construct - , std::forward_as_tuple(cls) - , std::forward_as_tuple(name, world_.srs, true)) - .first->second; - } - - const semantic::World &world_; - LayerMap layers_; - Features::Fid fid_; - std::vector materials_; -}; - -} // namespace - void GeodataSemanticTiled::prepare_impl(Arsenal&) { LOG(info2) << "Preparing <" << id() << ">."; @@ -477,7 +403,7 @@ class SemanticJob : public WorkRequest { auto world(ds.world(query)); // TODO: add meshconfig - auto fl(LayerBuilder(world, lod_).featureLayers()); + auto fl(semantic::featureLayers(world, {}, lod_)); fl.transform(outputSrs_, outputAdjustVertical_); { diff --git a/mapproxy/src/mapproxy/generator/geodata-semantic.cpp b/mapproxy/src/mapproxy/generator/geodata-semantic.cpp index f2522f9..b8770db 100644 --- a/mapproxy/src/mapproxy/generator/geodata-semantic.cpp +++ b/mapproxy/src/mapproxy/generator/geodata-semantic.cpp @@ -37,7 +37,6 @@ #include "math/transform.hpp" -#include "geo/featurelayers.hpp" #include "geometry/meshop.hpp" #include "jsoncpp/as.hpp" @@ -45,6 +44,7 @@ #include "semantic/io.hpp" #include "semantic/mesh.hpp" +#include "semantic/featurelayers.hpp" #include "vts-libs/storage/fstreams.hpp" #include "vts-libs/registry/json.hpp" @@ -224,69 +224,6 @@ geo::FeatureLayers mesh2fl(const geometry::Mesh::list meshes return fl; } -class LayerBuilder { -public: - LayerBuilder(const semantic::World &world) - : world_(world), fid_() - , materials_(semantic::materials()) - { - semantic::mesh(world, semantic::MeshConfig() - , [this](auto&&... args) { - this->mesh(std::forward(args)...); - } - , 2); - } - - geo::FeatureLayers featureLayers() { - geo::FeatureLayers fl; - for (auto &item : layers_) { - fl.layers.emplace_back(std::move(item.second)); - } - return fl; - } - -private: - using Layer = geo::FeatureLayers::Layer; - using LayerMap = std::map; - using Features = geo::FeatureLayers::Features; - - template - void mesh(const Entity &entity, const geometry::Mesh &mesh) - { - auto &l(layer(entity.cls)); - - for (const auto &sm : geometry::splitById(mesh)) { - // TODO: get more properties from the source - Features::Properties props; - props["material"] = materials_[sm.faces.front().imageId]; - - // add surface - auto &s(l.features.addSurface(++fid_, entity.id, props)); - s.vertices = sm.vertices; - for (const auto &face : sm.faces) { - s.surface.emplace_back(face.a, face.b, face.c); - } - } - } - - Layer& layer(semantic::Class cls) { - auto flayers(layers_.find(cls)); - if (flayers != layers_.end()) { return flayers->second; } - - const auto name(boost::lexical_cast(cls)); - return layers_.emplace - (std::piecewise_construct - , std::forward_as_tuple(cls) - , std::forward_as_tuple(name, world_.srs, true)) - .first->second; - } - - const semantic::World &world_; - LayerMap layers_; - Features::Fid fid_; - std::vector materials_; -}; - geo::FeatureLayers generateLayer(const semantic::World &world, bool simplified) { if (simplified) { @@ -297,7 +234,7 @@ geo::FeatureLayers generateLayer(const semantic::World &world, bool simplified) , semantic::materials(), world.srs, true); } - return LayerBuilder(world).featureLayers(); + return semantic::featureLayers(world, {}); } } // namespace