QVariant AttributeDefinition::checkInput(const QVariant& inputVar, quint32 columnIndex) const{ QVariant actualval= inputVar; const ColumnDefinition& coldef = columndefinitionRef(columnIndex); QString typenm = inputVar.typeName(); if ( !coldef.datadef().domain<>().isValid()){ ERROR2(ERR_NO_INITIALIZED_2,"Domain",coldef.name()); return QVariant(); } IlwisTypes domtype = coldef.datadef().domain<>()->ilwisType(); IlwisTypes valueType = coldef.datadef().domain<>()->valueType(); IDomain dm = coldef.datadef().domain<>(); if ( domtype == itITEMDOMAIN){ if ( inputVar == sUNDEF){ return QVariant((int)iUNDEF); } else if ( typenm == "QString"){ actualval = dm->impliedValue(inputVar); SPItemRange rng2 = coldef.datadef().range<ItemRange>(); if ( !hasType(valueType,itINDEXEDITEM)){ SPItemRange rng1 = dm->range<ItemRange>(); SPDomainItem item = rng1->item(inputVar.toString()); if ( item.isNull()){ return QVariant((int)iUNDEF); } if ( !rng2->contains(item->name())){ rng2->add(item->clone()); } actualval = item->raw(); } } }else if ( domtype == itNUMERICDOMAIN){ if (typenm == "QString") actualval = dm->impliedValue(inputVar); if ( hasType(valueType,itDATETIME) && actualval.value<Ilwis::Time>() == tUNDEF) return actualval; else if (isNumericalUndef(actualval.toDouble())) return rUNDEF; if (! dm->contains(actualval)) actualval = rUNDEF; else { SPNumericRange rng = coldef.datadef().range<NumericRange>(); if ( !rng.isNull()){ if ( hasType(valueType,itDATETIME)) rng->add(actualval.value<Ilwis::Time>()); else rng->add(actualval.toDouble()); } } } else if ( domtype == itTEXTDOMAIN){ return dm->impliedValue(inputVar); } return actualval; }
void PostgresqlFeatureCoverageLoader::setSubfeatureSemantics(FeatureCoverage *fcoverage, IDomain &semantics) const { std::vector<QString> items; ItemRangeIterator iter(semantics->range<>().data()); while (iter.isValid()) { SPDomainItem geomName = (*iter); items.push_back(geomName->name()); ++iter; } fcoverage->attributeDefinitionsRef().setSubDefinition(semantics, items); }
void ItemDomainMergerNamedItems::renumber(const std::unique_ptr<NamedIdentifierRange>& newRange, const QSharedPointer<NamedIdentifierRange>& range1, QSharedPointer<NamedIdentifierRange>& range2 ) { quint32 maxraw = 0; for(int i=0; i < range1->count(); ++i) { maxraw = std::max(range1->itemByOrder(i)->raw(), maxraw); } for(int i=0; i < newRange->count(); ++i) { SPDomainItem item = newRange->item(i); bool inrange1 = range1->contains(item->name()); bool inrange2 = range2->contains(item->name()); if ( !inrange1 && inrange2){ _renumber[item->raw()] = ++maxraw; item->raw(maxraw); } } }
void TableSelector::stringCase(const LogicalExpressionPart& part, const ColumnDefinition& coldef, const QVariant& var, std::vector<bool>::iterator& iter) { QString text = part.value(); QString fieldtxt = var.toString(); if ( coldef.datadef().domain<>()->valueType() == itTHEMATICITEM){ quint32 raw = var.toUInt(); INamedIdDomain domainid = coldef.datadef().domain<>().as<NamedIdDomain>(); SPDomainItem item = domainid->item(raw); fieldtxt = item->name(); } LogicalOperator lconnector = part.logicalConnector(); switch(part.condition()){ case loEQ:{ switch(lconnector){ case loNONE: *iter = fieldtxt == text;break; case loOR: *iter = *iter || fieldtxt == text;break; case loAND: *iter = *iter && fieldtxt == text;break; default: *iter = false;break; } break; } case loNEQ:{ switch(lconnector){ case loNONE: *iter = fieldtxt != text;break; case loOR: *iter = *iter || fieldtxt != text;break; case loAND: *iter = *iter && fieldtxt != text;break; default: *iter = false;break; } break; } default: *iter = false; } }
QString IntervalRange::valueAsString(quint32 index, const Range *rng) { SPDomainItem item = valueAt(index, rng); return item->name(); }