Salome HOME
test Strickler
[modules/hydro.git] / src / HYDROData / HYDROData_LandCoverMap.cxx
index 55e516564ebbf07884dca7f84d86dcd844fc0841..18eaeee8f584d2a19cb444de85aa5a08529895a2 100644 (file)
@@ -1084,7 +1084,7 @@ TopoDS_Face HYDROData_LandCoverMap::FindByPoint( const gp_Pnt2d& thePoint, QStri
 
 void Dump( const QString& theName, const QStringList& theList, QStringList& theLines )
 {
-  theLines.append( QString( "%1 = QStringList()" ).arg( theName ) );
+  theLines.append( QString( "%1 = []" ).arg( theName ) );
   foreach( QString anItem, theList )
     theLines.append( QString( "%1.append( u\"%2\" )" ).arg( theName ).arg( anItem ) );
 }
@@ -1111,13 +1111,15 @@ QStringList HYDROData_LandCoverMap::DumpToPython( const QString&       thePyScri
   HYDROData_Document::Document( myLab )->CollectQGISValues( anAttr, anAttrValues, aTypes );
   ExportDBF( aDbfFileName, anAttr, anAttrValues, aTypes );
 
-  aResList << QString( "%1.ImportSHP( '%2' )" ).
+  aResList << QString( "if not(%1.ImportSHP( '%2' )):" ).
     arg( aName ).arg( QFileInfo( aShpFileName ).fileName() );
+  aResList << QString( "  raise ValueError('problem while loading LandCoverMap shape')" );
 
   Dump( "attr_values", anAttrValues, aResList );
   Dump( "types", aTypes, aResList );
-  aResList << QString( "%1.ImportDBF( '%2', '%3', attr_values, types )" ).
+  aResList << QString( "if (%1.ImportDBF( '%2', '%3', attr_values, types ) != %1.DBFStatus_OK):" ).
     arg( aName ).arg( QFileInfo( aDbfFileName ).fileName() ).arg( anAttr );
+  aResList << QString( "  raise ValueError('problem while loading LandCoverMap data base')" );
 
   return aResList;
 }
@@ -1181,7 +1183,7 @@ void HYDROData_LandCoverMap::SetTransparency( double theTransparency )
 
 double HYDROData_LandCoverMap::GetTransparency() const
 {
-  return GetDouble( DataTag_Transparency, 0.5 );
+  return GetDouble( DataTag_Transparency, 0.25 );
 }
 
 bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName,
@@ -1272,14 +1274,38 @@ void HYDROData_LandCoverMap::UpdateLocalCS( double theDx, double theDy )
   SetShape( aLocatedShape );
 }
 
-void HYDROData_LandCoverMap::ClassifyPoints( const std::vector<gp_XY>& thePoints, std::vector<std::set <QString> >& theTypes ) const
+void HYDROData_LandCoverMap::ClassifyPoints( const std::vector<gp_XY>& thePoints,
+                                             std::vector<std::set <QString> >& theTypes ) const
 {
   HYDROData_LCM_FaceClassifier FC(this);
   FC.Classify(thePoints, theTypes, NULL);
 }
 
+void HYDROData_LandCoverMap::ClassifyPoints( const std::vector<gp_XY>& thePoints,
+                                             const Handle(HYDROData_StricklerTable)& theTable,
+                                             std::vector<int>& theTypes ) const
+{
+  std::vector<std::set <QString> > types;
+  HYDROData_LCM_FaceClassifier FC(this);
+  FC.Classify(thePoints, types, NULL);
+
+  size_t n = types.size();
+  theTypes.resize( n );
+  for( size_t i=0; i<n; i++ )
+  {
+    const std::set<QString>& sub_types = types[i];
+    int aType = 0;
+    if( !sub_types.empty() )
+    {
+      const QString& aSType = *sub_types.begin();
+      aType = theTable->GetAttrValue( aSType ).toInt();
+    }
+    theTypes[i] = aType;
+  }
+}
+
 void HYDROData_LandCoverMap::ClassifyPoints( const std::vector<gp_XY>& thePoints,  
-  Handle(HYDROData_StricklerTable) theTable, 
+  const Handle(HYDROData_StricklerTable)& theTable, 
   std::vector<double>& theCoeffs, double DefValue, bool UseMax ) const
 {
   std::vector<std::set <QString> > Types;