本文整理汇总了C++中IRasterCoverage::primaryKey方法的典型用法代码示例。如果您正苦于以下问题:C++ IRasterCoverage::primaryKey方法的具体用法?C++ IRasterCoverage::primaryKey怎么用?C++ IRasterCoverage::primaryKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRasterCoverage
的用法示例。
在下文中一共展示了IRasterCoverage::primaryKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}