From ccab1978bc249c3b80521482f8dd1bbaf3e021db Mon Sep 17 00:00:00 2001 From: ftomei Date: Thu, 26 Oct 2023 14:41:32 +0200 Subject: [PATCH] remove netcdf --- bin/CRITERIAGEO/criteriaGeoProject.cpp | 46 ++++++++++++++------------ bin/CRITERIAGEO/criteriaGeoProject.h | 4 +-- bin/CRITERIAGEO/gisObject.cpp | 37 ++++++--------------- bin/CRITERIAGEO/gisObject.h | 12 ++++--- bin/CRITERIAGEO/mainWindow.cpp | 21 ++++++++---- bin/CRITERIAGEO/mainWindow.h | 8 ++--- bin/CRITERIAGEO/mainWindow.ui | 3 +- 7 files changed, 63 insertions(+), 68 deletions(-) diff --git a/bin/CRITERIAGEO/criteriaGeoProject.cpp b/bin/CRITERIAGEO/criteriaGeoProject.cpp index 39a4ac0b..9af18d17 100644 --- a/bin/CRITERIAGEO/criteriaGeoProject.cpp +++ b/bin/CRITERIAGEO/criteriaGeoProject.cpp @@ -57,20 +57,22 @@ void CriteriaGeoProject::addRaster(gis::Crit3DRasterGrid *myRaster, QString file } -void CriteriaGeoProject::addNetcdf(NetCDFHandler *myNetcdf, QString fileNameWithPath, int utmZone) +void CriteriaGeoProject::addShapeFile(Crit3DShapeHandler *myShape, QString fileNameWithPath, QString projectName, int utmZone) { GisObject* newObject = new(GisObject); - newObject->setNetcdf(fileNameWithPath, myNetcdf, utmZone); + newObject->setShapeFile(fileNameWithPath, projectName, myShape, utmZone); this->objectList.push_back(newObject); } -void CriteriaGeoProject::addShapeFile(Crit3DShapeHandler *myShape, QString fileNameWithPath, QString projectName, int utmZone) +/* +void CriteriaGeoProject::addNetcdf(NetCDFHandler *myNetcdf, QString fileNameWithPath, int utmZone) { GisObject* newObject = new(GisObject); - newObject->setShapeFile(fileNameWithPath, projectName, myShape, utmZone); + newObject->setNetcdf(fileNameWithPath, myNetcdf, utmZone); this->objectList.push_back(newObject); } +*/ bool CriteriaGeoProject::loadRaster(QString fileNameWithPath) @@ -100,6 +102,7 @@ bool CriteriaGeoProject::loadRaster(QString fileNameWithPath) } +/* bool CriteriaGeoProject::loadNetcdf(QString fileNameWithPath) { NetCDFHandler* netCDF = new NetCDFHandler(); @@ -115,6 +118,7 @@ bool CriteriaGeoProject::loadNetcdf(QString fileNameWithPath) addNetcdf(netCDF, fileNameWithPath, gisSettings.utmZone); return true; } +*/ bool CriteriaGeoProject::loadShapefile(QString fileNameWithPath, QString projectName) @@ -156,7 +160,6 @@ void CriteriaGeoProject::getRasterFromShape(Crit3DShapeHandler &shape, QString f } if (showInfo) formInfo.close(); - } @@ -167,10 +170,10 @@ bool CriteriaGeoProject::addUnitCropMap(Crit3DShapeHandler *shapeCrop, Crit3DSha { std::string errorStr; - Crit3DShapeHandler *shapeUCM = new(Crit3DShapeHandler); - if (isPrevailing) { + Crit3DShapeHandler *shapeUCM = new Crit3DShapeHandler(); + if (computeUcmPrevailing(*shapeUCM, *shapeCrop, *shapeSoil, *shapeMeteo, idCrop, idSoil, idMeteo, cellSize, threshold, ucmFileName, errorStr, showInfo)) { @@ -186,26 +189,27 @@ bool CriteriaGeoProject::addUnitCropMap(Crit3DShapeHandler *shapeCrop, Crit3DSha else { #ifdef GDAL - /* - if (computeUcmIntersection(shapeUCM, shapeCrop, shapeSoil, shapeMeteo, idCrop, idSoil, idMeteo, ucmFileName, &errorStr)) - { - addShapeFile(shapeUCM, QString::fromStdString(shapeUCM->getFilepath()), "", shapeUCM->getUtmZone()); - return true; - } - else - { - logError(QString::fromStdString(errorStr)); + /* + Crit3DShapeHandler *shapeUCM = new Crit3DShapeHandler(); + + if (computeUcmIntersection(shapeUCM, shapeCrop, shapeSoil, shapeMeteo, idCrop, idSoil, idMeteo, ucmFileName, &errorStr)) + { + addShapeFile(shapeUCM, QString::fromStdString(shapeUCM->getFilepath()), "", shapeUCM->getUtmZone()); + return true; + } + else + { + logError(QString::fromStdString(errorStr)); + return false; + } + */ + logError("TO DO function"); return false; - } - */ - logError("TO DO function"); - return false; #else logError("Function is not available (needs GDAL library)"); return false; #endif } - } diff --git a/bin/CRITERIAGEO/criteriaGeoProject.h b/bin/CRITERIAGEO/criteriaGeoProject.h index 9cb3fd28..69b5834c 100644 --- a/bin/CRITERIAGEO/criteriaGeoProject.h +++ b/bin/CRITERIAGEO/criteriaGeoProject.h @@ -30,11 +30,11 @@ bool loadRaster(QString fileNameWithPath); bool loadShapefile(QString fileNameWithPath, QString projectName); - bool loadNetcdf(QString fileNameWithPath); + //bool loadNetcdf(QString fileNameWithPath); void addRaster(gis::Crit3DRasterGrid *myRaster, QString fileNameWithPath, int utmZone); - void addNetcdf(NetCDFHandler *myNetcdf, QString fileNameWithPath, int utmZone); void addShapeFile(Crit3DShapeHandler *myShape, QString fileNameWithPath, QString projectName, int utmZone); + //void addNetcdf(NetCDFHandler *myNetcdf, QString fileNameWithPath, int utmZone); void getRasterFromShape(Crit3DShapeHandler &shape, QString field, QString outputName, double cellSize, bool showInfo); diff --git a/bin/CRITERIAGEO/gisObject.cpp b/bin/CRITERIAGEO/gisObject.cpp index 0f323ef5..dd0932de 100644 --- a/bin/CRITERIAGEO/gisObject.cpp +++ b/bin/CRITERIAGEO/gisObject.cpp @@ -64,18 +64,6 @@ void GisObject::setRaster(QString fileNameWithPath, gis::Crit3DRasterGrid* _rast } -void GisObject::setNetcdf(QString fileNameWithPath, NetCDFHandler* _netcdfPtr, int utmZone) -{ - this->type = gisObjectNetcdf; - this->fileNameWithPath = fileNameWithPath; - this->fileName = getFileName(fileNameWithPath); - this->isSelected = true; - - this->netcdfPtr = _netcdfPtr; - this->gisSettings.utmZone = utmZone; -} - - void GisObject::setShapeFile(QString fileNameWithPath, QString projectName, Crit3DShapeHandler* _shapePtr, int utmZone) { this->type = gisObjectShape; @@ -89,22 +77,18 @@ void GisObject::setShapeFile(QString fileNameWithPath, QString projectName, Crit } -gis::Crit3DRasterGrid* GisObject::getRaster() -{ - return this->rasterPtr; -} - - -Crit3DShapeHandler* GisObject::getShapeHandler() +/* +void GisObject::setNetcdf(QString fileNameWithPath, NetCDFHandler* _netcdfPtr, int utmZone) { - return this->shapePtr; -} - + this->type = gisObjectNetcdf; + this->fileNameWithPath = fileNameWithPath; + this->fileName = getFileName(fileNameWithPath); + this->isSelected = true; -NetCDFHandler* GisObject::getNetcdfHandler() -{ - return this->netcdfPtr; + this->netcdfPtr = _netcdfPtr; + this->gisSettings.utmZone = utmZone; } +*/ void GisObject::close() @@ -120,10 +104,11 @@ void GisObject::close() shapePtr->close(); } + /* if (this->type == gisObjectNetcdf) { netcdfPtr->close(); - } + }*/ this->initialize(); } diff --git a/bin/CRITERIAGEO/gisObject.h b/bin/CRITERIAGEO/gisObject.h index d8213c34..11a424f1 100644 --- a/bin/CRITERIAGEO/gisObject.h +++ b/bin/CRITERIAGEO/gisObject.h @@ -8,9 +8,11 @@ #ifndef SHAPEHANDLER_H #include "shapeHandler.h" #endif +/* #ifndef NETCDFHANDLER_H #include "netcdfHandler.h" #endif +*/ #include @@ -23,7 +25,7 @@ gis::Crit3DRasterGrid* rasterPtr; Crit3DShapeHandler* shapePtr; - NetCDFHandler* netcdfPtr; + //NetCDFHandler* netcdfPtr; void initialize(); @@ -36,13 +38,13 @@ GisObject(); - gis::Crit3DRasterGrid* getRaster(); - Crit3DShapeHandler* getShapeHandler(); - NetCDFHandler* getNetcdfHandler(); + gis::Crit3DRasterGrid* getRaster() { return rasterPtr; } + Crit3DShapeHandler* getShapeHandler() { return shapePtr; } + //NetCDFHandler* getNetcdfHandler() { return netcdfPtr; } void setRaster(QString filename, gis::Crit3DRasterGrid* rasterPtr, int utmZone); - void setNetcdf(QString fileNameWithPath, NetCDFHandler* _netcdfPtr, int utmZone); void setShapeFile(QString filename, QString projectName, Crit3DShapeHandler* shapePtr, int utmZone); + //void setNetcdf(QString fileNameWithPath, NetCDFHandler* _netcdfPtr, int utmZone); void close(); diff --git a/bin/CRITERIAGEO/mainWindow.cpp b/bin/CRITERIAGEO/mainWindow.cpp index bd60595f..9a16bd1e 100644 --- a/bin/CRITERIAGEO/mainWindow.cpp +++ b/bin/CRITERIAGEO/mainWindow.cpp @@ -35,6 +35,7 @@ #include "shapeUtilities.h" #include "utilities.h" #include "formInfo.h" +#include "mapGraphicsRasterObject.h" #ifdef GDAL #include "gdalExtensions.h" @@ -313,9 +314,9 @@ void MainWindow::addRasterObject(GisObject* myObject) item->setCheckState(Qt::Checked); ui->checkList->addItem(item); - RasterObject* newRasterObj = new RasterObject(this->mapView); + RasterUtmObject* newRasterObj = new RasterUtmObject(this->mapView); newRasterObj->setOpacity(0.66); - newRasterObj->initializeUTM(myObject->getRaster(), myObject->gisSettings, false); + newRasterObj->initialize(myObject->getRaster(), myObject->gisSettings); this->rasterObjList.push_back(newRasterObj); this->mapView->scene()->addObject(newRasterObj); @@ -323,6 +324,7 @@ void MainWindow::addRasterObject(GisObject* myObject) } +/* void MainWindow::addNetcdfObject(GisObject* myObject) { QListWidgetItem* item = new QListWidgetItem("[NETCDF] " + myObject->fileName); @@ -349,6 +351,7 @@ void MainWindow::addNetcdfObject(GisObject* myObject) this->mapView->scene()->addObject(netcdfObj); this->updateMaps(); } +*/ bool MainWindow::addShapeObject(GisObject* myObject) @@ -394,13 +397,13 @@ bool MainWindow::addShapeObject(GisObject* myObject) // resize and center map on last raster size void MainWindow::zoomOnLastRaster() { - RasterObject* myRaster = this->rasterObjList.back(); + RasterUtmObject* myRaster = this->rasterObjList.back(); - gis::Crit3DGeoPoint* center = myRaster->getRasterCenter(); + Position center = myRaster->getRasterCenter(); float size = myRaster->getRasterMaxSize(); this->mapView->setZoomLevel(quint8(log2(float(ui->widgetMap->width()) / size))); - this->mapView->centerOn(qreal(center->longitude), qreal(center->latitude)); + this->mapView->centerOn(center.longitude(), center.latitude()); this->updateMaps(); } @@ -431,6 +434,7 @@ void MainWindow::on_actionLoadRaster_triggered() } +/* void MainWindow::on_actionLoad_NetCDF_triggered() { QString fileNameWithPath = QFileDialog::getOpenFileName(this, tr("Open NetCDF file"), "", tr("NetCDF files (*.nc)")); @@ -444,6 +448,7 @@ void MainWindow::on_actionLoad_NetCDF_triggered() this->addNetcdfObject(myObject); this->zoomOnLastRaster(); } +*/ void MainWindow::on_actionLoadShapefile_triggered() @@ -469,11 +474,13 @@ int MainWindow::getRasterIndex(GisObject* myObject) if (rasterObjList.at(i)->getRaster() == myObject->getRaster()) return i; } + /* else if (myObject->type == gisObjectNetcdf) { if (rasterObjList.at(i)->getRaster() == myObject->getNetcdfHandler()->getRaster()) return i; } + */ } return NODATA; @@ -548,7 +555,7 @@ void MainWindow::removeRaster(GisObject* myObject) } -RasterObject* MainWindow::getRasterObject(GisObject* myObject) +RasterUtmObject* MainWindow::getRasterObject(GisObject* myObject) { int i = getRasterIndex(myObject); @@ -706,7 +713,7 @@ void MainWindow::itemMenuRequested(const QPoint point) GisObject* myObject = myProject.objectList.at(unsigned(pos)); QMenu submenu; - RasterObject* myRasterObject = getRasterObject(myObject); + RasterUtmObject* myRasterObject = getRasterObject(myObject); MapGraphicsShapeObject* myShapeObject = getShapeObject(myObject); if (myObject->type == gisObjectShape) diff --git a/bin/CRITERIAGEO/mainWindow.h b/bin/CRITERIAGEO/mainWindow.h index e134fa95..35b48e75 100644 --- a/bin/CRITERIAGEO/mainWindow.h +++ b/bin/CRITERIAGEO/mainWindow.h @@ -7,7 +7,7 @@ #include "tileSources/WebTileSource.h" #include "Position.h" - #include "mapGraphicsRasterObject.h" + #include "mapGraphicsRasterUtm.h" #include "mapGraphicsShapeObject.h" #include "colorLegend.h" #include "criteriaGeoProject.h" @@ -56,8 +56,6 @@ void on_actionClose_Project_triggered(); void closeGeoProject(); - void on_actionLoad_NetCDF_triggered(); - protected: /*! * \brief mouseReleaseEvent call moveCenter @@ -87,7 +85,7 @@ Position* startCenter; MapGraphicsScene* mapScene; MapGraphicsView* mapView; - std::vector rasterObjList; + std::vector rasterObjList; std::vector shapeObjList; void setTileSource(WebTileSource::WebTileType tileType); @@ -108,7 +106,7 @@ bool exportToNetCDF(GisObject* myObject); MapGraphicsShapeObject* getShapeObject(GisObject* myObject); - RasterObject* getRasterObject(GisObject* myObject); + RasterUtmObject* getRasterObject(GisObject* myObject); QPoint getMapPos(const QPoint& screenPos); bool isInsideMap(const QPoint& pos); diff --git a/bin/CRITERIAGEO/mainWindow.ui b/bin/CRITERIAGEO/mainWindow.ui index d344e42c..3678abfc 100644 --- a/bin/CRITERIAGEO/mainWindow.ui +++ b/bin/CRITERIAGEO/mainWindow.ui @@ -302,7 +302,7 @@ 0 0 1280 - 25 + 20 @@ -543,7 +543,6 @@ -