aDoc->Close();
}
-
+#include <QTest>
void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
{
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
// show presentation in viewer
TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" );
// select one of faces (first)
- TestViewer::select( 200, 300 );
+ TestViewer::select( 200, 300 );
+ QTest::qWait(1000);
+ TestViewer::select( 220, 300 );
+ QTest::qWait(1000);
+ TestViewer::select( 250, 300 );
+ QTest::qWait(1000);
+ TestViewer::select( 300, 300 );
+ QTest::qWait(1000);
+ TestViewer::select( 200, 350 );
+ QTest::qWait(1000);
+ TestViewer::select( 200, 500 );
+ QTest::qWait(1000);
+ TestViewer::select( 250, 400 );
+ QTest::qWait(1000);
+ TestViewer::select( 300, 99 );
+ QTest::qWait(1000);
+
CPPUNIT_ASSERT_IMAGES
TestViewer::eraseAll(true, true);
aDoc->Close();
TestViewer::showColorScale( true );
aPrs->SetColorScale( TestViewer::colorScale() );
TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByCoeff" );
+
CPPUNIT_ASSERT_IMAGES
TestViewer::showColorScale( false );
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
- int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type);
+
+ int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces);
+ int Type = anImporter.GetShapeType();
CPPUNIT_ASSERT(aStat == 1);
CPPUNIT_ASSERT_EQUAL(5, Type);
CPPUNIT_ASSERT_EQUAL(268, PolygonFaces.Length());
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
- int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type);
+ int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces);
+ int Type = anImporter.GetShapeType();
+
CPPUNIT_ASSERT(aStat == 1);
CPPUNIT_ASSERT_EQUAL(5, Type);
CPPUNIT_ASSERT_EQUAL(625, PolygonFaces.Length());
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
- int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type);
+ int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces);
+ int Type = anImporter.GetShapeType();
CPPUNIT_ASSERT(aStat == 1);
CPPUNIT_ASSERT_EQUAL(5, Type);
CPPUNIT_ASSERT_EQUAL(127, PolygonFaces.Length());
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
//import LCM from file (#2-4; #12-14 polygons)
- CPPUNIT_ASSERT( anImporter.ImportPolygons(aDoc, aFFileName, PolygonList, PolygonFaces, Type));
+ CPPUNIT_ASSERT( anImporter.ImportPolygons(aDoc, aFFileName, PolygonList, PolygonFaces));
Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
HYDROData_MapOfFaceToStricklerType aMapFace2ST;
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
-
//import all
- CPPUNIT_ASSERT( anImporter.ImportPolygons(aDoc, aSFileName, PolygonList, PolygonFaces, Type));
+ CPPUNIT_ASSERT( anImporter.ImportPolygons(aDoc, aSFileName, PolygonList, PolygonFaces));
Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
HYDROData_MapOfFaceToStricklerType aMapFace2ST;
CPPUNIT_ASSERT_EQUAL(PolygonFaces.Length(), 6);
CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, type9 ) );
QString aTmpFileName = "test.telemac";
-#ifdef WIN32
QString aTmpPath = TMP_DIR + "/" + aTmpFileName;
-#else
- QString aTmpPath = TMP_DIR + "/hydro/" + aTmpFileName;
-#endif
QString messStat;
CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable, messStat ) );
CPPUNIT_ASSERT_SCRIPTS_EQUAL( aTmpFileName, true, true, 0 );
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
- int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type);
+ int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces);
+ int Type = anImporter.GetShapeType();
CPPUNIT_ASSERT(aStat == 1);
CPPUNIT_ASSERT_EQUAL(5, Type);
CPPUNIT_ASSERT_EQUAL(625, PolygonFaces.Length());
HYDROData_ShapeFile anImporter;
QStringList PolygonList;
TopTools_SequenceOfShape PolygonFaces;
- int Type = -1;
- int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type);
+ int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces);
CPPUNIT_ASSERT(aStat == 1);
Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
HYDROData_MapOfFaceToStricklerType aMapFace2ST;
}
+void test_HYDROData_LandCoverMap::test_lcm_classification()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_StricklerTable) aTable =
+ Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+ CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
+
+ Handle(HYDROData_PolylineXY) ContourP = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ ContourP->SetName( "Contour" );
+ ContourP->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+ ContourP->AddPoint( 0, gp_XY( 89.57, 81.63 ) );
+ ContourP->AddPoint( 0, gp_XY( 479.59, 81.63 ) );
+ ContourP->AddPoint( 0, gp_XY( 472.79, 671.20 ) );
+ ContourP->AddPoint( 0, gp_XY( 69.16, 696.15 ) );
+ ContourP->Update();
+
+ Handle(HYDROData_PolylineXY) Poly_Sens_TrigoP =
+ Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ Poly_Sens_TrigoP->SetName( "Poly_Sens_Trigo" );
+ Poly_Sens_TrigoP->SetZLevel( 3 );
+ Poly_Sens_TrigoP->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, 1 );
+ Poly_Sens_TrigoP->AddPoint( 0, gp_XY( 130.46, 223.57 ) );
+ Poly_Sens_TrigoP->AddPoint( 0, gp_XY( 252.16, 239.58 ) );
+ Poly_Sens_TrigoP->AddPoint( 0, gp_XY( 240.95, 498.99 ) );
+ Poly_Sens_TrigoP->AddPoint( 0, gp_XY( 119.26, 510.20 ) );
+ Poly_Sens_TrigoP->AddPoint( 0, gp_XY( 141.67, 378.89 ) );
+ Poly_Sens_TrigoP->Update();
+
+ Handle(HYDROData_PolylineXY) Polyline_Sens_HoraireP =
+ Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ Polyline_Sens_HoraireP->SetName( "Polyline_Sens_Horaire" );
+ Polyline_Sens_HoraireP->SetZLevel( 4 );
+ Polyline_Sens_HoraireP->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, 1 );
+ Polyline_Sens_HoraireP->AddPoint( 0, gp_XY( 313.01, 470.16 ) );
+ Polyline_Sens_HoraireP->AddPoint( 0, gp_XY( 313.01, 627.09 ) );
+ Polyline_Sens_HoraireP->AddPoint( 0, gp_XY( 426.70, 633.49 ) );
+ Polyline_Sens_HoraireP->AddPoint( 0, gp_XY( 442.71, 398.11 ) );
+ Polyline_Sens_HoraireP->Update();
+
+
+ Handle(HYDROData_LandCoverMap) Land_cover_map_1 =
+ Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+ Land_cover_map_1->SetName( "Land cover map_1" );
+ Land_cover_map_1->SetZLevel( 2 );
+ CPPUNIT_ASSERT_EQUAL( true, Land_cover_map_1->Add( ContourP, "Vignobles" ) );
+ CPPUNIT_ASSERT_EQUAL( true, Land_cover_map_1->Add( Poly_Sens_TrigoP, "Oliveraies" ) );
+ CPPUNIT_ASSERT_EQUAL( true, Land_cover_map_1->Add( Polyline_Sens_HoraireP, "Estuaires" ) );
+
+ Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( Land_cover_map_1 );
+ TopoDS_Shape aSh = Land_cover_map_1->GetShape();
+ TestViewer::show( aPrs, AIS_Shaded, 0, true, "Land_cover_map_1" );
+
+ std::vector<gp_XY> pnts;
+ pnts.push_back(gp_XY(90, 90));
+ pnts.push_back(gp_XY(300, 90));
+ pnts.push_back(gp_XY(200, 350));
+ pnts.push_back(gp_XY(400, 500));
+ std::vector<double> theCoeffs;
+ Land_cover_map_1->ClassifyPoints(pnts, aTable, theCoeffs, -1, true );
+ CPPUNIT_ASSERT_EQUAL((int)theCoeffs.size(), 4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(theCoeffs[0], 24, 0.0001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(theCoeffs[1], 24, 0.0001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(theCoeffs[2], 26, 0.0001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(theCoeffs[3], 98, 0.0001);
+
+ aDoc->Close();
+}
+