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

Commit

Permalink
WMTS: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavblazek committed Apr 4, 2019
1 parent e3b9b14 commit b1f5e75
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 42 deletions.
2 changes: 1 addition & 1 deletion externals/vts-libs
2 changes: 1 addition & 1 deletion mapproxy/src/mapproxy/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void Core::Detail::generateReferenceFrameDems(const FileInfo &fi, Sink &sink)
auto link(prependRoot(boost::filesystem::path()
, record.resourceId
, Resource::Generator::Type::surface
, ResourceRoot::Depth::type));
, ResourceRoot::Depth::interface));

os << "<a href=\"" << link.string() << "\">"
<< record.id.id << "</a>\n";
Expand Down
34 changes: 33 additions & 1 deletion mapproxy/src/mapproxy/generator/tms-raster-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
*/

#include "utility/raise.hpp"
#include "utility/httpquery.hpp"

#include "../support/wmts.hpp"

#include "tms-raster-base.hpp"

namespace uq = utility::query;

namespace generator {

TmsRasterBase
Expand Down Expand Up @@ -72,6 +75,33 @@ const vre::Wmts& TmsRasterBase::getWmts() const
return *wmts_;
}

namespace {

bool hasIntrospection(const std::string &query)
{
return !uq::empty(uq::find(uq::splitQuery(query), "is"));
}

} // namespace

WmtsLayer TmsRasterBase::wmtsLayer(bool introspection) const
{
WmtsLayer layer(resource());

// build root path
if (introspection) {
// this is URL used in introspection -> local
layer.rootPath = "./";
layer.format = format_;
} else {
LOG(warn4) << "TODO: Use external path; must be configured.";
layer.rootPath = "./";
layer.format = format_;
}

return layer;
}

Generator::Task TmsRasterBase
::wmtsInterface(const FileInfo &fileInfo, Sink &sink) const
{
Expand All @@ -85,7 +115,9 @@ ::wmtsInterface(const FileInfo &fileInfo, Sink &sink) const
break;

case WmtsFileInfo::Type::capabilities:
sink.content(wmtsCapabilities({resource()}), fi.sinkFileInfo());
sink.content
(wmtsCapabilities({wmtsLayer(hasIntrospection(fileInfo.query))})
, fi.sinkFileInfo());
return {};

case WmtsFileInfo::Type::support:
Expand Down
3 changes: 3 additions & 0 deletions mapproxy/src/mapproxy/generator/tms-raster-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "vts-libs/registry/extensions.hpp"

#include "../support/wmts.hpp"
#include "../generator.hpp"

namespace vre = vtslibs::registry::extensions;
Expand All @@ -52,6 +53,8 @@ class TmsRasterBase : public Generator {

Task wmtsInterface(const FileInfo &fileInfo, Sink &sink) const;

WmtsLayer wmtsLayer(bool introspection) const;

const vre::Wmts& getWmts() const;

RasterFormat format_;
Expand Down
5 changes: 4 additions & 1 deletion mapproxy/src/mapproxy/ol/ol.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ function startBrowser() {

var parser = new WMTSCapabilities();

fetch('./WMTSCapabilities.xml').then(function(response) {
fetch('./WMTSCapabilities.xml?is=1').then(function(response) {
return response.text();
}).then(function(text) {
var capabilities = parser.read(text);
console.dir(capabilities);

// TODO: use first layer from capabilities

Expand All @@ -27,6 +28,8 @@ function startBrowser() {
matrixSet: 'EPSG:3857'
});

console.dir(options);

map = new Map({
layers: [
new TileLayer({
Expand Down
18 changes: 9 additions & 9 deletions mapproxy/src/mapproxy/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ Changed Resource::changed(const Resource &o) const

boost::filesystem::path prependRoot(const boost::filesystem::path &path
, const Resource::Id &resource
, Resource::Generator::Type generatorType
, GeneratorInterface generatorIface
, const ResourceRoot &root)
{
boost::filesystem::path out;
Expand All @@ -545,8 +545,8 @@ boost::filesystem::path prependRoot(const boost::filesystem::path &path
out /= resource.referenceFrame;
// fall through

case ResourceRoot::type:
out /= boost::lexical_cast<std::string>(generatorType);
case ResourceRoot::interface:
out /= boost::lexical_cast<std::string>(generatorIface);
// fall through

case ResourceRoot::group:
Expand All @@ -568,17 +568,17 @@ boost::filesystem::path prependRoot(const boost::filesystem::path &path

std::string prependRoot(const std::string &path
, const Resource::Id &resource
, Resource::Generator::Type generatorType
, const GeneratorInterface &generatorIface
, const ResourceRoot &root)
{
fs::path tmp(path);
return prependRoot(tmp, resource, generatorType, root).string();
return prependRoot(tmp, resource, generatorIface, root).string();
}

ResourceRoot resolveRoot(const Resource::Id &thisResource
, Resource::Generator::Type thisGeneratorType
, const GeneratorInterface &thisGeneratorIface
, const Resource::Id &thatResource
, Resource::Generator::Type thatGeneratorType
, const GeneratorInterface &thatGeneratorIface
, ResourceRoot::Depth thisDepth)
{
// compute difference between two resources
Expand All @@ -588,8 +588,8 @@ ResourceRoot resolveRoot(const Resource::Id &thisResource
return { ResourceRoot::referenceFrame, 4 };
}

if (thisGeneratorType != thatGeneratorType) {
return { ResourceRoot::type, 3 };
if (thisGeneratorIface != thatGeneratorIface) {
return { ResourceRoot::interface, 3 };
}

if (thisResource.group != thatResource.group) {
Expand Down
42 changes: 35 additions & 7 deletions mapproxy/src/mapproxy/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,15 @@ struct GeneratorInterface {
Type type;
Interface interface;

GeneratorInterface(Type type = Type(), Interface interface = Interface())
GeneratorInterface(Type type = Type()
, Interface interface = Interface::vts)
: type(type), interface(interface)
{}

operator Type() const { return type; }

bool operator==(const GeneratorInterface &o) const;
bool operator!=(const GeneratorInterface &o) const;
};

vr::Credits asInlineCredits(const Resource &res);
Expand Down Expand Up @@ -274,7 +278,7 @@ struct ResourceRoot {
* the code.
*/
enum Depth : int {
referenceFrame = 0, type = 1, group = 2, id = 3, none = 4
referenceFrame = 0, interface = 1, group = 2, id = 3, none = 4
};

/** Root location.
Expand All @@ -300,9 +304,9 @@ struct ResourceRoot {
/** Computes path from this resource to that resource.
*/
ResourceRoot resolveRoot(const Resource::Id &thisResource
, Resource::Generator::Type thisGeneratorType
, const GeneratorInterface &thisGeneratorIface
, const Resource::Id &thatResource
, Resource::Generator::Type thatGeneratorType
, const GeneratorInterface &thatGeneratorIface
, ResourceRoot::Depth thisDepth = ResourceRoot::none);

/** Computes path from this resource to that resource.
Expand All @@ -315,7 +319,7 @@ ResourceRoot resolveRoot(const Resource &thisResource
*/
UTILITY_GENERATE_ENUM_IO(ResourceRoot::Depth,
((referenceFrame))
((type))
((interface))
((group))
((id))
((none))
Expand Down Expand Up @@ -364,11 +368,11 @@ std::string prependRoot(const std::string &path, const Resource &resource

boost::filesystem::path prependRoot(const boost::filesystem::path &path
, const Resource::Id &resource
, Resource::Generator::Type generatorType
, GeneratorInterface generatorInterface
, const ResourceRoot &root);

std::string prependRoot(const std::string &path, const Resource::Id &resource
, Resource::Generator::Type generatorType
, const GeneratorInterface &generatorIface
, const ResourceRoot &root);

std::string contentType(RasterFormat format);
Expand Down Expand Up @@ -447,6 +451,22 @@ inline std::string prependRoot(const std::string &path
return prependRoot(path, resource.id, resource.generator.type, root);
}

inline boost::filesystem::path prependRoot(const boost::filesystem::path &path
, const Resource &resource
, const GeneratorInterface &iface
, const ResourceRoot &root)
{
return prependRoot(path, resource.id, iface, root);
}

inline std::string prependRoot(const std::string &path
, const Resource &resource
, const GeneratorInterface &iface
, const ResourceRoot &root)
{
return prependRoot(path, resource.id, iface, root);
}

inline ResourceRoot resolveRoot(const Resource &thisResource
, const Resource &thatResource
, ResourceRoot::Depth thisDepth)
Expand All @@ -456,4 +476,12 @@ inline ResourceRoot resolveRoot(const Resource &thisResource
, thisDepth);
}

inline bool GeneratorInterface::operator==(const GeneratorInterface &o) const {
return (type == o.type) && (interface != o.interface);
}

inline bool GeneratorInterface::operator!=(const GeneratorInterface &o) const {
return !(*this == o);
}

#endif // mapproxy_resource_hpp_included_
Loading

0 comments on commit b1f5e75

Please sign in to comment.