From acecf4afbacc01753135b4fb2aae832d6157c64b Mon Sep 17 00:00:00 2001 From: isn Date: Fri, 16 Oct 2015 17:26:21 +0300 Subject: [PATCH] always store a field type of attribute even inside internal dbf-structure --- src/HYDROData/HYDROData_ShapeFile.cxx | 10 ++++++++++ src/HYDROData/HYDROData_ShapeFile.h | 1 + src/HYDRO_tests/test_HYDROData_ShapeFile.cxx | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index 69c6a276..10b47b36 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -737,6 +737,16 @@ void HYDROData_ShapeFile::DBF_GetAttributeList(int theIndexOfField, std::vector< if( DBFIsAttributeNULL( myHDBF, i, theIndexOfField ) ) { anAttr.myIsNull = true; + DBF_FieldType FT = DBF_FieldType_None; + if( eType == FTString ) + FT = DBF_FieldType_String; + else if( eType == FTInteger ) + FT = DBF_FieldType_Integer; + else if( eType == FTDouble ) + FT = DBF_FieldType_Double; + else if( eType == FTInvalid ) + FT = DBF_FieldType_Invalid; + anAttr.myFieldType = FT; } else { diff --git a/src/HYDROData/HYDROData_ShapeFile.h b/src/HYDROData/HYDROData_ShapeFile.h index 11517a66..ad1df754 100644 --- a/src/HYDROData/HYDROData_ShapeFile.h +++ b/src/HYDROData/HYDROData_ShapeFile.h @@ -59,6 +59,7 @@ enum DBF_FieldType DBF_FieldType_Invalid }; + struct DBF_AttrValue { DBF_AttrValue() diff --git a/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx b/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx index 035d6914..ccbb8fad 100644 --- a/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx +++ b/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx @@ -98,7 +98,7 @@ void test_HYDROData_ShapeFile::test_GetAttrListIndex() //Null attr CPPUNIT_ASSERT_EQUAL( true, theAttrV[35].myIsNull); CPPUNIT_ASSERT_EQUAL( true, theAttrV[35].myRawValue.empty()); - CPPUNIT_ASSERT_EQUAL( HYDROData_ShapeFile::DBF_FieldType_None, theAttrV[35].myFieldType); + CPPUNIT_ASSERT_EQUAL( HYDROData_ShapeFile::DBF_FieldType_String, theAttrV[35].myFieldType); theAttrV.clear(); aSHPFile.DBF_GetAttributeList(1, theAttrV ); //second field -- 2.39.2