const QStringList& theStricklerTypes,
QMap<int, int> theIndices )
{
+ if (theDBFValues.size() != theStricklerTypes.size())
+ return DBFStatus_DIFF_SIZE_ERROR;
HYDROData_ShapeFile aDBFImporter;
- if (aDBFImporter.DBF_OpenDBF(theDBFFileName))
+ if (!aDBFImporter.DBF_OpenDBF(theDBFFileName))
return DBFStatus_OPEN_FILE_ERROR; //cant open file
QStringList FieldList = aDBFImporter.DBF_GetFieldList();
HYDROData_ShapeFile::DBF_AttrValue AValue = theAttrV[theIndices[CurIndex]];
int StricklerTypesInd = theDBFValues.indexOf(QString(AValue.myStrVal));
if ( StricklerTypesInd != -1)
- anIt.SetStricklerType(theDBFValues[StricklerTypesInd]);
+ anIt.SetStricklerType(theStricklerTypes[StricklerTypesInd]);
else
allOK = false;
}
#include <AIS_DisplayMode.hxx>
#include <QString>
#include <QColor>
-
+#include <QMap>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
}
+}
+
+void test_HYDROData_LandCoverMap::test_import_dbf()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_LandCoverMap) aMap =
+ Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+
+ CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
+ QString aFileName = REF_DATA_PATH + "/t1.dbf";
+ QStringList aDBFV;
+ QStringList aST;
+ aDBFV.append("100");
+ aDBFV.append("200");
+ aDBFV.append("300");
+ aST.append("water");
+ aST.append("forest");
+ aST.append("road");
+ // aST.size() == aDBFV.size()!!
+ Handle(HYDROData_PolylineXY) aPolyline =
+ Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire();
+ aPolyline->SetShape( aWire );
+ for (int i = 0; i < 3; i++)
+ aMap->Add(aPolyline, "");
+ TopoDS_Face aLC1 = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+ CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
+
+ CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
+ QMap<int, int> Inds;
+ Inds.insert(1, 1);
+ Inds.insert(2, 2);
+ Inds.insert(3, 3);
+ aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds);
+ HYDROData_LandCoverMap::Iterator anIt( aMap );
+
+ CPPUNIT_ASSERT_EQUAL(true, "water" == anIt.StricklerType());
+ anIt.Next();
+ CPPUNIT_ASSERT_EQUAL(true, "forest" == anIt.StricklerType());
+
}
\ No newline at end of file
CPPUNIT_TEST( test_remove );
CPPUNIT_TEST( test_merge_faces_boxes );
CPPUNIT_TEST( test_merge_faces_circles );
+ CPPUNIT_TEST( test_import_dbf );
CPPUNIT_TEST_SUITE_END();
public:
void test_remove();
void test_merge_faces_boxes();
void test_merge_faces_circles();
+ void test_import_dbf();
};
CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );