]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
take into account Local Coordinates System on LandCoverMap Shapefile import
authorPaul RASCLE <paul.rascle@edf.fr>
Thu, 5 May 2016 21:59:28 +0000 (23:59 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Thu, 5 May 2016 21:59:28 +0000 (23:59 +0200)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDROData/HYDROData_ShapeFile.h
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index 1226dbc5a865cdabcbe737ef1ad5e429193a8dea..4b577db8b69a924b3a4df0c096c3c3c00c16c408 100644 (file)
@@ -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;
index bea35fafbc1fc1c49cdd07a0f06d7de05341314f..3538a6ea2fb86aced858736bfbe744803c0bc6b9 100644 (file)
@@ -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
index 16d92ad1c544cf4951ab85ddda9aa018dc408456..157ea9a438ef36159f598043b1e19ef4a654c768 100644 (file)
@@ -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);
index 437f84dd4b58f4d0ede044c8d325feb93e57b232..a2d3a09b55c1712992a782b2a07009923d61cb8d 100644 (file)
@@ -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);
index 83345f84f23a6bc5c5116caba53b76c7e9b8bae6..154e95eabd55c7ec36134f3a813b504d4e8e23d9 100644 (file)
@@ -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);