X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ShapeFile.cxx;h=357ceedd567be540bd9e3d841d982ea8bab8f91f;hb=9c947f35615e69e9e54a8c4b074dd1f2be13689c;hp=1a9e9251776ed1983943c11e2b136dc773d0327b;hpb=a9b9345d9e3ee5d9d42e76ec20a3195e63aafc0f;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index 1a9e9251..357ceedd 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -52,6 +51,10 @@ #include #include +#ifdef WIN32 + #pragma warning( disable: 4996 ) +#endif + HYDROData_ShapeFile::HYDROData_ShapeFile() : myHSHP(NULL) { } @@ -64,9 +67,10 @@ HYDROData_ShapeFile::~HYDROData_ShapeFile() void HYDROData_ShapeFile::Export(const QString& aFileName, NCollection_Sequence aPolyXYSeq, NCollection_Sequence aPoly3DSeq, - NCollection_Sequence aLCSeq, + const Handle_HYDROData_LandCoverMap& aLCSeq, QStringList& aNonExpList) { + /*TODO SHPHandle hSHPHandle; if (!aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty()) { @@ -98,7 +102,7 @@ void HYDROData_ShapeFile::Export(const QString& aFileName, QString aFN = aFileName.simplified(); remove (aFN.toStdString().c_str()); remove (aFN.replace( ".shp", ".shx", Qt::CaseInsensitive).toStdString().c_str()); - } + }*/ } int HYDROData_ShapeFile::WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly ) @@ -168,7 +172,7 @@ int HYDROData_ShapeFile::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROD return 1; } -int HYDROData_ShapeFile::WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC ) +/*TODO:int HYDROData_ShapeFile::WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC ) { TopoDS_Shape aSh = theLC->GetShape(); if (aSh.IsNull()) @@ -215,7 +219,7 @@ int HYDROData_ShapeFile::WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_ return 1; } - +*/ void HYDROData_ShapeFile::ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle) { SHPObject *aSHPObj; @@ -768,7 +772,7 @@ void HYDROData_ShapeFile::DBF_GetAttributeList(int theIndexOfField, std::vector< anAttr.myIsNull = false; anAttr.myFieldType = DBF_FieldType_Integer; anAttr.myRawValue = DBFReadStringAttribute( myHDBF, i, theIndexOfField ); - anAttr.myStrVal = QString::number(iAttr); + anAttr.myIntVal = iAttr; break; } @@ -778,7 +782,7 @@ void HYDROData_ShapeFile::DBF_GetAttributeList(int theIndexOfField, std::vector< anAttr.myIsNull = false; anAttr.myFieldType = DBF_FieldType_Double; anAttr.myRawValue = DBFReadStringAttribute( myHDBF, i, theIndexOfField ); - anAttr.myStrVal = QString::number(dAttr, 'g', 20); + anAttr.myDoubleVal = dAttr; break; } default: @@ -790,7 +794,7 @@ void HYDROData_ShapeFile::DBF_GetAttributeList(int theIndexOfField, std::vector< } -bool HYDROData_ShapeFile::DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector& theAttrV, bool bUseStrValue) +bool HYDROData_ShapeFile::DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector& theAttrV, bool bUseRawValue) { // Check that given field type is equal to field types of attributes values for (size_t i = 0; i < theAttrV.size(); i++) @@ -846,18 +850,57 @@ bool HYDROData_ShapeFile::DBF_WriteFieldAndValues(const QString& theFileName, co } int stat = -1; - //use raw values only //TODO - for (size_t i = 0; i < theAttrV.size(); i++) + if (bUseRawValue) { - if (!theAttrV[i].myIsNull) - stat = DBFWriteStringAttribute(hDBF, (int)i, 0, theAttrV[i].myRawValue.c_str()); - else - stat = DBFWriteNULLAttribute(hDBF, (int)i, 0 ); + for (size_t i = 0; i < theAttrV.size(); i++) + { + if (!theAttrV[i].myIsNull) + stat = DBFWriteStringAttribute(hDBF, (int)i, 0, theAttrV[i].myRawValue.c_str()); + else + stat = DBFWriteNULLAttribute(hDBF, (int)i, 0 ); - if (stat != 1) + if (stat != 1) + { + DBFClose( hDBF ); + return false; + } + } + } + else + { + for (size_t i = 0; i < theAttrV.size(); i++) { - DBFClose( hDBF ); - return false; + if (!theAttrV[i].myIsNull) + switch( theType ) + { + case DBF_FieldType_String: + { + stat = DBFWriteStringAttribute(hDBF, (int)i, 0, theAttrV[i].myStrVal.toStdString().c_str()); + break; + } + + case DBF_FieldType_Integer: + { + stat = DBFWriteIntegerAttribute(hDBF, (int)i, 0, theAttrV[i].myIntVal); + break; + } + + case DBF_FieldType_Double: + { + stat = DBFWriteDoubleAttribute(hDBF, (int)i, 0, theAttrV[i].myDoubleVal); + break; + } + default: + break; + } + else + stat = DBFWriteNULLAttribute(hDBF, (int)i, 0 ); + + if (stat != 1) + { + DBFClose( hDBF ); + return false; + } } }