1#include "TerrainProviderFunctions.h"
3#include "../Source/JsonSerialization.h"
6#include "Resources/ResourceStore.h"
7#include "Services/Services.h"
9#include "Foundation/Logging/Logger.h"
10#include "Foundation/Platform/IO.h"
17Cogs::Core::TerrainProvider::IRasterSource::~IRasterSource()
24 std::string fullPath = sourceLocation.protocol == ResourceProtocol::File ? sourceLocation.path : path;
25 auto configFile = context->resourceStore->getResourceContents(fullPath);
26 if (!configFile.buffer) {
27 LOG_ERROR(logger,
"Error reading %s", fullPath.c_str());
31 LOG_DEBUG(logger,
"Parsing %s", fullPath.c_str());
32 auto* rasterSource = deserialize(context, IO::parentPath(fullPath),
33 StringView((
const char*)configFile.buffer->data(),
34 configFile.buffer->size()));
35 if (rasterSource ==
nullptr) {
36 LOG_ERROR(logger,
"Error parsing %s", fullPath.c_str());
41 if (!serializeConfig(buf, rasterSource)) {
42 LOG_ERROR(logger,
"Failed to serialize rastersource");
48Cogs::Core::TerrainProvider::MimeType Cogs::Core::TerrainProvider::parseMimeType(
size_t textHash)
59 return MimeType::Jpeg;
63 return MimeType::Tiff;
66 return MimeType::Tiff;
69 return MimeType::Tiff;
76 return MimeType::None;
80Cogs::Core::TerrainProvider::MimeType Cogs::Core::TerrainProvider::parseMimeType(StringView text)
82 MimeType type = parseMimeType(text.hash());
83 if (type == MimeType::None) {
84 LOG_ERROR(logger,
"Unrecognized mime type '%.*s'", StringViewFormat(text));
96 return Strings::add(
"image/png");
99 return Strings::add(
"image/gif");
102 return Strings::add(
"image/jpeg");
105 return Strings::add(
"image/geotiff");
108 return Strings::add(
"image/raw-f32");
110 case MimeType::RGBA8:
111 return Strings::add(
"image/raw-rgba8");
114 return Strings::add(
"text/xml");
117 assert(
false &&
"Illegal mime-type");
Log implementation class.
@ NoCachedContent
Never use cached data.
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.