From: Paul RASCLE Date: Thu, 5 May 2016 21:59:28 +0000 (+0200) Subject: take into account Local Coordinates System on LandCoverMap Shapefile import X-Git-Tag: v1.6~113^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be02b659575f15f9efe926892feeaffe4742f2b6;p=modules%2Fhydro.git take into account Local Coordinates System on LandCoverMap Shapefile import --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 1226dbc5..4b577db8 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -1123,7 +1123,7 @@ bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName, QStringList aPolyList; TopTools_SequenceOfShape aFaces; int aSHapeType = -1; - int Stat = anImporter.ImportPolygons(theSHPFileName, aPolyList, aFaces, aSHapeType); + int Stat = anImporter.ImportPolygons(HYDROData_Document::Document(1), theSHPFileName, aPolyList, aFaces, aSHapeType); // if (Stat != 1) return false; diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index bea35faf..3538a6ea 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -367,7 +367,7 @@ bool HYDROData_ShapeFile::Parse(SHPHandle theHandle, ShapeType theType, int& the return false; } -void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F) +void HYDROData_ShapeFile::ReadSHPPolygon(Handle(HYDROData_Document) theDocument, SHPObject* anObj, int i, TopoDS_Face& F) { if (!anObj) return; @@ -401,6 +401,7 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F for ( int k = StartIndex; k < EndIndex; k++ ) { gp_Pnt P (anObj->padfX[k], anObj->padfY[k], 0); + theDocument->Transform(P, true); VPoints.ChangeValue(j) = BRepLib_MakeVertex(P).Vertex(); j--; } @@ -488,7 +489,7 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F F.Closed(Standard_True); } -int HYDROData_ShapeFile::ImportPolygons(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile) +int HYDROData_ShapeFile::ImportPolygons(Handle(HYDROData_Document) theDocument, const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile) { Free(); int Stat = TryOpenShapeFile(theFileName); @@ -509,7 +510,7 @@ int HYDROData_ShapeFile::ImportPolygons(const QString theFileName, QStringList& #endif for (size_t i = 0; i < mySHPObjects.size(); i++) { - ReadSHPPolygon(mySHPObjects[i], i, aF); + ReadSHPPolygon(theDocument, mySHPObjects[i], i, aF); theFaces.Append(aF); } #ifdef OSD_TIMER diff --git a/src/HYDROData/HYDROData_ShapeFile.h b/src/HYDROData/HYDROData_ShapeFile.h index 16d92ad1..157ea9a4 100644 --- a/src/HYDROData/HYDROData_ShapeFile.h +++ b/src/HYDROData/HYDROData_ShapeFile.h @@ -101,9 +101,10 @@ public: //Import bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile); //Import Landcover - void ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F); + void ReadSHPPolygon(Handle(HYDROData_Document) theDocument, SHPObject* anObj, int i, TopoDS_Face& F); - HYDRODATA_EXPORT int ImportPolygons(const QString theFileName, + HYDRODATA_EXPORT int ImportPolygons(Handle(HYDROData_Document) theDocument, + const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile); diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx index 437f84dd..a2d3a09b 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx @@ -132,7 +132,7 @@ void HYDROGUI_ImportLandCoverMapOp::onFileSelected() //Import polygons from SHP file as faces //This faces should be added to the new LCM object - int aStat = myImporter.ImportPolygons(myFileName, aPolygonsList, myPolygonFaces, aShapeTypeOfFile); + int aStat = myImporter.ImportPolygons(doc(), myFileName, aPolygonsList, myPolygonFaces, aShapeTypeOfFile); if (aStat == 1) { aPanel->setPolygonNames(aPolygonsList); diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 83345f84..154e95ea 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -796,7 +796,7 @@ void test_HYDROData_LandCoverMap::test_shp_import_cyp() QStringList PolygonList; TopTools_SequenceOfShape PolygonFaces; int Type = -1; - int aStat = anImporter.ImportPolygons(aFileName, PolygonList, PolygonFaces, Type); + int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type); CPPUNIT_ASSERT(aStat == 1); CPPUNIT_ASSERT_EQUAL(5, Type); CPPUNIT_ASSERT_EQUAL(268, PolygonFaces.Length()); @@ -826,7 +826,7 @@ void test_HYDROData_LandCoverMap::test_shp_import_clc_dec() QStringList PolygonList; TopTools_SequenceOfShape PolygonFaces; int Type = -1; - int aStat = anImporter.ImportPolygons(aFileName, PolygonList, PolygonFaces, Type); + int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type); CPPUNIT_ASSERT(aStat == 1); CPPUNIT_ASSERT_EQUAL(5, Type); CPPUNIT_ASSERT_EQUAL(625, PolygonFaces.Length()); @@ -856,7 +856,7 @@ void test_HYDROData_LandCoverMap::test_shp_import_nld_areas() QStringList PolygonList; TopTools_SequenceOfShape PolygonFaces; int Type = -1; - int aStat = anImporter.ImportPolygons(aFileName, PolygonList, PolygonFaces, Type); + int aStat = anImporter.ImportPolygons(aDoc, aFileName, PolygonList, PolygonFaces, Type); CPPUNIT_ASSERT(aStat == 1); CPPUNIT_ASSERT_EQUAL(5, Type); CPPUNIT_ASSERT_EQUAL(127, PolygonFaces.Length()); @@ -891,7 +891,7 @@ void test_HYDROData_LandCoverMap::test_shp_loop_back() int Type = -1; //import LCM from file (#2-4; #12-14 polygons) - CPPUNIT_ASSERT( anImporter.ImportPolygons(aFFileName, PolygonList, PolygonFaces, Type)); + CPPUNIT_ASSERT( anImporter.ImportPolygons(aDoc, aFFileName, PolygonList, PolygonFaces, Type)); Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); HYDROData_MapOfFaceToStricklerType aMapFace2ST; @@ -925,7 +925,7 @@ void test_HYDROData_LandCoverMap::test_shp_loop_back() int Type = -1; //import all - CPPUNIT_ASSERT( anImporter.ImportPolygons(aSFileName, PolygonList, PolygonFaces, Type)); + CPPUNIT_ASSERT( anImporter.ImportPolygons(aDoc, aSFileName, PolygonList, PolygonFaces, Type)); Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); HYDROData_MapOfFaceToStricklerType aMapFace2ST; CPPUNIT_ASSERT_EQUAL(PolygonFaces.Length(), 6);