This repository was archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Raster Time Series Integration #23
Open
SoerenHoffstedt
wants to merge
5
commits into
umr-dbs:master
Choose a base branch
from
SoerenHoffstedt:raster-time-series-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c5d1d7e
Basic integration of raster time series processing.
SoerenHoffstedt 2de7138
Raster Time Series: GDAL source backend.
SoerenHoffstedt 3cb6f08
Raster Time Series: Expression operator added.
SoerenHoffstedt 8cdf120
Raster Time Series: Projection operator added.
SoerenHoffstedt a84adc2
Header for std::optional added
SoerenHoffstedt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
|
||
#include <iostream> | ||
#include <cmath> | ||
#include <cache/manager.h> | ||
|
||
#include "descriptor.h" | ||
#include "operators/operator.h" | ||
|
||
using namespace rts; | ||
|
||
// DescriptorInfo: | ||
|
||
DescriptorInfo::DescriptorInfo(const TemporalReference &temporalInfo, | ||
const SpatialReference &rasterSpatialInfo, | ||
const SpatialReference &tileSpatialInfo, | ||
const Resolution &rasterResolution, | ||
const Resolution &tileResolution, | ||
ProcessingOrder order, | ||
uint32_t tileIndex, | ||
Resolution rasterTileCountDimensional, | ||
double nodata, | ||
GDALDataType dataType, | ||
GenericOperator *op) | ||
: temporalInfo(temporalInfo), | ||
rasterSpatialInfo(rasterSpatialInfo), | ||
tileSpatialInfo(tileSpatialInfo), | ||
rasterResolution(rasterResolution), | ||
tileResolution(tileResolution), | ||
order(order), | ||
tileIndex(tileIndex), | ||
rasterTileCountDimensional(rasterTileCountDimensional), | ||
rasterTileCount(rasterTileCountDimensional.resX * rasterTileCountDimensional.resY), | ||
nodata(nodata), | ||
dataType(dataType), | ||
op(op) | ||
{ | ||
|
||
} | ||
|
||
DescriptorInfo::DescriptorInfo(const OptionalDescriptor &desc, GenericOperator *newOperator) | ||
: temporalInfo(desc->temporalInfo), | ||
order(desc->order), | ||
rasterSpatialInfo(desc->rasterSpatialInfo), | ||
tileSpatialInfo(desc->tileSpatialInfo), | ||
rasterResolution(desc->rasterResolution), | ||
tileResolution(desc->tileResolution), | ||
tileIndex(desc->tileIndex), | ||
rasterTileCountDimensional(desc->rasterTileCountDimensional), | ||
rasterTileCount(desc->rasterTileCount), | ||
nodata(desc->nodata), | ||
_isOnlyNodata(desc->_isOnlyNodata), | ||
dataType(desc->dataType), | ||
op(newOperator) //assuming this copies an input descriptor, the operator pointer should not be copied. | ||
{ | ||
|
||
} | ||
|
||
bool DescriptorInfo::isOnlyNodata() const { | ||
return _isOnlyNodata; | ||
} | ||
|
||
// Descriptor: | ||
|
||
Descriptor::Descriptor(std::function<UniqueRaster(const Descriptor&)> &&getter, | ||
const TemporalReference &temporalInfo, | ||
const SpatialReference &rasterSpatialInfo, | ||
const SpatialReference &tileSpatialInfo, | ||
const Resolution &rasterResolution, | ||
const Resolution &tileResolution, | ||
ProcessingOrder order, | ||
uint32_t tileIndex, | ||
Resolution rasterTileCountDimensional, | ||
double nodata, | ||
GDALDataType dataType, | ||
GenericOperator *op) | ||
: getter(std::move(getter)), | ||
DescriptorInfo(temporalInfo, rasterSpatialInfo, tileSpatialInfo, rasterResolution, tileResolution, order, tileIndex, rasterTileCountDimensional, nodata, dataType, op) | ||
{ | ||
|
||
} | ||
|
||
std::unique_ptr<GenericRaster> Descriptor::getRaster() const { | ||
return getter(*this); | ||
} | ||
|
||
|
||
QueryRectangle Descriptor::getAsQueryRectangle() const { | ||
|
||
return QueryRectangle( | ||
tileSpatialInfo, | ||
temporalInfo, | ||
QueryResolution(QueryResolution::Type::PIXELS, tileResolution.resX, tileResolution.resY) | ||
); | ||
} | ||
|
||
std::unique_ptr<GenericRaster> Descriptor::getRasterCached() const { | ||
|
||
QueryRectangle rect = getAsQueryRectangle(); | ||
|
||
QueryProfiler parent_profiler; // = tools.profiler; TODO: this profiler clock is already started. | ||
QueryProfilerSimpleGuard parent_guard(parent_profiler); | ||
|
||
op->validateQRect(rect, GenericOperator::ResolutionRequirement::REQUIRED); | ||
|
||
auto &cache = CacheManager::get_instance().get_raster_cache(); | ||
std::unique_ptr<GenericRaster> result; | ||
|
||
try { | ||
result = cache.query( *op, rect, parent_profiler ); | ||
} | ||
catch ( NoSuchElementException &nse ) { | ||
QueryProfilerStoppingGuard stop_guard(parent_profiler); | ||
QueryProfiler exec_profiler; | ||
{ | ||
QueryProfilerRunningGuard guard(parent_profiler, exec_profiler); | ||
TIME_EXEC("Operator.getRaster"); | ||
result = getRaster(); | ||
} | ||
//TODO: not accessible here. could put the function into the operator class, curr. it is only in the operator.cpp | ||
//d_profile(op->depth, op->type, "raster", exec_profiler); | ||
if ( cache.put(op->getSemanticId(), result, rect, exec_profiler) ) { | ||
parent_profiler.cached(exec_profiler); | ||
} | ||
} | ||
op->validateResult(rect, result.get()); | ||
result = result->fitToQueryRectangle(rect); | ||
return result; | ||
|
||
} | ||
|
||
std::optional<Descriptor> Descriptor::createNodataDescriptor(const TemporalReference &temporalInfo, | ||
const SpatialReference &rasterSpatialInfo, | ||
const SpatialReference &tileSpatialInfo, | ||
const Resolution &rasterResolution, | ||
const Resolution &tileResolution, | ||
ProcessingOrder order, | ||
uint32_t tileIndex, | ||
Resolution rasterTileCountDimensional, | ||
double nodata, | ||
GDALDataType dataType, | ||
GenericOperator *op) | ||
{ | ||
auto getter = [](const Descriptor &self) -> UniqueRaster { | ||
//TODO: implement | ||
//UniqueRaster raster = Raster::createRaster(self.dataType, self.tileResolution); | ||
//set all values to nodata with the AllValuesSetter | ||
//RasterOperations::callUnary<RasterOperations::AllValuesSetter>(raster.get(), self.nodata); | ||
return nullptr; | ||
}; | ||
auto ret = std::make_optional<Descriptor>(std::move(getter), temporalInfo, rasterSpatialInfo, tileSpatialInfo, rasterResolution, tileResolution, order, tileIndex, rasterTileCountDimensional, nodata, dataType, op); | ||
ret->_isOnlyNodata = true; | ||
return ret; | ||
} | ||
|
||
Descriptor::Descriptor(std::function<UniqueRaster(const Descriptor &)> &&getter, const DescriptorInfo &args) | ||
: getter(std::move(getter)), DescriptorInfo(args) | ||
{ | ||
|
||
} | ||
|
||
|
||
// Definition of Resolution, Origin, Scale classes: | ||
|
||
Resolution::Resolution() : resX(0), resY(0) { | ||
|
||
} | ||
|
||
Resolution::Resolution(int resX, int resY) : resX(resX), resY(resY) { | ||
|
||
} | ||
|
||
Resolution Resolution::operator+(const Resolution &other) const { | ||
return Resolution(this->resX + other.resX, this->resY + other.resY); | ||
} | ||
|
||
Resolution Resolution::operator-(const Resolution &other) const { | ||
return Resolution(this->resX - other.resX, this->resY - other.resY); | ||
} | ||
|
||
|
||
Scale::Scale() : x(0), y(0) { | ||
|
||
} | ||
|
||
Scale::Scale(double x, double y) : x(x), y(y) { | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a raw pointer and what do you mean by descriptor?