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

Commit

Permalink
surface: introspection can reference local layer or remote layer
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavblazek committed Apr 11, 2019
1 parent 606943c commit 00e2cf8
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 185 deletions.
2 changes: 1 addition & 1 deletion externals/vts-libs
3 changes: 2 additions & 1 deletion mapproxy/src/mapproxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ set(mapproxy-core_SOURCES
support/coverage.hpp support/coverage.cpp
support/tileindex.hpp support/tileindex.cpp
support/fileclass.hpp support/fileclass.cpp
support/serialization.hpp support/serialization.cpp
support/introspection.hpp support/introspection.cpp
support/serialization.cpp
support/aborter.hpp
support/glob.hpp support/glob.cpp
support/tilejson.hpp support/tilejson.cpp
Expand Down
10 changes: 5 additions & 5 deletions mapproxy/src/mapproxy/definition/geodatavectorbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "vts-libs/registry/py.hpp"

#include "../support/python.hpp"
#include "../support/serialization.hpp"
#include "../support/introspection.hpp"

#include "geodata.hpp"
#include "options.hpp"
Expand Down Expand Up @@ -141,7 +141,7 @@ void parseDefinition(GeodataVectorBase &def
const auto &jintrospection(value["introspection"]);

def.introspection.surface
= introspectionIdFrom(jintrospection, "surface");
= introspection::idFrom(jintrospection, "surface");

if (jintrospection.isMember("browserOptions")) {
def.introspection.browserOptions
Expand Down Expand Up @@ -220,8 +220,8 @@ void buildDefinition(Json::Value &value

if (!def.introspection.empty()) {
auto &jintrospection(value["introspection"] = Json::objectValue);
introspectionIdTo(jintrospection, "surface"
, def.introspection.surface);
introspection::idTo(jintrospection, "surface"
, def.introspection.surface);

if (!def.introspection.browserOptions.empty()) {
jintrospection["browserOptions"]
Expand Down Expand Up @@ -331,7 +331,7 @@ void parseDefinition(GeodataVectorBase &def
if (value.has_key("introspection")) {
boost::python::dict pintrospection(value["introspection"]);
def.introspection.surface
= introspectionIdFrom(pintrospection, "surface");
= introspection::idFrom(pintrospection, "surface");
}
}

Expand Down
14 changes: 7 additions & 7 deletions mapproxy/src/mapproxy/definition/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "vts-libs/registry/py.hpp"

#include "../support/python.hpp"
#include "../support/serialization.hpp"

#include "surface.hpp"

Expand Down Expand Up @@ -88,9 +87,9 @@ void Surface::parse(const Json::Value &value)
const auto &jintrospection(value["introspection"]);

introspection.tms
= introspectionListFrom(jintrospection, "tms");
= introspection::layersFrom(jintrospection, "tms");
introspection.geodata
= introspectionListFrom(jintrospection, "geodata");
= introspection::layersFrom(jintrospection, "geodata");

if (jintrospection.isMember("position")) {
introspection.position
Expand Down Expand Up @@ -122,8 +121,9 @@ void Surface::build(Json::Value &value) const

if (!introspection.empty()) {
auto &jintrospection(value["introspection"] = Json::objectValue);
introspectionListTo(jintrospection, "tms", introspection.tms) ;
introspectionListTo(jintrospection, "geodata", introspection.geodata);
introspection::layersTo(jintrospection, "tms", introspection.tms) ;
introspection::layersTo
(jintrospection, "geodata", introspection.geodata);

if (introspection.position) {
jintrospection["position"] = vr::asJson(*introspection.position);
Expand Down Expand Up @@ -154,9 +154,9 @@ void Surface::parse(const boost::python::dict &value)
if (value.has_key("introspection")) {
boost::python::dict pintrospection(value["introspection"]);
introspection.tms
= introspectionListFrom(pintrospection, "tms");
= introspection::layersFrom(pintrospection, "tms");
introspection.geodata
= introspectionListFrom(pintrospection, "geodata");
= introspection::layersFrom(pintrospection, "geodata");

if (pintrospection.has_key("position")) {
introspection.position = boost::in_place();
Expand Down
14 changes: 12 additions & 2 deletions mapproxy/src/mapproxy/definition/surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include "../heightfunction.hpp"

#include "../support/introspection.hpp"

// fwd
namespace Json { class Value; }
namespace boost { namespace python { class dict; } }
Expand All @@ -48,8 +50,8 @@ namespace resource {
class Surface : public DefinitionBase {
public:
struct Introspection {
Resource::Id::list tms;
Resource::Id::list geodata;
introspection::Layers tms;
introspection::Layers geodata;
boost::optional<vr::Position> position;
boost::any browserOptions;

Expand All @@ -66,6 +68,8 @@ class Surface : public DefinitionBase {
void build(Json::Value &value) const;
void parse(const boost::python::dict &value);

virtual boost::optional<std::string> getGeoidGrid() const = 0;

static constexpr Resource::Generator::Type type
= Resource::Generator::Type::surface;

Expand All @@ -85,6 +89,9 @@ struct SurfaceSpheroid : public Surface {
virtual void from_impl(const boost::any &value);
virtual void to_impl(boost::any &value) const;
virtual Changed changed_impl(const DefinitionBase &other) const;
virtual boost::optional<std::string> getGeoidGrid() const {
return geoidGrid;
}
};

struct SurfaceDem : public Surface {
Expand All @@ -101,6 +108,9 @@ struct SurfaceDem : public Surface {
virtual void from_impl(const boost::any &value);
virtual void to_impl(boost::any &value) const;
virtual Changed changed_impl(const DefinitionBase &other) const;
virtual boost::optional<std::string> getGeoidGrid() const {
return dem.geoidGrid;
}
};

} // namespace resource
Expand Down
1 change: 0 additions & 1 deletion mapproxy/src/mapproxy/definition/tms-raster-patchwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "jsoncpp/as.hpp"

#include "../support/python.hpp"
#include "../support/serialization.hpp"

#include "tms.hpp"
#include "factory.hpp"
Expand Down
1 change: 0 additions & 1 deletion mapproxy/src/mapproxy/definition/tms-raster-solid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "jsoncpp/as.hpp"

#include "../support/python.hpp"
#include "../support/serialization.hpp"

#include "tms.hpp"
#include "factory.hpp"
Expand Down
1 change: 0 additions & 1 deletion mapproxy/src/mapproxy/generator/geodata-vector-tiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "jsoncpp/as.hpp"

#include "../support/python.hpp"
#include "../support/serialization.hpp"

#include "vts-libs/vts/opencv/navtile.hpp"

Expand Down
1 change: 0 additions & 1 deletion mapproxy/src/mapproxy/generator/geodatavectorbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "vts-libs/storage/fstreams.hpp"

#include "../support/python.hpp"
#include "../support/serialization.hpp"

#include "geodatavectorbase.hpp"
#include "files.hpp"
Expand Down
112 changes: 47 additions & 65 deletions mapproxy/src/mapproxy/generator/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
#include "../support/srs.hpp"
#include "../support/grid.hpp"
#include "../support/python.hpp"
#include "../support/serialization.hpp"
#include "../support/mmapped/qtree-rasterize.hpp"
#include "../support/tilejson.hpp"
#include "../support/cesiumconf.hpp"
#include "../support/revision.hpp"
#include "../support/tms.hpp"
#include "../support/introspection.hpp"

#include "surface.hpp"

Expand Down Expand Up @@ -503,54 +503,32 @@ SurfaceBase::extraProperties(const Definition &def) const
{
vts::ExtraTileSetProperties extra;

Resource::Id::list introspectionTmsList(def.introspection.tms);
if (introspectionTmsList.empty()) {
// defaults to patchwork
introspectionTmsList.emplace_back(referenceFrameId()
, systemGroup()
, "tms-raster-patchwork");
}

for (const auto &tms : introspectionTmsList) {
const auto &findResource([this](Resource::Generator::Type type
, const Resource::Id &id)
-> const Resource*
{
if (auto other = otherGenerator
(Resource::Generator::Type::tms
, addReferenceFrame(tms, referenceFrameId())))
(type, addReferenceFrame(id, referenceFrameId())))
{
// we have found tms resource, use it as a boundlayer
const auto otherId(tms.fullId());
const auto &otherResource(other->resource());
const auto resdiff(resolveRoot(resource(), otherResource));

const fs::path blPath
(prependRoot(fs::path(), otherResource, resdiff)
/ "boundlayer.json");
return &other->resource();
}
return nullptr;
});

extra.boundLayers.add(vr::BoundLayer(otherId, blPath.string()));
const auto &r(resource());

extra.view.surfaces[id().fullId()]
.push_back(vr::View::BoundLayerParams(otherId));
};
if (def.introspection.tms.empty()) {
introspection::add
(extra, Resource::Generator::Type::tms, introspection::LocalLayer
({}, systemGroup(), "tms-raster-patchwork")
, r, findResource);
} else {
introspection::add(extra, Resource::Generator::Type::tms
, def.introspection.tms, r, findResource);
}

for (const auto &geodata : def.introspection.geodata) {
if (auto other = otherGenerator
(Resource::Generator::Type::geodata
, addReferenceFrame(geodata, referenceFrameId())))
{
// we have found geodata resource, use it as a boundlayer
const auto otherId(geodata.fullId());
const auto &otherResource(other->resource());
const auto resdiff(resolveRoot(resource(), otherResource));

const fs::path flPath
(prependRoot(fs::path(), otherResource, resdiff)
/ "freelayer.json");

extra.freeLayers.add(vr::FreeLayer(otherId, flPath.string()));

extra.view.freeLayers[otherId];
};
}
introspection::add(extra, Resource::Generator::Type::geodata
, def.introspection.geodata, r, findResource);

if (def.introspection.position) {
extra.position = *def.introspection.position;
Expand All @@ -559,7 +537,6 @@ SurfaceBase::extraProperties(const Definition &def) const
// browser options (must be Json::Value!)
extra.browserOptions = def.introspection.browserOptions;


return extra;
}

Expand Down Expand Up @@ -648,7 +625,7 @@ void SurfaceBase::generateTerrain(const vts::TileId &tmsTileId
qmf::save(qmfMesh(lm.mesh, nodeInfo
, (tms.physicalSrs ? *tms.physicalSrs
: referenceFrame().model.physicalSrs)
, boost::none)
, definition_.getGeoidGrid())
, utility::Gzipper(os), fi.fileInfo.filename);

auto sfi(fi.sinkFileInfo());
Expand Down Expand Up @@ -781,31 +758,36 @@ void SurfaceBase::layerJson(Sink &sink, const TerrainFileInfo &fi
void SurfaceBase::cesiumConf(Sink &sink, const TerrainFileInfo &fi
, const vre::Tms &tms) const
{
const auto &def(definition_);

const auto introId(def.introspection.tms.empty()
? Resource::Id(referenceFrameId(), systemGroup()
, "tms-raster-patchwork")
: def.introspection.tms.front());
const auto &findResource([this](Resource::Generator::Type type
, const Resource::Id &id)
-> const Resource*
{
if (auto other = otherGenerator
(type, addReferenceFrame(id, referenceFrameId())))
{
return &other->resource();
}
return nullptr;
});

CesiumConf conf;
conf.tms = tms;

if (auto other = otherGenerator
(Resource::Generator::Type::tms
, addReferenceFrame(introId, referenceFrameId())))
if (definition_.introspection.tms.empty()) {
if (const auto intro = introspection::remote
(Resource::Generator::Type::tms
, Resource::Id({}, systemGroup(), "tms-raster-patchwork")
, resource(), findResource))
{
conf.boundLayer = intro->url;
}
} else if (const auto intro = introspection::remote
(Resource::Generator::Type::tms
, definition_.introspection.tms.front()
, resource(), findResource))
{
// we have found matching tms resource, use it as an imagery provider
const auto otherId(introId.fullId());
const auto &otherResource(other->resource());
const auto resdiff(resolveRoot(resource(), otherResource));

// boundlayer path
const fs::path blPath
(prependRoot(fs::path(), otherResource, resdiff)
/ "boundlayer.json");
conf.boundLayer = blPath.string();
};
conf.boundLayer = intro->url;
}

const auto tb(terrainBounds(resource(), tms));
conf.defaultView = tb.bounds;
Expand Down
3 changes: 3 additions & 0 deletions mapproxy/src/mapproxy/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ struct Resource {
typedef std::vector<Id> list;
};

typedef boost::optional<Id> OptId;
typedef std::vector<OptId> OptIds;

struct Generator {
enum class Type { tms, surface, geodata };
Type type;
Expand Down
Loading

0 comments on commit 00e2cf8

Please sign in to comment.