本文整理汇总了C++中IRasterCoverage::georeference方法的典型用法代码示例。如果您正苦于以下问题:C++ IRasterCoverage::georeference方法的具体用法?C++ IRasterCoverage::georeference怎么用?C++ IRasterCoverage::georeference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRasterCoverage
的用法示例。
在下文中一共展示了IRasterCoverage::georeference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
void SelectionBase::ExpressionPart::setEnvelopePolygon(const IRasterCoverage& raster)
{
double deltax = _envelope.size().xsize() / 10.0;
double deltay = _envelope.size().ysize() / 10.0;
std::vector<geos::geom::Coordinate> *coords = new std::vector<geos::geom::Coordinate>();
double x,y = _envelope.min_corner().y;
for(x = _envelope.min_corner().x; x < _envelope.max_corner().x; x+= deltax){
Pixel px = raster->georeference()->coord2Pixel(Coordinate(x,y));
coords->push_back(geos::geom::Coordinate(px.x, px.y,0));
}
for(y = _envelope.min_corner().y; y < _envelope.max_corner().y; y+= deltay){
Pixel px = raster->georeference()->coord2Pixel(Coordinate(x,y));
coords->push_back(geos::geom::Coordinate(px.x, px.y,0));
}
for(x = _envelope.max_corner().x; x > _envelope.min_corner().x; x-= deltax){
Pixel px = raster->georeference()->coord2Pixel(Coordinate(x,y));
coords->push_back(geos::geom::Coordinate(px.x, px.y,0));
}
for(y = _envelope.max_corner().y; y > _envelope.min_corner().y; y-= deltay){
Pixel px = raster->georeference()->coord2Pixel(Coordinate(x,y));
coords->push_back(geos::geom::Coordinate(px.x, px.y,0));
}
Pixel px = raster->georeference()->coord2Pixel(Coordinate(_envelope.min_corner().x,_envelope.min_corner().y));
coords->push_back(geos::geom::Coordinate(px.x, px.y,0));
geos::geom::CoordinateArraySequence *points = new geos::geom::CoordinateArraySequence(coords);
geos::geom::LinearRing *ring = _geomfactory->createLinearRing(points);
_polygon.reset( _geomfactory->createPolygon(ring, 0));
}
示例3: 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);
}
}
}
}
示例4: 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;
}
示例5: initialize
IIlwisObject OperationHelperRaster::initialize(const IIlwisObject &inputObject, IlwisTypes tp, quint64 what)
{
Resource resource(tp);
if (inputObject->ilwisType() & itCOVERAGE) {
ICoverage cov = inputObject.as<Coverage>();
if (inputObject->ilwisType() == itRASTER) {
IRasterCoverage gcInput = inputObject.as<RasterCoverage>();
if ( what & itRASTERSIZE) {
Size<> sz = gcInput->size();
BoundingBox box(sz);
resource.addProperty("size", IVARIANT(box.size()));
}
if ( what & itGEOREF) {
resource.addProperty("georeference", IVARIANT(gcInput->georeference()));
}
if ( what & itDOMAIN) {
resource.addProperty("domain", IVARIANT(gcInput->datadef().domain()));
}
}
if ( what & itCOORDSYSTEM) {
resource.addProperty("coordinatesystem", IVARIANT(cov->coordinateSystem()));
}
}
resource.prepare();
IIlwisObject obj;
obj.prepare(resource);
if (inputObject->ilwisType() & itCOVERAGE) {
OperationHelper::initialize(inputObject, obj, tp, what);
}
return obj;
}
示例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: 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;
}
示例9: 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));
}
}
}
}
示例10: copyBinary
void RasterCoverage::copyBinary(const IRasterCoverage& raster, quint32 inputIndex, quint32 outputIndex) {
if ( isNumericalUndef(inputIndex) || isNumericalUndef(outputIndex)){
ERROR2(ERR_ILLEGAL_VALUE_2,TR("layer index"), isNumericalUndef(inputIndex) ? "input" : "output");
return;
}
if ( inputIndex >= size().zsize()){
//ERROR2(ERR_ILLEGAL_VALUE_2,TR("layer index"), "input");
}
IRasterCoverage gcNew;
gcNew.set(this);
Size<> inputSize = raster->size();
Size<> sz(inputSize.xsize(),inputSize.ysize(), outputIndex + 1);
gcNew->georeference()->size(sz);
PixelIterator iterIn(raster, BoundingBox(Pixel(0,0,inputIndex), Pixel(inputSize.xsize(), inputSize.ysize(), inputIndex + 1)));
PixelIterator iterOut(gcNew, BoundingBox(Pixel(0,0,outputIndex), Pixel(inputSize.xsize(), inputSize.ysize(), outputIndex + 1)));
if ( raster->id() == id() && inputIndex == outputIndex){
ERROR2(ERR_ILLEGALE_OPERATION2, TR("copy"),TR("identical layers in same raster"));
return;
}
std::for_each(iterOut, iterOut.end(), [&](double& v){
v = *iterIn;
++iterIn;
});
}
示例11: 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;
}
示例12: resource
Ilwis::OperationImplementation::State Selection::prepare(ExecutionContext *, const SymbolTable &)
{
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>();
quint64 copylist = itCOORDSYSTEM;
QString selector = _expression.parm(1).value();
selector = selector.remove('"');
int index = selector.indexOf("box=");
Envelope box;
if ( index != -1) {
QString crdlist = "box(" + selector.mid(index+4) + ")";
_box = BoundingBox(crdlist);
box = inputRaster->georeference()->pixel2Coord(_box);
copylist |= itDOMAIN | itTABLE;
std::vector<qint32> vec{_box.min_corner().x, _box.min_corner().y,_box.min_corner().z};
_base = vec;
}
index = selector.indexOf("polygon=");
if ( index != -1)
{
//TODO:
copylist |= itDOMAIN | itTABLE;
}
index = selector.indexOf("attribute=");
if ( index != -1 ) {
if (! inputRaster->attributeTable().isValid()) {
ERROR2(ERR_NO_FOUND2,"attribute-table", "coverage");
return sPREPAREFAILED;
}
_attribColumn = selector.mid(index+10);
copylist |= itRASTERSIZE | itGEOREF | itENVELOPE;
}
int indexindex = selector.indexOf("index=");
if ( indexindex != -1) {
copylist |= itDOMAIN | itGEOREF | itENVELOPE | itTABLE;
_box = BoundingBox(inputRaster->size());
QString zvalues = selector.mid(6);
bool ok;
_zvalue = zvalues.toInt(&ok);
if ( !ok || _zvalue < 0) {
ERROR3(ERR_ILLEGAL_PARM_3, TR("layer index"), zvalues,"Selection");
return sPREPAREFAILED;
}
_box.min_corner().z = _zvalue;
_box.max_corner().z = _zvalue;
std::vector<qint32> vec{_box.min_corner().x, _box.min_corner().y,_box.min_corner().z};
_base = vec;
}
_outputObj = OperationHelperRaster::initialize(_inputObj,inputType, copylist);
if ( !_outputObj.isValid()) {
ERROR1(ERR_NO_INITIALIZED_1, "output coverage");
return sPREPAREFAILED;
}
IRasterCoverage outputRaster = _outputObj.as<RasterCoverage>();
if ( (copylist & itDOMAIN) == 0) {
outputRaster->datadefRef() = _attribColumn != "" ? inputRaster->attributeTable()->columndefinition(_attribColumn).datadef()
: outputRaster->datadefRef() = inputRaster->datadef();
}
QString outputName = _expression.parm(0,false).value();
if ( outputName != sUNDEF)
_outputObj->name(outputName);
if ( (copylist & itGEOREF) == 0) {
Resource resource(QUrl("ilwis://internalcatalog/georeference"),itGEOREF);
resource.addProperty("size", IVARIANT(_box.size()));
resource.addProperty("envelope", IVARIANT(box));
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(box);
}
if(indexindex != -1) {
Size<> sz(outputRaster->size().xsize(),outputRaster->size().xsize(), 1);
outputRaster->size(sz);
}
return sPREPARED;
}
示例13: 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;
}
}
}
}
}
示例14: envUndetermned
LayerModel *LayerManager::create(QStandardItem *parentLayer, const ICoverage &cov, LayerManager *lm, const IOOptions &options)
{
if (cov->coordinateSystem()->isUnknown() && lm->rootLayer()->screenCsy().isValid()){
QString mes = QString("coordinate system 'unknown' not compatible with coordinate system of the layerview");
kernel()->issues()->log(mes, IssueObject::itWarning);
return 0;
}
if (parentLayer == 0)
parentLayer = lm->layerTree()->invisibleRootItem();
QString type = TypeHelper::type2name(cov->ilwisType());
if (options.contains("createtype")) {
type = options["createtype"].toString();
}
auto iter = _createLayers.find(type);
if ( iter != _createLayers.end()){
auto createFunc = (*iter).second;
QString layername = options.contains("layername") ? options["layername"].toString(): cov->name();
LayerModel *layer = createFunc(lm, parentLayer,layername, cov->description(),options);
if (!lm->rootLayer()->screenCsy().isValid()) {// first real layer sets the csy
lm->rootLayer()->screenCsy(cov->coordinateSystem());
lm->rootLayer()->coverageEnvelope(cov->envelope());
if (cov->ilwisType() == itRASTER) {
IRasterCoverage rc = cov.as<RasterCoverage>();
if (rc->georeference()->grfType<UndeterminedGeoReference>()) {
Envelope envUndetermned(Coordinate(0, 0), Coordinate(rc->size().xsize(), rc->size().ysize())); // none.grf bounds
lm->rootLayer()->coverageEnvelope(envUndetermned);
}
}
lm->setLayerListName(layername);
}
else {
// adjust rootlayer envelop to fit all layers
Coordinate crd1_trans;
Coordinate crd2_trans;
Envelope envelop = cov->envelope();
if (!cov->coordinateSystem()->isEqual(lm->rootLayer()->screenCsy().ptr())) {
Coordinate crn1 = envelop.min_corner();
Coordinate crn2 = envelop.max_corner();
crd1_trans = lm->rootLayer()->screenCsy()->coord2coord(cov->coordinateSystem(), crn1);
crd2_trans = lm->rootLayer()->screenCsy()->coord2coord(cov->coordinateSystem(), crn2);
}
else {
crd1_trans = envelop.min_corner();
crd2_trans = envelop.max_corner();
}
Envelope orgenv = lm->rootLayer()->coverageEnvelope();
if (!(orgenv.contains(crd1_trans) && orgenv.contains(crd2_trans))) {
orgenv += crd1_trans;
orgenv += crd2_trans;
lm->rootLayer()->coverageEnvelope(orgenv);
if (cov->ilwisType() == itRASTER) {
// TODO: check georef none ?
}
}
}
qint32 lowernodeid = options.contains("lowernodeid") ? options["lowernodeid"].toInt() : iUNDEF;
layer->nodeId(lm->nextId());
layer->fillData();
addLayer(parentLayer, layer, lm, lowernodeid);
lm->lastAddedCoverageLayer(layer);
return layer;
}
return 0;
}
示例15: box
Ilwis::OperationImplementation::State AggregateRaster::prepare(ExecutionContext *, const SymbolTable & )
{
QString raster = _expression.parm(0).value();
QString outputName = _expression.parm(0,false).value();
int copylist = itDOMAIN | itCOORDSYSTEM;
if (!_inputObj.prepare(raster, itRASTER)) {
ERROR2(ERR_COULD_NOT_LOAD_2,raster,"");
return sPREPAREFAILED;
}
_method = toMethod(_expression.parm(1).value());
if ( _method == NumericStatistics::pLAST) {
ERROR2(ERR_ILLEGAL_VALUE_2, "parameter value", " aggregation method");
return sPREPAREFAILED;
}
bool ok;
quint32 groupSz = _expression.parm(2).value().toInt(&ok);
if (!ok) {
QString blist = _expression.parm(2).value();
blist.remove("{");
blist.remove("}");
QStringList dims = blist.split(" ");
if ( dims.size() > 0) {
for(int i=0; i < dims.size(); ++i) {
quint32 val = dims[i].toInt(&ok);
if ( ok) {
_groupSize[i] = val;
}else
break;
}
}
}else {
_groupSize[0] = groupSz;
_groupSize[1] = groupSz;
}
if ( !ok || groupSize() < 2) {
ERROR2(ERR_ILLEGAL_VALUE_2, "aggregation group size", QString::number(groupSize()));
return sPREPAREFAILED;
}
_grouped = _expression.parm(3).value().toLower() == "true";
if ( !_grouped)
copylist |= itGEOREF;
_outputObj = OperationHelperRaster::initialize(_inputObj,itRASTER, copylist);
if ( !_outputObj.isValid()) {
ERROR1(ERR_NO_INITIALIZED_1, "output rastercoverage");
return sPREPAREFAILED;
}
QString outputBaseName = outputName;
int index = 0;
if ( (index = outputName.lastIndexOf(".")) != -1) {
outputBaseName = outputName.left(index);
}
IRasterCoverage inputRaster = _inputObj.as<RasterCoverage>();
IRasterCoverage outputRaster = _outputObj.as<RasterCoverage>();
if ( outputName != sUNDEF)
_outputObj->name(outputName);
outputRaster->coordinateSystem(inputRaster->coordinateSystem());
BoundingBox box(inputRaster->size());
if ( _grouped) {
int xs = box.xlength();
int ys = box.ylength();
int zs = box.zlength();
int newxs = xs / groupSize(0);
int newys = ys / groupSize(1);
int newzs = zs / groupSize(2);
box = BoundingBox(Size<>(newxs, newys, newzs));
}
if ( _expression.parameterCount() == 5 || _grouped) {
Envelope envlope = inputRaster->envelope();
Resource resource(QUrl("ilwis://internalcatalog/georeference"),itGEOREF);
resource.addProperty("size", IVARIANT(box.size()));
resource.addProperty("envelope", IVARIANT(envlope));
resource.addProperty("coordinatesystem", inputRaster->coordinateSystem()->id());
resource.addProperty("name", outputBaseName);
resource.addProperty("centerofpixel",inputRaster->georeference()->centerOfPixel());
IGeoReference grf;
if (grf.prepare(resource)) {
mastercatalog()->addItems({resource});
outputRaster->georeference(grf);
}
outputRaster->envelope(envlope);
outputRaster->size(box.size());
}
initialize(outputRaster->size().linearSize());
return sPREPARED;
}