Esempio n. 1
0
Ilwis::OperationImplementation::State Polygon2Line::prepare(ExecutionContext *ctx, const SymbolTable &st)
{
    OperationImplementation::prepare(ctx,st);
    QString features = _expression.parm(0).value();
    QString outputName = _expression.parm(0,false).value();

    if (!_inputfeatures.prepare(features, itFEATURE)) {

        ERROR2(ERR_COULD_NOT_LOAD_2,features,"");
        return sPREPAREFAILED;
    }

    _outputfeatures = OperationHelperFeatures::initialize(_inputfeatures, itFEATURE, itCOORDSYSTEM | itENVELOPE);
    std::set<QString> booleans ={ "yes","true","1"};
    auto iter = booleans.find(_expression.parm(1).value().toLower());
    _singleId = iter != booleans.end();
    if ( _singleId){
        IIndexedIdDomain dom;
        dom.prepare();
        dom->addItem(new IndexedIdentifier("boundary",0,1));
       _outputfeatures->attributeDefinitionsRef().addColumn(ColumnDefinition("boundaries", dom));
    }else {
        auto cd = ColumnDefinition("boundaries", _inputfeatures->attributeDefinitions().domain());
       _outputfeatures->attributeDefinitionsRef().addColumn(cd);
    }

    return sPREPARED;
}
bool FeatureConnector::storeMetaData(FeatureCoverage *fcov, IlwisTypes type) {
    if ( type == 0)
        return false;
    DataDefinition datadef;

    ITable attTable = fcov->attributeTable();
    ColumnDefinition coldef = attTable->columndefinition(COVERAGEKEYCOLUMN);
    if ( coldef.isValid()) {
        datadef = coldef.datadef();
    } else {
        IIndexedIdDomain indexdom;
        indexdom.prepare();
        indexdom->setRange(IndexedIdentifierRange(type2Prefix(type),fcov->featureCount(type)));
        datadef.domain(indexdom);
    }

    bool ok = CoverageConnector::storeMetaData(fcov, type, datadef);
    if ( !ok)
        return false;

    QString dataFile = fcov->name();
    int index = dataFile.lastIndexOf(".");
    if ( index != -1) {
        dataFile = dataFile.left(index);
    }

    _odf->setKeyValue("Domain","Type","DomainUniqueID");
    _odf->setKeyValue("DomainSort","Sorting","AlphaNumeric");
    _odf->setKeyValue("DomainSort","Prefix","feature");
    _odf->setKeyValue("DomainSort","Class","Domain UniqueID");
    _odf->setKeyValue("DomainIdentifier","Nr",QString::number(fcov->featureCount(type)));


    if ( fcov->featureTypes() & itPOLYGON){
        ok = storeMetaPolygon(fcov, dataFile);
    }
    if ( fcov->featureTypes() & itLINE){
        ok = storeMetaLine(fcov, dataFile);
    }

    _odf->store();
    return ok;
}
Esempio n. 3
0
bool ItemDomainMergerIndexedItems::merge()
{
    IIndexedIdDomain iddom;

    QSharedPointer<IndexedIdentifierRange> range1 = _domain1->range<IndexedIdentifierRange>();
    QSharedPointer<IndexedIdentifierRange> range2 = _domain1->range<IndexedIdentifierRange>();

    std::unique_ptr<IndexedIdentifierRange> newRange(IndexedIdentifierRange::merge(range1, range2));
    if ( newRange->count() == 0)
        return false;

    for(quint32 i=0; i < range2->count(); ++i) {
        _renumber[i] =  range1->count() + i + 1;
    }

    iddom.prepare();
    iddom->setRange(*newRange.get());
    _mergedDomain = iddom;
    return true;
}