mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-25 13:38:35 -05:00
Move getIODescription from GdalRawTileDataReader to RawTileDataReader.
This commit is contained in:
@@ -122,38 +122,6 @@ std::array<double, 6> GdalRawTileDataReader::getGeoTransform() const {
|
||||
return _gdalDatasetMetaDataCached.padfTransform;
|
||||
}
|
||||
|
||||
IODescription GdalRawTileDataReader::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.dimensionsWithoutPadding().x, _initData.dimensionsWithoutPadding().y);
|
||||
|
||||
io.read.overview = 0;
|
||||
io.read.fullRegion = fullPixelRegion();
|
||||
// For correct sampling in dataset, we need to pad the texture tile
|
||||
|
||||
PixelRegion scaledPadding = padding;
|
||||
double scale =
|
||||
io.read.region.numPixels.x / static_cast<double>(io.write.region.numPixels.x);
|
||||
scaledPadding.numPixels *= scale;
|
||||
scaledPadding.start *= scale;
|
||||
|
||||
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();
|
||||
|
||||
ghoul_assert(io.write.region.numPixels.x == io.write.region.numPixels.y, "");
|
||||
ghoul_assert(io.write.region.numPixels.x == _initData.dimensionsWithPadding().x, "");
|
||||
|
||||
return io;
|
||||
}
|
||||
|
||||
void GdalRawTileDataReader::initialize() {
|
||||
if (_datasetFilePath.empty()) {
|
||||
throw ghoul::RuntimeError("File path must not be empty");
|
||||
|
||||
@@ -92,7 +92,6 @@ protected:
|
||||
* the pixel coordinates to cover the whole geodetic lat long space.
|
||||
*/
|
||||
virtual std::array<double, 6> getGeoTransform() const override;
|
||||
virtual IODescription getIODescription(const TileIndex& tileIndex) const override;
|
||||
|
||||
private:
|
||||
// Private virtual function overloading
|
||||
|
||||
@@ -244,6 +244,40 @@ void RawTileDataReader::readImageData(
|
||||
}
|
||||
}
|
||||
|
||||
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.dimensionsWithoutPadding().x, _initData.dimensionsWithoutPadding().y);
|
||||
|
||||
io.read.overview = 0;
|
||||
io.read.fullRegion = fullPixelRegion();
|
||||
// For correct sampling in dataset, we need to pad the texture tile
|
||||
|
||||
PixelRegion scaledPadding = padding;
|
||||
double scale =
|
||||
io.read.region.numPixels.x / static_cast<double>(io.write.region.numPixels.x);
|
||||
scaledPadding.numPixels *= scale;
|
||||
scaledPadding.start *= scale;
|
||||
|
||||
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();
|
||||
|
||||
ghoul_assert(io.write.region.numPixels.x == io.write.region.numPixels.y,
|
||||
"Write region must be square");
|
||||
ghoul_assert(io.write.region.numPixels.x == _initData.dimensionsWithPadding().x,
|
||||
"Write region must match tile it writes to.");
|
||||
|
||||
return io;
|
||||
}
|
||||
|
||||
TileDepthTransform RawTileDataReader::getDepthTransform() const {
|
||||
return _depthTransform;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ protected:
|
||||
virtual RawTile::ReadError rasterRead(
|
||||
int rasterBand, const IODescription& io, char* dst) const = 0;
|
||||
|
||||
virtual IODescription getIODescription(const TileIndex& tileIndex) const = 0;
|
||||
IODescription getIODescription(const TileIndex& tileIndex) const;
|
||||
|
||||
/**
|
||||
* Get the pixel corresponding to a specific position on the globe defined by the
|
||||
|
||||
@@ -85,6 +85,7 @@ float SimpleRawTileDataReader::depthScale() const {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
IODescription SimpleRawTileDataReader::getIODescription(const TileIndex& tileIndex) const {
|
||||
IODescription io;
|
||||
io.read.overview = 0;
|
||||
@@ -96,6 +97,7 @@ IODescription SimpleRawTileDataReader::getIODescription(const TileIndex& tileInd
|
||||
|
||||
return io;
|
||||
}
|
||||
*/
|
||||
|
||||
void SimpleRawTileDataReader::initialize() {
|
||||
_dataTexture = ghoul::io::TextureReader::ref().loadTexture(_datasetFilePath);
|
||||
@@ -146,7 +148,7 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead(
|
||||
ghoul_assert(io.read.region.numPixels.y == io.write.region.numPixels.y,
|
||||
"IODescription does not match data texture.");
|
||||
|
||||
char* pixelWriteRow = dataDestination;
|
||||
char* pixelWriteRow = dataDestination + io.write.bytesPerLine;
|
||||
|
||||
/*
|
||||
try {
|
||||
|
||||
@@ -62,10 +62,6 @@ public:
|
||||
virtual float depthOffset() const override;
|
||||
virtual float depthScale() const override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual IODescription getIODescription(const TileIndex& tileIndex) const override;
|
||||
|
||||
private:
|
||||
// Private virtual function overloading
|
||||
virtual void initialize() override;
|
||||
|
||||
Reference in New Issue
Block a user