+HYDROData_LandCoverMap::DBFStatus HYDROData_LandCoverMap::ImportDBF( const QString& theDBFFileName,
+ const QString& theFieldName,
+ const QStringList& theDBFValues,
+ const QStringList& theStricklerTypes,
+ const QList<int>& theIndices )
+{
+ if (theDBFValues.size() != theStricklerTypes.size())
+ return DBFStatus_DIFF_SIZE_ERROR;
+ HYDROData_ShapeFile aDBFImporter;
+ if (!aDBFImporter.DBF_OpenDBF(theDBFFileName))
+ return DBFStatus_OPEN_FILE_ERROR; //cant open file
+
+ QStringList FieldList = aDBFImporter.DBF_GetFieldList();
+ int FieldNameIndex = FieldList.indexOf(theFieldName);
+ if (FieldNameIndex == -1)
+ return DBFStatus_NO_SUCH_FIELD_ERROR; //no such field
+
+ std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
+ aDBFImporter.DBF_GetAttributeList(FieldNameIndex, theAttrV );
+
+ bool allOK = true;
+ Iterator anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ int CurIndex = anIt.Index();
+ HYDROData_ShapeFile::DBF_AttrValue AValue = theAttrV[theIndices[CurIndex]];
+ int StricklerTypesInd = theDBFValues.indexOf(QString(AValue.myStrVal));
+ if ( StricklerTypesInd != -1)
+ anIt.SetStricklerType(theStricklerTypes[StricklerTypesInd]);
+ else
+ allOK = false;
+ }
+ if (allOK)
+ return DBFStatus_OK;
+ else
+ return DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING;