本文整理汇总了C++中IRasterCoverage::prepare方法的典型用法代码示例。如果您正苦于以下问题:C++ IRasterCoverage::prepare方法的具体用法?C++ IRasterCoverage::prepare怎么用?C++ IRasterCoverage::prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRasterCoverage
的用法示例。
在下文中一共展示了IRasterCoverage::prepare方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kernel
Ilwis::OperationImplementation::State CreateSimpelRasterCoverage::prepare(ExecutionContext *ctx,const SymbolTable&){
IRasterCoverage inputRaster;
if ( _expression.parm(0).valuetype() == itRASTER){
if(!inputRaster.prepare(_expression.input<QString>(0))){
kernel()->issues()->log(TR("Invalid raster used to create new raster:") + _expression.input<QString>(0));
return sPREPAREFAILED;
}
_outputRaster = OperationHelperRaster::initialize(inputRaster,itRASTER,itRASTERSIZE|itDOMAIN|itCOORDSYSTEM|itGEOREF);
return sPREPARED;
}
QString grf = _expression.input<QString>(0);
if ( ! _grf.prepare(grf)){
kernel()->issues()->log(QString(TR("%1 is and invalid georeference")).arg(grf));
return sPREPAREFAILED;
}
_empty = _expression.input<bool>(1);
_domain.prepare("code=domain:value");
_stackDomain = IDomain("count");
if (!_empty){
_stackValueStrings = {"1"};
_stackValueNumbers = {1};
}
_outputRaster.prepare();
_outputRaster->georeference(_grf);
_outputRaster->setDataDefintions(_domain, _stackValueNumbers , _stackDomain);
return sPREPARED;
}
示例2: findParameterDataDef
DataDefinition IfOperation::findParameterDataDef(const OperationExpression &expr, int index) {
const Parameter& parm = expr.parm(index);
DataDefinition def;
QString parmvalue = parm.value().toLower();
quint64 gcid = mastercatalog()->name2id(parmvalue, itRASTER);
if ( gcid != i64UNDEF) {
IRasterCoverage cov;
if(cov.prepare(gcid)) {
def = cov->datadef();
_coverages[index - 1] = cov.get<Coverage>();
}
} else {
bool ok;
_number[index - 1] =parmvalue.toDouble(&ok);
if ( ok){
def.domain().prepare("value");
} else {
std::vector<QString> bools = {"true","false","yes","no","?"};
auto iter = std::find(bools.begin(), bools.end(), parmvalue.toLower());
if ( iter != bools.end()) {
int v = 0;
if ( parmvalue == "?" )
v= 2;
else if ( parmvalue == "yes" || parmvalue == "true")
v = 1;
_number[index - 1] = v;
IDomain dm;
dm.prepare("boolean");
def.domain(dm);
}
}
}
return def;
}
示例3: findParameterDataDef
DataDefinition IfOperation::findParameterDataDef(const OperationExpression &expr, int index) {
const Parameter& parm = expr.parm(index);
DataDefinition def;
QString parmvalue = parm.value();
IlwisTypes ptype = parm.valuetype();
if (hasType(ptype,itRASTER)) {
IRasterCoverage cov;
if (cov.prepare(parmvalue)) {
def = cov->datadef();
_coverages[index - 1] = cov.as<Coverage>();
}
} else {
bool ok;
_number[index - 1] = parmvalue.toDouble(&ok);
if ( ok){
IDomain dom("code=domain:value");
def.domain(dom);
} else {
std::vector<QString> bools = {"true","false","yes","no","?"};
auto iter = std::find(bools.begin(), bools.end(), parmvalue.toLower());
if ( iter != bools.end()) {
int v = 0;
if ( parmvalue == "?" )
v= 2;
else if ( parmvalue == "yes" || parmvalue == "true")
v = 1;
_number[index - 1] = v;
IDomain dm;
dm.prepare("boolean");
def.domain(dm);
}
}
}
return def;
}
示例4: 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;
}
示例5: SampleSet
Ilwis::OperationImplementation::State RasterClassification::prepare(ExecutionContext *, const SymbolTable &sym){
QString rasterSetName = _expression.parm(0).value();
IRasterCoverage rcSet;
if (!rcSet.prepare(rasterSetName)) {
ERROR2(ERR_COULD_NOT_LOAD_2,rasterSetName,"");
return sPREPAREFAILED;
}
QString domain = _expression.parm(1).value();
IThematicDomain themes;
if ( !themes.prepare(domain)){
ERROR2(ERR_COULD_NOT_LOAD_2,domain,"");
return sPREPAREFAILED;
}
QString trainingsRaster = _expression.parm(2).value();
IRasterCoverage rcTraining;
if (!rcTraining.prepare(trainingsRaster, itRASTER)) {
ERROR2(ERR_COULD_NOT_LOAD_2,trainingsRaster,"");
return sPREPAREFAILED;
}
_sampleSet = SampleSet(rcSet, themes, rcTraining);
_sampleSet.prepare();
QString outputName = _expression.parm(0,false).value();
OperationHelperRaster::initialize(_sampleSet.sampleRasterSet(), _outputRaster, itCOORDSYSTEM | itGEODETICDATUM | itGEOREF | itRASTERSIZE);
if ( !_outputRaster.isValid()) {
ERROR1(ERR_NO_INITIALIZED_1, "output rastercoverage");
return sPREPAREFAILED;
}
_outputRaster->datadefRef().domain(_sampleSet.thematicDomain());
_outputRaster->size(_sampleSet.sampleRasterSet()->size().twod());
if ( outputName!= sUNDEF)
_outputRaster->name(outputName);
return sPREPARED;
}
示例6: 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;
}
示例7: setStackDomain
bool PinDataSource::setStackDomain(const QString& id) {
IRasterCoverage raster;
raster.prepare(_objid);
bool ok;
_actives.clear();
quint64 oid = id.toULongLong(&ok);
if (!ok) {
kernel()->issues()->log(TR("No valid object id used: ") + id);
return false;
}
RasterStackDefinition& stack = raster->stackDefinitionRef();
IDomain dom;
if (dom.prepare(oid) && dom->ilwisType() == itITEMDOMAIN) {
_stackDomain = dom;
IItemDomain itemdom = dom.as< ItemDomain<DomainItem>>();
if (itemdom->count() == raster->size().zsize()) {
std::vector<QString> items;
for (auto item : itemdom) {
items.push_back(item->name());
}
stack.setSubDefinition(itemdom, items);
}
else {
kernel()->issues()->log(TR("Item domain must have same size as tjhe number of bands in the container"));
return false;
}
}
for (quint32 i = 0; i < stack.count(); ++i) {
QString name = QString::number(i + 1); // stack.index(i+1);
QVariantMap data;
data["name"] = name;
data["active"] = true;
if (_stackDomain->valueType() != itNUMERICITEM) {
data["minvalue"] = "?";
data["maxvalue"] = "?";
}
else {
IIntervalDomain idomain = _stackDomain.as<IntervalDomain>();
if (idomain->count() == stack.count()) {
auto item = idomain->item(i)->as<Interval>();
data["name"] = item->name();
auto range = item->range().as<NumericRange>();
data["minvalue"] = QString::number(range->min());
data["maxvalue"] = QString::number(range->max());
}
}
_actives.push_back(data);
}
return true;
}
示例8: 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()));
}