Cleanup for coding style

Add strict mode to check_style_guide script
This commit is contained in:
Alexander Bock
2017-11-08 10:35:39 -06:00
parent d94408224c
commit b50b52d351
387 changed files with 1907 additions and 2132 deletions
@@ -41,7 +41,7 @@ namespace openspace::globebrowsing {
namespace {
const char* _loggerCat = "AsyncTileDataProvider";
}
} // namespace
AsyncTileDataProvider::AsyncTileDataProvider(const std::string& name,
const std::shared_ptr<RawTileDataReader> rawTileDataReader)
@@ -93,14 +93,14 @@ std::vector<std::shared_ptr<RawTile>> AsyncTileDataProvider::getRawTiles() {
finishedJob = popFinishedRawTile();
}
return readyResults;
}
}
std::shared_ptr<RawTile> AsyncTileDataProvider::popFinishedRawTile() {
if (_concurrentJobManager.numFinishedJobs() > 0) {
// Now the tile load job looses ownerwhip of the data pointer
std::shared_ptr<RawTile> product =
_concurrentJobManager.popFinishedJob()->product();
TileIndex::TileHashKey key = product->tileIndex.hashKey();
// No longer enqueued. Remove from set of enqueued tiles
_enqueuedTileRequests.erase(key);
@@ -122,7 +122,7 @@ std::shared_ptr<RawTile> AsyncTileDataProvider::popFinishedRawTile() {
}
else
return nullptr;
}
}
bool AsyncTileDataProvider::satisfiesEnqueueCriteria(const TileIndex& tileIndex) {
// Only satisfies if it is not already enqueued. Also bumps the request to the top.
@@ -240,7 +240,7 @@ bool AsyncTileDataProvider::shouldBeDeleted() {
void AsyncTileDataProvider::performReset(ResetRawTileDataReader resetRawTileDataReader) {
ghoul_assert(_enqueuedTileRequests.size() == 0, "No enqueued requests left");
// Re-initialize PBO container
if (_globeBrowsingModule->tileCache()->shouldUsePbo()) {
size_t pboNumBytes = _rawTileDataReader->tileTextureInitData().totalNumBytes();
@@ -39,7 +39,7 @@
#include <unordered_map>
namespace openspace::globebrowsing {
//class GlobeBrowsingModule;
struct RawTile;
class RawTileDataReader;
@@ -114,7 +114,7 @@ private:
GlobeBrowsingModule* _globeBrowsingModule;
/// The reader used for asynchronous reading
std::shared_ptr<RawTileDataReader> _rawTileDataReader;
PrioritizingConcurrentJobManager<RawTile, TileIndex::TileHashKey>
_concurrentJobManager;
+2 -2
View File
@@ -27,7 +27,7 @@
#include <ghoul/misc/assert.h>
namespace openspace::globebrowsing {
PixelRegion::PixelRegion(const PixelCoordinate& pixelStart,
const PixelRange& numberOfPixels)
: start(pixelStart)
@@ -94,7 +94,7 @@ void PixelRegion::align(Side side, int pos) {
void PixelRegion::alignLeft(int x) {
start.x = x;
}
void PixelRegion::alignTop(int y) {
start.y = y;
}
+3 -3
View File
@@ -43,7 +43,7 @@ struct PixelRegion {
PixelRegion(const PixelRegion& o);
PixelRegion(const PixelCoordinate& pixelStart = PixelCoordinate(0, 0),
const PixelRange& numberOfPixels = PixelRange(0, 0));
/**
* Sets one of the sides of the pixel region the specified position. This changes
* the number of pixels in the region.
@@ -56,7 +56,7 @@ struct PixelRegion {
void setTop(int p);
void setRight(int x);
void setBottom(int y);
/**
* Aligns one the sides of the pixel regino to the specified position. This does
* not change the number of pixels within the region.
@@ -69,7 +69,7 @@ struct PixelRegion {
void alignTop(int y);
void alignRight(int x);
void alignBottom(int y);
void scale(const glm::dvec2& s);
void scale(double s);
void downscalePow2(int exponent, PixelCoordinate wrt = { 0, 0 });
+2 -2
View File
@@ -34,7 +34,7 @@
#include <sstream>
namespace openspace::globebrowsing {
struct TileMetaData;
class TileTextureInitData;
@@ -55,7 +55,7 @@ struct RawTile {
TileIndex tileIndex;
ReadError error;
GLuint pbo;
static RawTile createDefault(const TileTextureInitData& initData);
};
@@ -132,7 +132,7 @@ void GdalRawTileDataReader::initialize() {
_gdalDatasetMetaDataCached.rasterYSize = _dataset->GetRasterYSize();
_gdalDatasetMetaDataCached.noDataValue = _dataset->GetRasterBand(1)->GetNoDataValue();
_gdalDatasetMetaDataCached.dataType = tiledatatype::getGdalDataType(_initData.glType());
CPLErr err = _dataset->GetGeoTransform(&_gdalDatasetMetaDataCached.padfTransform[0]);
if (err == CE_Failure) {
_gdalDatasetMetaDataCached.padfTransform = RawTileDataReader::getGeoTransform();
@@ -175,7 +175,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
// handle requested write region. Note -= since flipped y axis
dataDest -= io.write.region.start.y * io.write.bytesPerLine;
dataDest += io.write.region.start.x * _initData.bytesPerPixel();
GDALRasterBand* gdalRasterBand = _dataset->GetRasterBand(rasterBand);
CPLErr readError = CE_Failure;
readError = gdalRasterBand->RasterIO(
@@ -191,7 +191,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
static_cast<int>(_initData.bytesPerPixel()), // Pixel spacing
static_cast<int>(-io.write.bytesPerLine) // Line spacing
);
// Convert error to RawTile::ReadError
RawTile::ReadError error;
switch (readError) {
@@ -99,7 +99,7 @@ private:
// GDAL Helper methods
GDALDataset* openGdalDataset(const std::string& filePath);
/**
* Use as a helper function when determining the maximum tile level. This function
* returns the negated number of overviews requred to downscale the highest overview
@@ -110,7 +110,7 @@ private:
// Member variables
std::string _initDirectory;
std::string _datasetFilePath;
GDALDataset* _dataset;
struct GdalDatasetMetaDataCached {
@@ -136,7 +136,7 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize
);
setGdalProxyConfiguration();
CPLSetErrorHandler(gdalErrorHandler);
_gdalMaximumCacheSize.onChange([&] {
// MB to Bytes
GDALSetCacheMax64(
@@ -77,9 +77,9 @@ public:
private:
GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize);
~GdalWrapper() = default;
void setGdalProxyConfiguration();
properties::BoolProperty _logGdalErrors;
properties::IntProperty _gdalMaximumCacheSize;
@@ -41,7 +41,7 @@ IODescription IODescription::cut(PixelRegion::Side side, int pos) {
PixelRegion::PixelRange cutSize = whatCameOff.read.region.numPixels;
PixelRegion::PixelRange localWriteCutSize = ratio * glm::dvec2(cutSize);
if (cutSize.x == 0 || cutSize.y == 0) {
ghoul_assert(
read.region.equals(readPreCut),
@@ -41,13 +41,13 @@ struct IODescription {
PixelRegion region;
PixelRegion fullRegion;
} read;
struct WriteData {
PixelRegion region;
size_t bytesPerLine;
size_t totalNumBytes;
} write;
IODescription cut(PixelRegion::Side side, int pos);
};
@@ -53,12 +53,12 @@
#include <math.h>
namespace openspace::globebrowsing {
RawTileDataReader::RawTileDataReader(const TileTextureInitData& initData,
PerformPreprocessing preprocess)
: _initData(initData)
, _preprocess(preprocess)
{ }
{}
std::shared_ptr<RawTile> RawTileDataReader::defaultTileData() const {
return std::make_shared<RawTile>(RawTile::createDefault(_initData));
@@ -72,7 +72,7 @@ std::shared_ptr<RawTile> RawTileDataReader::readTileData(TileIndex tileIndex,
// Build the RawTile from the data we querred
std::shared_ptr<RawTile> rawTile = std::make_shared<RawTile>();
if (dataDestination && !pboMappedDataDestination) {
// Write only to cpu data destination
memset(dataDestination, 255, _initData.totalNumBytes());
@@ -239,21 +239,21 @@ IODescription RawTileDataReader::adjustIODescription(const IODescription& io) co
IODescription RawTileDataReader::getIODescription(const TileIndex& tileIndex) const {
IODescription io;
io.read.region = highestResPixelRegion(tileIndex);
// write region starts in origin
io.write.region.start = PixelRegion::PixelCoordinate(0, 0);
io.write.region.numPixels = PixelRegion::PixelCoordinate(
_initData.dimensions().x, _initData.dimensions().y);
io.read.overview = 0;
io.read.fullRegion = fullPixelRegion();
// For correct sampling in dataset, we need to pad the texture tile
PixelRegion padding = PixelRegion(
_initData.tilePixelStartOffset(),
_initData.tilePixelSizeDifference()
);
PixelRegion scaledPadding = padding;
double scale =
io.read.region.numPixels.x / static_cast<double>(io.write.region.numPixels.x);
@@ -263,7 +263,7 @@ IODescription RawTileDataReader::getIODescription(const TileIndex& tileIndex) co
io.read.region.pad(scaledPadding);
//io.write.region.pad(padding);
//io.write.region.start = PixelRegion::PixelCoordinate(0, 0);
io.write.bytesPerLine = _initData.bytesPerLine();
io.write.totalNumBytes = _initData.totalNumBytes();
@@ -298,7 +298,7 @@ PixelRegion RawTileDataReader::fullPixelRegion() const {
std::array<double, 6> RawTileDataReader::getGeoTransform() const {
std::array<double, 6> padfTransform;
GeodeticPatch globalCoverage(Geodetic2(0,0), Geodetic2(M_PI / 2.0, M_PI));
padfTransform[1] = Angle<double>::fromRadians(
globalCoverage.size().lon).asDegrees() / rasterXSize();
@@ -316,7 +316,7 @@ std::array<double, 6> RawTileDataReader::getGeoTransform() const {
PixelRegion::PixelCoordinate RawTileDataReader::geodeticToPixel(
const Geodetic2& geo) const {
std::array<double, 6> padfTransform = getGeoTransform();
double Y = Angle<double>::fromRadians(geo.lat).asDegrees();
double X = Angle<double>::fromRadians(geo.lon).asDegrees();
@@ -372,7 +372,7 @@ RawTile::ReadError RawTileDataReader::repeatedRasterRead(
int depth) const
{
RawTile::ReadError worstError = RawTile::ReadError::None;
// NOTE:
// Ascii graphics illustrates the implementation details of this method, for one
// specific case. Even though the illustrated case is specific, readers can
@@ -461,7 +461,7 @@ RawTile::ReadError RawTileDataReader::repeatedRasterRead(
}
}
}
RawTile::ReadError err = rasterRead(rasterBand, io, dataDestination);
// The return error from a repeated rasterRead is ONLY based on the main region,
@@ -478,7 +478,7 @@ std::shared_ptr<TileMetaData> RawTileDataReader::getTileMetaData(
preprocessData->maxValues.resize(_initData.nRasters());
preprocessData->minValues.resize(_initData.nRasters());
preprocessData->hasMissingData.resize(_initData.nRasters());
std::vector<float> noDataValues;
noDataValues.resize(_initData.nRasters());
@@ -523,7 +523,7 @@ std::shared_ptr<TileMetaData> RawTileDataReader::getTileMetaData(
}
}
}
if (allIsMissing) {
rawTile->error = RawTile::ReadError::Failure;
}
@@ -557,11 +557,11 @@ RawTile::ReadError RawTileDataReader::postProcessErrorCheck(
float missingDataValue = noDataValueAsFloat();
bool hasMissingData = false;
for (size_t c = 0; c < _initData.nRasters(); c++) {
hasMissingData |= rawTile->tileMetaData->maxValues[c] == missingDataValue;
}
bool onHighLevel = rawTile->tileIndex.level > 6;
if (hasMissingData && onHighLevel) {
return RawTile::ReadError::Fatal;
@@ -61,13 +61,13 @@ public:
TileDepthTransform getDepthTransform() const;
const TileTextureInitData& tileTextureInitData() const;
const PixelRegion::PixelRange fullPixelSize() const;
/**
* \returns the maximum chunk level available in the dataset. Should be a value
* between 2 and 31.
*/
virtual int maxChunkLevel() const = 0;
/**
* Reset the dataset to its initial state. This is the place to clear any cache used.
*/
@@ -79,14 +79,13 @@ public:
virtual float depthOffset() const;
virtual float depthScale() const;
PixelRegion fullPixelRegion() const;
/**
* Returns a single channeled empty <code>RawTile</code> of size 16 * 16 pixels.
*/
std::shared_ptr<RawTile> defaultTileData() const;
protected:
/**
* This function should set the variables <code>_cached</code>,
* <code>_dataLayout</code> and <code>_depthTransform</code>.
@@ -98,7 +97,7 @@ protected:
* the pixel coordinates to cover the whole geodetic lat long space.
*/
virtual std::array<double, 6> getGeoTransform() const;
/**
* Read image data as described by the given <code>IODescription</code>.
* \param <code>io</code> describes how to read the data.
@@ -194,7 +194,7 @@ IODescription SimpleRawTileDataReader::adjustIODescription(const IODescription&
modifiedIO.read.fullRegion.numPixels.y -
modifiedIO.read.region.numPixels.y -
modifiedIO.read.region.start.y;
return modifiedIO;
}
+1 -1
View File
@@ -73,7 +73,7 @@ public:
*/
OK
};
Tile(ghoul::opengl::Texture* texture,
std::shared_ptr<TileMetaData> metaData,
Status status);
+10 -12
View File
@@ -111,18 +111,16 @@ int TileIndex::manhattan(const TileIndex& other) const {
return std::abs(x - other.x) + std::abs(y - other.y);
}
/**
Creates a hash which can be used as key in hash maps.
+-------+------------+-------+------------+
| USAGE | BIT RANGE | #BITS | MAX VALUE |
+-------+------------+-------+------------+
| level | 0 - 5 | 5 | 31 |
| x | 5 - 35 | 30 | 1073741824 |
| y | 35 - 64 | 29 | 536870912 |
+-------+------------+-------+------------+
*/
// Creates a hash which can be used as key in hash maps.
//
// +-------+------------+-------+------------+
// | USAGE | BIT RANGE | #BITS | MAX VALUE |
// +-------+------------+-------+------------+
// | level | 0 - 5 | 5 | 31 |
// | x | 5 - 35 | 30 | 1073741824 |
// | y | 35 - 64 | 29 | 536870912 |
// +-------+------------+-------+------------+
TileIndex::TileHashKey TileIndex::hashKey() const {
TileHashKey key = 0LL;
key |= level;
+3 -3
View File
@@ -45,9 +45,9 @@ enum CardinalDirection {
struct TileIndex {
using TileHashKey = uint64_t;
int x, y, level;
TileIndex(int x = 0, int y = 0, int level = 0);
TileIndex(const TileIndex& other);
@@ -68,7 +68,7 @@ struct TileIndex {
}
TileIndex parent() const;
TileIndex& operator--();
TileIndex operator--(int);
+1 -1
View File
@@ -42,7 +42,7 @@ struct TileLoadJob : public Job<RawTile> {
*/
TileLoadJob(std::shared_ptr<RawTileDataReader> rawTileDataReader,
const TileIndex& tileIndex);
/**
* No data is allocated unless specified so by the TileTextureInitData of
* rawTileDataReader but it is assumed that pboDataPtr is a mapped pointer to a pixel
@@ -69,7 +69,7 @@ namespace {
}
namespace openspace::globebrowsing::tileprovider {
DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
: TileProvider(dictionary)
, _filePath(FilePathInfo, "")
@@ -102,7 +102,7 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
_padTiles = true;
dictionary.getValue<bool>(KeyPadTiles, _padTiles);
TileTextureInitData initData(LayerManager::getTileTextureInitData(
_layerGroupID, _padTiles, tilePixelSize));
_tilePixelSize.setValue(initData.dimensions().x);
@@ -37,7 +37,7 @@ namespace openspace::globebrowsing {
class AsyncTileDataProvider;
struct RawTile;
} // namespace openspace::globebrowsing
namespace openspace::globebrowsing::tileprovider {
/**
@@ -50,7 +50,7 @@ public:
DefaultTileProvider(std::shared_ptr<AsyncTileDataProvider> tileReader);
virtual ~DefaultTileProvider() override;
/**
* \returns a Tile with status OK iff it exists in in-memory
* cache. If not, it may enqueue some IO operations on a
@@ -77,7 +77,7 @@ private:
void initAsyncTileDataReader(TileTextureInitData initData);
std::shared_ptr<AsyncTileDataProvider> _asyncTextureDataProvider;
cache::MemoryAwareTileCache* _tileCache;
properties::StringProperty _filePath;
@@ -1,118 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#if 0
#include <modules/globebrowsing/geometry/geodetic2.h>
#include <modules/globebrowsing/tile/tileprovider/presentationslideprovider.h>
#include <modules/globebrowsing/tile/tileindex.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <openspace/engine/openspaceengine.h>
namespace {
const std::string _loggerCat = "PresentationSlideProvider";
const std::string KeyDefaultProvider = "DefaultProvider";
const std::string KeySlideProviders = "SlideProviders";
const std::string KeyTileIndex = "TileIndex";
const std::string KeyTileProvider = "TileProvider";
}
namespace openspace {
namespace globebrowsing {
namespace tileprovider {
PresentationSlideProvider::PresentationSlideProvider(const ghoul::Dictionary& dictionary)
: _slideIndex("slideIndex", "slideIndex", 0, 0, 0)
{
setName("SlideProvider");
ghoul::Dictionary defaultProviderDict = dictionary.value<ghoul::Dictionary>(KeyDefaultProvider);
_defaultProvider = TileProvider::createFromDictionary(defaultProviderDict);
ghoul::Dictionary tileIndexDict = dictionary.value<ghoul::Dictionary>(KeyTileIndex);
_tileIndex = TileIndex(tileIndexDict);
ghoul::Dictionary slideProvidersDict = dictionary.value<ghoul::Dictionary>(KeySlideProviders);
_slideProviders.resize(slideProvidersDict.size());
for (size_t i = 0; i < slideProvidersDict.size(); i++) {
std::string dictKey = std::to_string(i + 1);
ghoul::Dictionary providerDict = slideProvidersDict.value<ghoul::Dictionary>(dictKey);
_slideProviders[i] = TileProvider::createFromDictionary(providerDict);
}
_slideIndex.setMaxValue(_slideProviders.size() - 1);
addProperty(_slideIndex);
}
Tile PresentationSlideProvider::getTile(const TileIndex& tileIndex) {
if(tileIndex == _tileIndex){
return slideProvider()->getTile(tileIndex);
}
return Tile::TileUnavailable;
}
Tile::Status PresentationSlideProvider::getTileStatus(const TileIndex& tileIndex) {
if(tileIndex == _tileIndex){
return slideProvider()->getTileStatus(tileIndex);
}
return Tile::Status::Unavailable;
}
TileDepthTransform PresentationSlideProvider::depthTransform() {
return slideProvider()->depthTransform();
}
void PresentationSlideProvider::update() {
slideProvider()->update();
_defaultProvider->update();
}
void PresentationSlideProvider::reset() {
for(auto& tp : _slideProviders){
tp->reset();
}
_defaultProvider->reset();
}
int PresentationSlideProvider::maxLevel() {
return _defaultProvider->maxLevel();
}
TileProvider* PresentationSlideProvider::slideProvider() {
int maxIndex = static_cast<int>(_slideProviders.size()) - 1;
int clampedIndex = std::max(0, std::min(_slideIndex.value(), maxIndex));
_slideIndex.setValue(clampedIndex);
return _slideProviders[clampedIndex].get();
}
} // namespace tileprovider
} // namespace globebrowsing
} // namespace openspace
#endif
@@ -32,20 +32,19 @@
#include <modules/newhorizons/util/projectioncomponent.h>
#include <modules/newhorizons/util/sequenceparser.h>
namespace openspace {
namespace globebrowsing {
namespace openspace::globebrowsing {
class AsyncTileDataProvider;
class RawTile;
namespace tileprovider {
} // namespace openspace::globebrowsing
namespace openspace::globebrowsing::tileprovider {
class ProjectionTileProvider : public TileProvider {
public:
ProjectionTileProvider(const ghoul::Dictionary& dictionary);
virtual ~ProjectionTileProvider() override;
virtual Tile getTile(const TileIndex& tileIndex) override;
virtual Tile::Status getTileStatus(const TileIndex& tileIndex) override;
@@ -85,7 +84,7 @@ private:
//properties::FloatProperty _debugProjectionTextureRotation;
std::unique_ptr<planetgeometry::PlanetGeometry> _geometry;
glm::vec2 _camScaling;
glm::vec3 _up;
glm::mat4 _transform;
@@ -106,15 +105,10 @@ private:
GLuint _quad;
GLuint _vertexPositionBuffer;
private:
Tile _defaultTile;
};
} // namespace tileprovider
} // namespace globebrowsing
} // namespace openspace
} // namespace openspace::globebrowsing::tileprovider
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PROJECTION_TILE_PROVIDER___H__
@@ -40,7 +40,7 @@ namespace {
} // namespace
namespace openspace::globebrowsing::tileprovider {
SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary)
: _tile(nullptr, nullptr, Tile::Status::Unavailable)
, _filePath(FilePathInfo)
@@ -92,7 +92,7 @@ void SingleImageProvider::reset() {
throw std::runtime_error(std::string("Unable to load texture '")
+ _filePath.value() + "'");
}
_tileTexture->uploadTexture();
_tileTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
@@ -61,7 +61,7 @@ void SizeReferenceTileProvider::renderText(const ghoul::fontrendering::FontRende
{
GeodeticPatch patch(tileIndex);
bool aboveEquator = patch.isNorthern();
double tileLongitudalLength = roundedLongitudalLength(tileIndex);
std::string unit = "m";
@@ -30,7 +30,7 @@
#include <modules/globebrowsing/geometry/ellipsoid.h>
namespace openspace::globebrowsing::tileprovider {
/**
* Constructed with an ellipsoid and uses that to render the longitudal length of each
* of each tile.
@@ -52,7 +52,7 @@ namespace {
} // namespace
namespace openspace::globebrowsing::tileprovider {
const char* TemporalTileProvider::URL_TIME_PLACEHOLDER("${OpenSpaceTimeId}");
const char* TemporalTileProvider::TemporalXMLTags::TIME_START = "OpenSpaceTimeStart";
@@ -74,10 +74,10 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary)
catch (const std::runtime_error&) {
// File path was not a path to a file but a GDAL config or empty
}
_filePath.setValue(filePath);
addProperty(_filePath);
if (readFilePath()) {
const bool hasStart = dictionary.hasKeyAndValue<std::string>(KeyPreCacheStartTime);
const bool hasEnd = dictionary.hasKeyAndValue<std::string>(KeyPreCacheEndTime);
@@ -188,7 +188,7 @@ std::string TemporalTileProvider::consumeTemporalMetaData(const std::string& xml
gdalNode = CPLSearchXMLNode(node, "FilePath");
gdalDescription = std::string(gdalNode->psChild->pszValue);
}
return gdalDescription;
}
@@ -321,7 +321,7 @@ std::shared_ptr<TileProvider> TemporalTileProvider::initTileProvider(TimeKey tim
auto tileProvider = std::make_shared<DefaultTileProvider>(_initDict);
return tileProvider;
}
std::string TemporalTileProvider::getGdalDatasetXML(Time t) {
TimeKey timekey = _timeFormat->stringify(t);
return getGdalDatasetXML(timekey);
@@ -354,7 +354,7 @@ std::string YYYYMMDD_hhmmss::stringify(const Time& t) const {
std::string YYYYMMDD_hhmm::stringify(const Time& t) const {
std::string ts = t.ISO8601().substr(0, 16);
// YYYY_MM_DDThh_mm -> YYYYMMDD_hhmm
ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end());
ts.erase(std::remove(ts.begin(), ts.end(), ':'), ts.end());
@@ -365,7 +365,7 @@ std::string YYYYMMDD_hhmm::stringify(const Time& t) const {
std::string YYYY_MM_DDThhColonmmColonssZ::stringify(const Time& t) const {
return t.ISO8601().substr(0, 19) + "Z";
}
std::string YYYY_MM_DDThh_mm_ssZ::stringify(const Time& t) const {
std::string timeString = t.ISO8601().substr(0, 19) + "Z";
replace( timeString.begin(), timeString.end(), ':', '_' );
@@ -421,7 +421,7 @@ TimeQuantizer::TimeQuantizer(const Time& start, const Time& end,
double TimeQuantizer::parseTimeResolutionStr(const std::string& resoltutionStr) {
const char unit = resoltutionStr.back();
std::string numberString = resoltutionStr.substr(0, resoltutionStr.length() - 1);
char* p;
double value = strtol(numberString.c_str(), &p, 10);
if (*p) { // not a number
@@ -45,7 +45,7 @@
struct CPLXMLNode;
namespace openspace::globebrowsing::tileprovider {
/**
* Interface for stringifying OpenSpace Time instances.
*
@@ -97,7 +97,7 @@ struct YYYY_MM_DDThhColonmmColonssZ : public TimeFormat {
virtual ~YYYY_MM_DDThhColonmmColonssZ() override = default;
virtual std::string stringify(const Time& t) const override;
};
/**
* Stringifies OpenSpace to the format "YYYY-MM-DDThh:mm:ssZ"
* Example: 2016-09-08T23:05:05Z
@@ -209,8 +209,7 @@ public:
virtual void reset() override;
virtual int maxLevel() override;
typedef std::string TimeKey;
using TimeKey = std::string;
std::shared_ptr<TileProvider> getTileProvider(
const Time& t = OsEng.timeManager().time());
@@ -261,7 +260,6 @@ private:
static const char* TIME_FORMAT;
};
/**
* Create a GDAL dataset description based on the time t
* \param t Time to generate a GDAL dataset description for
@@ -314,7 +312,7 @@ private:
* Ensures that the TemporalTileProvider is up to date.
*/
void ensureUpdated();
bool readFilePath();
// Used for creation of time specific instances of CachingTileProvider
@@ -326,7 +324,7 @@ private:
std::shared_ptr<TileProvider> _currentTileProvider;
TimeFormat* _timeFormat;
TimeQuantizer _timeQuantizer;
bool _successfulInitialization;
@@ -41,17 +41,17 @@
using namespace ghoul::fontrendering;
namespace openspace::globebrowsing::tileprovider {
TextTileProvider::TextTileProvider(const TileTextureInitData& initData, size_t fontSize)
: _initData(initData)
, _fontSize(fontSize)
{
_tileCache = OsEng.moduleEngine().module<GlobeBrowsingModule>()->tileCache();
_font = OsEng.fontManager().font("Mono", static_cast<float>(_fontSize));
_fontRenderer = std::unique_ptr<FontRenderer>(FontRenderer::createDefault());
_fontRenderer->setFramebufferSize(glm::vec2(_initData.dimensions()));
glGenFramebuffers(1, &_fbo);
}
@@ -115,7 +115,7 @@ Tile TextTileProvider::createChunkIndexTile(const TileIndex& tileIndex) {
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
ghoul_assert(_fontRenderer != nullptr, "_fontRenderer must not be null");
renderText(*_fontRenderer, tileIndex);
@@ -69,7 +69,7 @@ public:
* \returns hashkey used for in LRU cache for this tile
*/
virtual TileIndex::TileHashKey toHash(const TileIndex& tileIndex) const;
/**
* Uses the fontRenderer to render some text onto the tile texture provided in
* backgroundTile(const TileIndex& tileIndex).
@@ -89,9 +89,9 @@ private:
Tile
createChunkIndexTile(const TileIndex& tileIndex);
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
GLuint _fbo;
cache::MemoryAwareTileCache* _tileCache;
};
@@ -28,14 +28,14 @@
#include <modules/globebrowsing/tile/tileprovider/texttileprovider.h>
namespace openspace::globebrowsing::tileprovider {
/**
* Provides <code>Tile</code>s with the chunk index rendered as text onto its tiles.
*/
class TileIndexTileProvider : public TextTileProvider {
public:
TileIndexTileProvider(const ghoul::Dictionary& dict);
virtual void renderText(const ghoul::fontrendering::FontRenderer& fontRenderer,
const TileIndex& tileIndex) const override;
};
@@ -94,7 +94,7 @@ ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxPa
if(maxParents < 0){
return ChunkTile{ Tile::TileUnavailable, uvTransform, TileDepthTransform() };
}
// Step 3. Traverse 0 or more parents up the chunkTree until we find a chunk that
// has a loaded tile ready to use.
while (tileIndex.level > 1) {
@@ -110,7 +110,7 @@ ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxPa
return ChunkTile{ tile, uvTransform, TileDepthTransform() };
}
}
return ChunkTile{ Tile::TileUnavailable, uvTransform, TileDepthTransform() };
}
@@ -150,7 +150,7 @@ bool TileProvider::initialize() {
_numTileProviders--;
return false;
}
_initialized = true;
return true;
}
@@ -159,7 +159,7 @@ void TileProvider::initializeDefaultTile() {
ghoul_assert(_defaultTile.texture() == nullptr,
"Default tile should not have been created");
using namespace ghoul::opengl;
// Create pixel data
TileTextureInitData initData(8, 8, GL_UNSIGNED_BYTE, Texture::Format::RGBA,
false,
@@ -37,7 +37,7 @@
#include <vector>
namespace openspace::globebrowsing::tileprovider {
/**
* Interface for providing <code>Tile</code>s given a
* <code>TileIndex</code>.
@@ -136,7 +136,7 @@ public:
* that this TileProvider is able provide.
*/
virtual int maxLevel() = 0;
/**
* \returns the no data value for the dataset. Default is the minimum float avalue.
*/
@@ -151,13 +151,14 @@ public:
protected:
std::string _name;
private:
void initializeDefaultTile();
static unsigned int _numTileProviders;
unsigned int _uniqueIdentifier;
bool _initialized;
std::unique_ptr<ghoul::opengl::Texture> _defaultTileTexture;
Tile _defaultTile;
};
@@ -53,28 +53,28 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) {
if (typeID == layergroupid::TypeID::Unknown) {
throw ghoul::RuntimeError("Unknown layer type: " + typeString);
}
_defaultTileProvider = TileProvider::createFromDictionary(
typeID, defaultProviderDict
);
ghoul::Dictionary indexProvidersDict = dictionary.value<ghoul::Dictionary>(
KeyProviders
);
);
for (size_t i = 0; i < indexProvidersDict.size(); i++) {
std::string dictKey = std::to_string(i + 1);
ghoul::Dictionary indexProviderDict = indexProvidersDict.value<ghoul::Dictionary>(
dictKey
);
);
ghoul::Dictionary tileIndexDict = indexProviderDict.value<ghoul::Dictionary>(
KeyTileIndex
);
);
ghoul::Dictionary providerDict = indexProviderDict.value<ghoul::Dictionary>(
KeyTileProvider
);
);
TileIndex tileIndex(tileIndexDict);
std::string providerTypeString;
defaultProviderDict.getValue("Type", providerTypeString);
layergroupid::TypeID providerTypeID = layergroupid::TypeID::Unknown;
@@ -88,7 +88,7 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) {
if (providerTypeID == layergroupid::TypeID::Unknown) {
throw ghoul::RuntimeError("Unknown layer type: " + providerTypeString);
}
std::shared_ptr<TileProvider> stp = TileProvider::createFromDictionary(
providerTypeID,
providerDict
@@ -40,15 +40,15 @@ namespace openspace::globebrowsing::tileprovider {
TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
std::string name = "Name unspecified";
dictionary.getValue("Name", name);
layergroupid::GroupID layerGroupID;
dictionary.getValue(KeyLayerGroupID, layerGroupID);
ghoul::Dictionary providers;
if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyProviders)) {
providers = dictionary.value<ghoul::Dictionary>(KeyProviders);
}
for (size_t i = 0; i < providers.size(); i++) {
std::string dictKey = std::to_string(i + 1);
ghoul::Dictionary levelProviderDict = providers.value<ghoul::Dictionary>(
@@ -62,7 +62,7 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
);
}
maxLevel = std::round(floatMaxLevel);
ghoul::Dictionary providerDict;
if (!levelProviderDict.getValue<ghoul::Dictionary>(KeyTileProvider, providerDict)) {
throw std::runtime_error(
@@ -93,12 +93,12 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
providerDict.getValue("Name", providerName);
_levelTileProviders.back()->setName(providerName);
addPropertySubOwner(_levelTileProviders.back().get());
// Ensure we can represent the max level
if (static_cast<int>(_providerIndices.size()) < maxLevel) {
_providerIndices.resize(maxLevel+1, -1);
}
// map this level to the tile provider index
_providerIndices[maxLevel] = static_cast<int>(_levelTileProviders.size()) - 1;
}
+1 -1
View File
@@ -39,7 +39,7 @@ ChunkTile getHighestResolutionTile(const LayerGroup& layerGroup,
Tile::TileUnavailable, uvTransform, TileDepthTransform()
};
mostHighResolution.tile = Tile::TileUnavailable;
for (const std::shared_ptr<Layer>& layer : layerGroup.activeLayers()) {
ChunkTile chunkTile = layer->tileProvider()->getChunkTile(tileIndex);
+1 -1
View File
@@ -49,7 +49,7 @@ std::vector<std::pair<ChunkTile, const LayerRenderSettings*> >
const TileIndex& tileIndex);
void ascendToParent(TileIndex& tileIndex, TileUvTransform& uv);
} // namespace openspace::globebrowsing::tileselector
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_SELECTOR___H__