本文整理汇总了C++中IRasterCoverage::resource方法的典型用法代码示例。如果您正苦于以下问题:C++ IRasterCoverage::resource方法的具体用法?C++ IRasterCoverage::resource怎么用?C++ IRasterCoverage::resource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRasterCoverage
的用法示例。
在下文中一共展示了IRasterCoverage::resource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resample
bool OperationHelperRaster::resample(IRasterCoverage& raster1, IRasterCoverage& raster2, ExecutionContext *ctx) {
if ( !raster1.isValid())
return false;
IGeoReference commonGeoref = raster1->georeference();
if ( ctx->_masterGeoref != sUNDEF) {
if(!commonGeoref.prepare(ctx->_masterGeoref))
return false;
}
if (raster1->georeference()!= commonGeoref ){
Resource res;
res.prepare();
QString expr = QString("%3=resample(%1,%2,nearestneighbour)").arg(raster1->resource().url().toString()).arg(commonGeoref->resource().url().toString()).arg(res.name());
ExecutionContext ctxLocal;
SymbolTable symtabLocal;
if(!commandhandler()->execute(expr,&ctxLocal,symtabLocal))
return false;
QVariant var = symtabLocal.getValue(res.name());
raster1 = var.value<IRasterCoverage>();
}
if ( raster2.isValid() && raster2->georeference()!= commonGeoref ){
Resource res;
res.prepare();
QString expr = QString("%3=resample(%1,%2,nearestneighbour)").arg(raster2->resource().url().toString()).arg(commonGeoref->resource().url().toString()).arg(res.name());
ExecutionContext ctxLocal;
SymbolTable symtabLocal;
if(!commandhandler()->execute(expr,&ctxLocal,symtabLocal))
return false;
QVariant var = symtabLocal.getValue(res.name());
IRasterCoverage outRaster = var.value<IRasterCoverage>();
raster2.assign(outRaster);
}
return true;
}
示例2: process
void OperationWorker::process(){
try {
Operation op(_expression);
SymbolTable tbl;
ExecutionContext ctx;
if(op->execute(&ctx, tbl)){
if ( ctx._results.size() > 0){
for(auto resultName : ctx._results){
Symbol symbol = tbl.getSymbol(resultName);
if ( hasType(symbol._type, itNUMBER)){
_result += symbol._var.toDouble();
}else if ( hasType(symbol._type, itSTRING)){
_result += symbol._var.toString();
}else if ( hasType(symbol._type, (itCOVERAGE | itTABLE))){
if ( symbol._type == itRASTER){
IRasterCoverage raster = symbol._var.value<IRasterCoverage>();
if ( raster.isValid())
_result = raster->resource().url().toString();
}else if(symbol._type == itTABLE){
ITable table = symbol._var.value<ITable>();
if(table.isValid())
_result = table->resource().url().toString();
}
}
}
}
kernel()->issues()->log(QString(TR("Operation has executed succesfully")), IssueObject::itMessage);
}else {
qDebug() << "operation failed";
}
emit finished();
}catch(const ErrorObject& err){
}
emit finished();
}
示例3: execute
bool SelectionRaster::execute(ExecutionContext *ctx, SymbolTable& symTable)
{
if (_prepState == sNOTPREPARED)
if((_prepState = prepare(ctx, symTable)) != sPREPARED)
return false;
IRasterCoverage outputRaster = _outputObj.as<RasterCoverage>();
IRasterCoverage inputRaster = _inputObj.as<RasterCoverage>();
std::map<Raw, quint32> raw2record;
int keyColumn = _inputAttributeTable.isValid() ? _inputAttributeTable->columnIndex(inputRaster->primaryKey()) : iUNDEF;
if (keyColumn != iUNDEF){
std::vector<QVariant> values = _inputAttributeTable->column(keyColumn);
for(quint32 rec=0; rec < values.size(); ++rec){
Raw r = values[rec].toDouble();
if ( !isNumericalUndef(r)){
raw2record[r] = rec;
}
}
}
std::vector<int> extraAtrrib = organizeAttributes();
std::vector<QString> selectionBands = bands(inputRaster);
initialize(outputRaster->size().linearSize() * selectionBands.size());
PixelIterator iterOut(outputRaster);
int count = 0;
bool numeric = outputRaster->datadef().domain()->ilwisType() == itNUMERICDOMAIN;
for(QString band : selectionBands){
PixelIterator iterIn = inputRaster->band(band, _box);
PixelIterator iterEnd = iterIn.end();
while(iterIn != iterEnd) {
bool ok = true;
double pixValue = *iterIn;
double matchValue = pixValue;
for(const auto& epart : _expressionparts){
bool partOk = epart.match(iterIn.position(), matchValue,this);
if ( epart._andor != loNONE)
ok = epart._andor == loAND ? ok && partOk : ok || partOk;
else
ok &= partOk;
if (epart._type == ExpressionPart::ptATTRIBUTE && extraAtrrib.size() == 1){
if ( pixValue < 0 || pixValue >= _inputAttributeTable->recordCount()){
ok = false;
continue;
}
// pixValue == ID; ID < zero means undef, ID's start at zero.
if (pixValue >= 0) {
if (keyColumn != iUNDEF){
auto iter = raw2record.find(pixValue);
if ( iter != raw2record.end()){
quint32 rec = iter->second;
const Record& record = _inputAttributeTable->record(rec);
pixValue = record.cell(extraAtrrib[0]).toDouble();
}else
pixValue = rUNDEF;
}
}
else
pixValue = rUNDEF;
}
}
if ( ok){
*iterOut = pixValue;
}else
*iterOut = rUNDEF;
++iterIn;
++iterOut;
updateTranquilizer(++count, 100);
}
// if there is an attribute table we must copy the correct attributes and records
if ( keyColumn != iUNDEF && _attTable.isValid()){
for(int recIndex=0; recIndex < _inputAttributeTable->recordCount(); ++recIndex){
const Record& rec = _inputAttributeTable->record(recIndex);
for(int i=0; i < extraAtrrib.size(); ++i){
_attTable->setCell(i, recIndex, rec.cell(extraAtrrib[i]));
}
}
}
}
if ( numeric)
outputRaster->statistics(ContainerStatistics<double>::pBASIC);
outputRaster->setAttributes(_attTable);
QVariant value;
value.setValue<IRasterCoverage>(outputRaster);
logOperation(outputRaster, _expression);
ctx->setOutput(symTable, value, outputRaster->name(), itRASTER,outputRaster->resource());
return true;
}
示例4: execute
bool PercentileFilterStretch::execute(ExecutionContext *ctx, SymbolTable& symTable)
{
if (_prepState == sNOTPREPARED)
if((_prepState = prepare(ctx,symTable)) != sPREPARED)
return false;
IRasterCoverage outputRaster = _outputObj.as<RasterCoverage>();
IRasterCoverage inputRaster = _inputObj.as<RasterCoverage>();
IRasterCoverage zoneRaster = _inputZones.as<RasterCoverage>();
ITable low = _lowPercentile.as<Table>();
ITable high = _highPercentile.as<Table>();
PixelIterator iterIn(inputRaster, BoundingBox(), PixelIterator::fZXY);
PixelIterator iterZone(zoneRaster, BoundingBox(), PixelIterator::fXYZ); // only one layer so Z is irrelevant
PixelIterator iterOut(outputRaster, BoundingBox(), PixelIterator::fZXY);
PixelIterator inEnd = iterIn.end();
_nb = inputRaster->size().zsize();
int rows = inputRaster->size().xsize();
int cols = inputRaster->size().ysize();
std::vector<double> slice(_nb);
std::vector<int> percentage(_nb);
int totalRows = low->recordCount(); // same as high->recordCount()
int totalCols = low->columnCount(); // same as high->columnCount()
std::vector<double> lowtab(low->columnCount() * low->recordCount());
std::vector<double> hightab(high->columnCount() * high->recordCount());
for (int row = 0; row < totalRows; ++row)
for (int col = 0; col < totalCols; ++col) {
// Let the first column in the percentile table match the start of time series
int actCol = (col + totalCols - _startDekad) % totalCols;
lowtab[actCol + row * totalCols] = low->cell(col, row).toDouble();
hightab[actCol + row * totalCols] = high->cell(col, row).toDouble();
}
// timeseries are assumed to be 10 day periods.
int pixCount = 0;
while (iterIn != inEnd) {
trq()->update(pixCount++);
// get the time slice at the current location
std::copy(iterIn, iterIn + _nb, slice.begin());
// get the zone at the current location
double dzone = *iterZone; // row index into low and high percentile tables
if (dzone == rUNDEF) {
// for out of area locations set to zero percent
std::fill(percentage.begin(), percentage.end(), 0);
}
else {
int zone = (long) dzone;
std::vector<double>::const_iterator liter = lowtab.begin() + zone * totalCols;
std::vector<double>::const_iterator hiter = hightab.begin() + zone * totalCols;
std::vector<int>::iterator piter = percentage.begin();
for (std::vector<double>::const_iterator siter = slice.begin(); siter != slice.end(); siter++) {
*piter = std::max(0, std::min(100, int(100.0 * (*hiter - *siter) / (*hiter - *liter))));
if (*piter <= 5) *piter = 0;
else if (*piter <= 10) *piter = 10;
piter++;
liter++;
hiter++;
}
}
std::copy(percentage.begin(), percentage.end(), iterOut);
iterIn += _nb;
iterOut += _nb;
iterZone += 1;
}
trq()->update(rows * cols);
trq()->inform("\nWriting...\n");
trq()->stop();
bool resource = true;
if ( resource && ctx != 0) {
QVariant value;
value.setValue<IRasterCoverage>(outputRaster);
ctx->setOutput(symTable, value, outputRaster->name(), itRASTER, outputRaster->resource() );
}
return resource;
}