X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_LandCoverMap.cxx;h=43320fc973aaf49e440ba0819e6107a425e1b643;hb=b4e2289f57dded4b33e1aad8740ed1e400726614;hp=37189f939c675ee094b15f98e916fa70e4f6d396;hpb=ccf1fc3746f78940dffc56d4958695c39a2a3088;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 37189f93..43320fc9 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -50,6 +50,7 @@ extern QString REF_DATA_PATH; const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table_06.txt"; +extern QString TMP_DIR; void test_HYDROData_LandCoverMap::test_add_2_objects() { @@ -601,7 +602,7 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types() // select one of faces (first) TestViewer::select( 200, 300 ); CPPUNIT_ASSERT_IMAGES - + TestViewer::eraseAll(true, true); aDoc->Close(); } @@ -672,7 +673,7 @@ void test_HYDROData_LandCoverMap::test_dump_python() QString aBaseName = "lc_dump.py"; QString aBaseShp = "lc_dump.shp"; QString aBaseDbf = "lc_dump.dbf"; - QString aTmpPath = QDir::tempPath() + "/" + aBaseName; + QString aTmpPath = TMP_DIR + "/" + aBaseName; CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) ); //TODO: CPPUNIT_ASSERT_SCRIPTS_EQUAL( aBaseName, true, false, 20 ); @@ -810,6 +811,8 @@ void test_HYDROData_LandCoverMap::test_assign_to_calc_case() void test_HYDROData_LandCoverMap::test_shp_import_cyp() { + //TestViewer::eraseAll(true); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); QString aFileName = REF_DATA_PATH + "/cyprus_natural.shp"; HYDROData_ShapeFile anImporter; @@ -824,7 +827,7 @@ void test_HYDROData_LandCoverMap::test_shp_import_cyp() Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); HYDROData_MapOfFaceToStricklerType aMapFace2ST; - for ( int i = 1; i <= PolygonFaces.Length(); i++ ) + for ( int i = 1; i <= 20; i++ ) { TopoDS_Shape aShape = PolygonFaces(i); if ( aShape.IsNull() ) @@ -854,7 +857,7 @@ void test_HYDROData_LandCoverMap::test_shp_import_clc_dec() Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); HYDROData_MapOfFaceToStricklerType aMapFace2ST; - for ( int i = 150; i <= 350; i++ ) + for ( int i = 150; i <= 160; i++ ) { TopoDS_Shape aShape = PolygonFaces(i); if ( aShape.IsNull() ) @@ -1084,21 +1087,29 @@ void test_HYDROData_LandCoverMap::test_export_telemac() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); + QStringList types = aTable->GetTypes(); + //foreach( QString type, types ) + // std::cout << type.toStdString() << std::endl; + + QString type7 = types[7]; + QString type8 = types[8]; + QString type9 = types[9]; + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); - CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Forêt et végétation arbustive en mutation")) ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, type7 ) ); TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); - CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, QString::fromUtf8("Forêts de conifères")) ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, type8 ) ); TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); - CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Forêts de feuillus")) ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, type9 ) ); QString aTmpFileName = "test.telemac"; - QString aTmpPath = QDir::tempPath() + "/" + aTmpFileName; + QString aTmpPath = TMP_DIR + "/" + aTmpFileName; QString messStat; CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable, messStat ) ); CPPUNIT_ASSERT_SCRIPTS_EQUAL( aTmpFileName, true, true, 0 ); @@ -1166,10 +1177,10 @@ void test_HYDROData_LandCoverMap::test_shp_clc_classification_perf() #ifdef NDEBUG int SI = 100; - int EI = 300; + int EI = 110; #else - int SI = 150; - int EI = 200; + int SI = 100; + int EI = 110; #endif for ( int i = SI; i <= EI; i++ ) @@ -1209,7 +1220,8 @@ void test_HYDROData_LandCoverMap::test_shp_clc_classification_perf() LCM->ClassifyPoints(pnts, TRes); aTimer.Stop(); #ifdef NDEBUG - CPPUNIT_ASSERT( aTimer.ElapsedTime() < 1.4); + std::cout << "Time: " << aTimer.ElapsedTime() << std::endl; + CPPUNIT_ASSERT( aTimer.ElapsedTime() < 6.0); aTimer.Show(); #endif } @@ -1271,10 +1283,79 @@ void test_HYDROData_LandCoverMap::test_shp_clc_classification_check() CPPUNIT_ASSERT_EQUAL (coeffs[0], 0.0); CPPUNIT_ASSERT_EQUAL (coeffs[1], 0.0); CPPUNIT_ASSERT_EQUAL (coeffs[2], 0.0); - CPPUNIT_ASSERT_EQUAL (coeffs[3], 1.0522); - CPPUNIT_ASSERT_EQUAL (coeffs[4], 1.0223); - CPPUNIT_ASSERT_EQUAL (coeffs[5], 1.0221); - CPPUNIT_ASSERT_EQUAL (coeffs[6], 1.0522); + CPPUNIT_ASSERT_EQUAL (coeffs[3], 98.0); + CPPUNIT_ASSERT_EQUAL (coeffs[4], 26.0); + CPPUNIT_ASSERT_EQUAL (coeffs[5], 24.0); + CPPUNIT_ASSERT_EQUAL (coeffs[6], 98.0); + +} + +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 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 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(); }