[QGIS Commit] r10336 - in branches/analysis_branch: src/analysis/vector tests/src/analysis

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Mar 20 13:35:32 EDT 2009


Author: timlinux
Date: 2009-03-20 13:35:32 -0400 (Fri, 20 Mar 2009)
New Revision: 10336

Modified:
   branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h
   branches/analysis_branch/tests/src/analysis/CMakeLists.txt
   branches/analysis_branch/tests/src/analysis/testqgsvectoranalyzer.cpp
Log:
Added stubs for unit tests for Geometry Analysis


Modified: branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h
===================================================================
--- branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h	2009-03-20 17:33:36 UTC (rev 10335)
+++ branches/analysis_branch/src/analysis/vector/qgsgeometryanalyzer.h	2009-03-20 17:35:32 UTC (rev 10336)
@@ -31,57 +31,83 @@
 {
   public:
 
-bool singlepartsToMultipart( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding,
-                             const int fieldIndex );
-                      
-bool multipartToSingleparts( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding );
-                      
-bool extractNodes( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding );
-                      
-bool polygonsToLines( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding );
+    /** 
+     * Convert a vector layer from single part geometry 
+     * to multipart geometry for a given field 
+     *
+     * */
+    bool singlepartsToMultipart( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding,
+        const int fieldIndex );
 
-bool exportGeometryInformation( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding );
-                      
-bool simplifyGeometry( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding,
-                             const double tolerance );
-                      
-bool polygonCentroids( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding );
-                      
-bool layerExtent( QgsVectorLayer* layer,
-                             const QString& shapefileName,
-                             const QString& fileEncoding );
-                             
-  private:
-                      
-bool simpleMeasure( QgsGeometry& geometry );
+    /** 
+     * Convert multipart features to multiple singlepart features. Creates
+     * simple polygons and lines.
+     */
+    bool multipartToSingleparts( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding );
 
-bool perimeterMeasure( QgsGeometry& geometry );
+    /** 
+     * Extract nodes from line and polygon vector layers and output them as
+     * points.
+     *
+     * */
+    bool extractNodes( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding );
 
-bool checkGeometryFields( QgsGeometry& geometry );
+    /**
+     * Convert polygon features to line features. Multipart polygons are
+     * converted to multiple singlepart lines.
+     */
+    bool polygonsToLines( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding );
 
-bool extractAsLine( QgsGeometry& geometry );
+    /**
+     * Add vector layer geometry info to point (XCOORD, YCOORD), line (LENGTH),
+     * or polygon (AREA, PERIMETER) layer.
+     */
+    bool exportGeometryInformation( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding );
+    
+    /**
+     * Simplify (generalise) line or polygon vector layers using (a modified)
+     * Douglas-Peucker algorithm.
+     */
+    bool simplifyGeometry( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding,
+        const double tolerance );
 
-bool extractAsSingle( QgsGeometry& geometry );
+    /**
+     * Calculate the true centroids, or 'center of mass' for each polygon in an
+     * input polygon layer.
+     */
+    bool polygonCentroids( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding );
 
-bool extractAsMulti( QgsGeometry& geometry );
+    /**
+     * Create a polygon based on the extents of all features (or all 
+     * selected features if applicable) and write it out to a shp.
+     */
+    bool layerExtent( QgsVectorLayer* layer,
+        const QString& shapefileName,
+        const QString& fileEncoding );
 
-bool convertGeometry( QgsGeometry& geometry );
+  private:
+    bool simpleMeasure( QgsGeometry& geometry );
+    bool perimeterMeasure( QgsGeometry& geometry );
+    bool checkGeometryFields( QgsGeometry& geometry );
+    bool extractAsLine( QgsGeometry& geometry );
+    bool extractAsSingle( QgsGeometry& geometry );
+    bool extractAsMulti( QgsGeometry& geometry );
+    bool convertGeometry( QgsGeometry& geometry );
+    bool extractPoints( QgsGeometry& geometry );
 
-bool extractPoints( QgsGeometry& geometry );
-
 };
 #endif //QGSVECTORANALYZER

Modified: branches/analysis_branch/tests/src/analysis/CMakeLists.txt
===================================================================
--- branches/analysis_branch/tests/src/analysis/CMakeLists.txt	2009-03-20 17:33:36 UTC (rev 10335)
+++ branches/analysis_branch/tests/src/analysis/CMakeLists.txt	2009-03-20 17:35:32 UTC (rev 10336)
@@ -7,6 +7,7 @@
 # the UI file won't be wrapped!
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} 
   ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/core/
   ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/analysis/vector
   ${QT_INCLUDE_DIR}
   ${GDAL_INCLUDE_DIR}

Modified: branches/analysis_branch/tests/src/analysis/testqgsvectoranalyzer.cpp
===================================================================
--- branches/analysis_branch/tests/src/analysis/testqgsvectoranalyzer.cpp	2009-03-20 17:33:36 UTC (rev 10335)
+++ branches/analysis_branch/tests/src/analysis/testqgsvectoranalyzer.cpp	2009-03-20 17:35:32 UTC (rev 10336)
@@ -21,16 +21,71 @@
 {
     Q_OBJECT;
   private slots:
-    void initTestCase();
+    void initTestCase();// will be called before the first testfunction is executed.
+    void cleanupTestCase();// will be called after the last testfunction was executed.
+    void init() ;// will be called before each testfunction is executed.
+    void cleanup() ;// will be called after every testfunction.
+    /** Our tests proper begin here */
+    void singleToMulti(  );
+    void multiToSingle(  );
+    void extractNodes(  );
+    void polygonsToLines(  );
+    void exportGeometryInfo(  );
+    void simplifyGeometry(  );
+    void polygonCentroids(  );
+    void layerExtent(  );
   private:
 };
 
+void  TestQgsVectorAnalyzer::initTestCase()
+{
+}
+void  TestQgsVectorAnalyzer::cleanupTestCase()
+{
 
-void TestQgsVectorAnalyzer::initTestCase()
+}
+void  TestQgsVectorAnalyzer::init() 
 {
+
 }
+void  TestQgsVectorAnalyzer::cleanup() 
+{
 
+}
 
+void TestQgsVectorAnalyzer::singleToMulti(  )
+{
+
+}
+void TestQgsVectorAnalyzer::multiToSingle(  )
+{
+
+}
+void TestQgsVectorAnalyzer::extractNodes(  )
+{
+
+}
+void TestQgsVectorAnalyzer::polygonsToLines(  )
+{
+
+}
+void TestQgsVectorAnalyzer::exportGeometryInfo(  )
+{
+
+}
+void TestQgsVectorAnalyzer::simplifyGeometry(  )
+{
+
+}
+void TestQgsVectorAnalyzer::polygonCentroids(  )
+{
+
+}
+void TestQgsVectorAnalyzer::layerExtent(  )
+{
+
+}
+
 QTEST_MAIN( TestQgsVectorAnalyzer )
 #include "moc_testqgsvectoranalyzer.cxx"
 



More information about the QGIS-commit mailing list