Skip to content

Commit

Permalink
remove netcdf
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Oct 26, 2023
1 parent 2ed82b4 commit ccab197
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 68 deletions.
46 changes: 25 additions & 21 deletions bin/CRITERIAGEO/criteriaGeoProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -100,6 +102,7 @@ bool CriteriaGeoProject::loadRaster(QString fileNameWithPath)
}


/*
bool CriteriaGeoProject::loadNetcdf(QString fileNameWithPath)
{
NetCDFHandler* netCDF = new NetCDFHandler();
Expand All @@ -115,6 +118,7 @@ bool CriteriaGeoProject::loadNetcdf(QString fileNameWithPath)
addNetcdf(netCDF, fileNameWithPath, gisSettings.utmZone);
return true;
}
*/


bool CriteriaGeoProject::loadShapefile(QString fileNameWithPath, QString projectName)
Expand Down Expand Up @@ -156,7 +160,6 @@ void CriteriaGeoProject::getRasterFromShape(Crit3DShapeHandler &shape, QString f
}

if (showInfo) formInfo.close();

}


Expand All @@ -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))
{
Expand All @@ -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
}

}


Expand Down
4 changes: 2 additions & 2 deletions bin/CRITERIAGEO/criteriaGeoProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
37 changes: 11 additions & 26 deletions bin/CRITERIAGEO/gisObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -120,10 +104,11 @@ void GisObject::close()
shapePtr->close();
}

/*
if (this->type == gisObjectNetcdf)
{
netcdfPtr->close();
}
}*/

this->initialize();
}
Expand Down
12 changes: 7 additions & 5 deletions bin/CRITERIAGEO/gisObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
#ifndef SHAPEHANDLER_H
#include "shapeHandler.h"
#endif
/*
#ifndef NETCDFHANDLER_H
#include "netcdfHandler.h"
#endif
*/

#include <QString>

Expand All @@ -23,7 +25,7 @@

gis::Crit3DRasterGrid* rasterPtr;
Crit3DShapeHandler* shapePtr;
NetCDFHandler* netcdfPtr;
//NetCDFHandler* netcdfPtr;

void initialize();

Expand All @@ -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();

Expand Down
21 changes: 14 additions & 7 deletions bin/CRITERIAGEO/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "shapeUtilities.h"
#include "utilities.h"
#include "formInfo.h"
#include "mapGraphicsRasterObject.h"

#ifdef GDAL
#include "gdalExtensions.h"
Expand Down Expand Up @@ -313,16 +314,17 @@ 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);
this->updateMaps();
}


/*
void MainWindow::addNetcdfObject(GisObject* myObject)
{
QListWidgetItem* item = new QListWidgetItem("[NETCDF] " + myObject->fileName);
Expand All @@ -349,6 +351,7 @@ void MainWindow::addNetcdfObject(GisObject* myObject)
this->mapView->scene()->addObject(netcdfObj);
this->updateMaps();
}
*/


bool MainWindow::addShapeObject(GisObject* myObject)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)"));
Expand All @@ -444,6 +448,7 @@ void MainWindow::on_actionLoad_NetCDF_triggered()
this->addNetcdfObject(myObject);
this->zoomOnLastRaster();
}
*/


void MainWindow::on_actionLoadShapefile_triggered()
Expand All @@ -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;
Expand Down Expand Up @@ -548,7 +555,7 @@ void MainWindow::removeRaster(GisObject* myObject)
}


RasterObject* MainWindow::getRasterObject(GisObject* myObject)
RasterUtmObject* MainWindow::getRasterObject(GisObject* myObject)
{
int i = getRasterIndex(myObject);

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions bin/CRITERIAGEO/mainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -56,8 +56,6 @@
void on_actionClose_Project_triggered();
void closeGeoProject();

void on_actionLoad_NetCDF_triggered();

protected:
/*!
* \brief mouseReleaseEvent call moveCenter
Expand Down Expand Up @@ -87,7 +85,7 @@
Position* startCenter;
MapGraphicsScene* mapScene;
MapGraphicsView* mapView;
std::vector<RasterObject *> rasterObjList;
std::vector<RasterUtmObject *> rasterObjList;
std::vector<MapGraphicsShapeObject *> shapeObjList;

void setTileSource(WebTileSource::WebTileType tileType);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions bin/CRITERIAGEO/mainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
<x>0</x>
<y>0</y>
<width>1280</width>
<height>25</height>
<height>20</height>
</rect>
</property>
<property name="palette">
Expand Down Expand Up @@ -543,7 +543,6 @@
<addaction name="separator"/>
<addaction name="actionLoadShapefile"/>
<addaction name="actionLoadRaster"/>
<addaction name="actionLoad_NetCDF"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuGIS_settings">
Expand Down

0 comments on commit ccab197

Please sign in to comment.