#include <TopExp_Explorer.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BRepTools.hxx>
#include <TopExp_Explorer.hxx>
return false;
}
+bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName )
+{
+ HYDROData_ShapeFile anImporter;
+ QStringList aPolygonsList;
+ TopTools_SequenceOfShape aPolygonFaces;
+ int aShapeTypeOfFile;
+ int aStatus = anImporter.ImportPolygons( theSHPFileName, aPolygonsList, aPolygonFaces, aShapeTypeOfFile);
+
+ bool isOK = ( aStatus == 1 );
+ if( isOK )
+ {
+ QString aDefaultStricklerType = "";
+
+ HYDROData_MapOfFaceToStricklerType aFaces;
+ for( int i=1, n=aPolygonFaces.Length(); i<=n; i++ )
+ {
+ TopoDS_Shape aShape = aPolygonFaces.Value( i );
+ if( aShape.ShapeType()==TopAbs_FACE )
+ aFaces.Add( TopoDS::Face( aShape ), aDefaultStricklerType );
+ }
+
+ StoreLandCovers( aFaces );
+ }
+
+ anImporter.Free();
+ return isOK;
+}
+
/**
Load attributes from DBF File
///
return DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING;
}
+void HYDROData_LandCoverMap::ExportSHP( const QString& theSHPFileName ) const
+{
+ //TODO
+}
+
/**
Export attributes to DBF File
///
QStringList aResList = dumpObjectCreation( theTreatedObjects );
QString aName = GetObjPyName();
- QString aShapeFileName = thePyScriptPath;
- aShapeFileName.replace( ".py", ".shp" );
+ QString aShpFileName = thePyScriptPath;
+ aShpFileName.replace( ".py", ".shp" );
QString aDbfFileName = thePyScriptPath;
aDbfFileName.replace( ".py", ".dbf" );
//TODO: export shape file
+ ExportSHP( aShpFileName );
QString anAttr = "CODE_06"; //TODO: some custom choice
QStringList anAttrValues, aTypes;
HYDROData_Document::Document( myLab )->CollectQGISValues( anAttr, anAttrValues, aTypes );
ExportDBF( aDbfFileName, anAttr, anAttrValues, aTypes );
- //TODO: insert command to import shape file
+ aResList << QString( "%1.ImportSHP( '%2' )" ).
+ arg( aName ).arg( aShpFileName );
Dump( "attr_values", anAttrValues, aResList );
Dump( "types", aTypes, aResList );
HYDRODATA_EXPORT virtual const ObjectKind GetKind() const;
+ HYDRODATA_EXPORT bool ImportSHP( const QString& theSHPFileName );
+
HYDRODATA_EXPORT DBFStatus ImportDBF( const QString& theDBFFileName,
const QString& theFieldName,
const QStringList& DBFValues,
const QStringList& StricklerTypes,
const QList<int>& theIndices = QList<int>() );
+ HYDRODATA_EXPORT void ExportSHP( const QString& theSHPFileName ) const;
+
HYDRODATA_EXPORT void ExportDBF( const QString& theDBFFileName,
const QString& theFieldName,
const QStringList& theDBFValues,