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

Commit

Permalink
terrain and wmts interfaces display listing and provide README file
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavblazek committed Apr 11, 2019
1 parent 00e2cf8 commit 73fdfae
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 21 deletions.
2 changes: 1 addition & 1 deletion externals/buildsys/cmake
2 changes: 1 addition & 1 deletion mapproxy/debian/bionic/control
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ m4_define({{{VAR_BuildDepends}}},{{{debhelper (>= 11), libboost1.65-all-dev
, libprocps-dev (>= 3.3.12)
, libmagic-dev (>= 5.32)
, libicu-dev (>= 60.2-3ubuntu3)
, gawk}}})m4_dnl
, gawk, pandoc}}})m4_dnl
2 changes: 1 addition & 1 deletion mapproxy/debian/stretch/control
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ m4_define({{{VAR_BuildDepends}}},{{{debhelper (>= 9.20150101+deb8u2), libboost1.
, protobuf-compiler
, libprocps-dev (>= 3.3.9)
, libmagic-dev (>= 5.25)
, gawk}}})m4_dnl
, gawk, pandoc}}})m4_dnl
2 changes: 1 addition & 1 deletion mapproxy/debian/wheezy/control
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ m4_define({{{VAR_BuildDepends}}},{{{debhelper (>= 7.0.50~), libboost-all-dev (>=
, libblas-dev (>= 1.2.20110419-5), libcrypto++-dev (>= 5.6)
, libgdal-dev (>= 2.0), libproj-dev (>= 4.9)
, libmysql++-dev (>= 3.0.9-1+b1), libopenmesh-dev (>= 2.3.1-2)
, libgeographiclib-dev (>= 1.21-1)}}})m4_dnl
, libgeographiclib-dev (>= 1.21-1), pandoc}}})m4_dnl
6 changes: 6 additions & 0 deletions mapproxy/src/mapproxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ file_to_cpp(mapproxy_CESIUM_SOURCES
file_to_cpp(mapproxy_CESIUM_SOURCES
cesium::melowntech_png
cesium/melown-technologies-logo-28.png)
pandoc_to_cpp(mapproxy_CESIUM_SOURCES
cesium::README_md
cesium/README.md)

set(mapproxy_OL_SOURCES
ol.hpp ol.cpp
Expand All @@ -189,6 +192,9 @@ file_to_cpp(mapproxy_OL_SOURCES
file_to_cpp(mapproxy_OL_SOURCES
ol::ol_js
ol/ol.js)
pandoc_to_cpp(mapproxy_OL_SOURCES
ol::README_md
ol/README.md)

add_executable(mapproxy
${mapproxy_SOURCES}
Expand Down
10 changes: 9 additions & 1 deletion mapproxy/src/mapproxy/cesium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
#include "cesium/cesium.html.hpp"
#include "cesium/cesium.js.hpp"
#include "cesium/melown-technologies-logo-28.png.hpp"
#include "cesium/README.md.html.hpp"

namespace cesium {

const vtslibs::storage::SupportFile::Files supportFiles =
{
{ "index.html"
{ "browser.html"
, {
cesium_html
, sizeof(cesium_html)
Expand All @@ -55,6 +56,13 @@ const vtslibs::storage::SupportFile::Files supportFiles =
, melowntech_png_attr_lastModified
, "image/png"
}
}, { "README"
, {
README_md
, sizeof(README_md)
, README_md_attr_lastModified
, "text/html; charset=utf-8"
}
}
};

Expand Down
23 changes: 23 additions & 0 deletions mapproxy/src/mapproxy/cesium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# VTS Mapproxy resource Cesium Terrain Provider interface

## Generail info

Cesium Terrain Proviver interface allowd VTS surface resource to be used in any
Cesium application as a terrain provider.

For every terrain-enabled reference frame mapproxy provides a
[layer.json](layer.json) file containing layer description and
appropriateterrain files.

If the original dataset doesn't cover whole Earth the undefined height is
replaced with zero height.

There's an [interactive browser](browser.html) provided by mapproxy for testing
and evaluation.

You can the use the [URL of this directory[(.) to add this resource as a terrain
provider to your Cesium application.

var terrainProvider = new Cesium.CesiumTerrainProvider({
url: "path-to-this-resource"
});
31 changes: 25 additions & 6 deletions mapproxy/src/mapproxy/fileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace constants {
const std::string DebugConfig("debug.json");
const std::string Self("");
const std::string Index("index.html");
const std::string Browser("browser.html");
const std::string README("README");
const std::string Dems("dems.html");
const std::string Geo("geo");
const std::string Style("style.json");
Expand Down Expand Up @@ -570,7 +572,10 @@ TerrainFileInfo::TerrainFileInfo(const FileInfo &fi)
LOG(debug) << "Browser enabled, checking browser files.";

auto path(fi.filename);
if (constants::Self == path) { path = constants::Index; }
if ((constants::Self == path) || (constants::Index == path)) {
type = Type::listing;
return;
}

// support files
auto fsupport(cesium::supportFiles.find(path));
Expand Down Expand Up @@ -611,21 +616,31 @@ Sink::FileInfo TerrainFileInfo::sinkFileInfo(std::time_t lastModified) const
return Sink::FileInfo(constants::applicationJson, lastModified)
.setFileClass(FileClass::config);

case Type::listing:
case Type::unknown:
return {};
}

return {};
}

const Sink::Listing TerrainFileInfo::listing {
{ constants::Browser }
, { constants::LayerJson }
, { constants::README }
};

WmtsFileInfo::WmtsFileInfo(const FileInfo &fi)
: fileInfo(fi), type(Type::unknown), support()
{
if (fi.flags & FileFlags::browserEnabled) {
LOG(debug) << "Browser enabled, checking browser files.";

auto path(fi.filename);
if (constants::Self == path) { path = constants::Index; }
if ((constants::Self == path) || (constants::Index == path)) {
type = Type::listing;
return;
}

// support files
auto fsupport(ol::supportFiles.find(path));
Expand Down Expand Up @@ -657,14 +672,18 @@ Sink::FileInfo WmtsFileInfo::sinkFileInfo(std::time_t lastModified) const
return Sink::FileInfo(constants::textXml, lastModified)
.setFileClass(FileClass::config);

case Type::listing:
case Type::unknown:
return {};
}

return {};
}

const std::string& WmtsFileInfo::capabilitesName()
{
return constants::WmtsCapabilities;
}
const std::string WmtsFileInfo::capabilitesName = constants::WmtsCapabilities;

const Sink::Listing WmtsFileInfo::listing {
{ constants::Browser }
, { constants::WmtsCapabilities }
, { constants::README }
};
10 changes: 7 additions & 3 deletions mapproxy/src/mapproxy/fileinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct TerrainFileInfo {
FileInfo fileInfo;

enum class Type {
unknown, tile, definition, support, cesiumConf
unknown, tile, definition, support, cesiumConf, listing
};

/** File type.
Expand All @@ -241,6 +241,8 @@ struct TerrainFileInfo {
/** Valid only when type == Type::support
*/
const vs::SupportFile *support;

static const Sink::Listing listing;
};

/** Parsed TMS file information.
Expand All @@ -254,7 +256,7 @@ struct WmtsFileInfo {
*/
FileInfo fileInfo;

enum class Type { unknown, capabilities, support };
enum class Type { unknown, capabilities, support, listing };

/** File type.
*/
Expand All @@ -264,7 +266,9 @@ struct WmtsFileInfo {
*/
const vs::SupportFile *support;

static const std::string& capabilitesName();
static const std::string capabilitesName;

static const Sink::Listing listing;
};

#endif // mapproxy_fileinfo_hpp_included_
4 changes: 4 additions & 0 deletions mapproxy/src/mapproxy/generator/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ ::terrainInterface(const FileInfo &fileInfo, Sink &sink) const
cesiumConf(sink, fi, tms);
break;

case TerrainFileInfo::Type::listing:
sink.listing(fi.listing);
break;

default:
sink.error(utility::makeError<InternalError>
("Not implemented yet."));
Expand Down
12 changes: 6 additions & 6 deletions mapproxy/src/mapproxy/generator/tms-raster-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ wmts::WmtsResources TmsRasterBase::wmtsResources(const WmtsFileInfo &fileInfo)
layer.rootPath =
prependRoot(std::string(), resource(), resdiff);

resources.capabilitiesUrl = "./" + fileInfo.capabilitesName();
resources.capabilitiesUrl = "./" + fileInfo.capabilitesName;
} else {
layer.rootPath = *config().externalUrl
+ prependRoot(std::string(), resource()
, ResourceRoot::Depth::referenceFrame);
resources.capabilitiesUrl =
layer.rootPath + "/" + fileInfo.capabilitesName();
layer.rootPath + "/" + fileInfo.capabilitesName;
}

return resources;
Expand All @@ -140,8 +140,6 @@ wmts::WmtsResources TmsRasterBase::wmtsResources(const WmtsFileInfo &fileInfo)
Generator::Task TmsRasterBase
::wmtsInterface(const FileInfo &fileInfo, Sink &sink) const
{
const auto &wmts(getWmts());

WmtsFileInfo fi(fileInfo);

switch (fi.type) {
Expand All @@ -157,14 +155,16 @@ ::wmtsInterface(const FileInfo &fileInfo, Sink &sink) const
supportFile(*fi.support, sink, fi.sinkFileInfo());
break;

case WmtsFileInfo::Type::listing:
sink.listing(fi.listing);
break;

default:
sink.error(utility::makeError<InternalError>
("Not implemented yet."));
}

return {};

(void) wmts;
}

} // namespace generator
10 changes: 9 additions & 1 deletion mapproxy/src/mapproxy/ol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

#include "ol/ol.html.hpp"
#include "ol/ol.js.hpp"
#include "ol/README.md.html.hpp"

namespace ol {

const vtslibs::storage::SupportFile::Files supportFiles =
{
{ "index.html"
{ "browser.html"
, {
ol_html
, sizeof(ol_html)
Expand All @@ -47,6 +48,13 @@ const vtslibs::storage::SupportFile::Files supportFiles =
, ol_js_attr_lastModified
, "application/javascript; charset=utf-8"
}
}, { "README"
, {
README_md
, sizeof(README_md)
, README_md_attr_lastModified
, "text/html; charset=utf-8"
}
}
};

Expand Down
50 changes: 50 additions & 0 deletions mapproxy/src/mapproxy/ol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# VTS Mapproxy resource WMTS interface

## Generail info

WMTS interface allowd VTS raster resource to be used in WMTS enabled WWW clients
or GIS tool.

For every WMTS-enabled reference frame mapproxy provides a
[WMTSCapabilities.xml](WMTSCapabilities.xml) file containing single layer for
this particular resource.

There's an [interactive browser](browser.html) provided by mapproxy for testing
and evaluation.

You can the use the [URL of this directory[(.)in tools like
[GDAL](https://www.gdal.org/) or [QGIS](https://qgis.org/en/site/).

## Examples

### GDAL

* GDAL: warp whole dataset into a TIF file 1024 px wide with aspect ratio kept

# gdalwarp wmts:http://.../WMTSCapabilities.xml output.tif -ts 1024 0 -r cubic

(please notice the `wmts:` URL prefix)

### QGIS
In QGIS desktop application:

* Open the "Add Layer(s) from a WM(T)S Server" dialog:
* either via menu: `Layer` -> `Add Layer` -> `Add WMT/WMTS Layer...`
* or by keyboard shortcut: `Ctrl+Shift+W`
* Click the `New` button to add new server connection
* Choose name for new server in tha `Name` field
* Paste the use [WMTSCapabilities.xml URL](WMTSCapabilities.xml) in the `URL` field
* Click OK to save the connection
* New server connection should become selected in the drop-down list
* Click the `Connect` button
* Select the only layer available
* Click the `Add` butto

---

*Nota bene*: If you want to use WMTS interface outside of introspection browser
you have to have properly configured the `http.externalUrl` mapproxy
configuration options. For example:

[http]
externalUrl = http://myserver.mydomain.com/mapproxy/root

0 comments on commit 73fdfae

Please sign in to comment.