[pktools] 269/375: debug: write centroid instead of polgon feature for maxvote in case polygon_opt is false

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:54:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch upstream-master
in repository pktools.

commit 32295b21445efb70ccd593e16b16c6782f3b00af
Author: Pieter Kempeneers <kempenep at gmail.com>
Date:   Wed May 14 17:52:27 2014 +0200

    debug: write centroid instead of polgon feature for maxvote in case polygon_opt is false
---
 qt/pkextract_gui/mainwindow.ui |  2 +-
 qt/pksvm_gui/mainwindow.cpp    | 40 ++++++++++++++++++++++------------------
 qt/pksvm_gui/mainwindow.h      |  2 --
 src/apps/pkextract.cc          | 38 ++++++++++++++++++++++----------------
 src/apps/pkstatogr.cc          |  3 ++-
 5 files changed, 47 insertions(+), 38 deletions(-)

diff --git a/qt/pkextract_gui/mainwindow.ui b/qt/pkextract_gui/mainwindow.ui
index 48fe2f1..e344b49 100644
--- a/qt/pkextract_gui/mainwindow.ui
+++ b/qt/pkextract_gui/mainwindow.ui
@@ -26,7 +26,7 @@
       <item>
        <widget class="QTabWidget" name="tabWidget">
         <property name="currentIndex">
-         <number>0</number>
+         <number>1</number>
         </property>
         <widget class="QWidget" name="tab_2">
          <attribute name="title">
diff --git a/qt/pksvm_gui/mainwindow.cpp b/qt/pksvm_gui/mainwindow.cpp
index 2e5e136..3d293c4 100644
--- a/qt/pksvm_gui/mainwindow.cpp
+++ b/qt/pksvm_gui/mainwindow.cpp
@@ -48,8 +48,14 @@ void MainWindow::setDefaults()
     //tab training
     //m_training="d:\\osgeo\\course\\openstreetmap\\training2.sqlite";
 //    ui->training->setText(m_training);
-    ui->label->setText("label");
     ui->cv->setText("0");
+    ui->training->clear();
+    ui->tln->clear();
+    ui->label->setText("label");
+    QStringList labels;
+    setClassTable(labels);
+    ui->nclass->clear();
+
     //tab input/output
     ui->input->clear();
     ui->msknodata->setText("0");
@@ -188,21 +194,24 @@ void MainWindow::on_pushButton_run_clicked()
             qsOption+=" --prior ";
             qsOption+=ui->tableView_labels->model()->data(ui->tableView_labels->model()->index(irow,2)).toString();
             program+=qsOption;
-            QString qsbalance=ui->tableView_labels->model()->data(ui->tableView_labels->model()->index(irow,3)).toString();
-            if(!qsbalance.isEmpty())
-                qslBalance << qsbalance;
+            if(ui->tableView_labels->model()->columnCount()>3){
+                QString qsbalance=ui->tableView_labels->model()->data(ui->tableView_labels->model()->index(irow,3)).toString();
+                if(!qsbalance.isEmpty())
+                    qslBalance << qsbalance;
+            }
         }
-        for(int irow=0;irow<ui->tableView_labels->model()->rowCount();++irow){
-            QString qsOption;
-            qsOption+=" --balance ";
-            if(qslBalance.size()==ui->tableView_labels->model()->rowCount())
-                qsOption+=qslBalance[irow];
-            else
-                qsOption+=qslBalance[0];
-            program+=qsOption;
+        if(qslBalance.size()){
+            for(int irow=0;irow<ui->tableView_labels->model()->rowCount();++irow){
+                QString qsOption;
+                qsOption+=" --balance ";
+                if(qslBalance.size()==ui->tableView_labels->model()->rowCount())
+                    qsOption+=qslBalance[irow];
+                else
+                    qsOption+=qslBalance[0];
+                program+=qsOption;
+            }
         }
 
-
         QList<QComboBox*> qcomboBoxList = this->findChildren<QComboBox *>();
 
         for(QList<QComboBox*>::ConstIterator qcbit=qcomboBoxList.begin();qcbit!=qcomboBoxList.end();++qcbit){
@@ -253,11 +262,6 @@ void MainWindow::on_pushButton_run_clicked()
     }
 }
 
-void MainWindow::on_toolButton_createTable_clicked()
-{
-
-}
-
 void MainWindow::on_pushButton_restore_clicked()
 {
     setDefaults();
diff --git a/qt/pksvm_gui/mainwindow.h b/qt/pksvm_gui/mainwindow.h
index 3c5fdd9..49d90d5 100644
--- a/qt/pksvm_gui/mainwindow.h
+++ b/qt/pksvm_gui/mainwindow.h
@@ -55,8 +55,6 @@ private slots:
 
     void on_pushButton_run_clicked();
 
-    void on_toolButton_createTable_clicked();
-
     void on_pushButton_restore_clicked();
 
     void on_commandLinkButtonPrepareTable_clicked();
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index e771a18..8f07c1f 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -1181,13 +1181,13 @@ int main(int argc, char *argv[])
 	      std::cout << "creating point feature" << std::endl;
 	    if(writeTest){
 	      if(writeTestLayer->CreateFeature( writeFeature ) != OGRERR_NONE ){
-		std::string errorString="Failed to create feature in shapefile";
+		std::string errorString="Failed to create feature in ogr vector file";
 		throw(errorString);
 	      }
 	    }
 	    else{
 	      if(writeLayer->CreateFeature( writeFeature ) != OGRERR_NONE ){
-		std::string errorString="Failed to create feature in shapefile";
+		std::string errorString="Failed to create feature in ogr vector file";
 		throw(errorString);
 	      }
 	    }
@@ -1484,13 +1484,13 @@ int main(int argc, char *argv[])
 		      std::cout << "creating point feature" << std::endl;
 		    if(writeTest){
 		      if(writeTestLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			std::string errorString="Failed to create feature in test shapefile";
+			std::string errorString="Failed to create feature in test ogr vector file";
 			throw(errorString);
 		      }
 		    }
 		    else{
 		      if(writeLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			std::string errorString="Failed to create feature in shapefile";
+			std::string errorString="Failed to create feature in ogr vector file";
 			throw(errorString);
 		      }
 		    }
@@ -1716,7 +1716,10 @@ int main(int argc, char *argv[])
 		  maxClass=class_opt[maxIndex];
 		  if(verbose_opt[0]>0)
 		    std::cout << "maxClass: " << maxClass << std::endl;
-		  writePolygonFeature->SetField(label_opt[0].c_str(),maxClass);
+		  if(polygon_opt[0])
+		    writePolygonFeature->SetField(label_opt[0].c_str(),maxClass);
+		  else
+		    writeCentroidFeature->SetField(label_opt[0].c_str(),maxClass);
 		}
 	      }
 	      if(polygon_opt[0]){
@@ -1724,13 +1727,13 @@ int main(int argc, char *argv[])
 		  std::cout << "creating polygon feature" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in shapefile";
+		    std::string errorString="Failed to create polygon feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
 		else{
 		  if(writeLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in shapefile";
+		    std::string errorString="Failed to create polygon feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
@@ -1744,7 +1747,7 @@ int main(int argc, char *argv[])
 		  std::cout << "creating point feature in centroid" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in shapefile";
+		    std::string errorString="Failed to create point feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
@@ -1752,7 +1755,7 @@ int main(int argc, char *argv[])
 		  //test
 		  assert(validFeature);
 		  if(writeLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in shapefile";
+		    std::string errorString="Failed to create point feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
@@ -2047,13 +2050,13 @@ int main(int argc, char *argv[])
 			std::cout << "creating point feature" << std::endl;
 		      if(writeTest){
 			if(writeTestLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			  std::string errorString="Failed to create feature in shapefile";
+			  std::string errorString="Failed to create feature in ogr vector file";
 			  throw(errorString);
 			}
 		      }
 		      else{
 			if(writeLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			  std::string errorString="Failed to create feature in shapefile";
+			  std::string errorString="Failed to create feature in ogr vector file";
 			  throw(errorString);
 			}
 		      }
@@ -2280,7 +2283,10 @@ int main(int argc, char *argv[])
 		  maxClass=class_opt[maxIndex];
 		  if(verbose_opt[0]>0)
 		    std::cout << "maxClass: " << maxClass << std::endl;
-		  writePolygonFeature->SetField(label_opt[0].c_str(),maxClass);
+		  if(polygon_opt[0])
+		    writePolygonFeature->SetField(label_opt[0].c_str(),maxClass);
+		  else
+		    writeCentroidFeature->SetField(label_opt[0].c_str(),maxClass);
 		}
 	      }
 
@@ -2289,13 +2295,13 @@ int main(int argc, char *argv[])
 		  std::cout << "creating polygon feature" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in shapefile";
+		    std::string errorString="Failed to create polygon feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
 		else{
 		  if(writeLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in shapefile";
+		    std::string errorString="Failed to create polygon feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
@@ -2309,7 +2315,7 @@ int main(int argc, char *argv[])
 		  std::cout << "creating point feature in centroid" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in shapefile";
+		    std::string errorString="Failed to create point feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
@@ -2317,7 +2323,7 @@ int main(int argc, char *argv[])
 		  //test
 		  assert(validFeature);
 		  if(writeLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in shapefile";
+		    std::string errorString="Failed to create point feature in ogr vector file";
 		    throw(errorString);
 		  }
 		}
diff --git a/src/apps/pkstatogr.cc b/src/apps/pkstatogr.cc
index 074d291..6cbbefd 100644
--- a/src/apps/pkstatogr.cc
+++ b/src/apps/pkstatogr.cc
@@ -106,7 +106,8 @@ int main(int argc, char *argv[])
 	continue;
     if(verbose_opt[0])
       cout << "processing layer " << currentLayername << endl;
-    cout << " --lname " << currentLayername;
+    if(layer_opt.size())
+      cout << " --lname " << currentLayername;
       
     for(int ifield=0;ifield<fieldname_opt.size();++ifield){
       if(verbose_opt[0])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git



More information about the Pkg-grass-devel mailing list