return theCoeffs;
}
+std::vector<int> HYDROData_CalculationCase::GetStricklerTypeForPoints( const std::vector<gp_XY>& thePoints ) const
+{
+ Handle( HYDROData_LandCoverMap ) aLCM = GetLandCoverMap();
+ Handle( HYDROData_StricklerTable ) aTable = GetStricklerTable();
+ std::vector<int> types;
+ if( aLCM.IsNull() || aTable.IsNull() )
+ return types;
+
+ aLCM->ClassifyPoints(thePoints, aTable, types );
+ return types;
+}
+
Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
{
Handle(HYDROData_Region) aResRegion;
double DefValue,
bool UseMax ) const;
+ HYDRODATA_EXPORT std::vector<int> GetStricklerTypeForPoints( const std::vector<gp_XY>& thePoints ) const;
+
/**
* Returns altitudes for given points on given region.
* \param thePoints the points to examine
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;
HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
- HYDRODATA_EXPORT void ClassifyPoints( const std::vector<gp_XY>& thePoints, std::vector<std::set <QString> >& theTypes ) const;
+ HYDRODATA_EXPORT void ClassifyPoints( const std::vector<gp_XY>& thePoints,
+ std::vector<std::set <QString> >& theTypes ) const;
+
+ HYDRODATA_EXPORT void ClassifyPoints( const std::vector<gp_XY>& thePoints,
+ const Handle(HYDROData_StricklerTable)& theTable,
+ std::vector<int>& theTypes ) const;
HYDRODATA_EXPORT void ClassifyPoints( const std::vector<gp_XY>& thePoints,
- Handle(HYDROData_StricklerTable) theTable,
- std::vector<double>& theCoeffs, double DefValue, bool UseMax ) const;
+ const Handle(HYDROData_StricklerTable)& theTable,
+ std::vector<double>& theCoeffs, double DefValue, bool UseMax ) const;
protected:
void SetShape( const TopoDS_Shape& );
%End
+ std::vector<int> GetStricklerTypeForPoints( const NCollection_Sequence<double>& theCoordsX,
+ const NCollection_Sequence<double>& theCoordsY ) const
+ [std::vector<int>( const NCollection_Sequence<gp_XY>& )];
+ %MethodCode
+ std::vector<gp_XY> aPnts;
+ int aLen = qMin( a0->Length(), a1->Length() );
+ for ( int i = 1; i <= aLen; ++i )
+ {
+ gp_XY aPnt( a0->Value( i ), a1->Value( i ) );
+ aPnts.push_back( aPnt );
+ }
+ std::vector<int> aRes;
+ Py_BEGIN_ALLOW_THREADS
+ aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetStricklerTypeForPoints( aPnts ) :
+ sipCpp->GetStricklerTypeForPoints( aPnts );
+ Py_END_ALLOW_THREADS
+ sipRes = new std::vector<int>( aRes );
+ %End
+
+
/**
* Returns altitudes for given points on given zone.
* \param thePoints the points to examine
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0123, values[1], EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0221, values[2], EPS );
+ std::vector<int> types = aCase->GetStricklerTypeForPoints( points );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)types.size() );
+ CPPUNIT_ASSERT_EQUAL( 123, types[0] );
+ CPPUNIT_ASSERT_EQUAL( 123, types[1] );
+ CPPUNIT_ASSERT_EQUAL( 221, types[2] );
+
aDoc->Close();
}