本文整理汇总了C++中IRasterCoverage::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ IRasterCoverage::isValid方法的具体用法?C++ IRasterCoverage::isValid怎么用?C++ IRasterCoverage::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRasterCoverage
的用法示例。
在下文中一共展示了IRasterCoverage::isValid方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,bicubic)").arg(raster1->source().url().toString()).arg(commonGeoref->source().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,bicubic)").arg(raster2->source().url().toString()).arg(commonGeoref->source().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->source().url().toString();
}
}
}
}
}else {
qDebug() << "operation failed";
}
emit finished();
}catch(const ErrorObject& err){
}
emit finished();
}
示例3: subdivideTasks
int OperationHelperRaster::subdivideTasks(ExecutionContext *ctx,const IRasterCoverage& raster, const BoundingBox &bnds, std::vector<BoundingBox > &boxes)
{
if ( !raster.isValid() || raster->size().isNull() || raster->size().ysize() == 0) {
return ERROR1(ERR_NO_INITIALIZED_1, "Grid size");
return iUNDEF;
}
int cores = std::min(QThread::idealThreadCount(),(int)raster->size().ysize());
if (raster->size().linearSize() < 10000 || ctx->_threaded == false)
cores = 1;
boxes.clear();
boxes.resize(cores);
BoundingBox bounds = bnds;
if ( bounds.isNull())
bounds = BoundingBox(raster->size());
int left = 0; //bounds.min_corner().x;
int right = bounds.size().xsize();
int top = bounds.size().ysize();
int step = bounds.size().ysize() / cores;
int currentY = 0;
for(int i=0 ; i < cores; ++i){
BoundingBox smallBox(Pixel(left, currentY,0), Pixel(right - 1, std::min(top - 1,currentY + step),bounds.zlength()) );
boxes[i] = smallBox;
currentY = currentY + step ;
}
return cores;
}
示例4: changeCoords
void CrosssectionTool::changeCoords(int index, int c, int r, bool useScreenPixels)
{
if (index >= 0 && index < _pins.size()) {
if (_panelCoverage->ilwisType() == itRASTER) {
IRasterCoverage raster = _panelCoverage.as<RasterCoverage>();
if (raster.isValid()) {
Coordinate crd;
if (useScreenPixels) {
crd = vpmodel()->layer()->layerManager()->rootLayer()->screenGrf()->pixel2Coord(Pixel(c, r));
Pixel pix = raster->georeference()->coord2Pixel(crd);
c = pix.x;
r = pix.y;
}
crd = raster->georeference()->pixel2Coord(Pixel(c, r));
_pins[index]->x(crd.x);
_pins[index]->y(crd.y);
_pins[index]->column(c);
_pins[index]->row(r);
_pins[index]->update();
vpmodel()->layer()->layerManager()->updatePostDrawers();
changePinData(index, crd);
}
}
}
}
示例5:
geos::geom::Point *SelectionBase::pixel2point(const Pixel& pix){
IRasterCoverage raster = _inputObj.as<RasterCoverage>();
if ( raster.isValid()) {
Coordinate crd = raster->georeference()->pixel2Coord(pix);
return _geomfactory->createPoint(crd);
}
return 0;
}
示例6: 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()));
}
示例7: maxC
int CrosssectionTool::maxC() const {
if (_panelCoverage.isValid() && _panelCoverage->ilwisType() == itRASTER) {
IRasterCoverage raster = _panelCoverage.as<RasterCoverage>();
if (raster.isValid()) {
return raster->georeference()->size().xsize();
}
}
return 0;
}
示例8: 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;
}
示例9: screenPixel
QVariantMap MouseGotoPixelEditor::screenPixel(int column, int row) const {
QVariantMap mp;
IRasterCoverage raster = static_cast<CoverageLayerModel *>(vpmodel()->layer())->coverage().as<RasterCoverage>();
if (raster.isValid()) {
auto crd = raster->georeference()->pixel2Coord(Pixel(column, row));
auto pix = vpmodel()->layer()->layerManager()->rootLayer()->screenGrf()->coord2Pixel(crd);
mp["x"] = pix.x;
mp["y"] = pix.y;
}
return mp;
}
示例10: resample
IRasterCoverage OperationHelperRaster::resample(const IRasterCoverage& sourceRaster, const IGeoReference& targetGrf) {
if (!sourceRaster.isValid() || !targetGrf.isValid())
return IRasterCoverage();
Resource res;
res.prepare();
QString expr = QString("%3=resample(%1,%2,nearestneighbour)").arg(sourceRaster->resource().url().toString()).arg(targetGrf->resource().url().toString()).arg(res.name());
ExecutionContext ctxLocal;
SymbolTable symtabLocal;
if (!commandhandler()->execute(expr, &ctxLocal, symtabLocal))
return false;
QVariant var = symtabLocal.getValue(res.name());
return var.value<IRasterCoverage>();
}
示例11: changePixel
void CrosssectionTool::changePixel(int index, double x, double y)
{
if (index >= 0 && index < _pins.size()) {
if (_panelCoverage->ilwisType() == itRASTER) {
IRasterCoverage raster = _panelCoverage.as<RasterCoverage>();
if (raster.isValid()) {
Pixel pix = raster->georeference()->coord2Pixel(Coordinate(x, y));
_pins[index]->x(x) ;
_pins[index]->y(y);
_pins[index]->column(pix.x);
_pins[index]->row(pix.y);
_pins[index]->update();
vpmodel()->layer()->layerManager()->updatePostDrawers();
changePinData(index, Coordinate(x,y));
}
}
}
}
示例12: setActiveVisualAttribute
void RasterLayerDrawer::setActiveVisualAttribute(const QString &attr)
{
IRasterCoverage raster = coverage().as<RasterCoverage>();
if ( attr == PIXELVALUE){
LayerDrawer::setActiveVisualAttribute(attr);
}
else if ( raster.isValid() ) {
if(raster->hasAttributes()) {
if ( raster->attributeTable()->columnIndex(attr) != iUNDEF){
IRepresentation newrpr = Representation::defaultRepresentation(raster->attributeTable()->columndefinition(attr).datadef().domain());
if ( newrpr.isValid()){
LayerDrawer::setActiveVisualAttribute(attr);
}
}
}
}
}
示例13: coverage
void RasterLayerDrawer::coverage(const ICoverage &cov)
{
LayerDrawer::coverage(cov);
setActiveVisualAttribute(PIXELVALUE);
IRasterCoverage raster = cov.as<RasterCoverage>();
if (!raster.isValid())
return;
// fot the moment test only single band value maps with no attribute table; will extend when this works
IlwisTypes attrType = raster->datadef().domain()->valueType();
VisualAttribute attr(raster->datadef().domain());
if ( hasType(attrType, itNUMBER)){
auto numrange = raster->datadef().range<NumericRange>();
attr.actualRange(NumericRange(numrange->min(), numrange->max(), numrange->resolution()));
visualProperty(PIXELVALUE, attr);
} else if ( hasType(attrType, itCONTINUOUSCOLOR)){
visualProperty(PIXELVALUE, attr);
}else if ( hasType(attrType, itPALETTECOLOR)){
auto colorrange = raster->datadef().range<ColorPalette>();
}
}