1#include "WCSRasterSource.h"
3#include "Foundation/Logging/Logger.h"
11Cogs::Core::TerrainProvider::WCSRasterSource::WCSRasterSource(
Context* context)
12 : HTTPRasterSource(context)
16Cogs::Core::TerrainProvider::WCSRasterSource::~WCSRasterSource()
20bool Cogs::Core::TerrainProvider::WCSRasterSource::init(
const WCSConfig& conf, std::unique_ptr<ICache>&& icache)
23 if (layer == NoString) {
24 LOG_ERROR(logger,
"No layer specified");
29 if (format == NoString) {
30 LOG_ERROR(logger,
"No format specified");
33 switch (Strings::get(format).
hash()) {
43 LOG_ERROR(logger,
"Unrecognized format '%s'", Strings::getC(format));
47 interpolation = conf.interpolation;
48 interpolationFieldName = conf.interpolationFieldName;
49 return HTTPRasterSource::init(conf, std::move(icache));
52void Cogs::Core::TerrainProvider::WCSRasterSource::getConfig(WCSConfig& conf)
const
54 HTTPRasterSource::getConfig(conf);
57 conf.interpolation = interpolation;
58 conf.interpolationFieldName = interpolationFieldName;
62bool Cogs::Core::TerrainProvider::WCSRasterSource::createFetchTileUrl(std::string& url, TileId
id)
64 double divisor = std::exp2(
static_cast<double>(
id.level));
65 double xres = tiling.size.x / divisor;
66 double yres = tiling.size.y / divisor;
67 double west = extent.min.x + (xres *
id.i);
68 double east = extent.min.x + (xres * (
id.i + 1));
69 double south = extent.min.y + (yres *
id.j);
70 double north = extent.min.y + (yres * (
id.j + 1));
72 url.assign(Strings::getC(baseUrl));
74 url.append(
"&COVERAGE=");
75 url.append(Strings::getC(layer));
76 url.append(
"&FORMAT=");
77 url.append(Strings::getC(format));
79 switch (coordsys.kind) {
80 case CoordSys::Kind::EPSG:
84 assert(
false &&
"Garbage in conf.coordSys.kind");
87 url.append(std::to_string(coordsys.id));
88 url.append(
"&WIDTH=");
89 url.append(std::to_string(tiling.width));
90 url.append(
"&HEIGHT=");
91 url.append(std::to_string(tiling.height));
93 url.append(std::to_string(west)); url.append(
",");
94 url.append(std::to_string(south)); url.append(
",");
95 url.append(std::to_string(east)); url.append(
",");
96 url.append(std::to_string(north));
97 if (interpolation != NoString && interpolationFieldName != NoString) {
99 url.append(Strings::getC(interpolationFieldName));
101 url.append(Strings::getC(interpolation));
103 LOG_DEBUG(logger,
"%s", url.c_str());
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Log implementation class.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Contains all Cogs related functionality.
constexpr size_t hash() noexcept
Simple getter function that returns the initial value for fnv1a hashing.