本文整理汇总了C++中IRasterCoverage::stackDefinition方法的典型用法代码示例。如果您正苦于以下问题:C++ IRasterCoverage::stackDefinition方法的具体用法?C++ IRasterCoverage::stackDefinition怎么用?C++ IRasterCoverage::stackDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRasterCoverage
的用法示例。
在下文中一共展示了IRasterCoverage::stackDefinition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepare
OperationImplementation::State MapCalc::prepare(ExecutionContext *ctx,const SymbolTable &st) {
OperationImplementation::prepare(ctx,st);
QString expr = _expression.input<QString>(0);
RasterStackDefinition stackdef;
for(int parmIndex = 1 ; parmIndex < _expression.parameterCount(); ++parmIndex){
Parameter parm = _expression.parm(parmIndex);
if ( hasType(parm.valuetype(), itRASTER)){
QString url = parm.value();
IRasterCoverage raster;
if(!raster.prepare(url)){
return sPREPAREFAILED;
}
if ( stackdef.isValid()){
if(!stackdef.checkStackDefintion(raster->stackDefinition())){
kernel()->issues()->log(TR("Incompatible stack definition for ") +raster->name() ) ;
return sPREPAREFAILED;
}
}else if ( raster->stackDefinition().domain()->code().indexOf("count") == -1)
stackdef = raster->stackDefinition();
_inputRasters[parmIndex] = PixelIterator(raster);
}else if ( hasType(parm.valuetype(), itNUMBER)){
bool ok;
double v = parm.value().toDouble(&ok);
if (!ok){
return sPREPAREFAILED;
}
_inputNumbers[parmIndex] = v;
}
}
OperationHelperRaster helper;
helper.initialize((*_inputRasters.begin()).second.raster(), _outputRaster, itRASTERSIZE | itENVELOPE | itCOORDSYSTEM | itGEOREF);
if ( stackdef.isValid()){
_outputRaster->stackDefinitionRef() = stackdef;
}
IDomain outputDomain;
try {
outputDomain = linearize(shuntingYard(expr));
if( !outputDomain.isValid())
return sPREPAREFAILED;
} catch(ErrorObject& err){
return sPREPAREFAILED;
}
_outputRaster->datadefRef().domain(outputDomain);
for(quint32 i = 0; i < _outputRaster->size().zsize(); ++i){
QString index = _outputRaster->stackDefinition().index(i);
_outputRaster->setBandDefinition(index,DataDefinition(outputDomain));
}
initialize(_outputRaster->size().linearSize());
return sPREPARED;
}
示例2: result
std::vector<QString> SelectionBase::bands(const IRasterCoverage& raster) const
{
std::set<QString> bands;
for(const auto& epart : _expressionparts){
for(QString bandIndex : epart._bands)
bands.insert(bandIndex);
if ( epart._box.isValid()){
for(quint32 z=epart._box.min_corner().z; z <= epart._box.max_corner().z; ++z){
bands.insert(raster->stackDefinition().index(z));
}
}
}
if ( bands.size() == 0){ // no bands selection, so all bands do count
const RasterStackDefinition& stackdef = raster->stackDefinition();
for(quint32 z=0; z < stackdef.count(); ++z)
bands.insert(raster->stackDefinition().index(z));
}
std::vector<QString> result(bands.size());
std::copy(bands.begin(), bands.end(), result.begin());
return result;
}
示例3: initialize
BoundingBox OperationHelperRaster::initialize(const IRasterCoverage &inputRaster, IRasterCoverage &outputRaster, quint64 what)
{
Resource resource(itRASTER);
Size<> sz = inputRaster->size();
BoundingBox box(sz);
if ( what & itRASTERSIZE) {
resource.addProperty("size", IVARIANT(sz.toString()));
}
if ( what & itENVELOPE) {
if ( box.isNull() || !box.isValid()) {
sz = inputRaster->size();
box = BoundingBox(sz);
}
Envelope bounds = inputRaster->georeference()->pixel2Coord(box);
resource.addProperty("envelope", IVARIANT(bounds.toString()));
}
if ( what & itCOORDSYSTEM) {
resource.addProperty("coordinatesystem", IVARIANT(inputRaster->coordinateSystem()->id()));
}
if ( what & itGEOREF) {
if ( box.isNull() || !box.isValid()) {
sz = inputRaster->size();
box = BoundingBox(sz);
}
if ( sz.xsize() == box.xlength() && sz.ysize() == box.ylength())
resource.addProperty("georeference", IVARIANT(inputRaster->georeference()->id()));
}
if ( what & itDOMAIN) {
resource.addProperty("domain", IVARIANT(inputRaster->datadef().domain<>()->id()));
}
resource.prepare();
outputRaster.prepare(resource);
if ( what & itTABLE) {
if ( inputRaster->attributeTable().isValid()) {
if ( inputRaster->datadef().domain<>() == outputRaster->datadef().domain<>()) {
if ( outputRaster.isValid())
outputRaster->setAttributes(inputRaster->attributeTable());
}
}
}
if ( what & itDOMAIN){
for(quint32 i = 0; i < outputRaster->size().zsize(); ++i){
QString index = outputRaster->stackDefinition().index(i);
outputRaster->setBandDefinition(index,DataDefinition(outputRaster->datadef().domain()));
}
}
return box;
}
示例4: ErrorObject
PinDataSource::PinDataSource(quint64 objid, QObject *parent) : QObject(parent) {
IRasterCoverage raster;
raster.prepare(objid);
if (!raster.isValid())
return;
_objid = objid;
_stackDomain = raster->stackDefinition().domain();
CrosssectionTool *tool = static_cast<CrosssectionTool *>(parent);
IRasterCoverage rasterPanel = tool->coverage().as<RasterCoverage>();
if (!rasterPanel.isValid()) {
throw ErrorObject(TR("Crossection tool only works for raster coverages"));
}
if (!raster->georeference()->isCompatible(rasterPanel->georeference())) {
throw ErrorObject(TR("Rasters must have compatible georeferences"));
}
setStackDomain( QString::number(_stackDomain->id()));
}
示例5: resource
Ilwis::OperationImplementation::State SelectionRaster::prepare(ExecutionContext *ctx, const SymbolTable &st)
{
OperationImplementation::prepare(ctx,st);
if ( _expression.parameterCount() != 2) {
ERROR3(ERR_ILLEGAL_NUM_PARM3,"rasvalue","1",QString::number(_expression.parameterCount()));
return sPREPAREFAILED;
}
IlwisTypes inputType = itRASTER;
QString raster = _expression.parm(0).value();
if (!_inputObj.prepare(raster, inputType)) {
ERROR2(ERR_COULD_NOT_LOAD_2,raster,"");
return sPREPAREFAILED;
}
IRasterCoverage inputRaster = _inputObj.as<RasterCoverage>();
_inputAttributeTable = inputRaster->attributeTable();
quint64 copylist = itCOORDSYSTEM ;
QString selector = _expression.parm(1).value();
parseSelector(selector, inputRaster);
std::vector<QString> selectionBands = bands(inputRaster);
_box = boundingBox(_inputObj.as<RasterCoverage>());
bool useOldGrf ;
if ( _box.isNull() || !_box.isValid()){
_box = inputRaster->size();
useOldGrf = true;
} else
useOldGrf = false;
if ( useOldGrf){
copylist |= itGEOREF | itRASTERSIZE | itENVELOPE;
}
int selectedAttributes = attributeNames().size();
if (selectedAttributes != 1)
copylist |= itDOMAIN;
_outputObj = OperationHelperRaster::initialize(_inputObj,inputType, copylist);
if ( !_outputObj.isValid()) {
ERROR1(ERR_NO_INITIALIZED_1, "output coverage");
return sPREPAREFAILED;
}
IRasterCoverage outputRaster = _outputObj.as<RasterCoverage>();
QString outputName = _expression.parm(0,false).value();
if ( outputName != sUNDEF)
_outputObj->name(outputName);
if ( selectedAttributes > 1) {
QString url = INTERNAL_CATALOG + "/" + outputName;
Resource resource(url, itFLATTABLE);
_attTable.prepare(resource);
}
if ( selectedAttributes == 1 && _inputAttributeTable.isValid()){
QStringList names = attributeNames();
//outputRaster->datadefRef().domain(_inputAttributeTable->columndefinition(names[0]).datadef().domain());
outputRaster->setDataDefintions(_inputAttributeTable->columndefinition(names[0]).datadef().domain(), selectionBands, inputRaster->stackDefinition().domain());
}else
outputRaster->setDataDefintions(inputRaster->datadef().domain(), selectionBands, inputRaster->stackDefinition().domain());
if ( (copylist & itGEOREF) == 0) {
Resource resource(QUrl(INTERNAL_CATALOG + "/" + outputRaster->name() + "_grf_" + QString::number(outputRaster->id())),itGEOREF);
resource.addProperty("size", IVARIANT(_box.size()));
auto envelope = inputRaster->georeference()->pixel2Coord(_box);
resource.addProperty("envelope", IVARIANT(envelope));
resource.addProperty("coordinatesystem", IVARIANT(inputRaster->coordinateSystem()));
resource.addProperty("name", _outputObj->name());
resource.addProperty("centerofpixel",inputRaster->georeference()->centerOfPixel());
IGeoReference grf;
grf.prepare(resource);
outputRaster->georeference(grf);
outputRaster->envelope(envelope);
}
return sPREPARED;
}
示例6: QString
SelectionBase::ExpressionPart::ExpressionPart(const ICoverage& coverage, const QString& p){
QString part = p.trimmed();
_isValid = false;
int index;
if ( (index = part.indexOf("envelope("))!= -1) {
_envelope = QString(part).replace("envelope", "box");
_isValid = _envelope.isValid();
_type = ptENVELOPE;
if ( coverage->ilwisType() == itRASTER && _envelope.isValid()){
IRasterCoverage raster = coverage.as<RasterCoverage>();
_box = raster->georeference()->coord2Pixel(_envelope);
//setEnvelopePolygon(raster);
}
} else if ((index = part.indexOf("boundingbox("))==0){
_box = QString(part).replace("boundingbox", "box");
_isValid = _box.isValid();
_type = ptBOX;
}else if ( (index = part.indexOf("polygon(")) != -1){
_polygon.reset(GeometryHelper::fromWKT(part,0));
_isValid = _polygon.get() != 0;
_type = ptPOLYGON;
}else if ( part.indexOf("attributes(")!= -1) {
index = part.indexOf("(");
int len = part.lastIndexOf(")") - index - 1;
QString lst = part.mid(index + 1, len);
QStringList attribs = lst.split(",");
for(auto attrib : attribs){
if ( coverage->attributeTable()->columnIndex(attrib) != iUNDEF) {
_attributes.push_back(attrib);
_isValid = true;
}
}
_type = ptATTRIBUTE;
} else if (part.indexOf("rasterbands(")!=-1){
index = part.indexOf("(");
int len = part.lastIndexOf(")") - index - 1;
QString lst = part.mid(index + 1, len);
QStringList indexes = lst.split(",");
IRasterCoverage raster = coverage.as<RasterCoverage>();
for(auto ind : indexes){
if (raster->stackDefinition().index(ind) != iUNDEF){
_bands.push_back(ind);
_isValid = true;
}
}
_type = ptBANDS;
}else if ((index = part.indexOf("featuretype("))==0){
QString ft = part.mid(index + 1);
if ( ft == "point")
_geometryType = itPOINT;
if ( ft == "line")
_geometryType = itLINE;
if ( ft == "polygon"){
_geometryType = itPOLYGON;
}
_isValid = true;
}else {
std::map<QString,LogicalOperator> operators = {{"==", loEQ},{"<=",loLESSEQ},{">=", loGREATEREQ},{"<",loLESS},{">", loGREATER},{"!=",loNEQ}};
int index1 = part.indexOf("\"");
if ( index1 == -1)
index1 = 10000;
int index2 = 0;
for(auto op : operators){
if ((index2 = part.indexOf(op.first)) != -1){
if ( index2 < index1) {
_operator = op.second;
QString rights = part.mid(index2 + op.first.size()).trimmed();
_rightSide = rights.remove("\'");
QString leftSide = part.left(index2).trimmed();
if ( leftSide.toLower() == "pixelvalue"){
_leftSide = iUNDEF;
_isValid = true;
}else {
if ( (_leftSide = coverage->attributeTable()->columnIndex(leftSide)) == iUNDEF){
_isValid = false;
}else {
ColumnDefinition coldef = coverage->attributeTable()->columndefinition(_leftSide);
QVariant val = coldef.datadef().domain()->impliedValue(_rightSide);
_rightSide = val;
}
}
_type = ptATTRIBUTESELECTION;
break;
}
}
}
}
}