Skip to content

Commit

Permalink
Merging bug fixes made on genericInterface branch
Browse files Browse the repository at this point in the history
  • Loading branch information
zcobell committed Feb 22, 2020
1 parent c7824fc commit 3471e13
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 52 deletions.
57 changes: 53 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,58 @@
MetOceanViewer.pro.user
nsis/MetOceanViewer_installer_v2.0.154.exe
*.exe
mov_libs
MetOceanViewer_installer/packages_windows/com.zachcobell.metoceanviewer/data
MetOceanViewer_installer/packages_windows/com.microsoft.vcredist/data
MetOceanViewer_installer/packages_unix/com.qt.qtsharedlibraries/data
MetOceanViewer_installer/packages_unix/com.unidata.netcdf/data
MetOceanViewer_installer/packages_unix/com.zachcobell.metoceanviewer/data

# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib

# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl

# Qt unit tests
target_wrapper.*

# QtCreator
*.autosave

# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*

# QtCreator CMake
CMakeLists.txt.user*

# QtCreator 4.8< compilation database
compile_commands.json

# QtCreator local machine specific files for imported projects
*creator.user*
6 changes: 3 additions & 3 deletions MetOceanInstaller/buildInstaller_Windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ redist=1
autoredist=0
redistexe="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Redist/MSVC/14.16.27012/vc_redist.x64.exe"
msvcVersion=2017
QtVersion=5_12_3
QtVersion=5_13_1
compileDirectory="../../build-MetOcean-Desktop_Qt_"$QtVersion"_MSVC"$msvcVersion"_64bit-Release"
winDeployQtBinary=/cygdrive/c/Qt/5.12.3/msvc2017_64/bin/windeployqt.exe
binaryCreator=/cygdrive/c/Qt/Tools/QtInstallerFramework/3.0/bin/binarycreator.exe
winDeployQtBinary=/cygdrive/c/Qt/5.13.1/msvc2017_64/bin/windeployqt.exe
binaryCreator=/cygdrive/c/Qt/Tools/QtInstallerFramework/3.1/bin/binarycreator.exe
version=$(git describe --always --tags)

if [ $redist == 1 ] ; then
Expand Down
2 changes: 1 addition & 1 deletion MetOceanViewer/qml/MapViewer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Rectangle {
anchors.fill: parent
activeMapType: supportedMapTypes[mapType]
plugin: mapPlugin;
copyrightsVisible: true
copyrightsVisible: false

property MovMapItem previousMarker

Expand Down
2 changes: 1 addition & 1 deletion MetOceanViewer/src/adcircstationoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int AdcircStationOutput::readAscii(QString AdcircOutputFile,
for (size_t i = 0; i < this->nSnaps; ++i) {
TempLine = MyFile.readLine().simplified();
TempList = TempLine.split(" ");
this->time[i] = TempList.value(1).toDouble();
this->time[i] = TempList.value(0).toDouble();
for (size_t j = 0; j < this->nStations; ++j) {
TempLine = MyFile.readLine().simplified();
TempList = TempLine.split(" ");
Expand Down
41 changes: 17 additions & 24 deletions MetOceanViewer/src/usertimeseries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void UserTimeseries::addMultipleStationsToPlot(
double addY = this->m_table->item(index, 5)->text().toDouble();

for (int j = 0; j < st->numSnaps(); j++) {
if (st->data(j) != HmdfStation::nullDataValue() &&
if (std::abs(st->data(j) - st->nullValue()) > 0.0001 &&
st->date(j) >= startDate && st->date(j) <= endDate) {
maxDate = std::max(st->date(j) + addX - offset, maxDate);
minDate = std::min(st->date(j) + addX - offset, minDate);
Expand Down Expand Up @@ -592,7 +592,7 @@ int UserTimeseries::processData() {
// and not show data where it doesn't exist for
// certain files
//-------------------------------------------//
int UserTimeseries::getUniqueStationList(QVector<Hmdf *> Data,
int UserTimeseries::getUniqueStationList(QVector<Hmdf *> &Data,
QVector<double> &X,
QVector<double> &Y) {
for (int i = 0; i < Data.length(); i++) {
Expand All @@ -601,7 +601,7 @@ int UserTimeseries::getUniqueStationList(QVector<Hmdf *> Data,
for (int k = 0; k < X.length(); k++) {
double dx = Data[i]->station(j)->longitude() - X[k];
double dy = Data[i]->station(j)->latitude() - Y[k];
double d = qSqrt(qPow(dx, 2.0) + qPow(dy, 2.0));
double d = std::sqrt(std::pow(dx, 2.0) + std::pow(dy, 2.0));
if (d < this->m_duplicateStationTolerance) {
found = true;
break;
Expand All @@ -613,6 +613,7 @@ int UserTimeseries::getUniqueStationList(QVector<Hmdf *> Data,
}
}
}
qDebug() << X.size();
return MetOceanViewer::Error::NOERR;
}
//-------------------------------------------//
Expand All @@ -622,8 +623,9 @@ int UserTimeseries::getUniqueStationList(QVector<Hmdf *> Data,
// which will have null data where there was
// not data in the file
//-------------------------------------------//
int UserTimeseries::buildRevisedIMEDS(QVector<Hmdf *> Data, QVector<double> X,
QVector<double> Y,
int UserTimeseries::buildRevisedIMEDS(QVector<Hmdf *> Data,
const QVector<double> &X,
const QVector<double> &Y,
QVector<Hmdf *> &DataOut) {
DataOut.resize(Data.length());

Expand All @@ -632,37 +634,28 @@ int UserTimeseries::buildRevisedIMEDS(QVector<Hmdf *> Data, QVector<double> X,
DataOut[i]->setHeader1(Data[i]->header1());
DataOut[i]->setHeader2(Data[i]->header2());
DataOut[i]->setHeader3(Data[i]->header3());

for (int j = 0; j < X.length(); j++) {
HmdfStation *station = new HmdfStation(DataOut[i]);
station->setLongitude(X[j]);
station->setLatitude(Y[j]);
DataOut[i]->addStation(station);
}
}

for (int i = 0; i < Data.length(); i++) {
for (int j = 0; j < DataOut[i]->nstations(); j++) {
for (int j = 0; j < X.length(); j++) {
bool found = false;
for (int k = 0; k < Data[i]->nstations(); k++) {
double dx = Data[i]->station(k)->longitude() -
DataOut[i]->station(j)->longitude();
double dy = Data[i]->station(k)->latitude() -
DataOut[i]->station(j)->latitude();
double d = qSqrt(qPow(dx, 2.0) + qPow(dy, 2.0));
double dx = Data[i]->station(k)->longitude() - X[j];
double dy = Data[i]->station(k)->latitude() - Y[j];
double d = std::sqrt(std::pow(dx, 2.0) + std::pow(dy, 2.0));
if (d < this->m_duplicateStationTolerance) {
DataOut[i]->station(j)->setName(Data[i]->station(k)->name());
DataOut[i]->station(j)->setData(Data[i]->station(k)->allData());
DataOut[i]->station(j)->setDate(Data[i]->station(k)->allDate());
DataOut[i]->station(j)->setNullValue(
Data[i]->station(k)->nullValue());
DataOut[i]->station(j)->setIsNull(false);
HmdfStation *p = Data[i]->station(k);
p->setIsNull(false);
DataOut[i]->addStation(p);
found = true;
break;
}
}
if (!found) {
// Build a station with a null dataset we can find later
DataOut[i]->addStation(new HmdfStation(DataOut[i]));
DataOut[i]->station(j)->setLongitude(X[j]);
DataOut[i]->station(j)->setLatitude(Y[j]);
DataOut[i]->station(j)->setName("NONAME");
DataOut[i]->station(j)->setNext(HmdfStation::nullDateValue(),
HmdfStation::nullDataValue());
Expand Down
6 changes: 3 additions & 3 deletions MetOceanViewer/src/usertimeseries.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class UserTimeseries : public QObject {
//...Private functions
int getStationSelections();
int setMarkerID();
int getUniqueStationList(QVector<Hmdf *> Data, QVector<double> &X,
int getUniqueStationList(QVector<Hmdf *> &Data, QVector<double> &X,
QVector<double> &Y);
int buildRevisedIMEDS(QVector<Hmdf *> Data, QVector<double> X,
QVector<double> Y, QVector<Hmdf *> &DataOut);
int buildRevisedIMEDS(QVector<Hmdf *> Data, const QVector<double> &X,
const QVector<double> &Y, QVector<Hmdf *> &DataOut);
int getDataBounds(double &ymin, double &ymax, QDateTime &minDateOut,
QDateTime &maxDateOut, QVector<double> &timeAddList);
int getMultipleMarkersFromMap();
Expand Down
10 changes: 10 additions & 0 deletions libraries/libmetocean/datum.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
#define VDATUM_H

#include <QString>
#include <QStringList>

namespace Datum {
enum VDatum { NullDatum, MLLW, MLW, MSL, MHW, MHHW, NGVD29, NAVD88 };

static QStringList noaaDatumList() {
return {"MHHW", "MHW", "MTL", "MSL", "MLW", "MLLW",
"NAVD", "LWI", "HWI", "IGLD", "STND"};
}

static QStringList vDatumList() {
return {"MHHW", "MHW", "MSL", "MLW", "MLLW", "NGVD29", "NAVD88"};
}

static QString datumName(VDatum datum) {
if (datum == NullDatum)
return "none";
Expand Down
7 changes: 5 additions & 2 deletions libraries/libmetocean/hmdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void Hmdf::setStation(int index, HmdfStation *station) {
}

void Hmdf::addStation(HmdfStation *station) {
if (station->parent() != this) {
station->setParent(this); //...Take ownership over
}
this->m_station.push_back(station);
}

Expand Down Expand Up @@ -476,7 +479,7 @@ void Hmdf::dataBounds(qint64 &dateMin, qint64 &dateMax, double &minValue,
maxValue = -std::numeric_limits<double>::max();
minValue = std::numeric_limits<double>::max();

for (int i = 0; i < this->nstations(); i++) {
for (size_t i = 0; i < this->nstations(); ++i) {
qint64 tempDateMin, tempDateMax;
double tempMinValue, tempMaxValue;
if (!this->station(i)->isNull()) {
Expand All @@ -491,7 +494,7 @@ void Hmdf::dataBounds(qint64 &dateMin, qint64 &dateMax, double &minValue,
return;
}

bool Hmdf::applyDatumCorrection(Station &s, Datum::VDatum datum) {
bool Hmdf::applyDatumCorrection(const Station &s, const Datum::VDatum &datum) {
int ierr = 0;
for (auto &stn : this->m_station) {
ierr += stn->applyDatumCorrection(s, datum);
Expand Down
3 changes: 2 additions & 1 deletion libraries/libmetocean/hmdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <ctime>
#include <string>
#include <vector>

#include "hmdfstation.h"
#include "metocean_global.h"
#include "timezone.h"
Expand Down Expand Up @@ -82,7 +83,7 @@ class Hmdf : public QObject {
void dataBounds(qint64 &dateMin, qint64 &dateMax, double &minValue,
double &maxValue);

bool applyDatumCorrection(Station &s, Datum::VDatum datum);
bool applyDatumCorrection(const Station &s, const Datum::VDatum &datum);
bool applyDatumCorrection(QVector<Station> &s, Datum::VDatum datum);

private:
Expand Down
10 changes: 7 additions & 3 deletions libraries/libmetocean/noaacoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//
//-----------------------------------------------------------------------*/
#include "noaacoops.h"

#include <QEventLoop>
#include <QJsonArray>
#include <QJsonDocument>
Expand All @@ -26,15 +27,17 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>

#include "boost/algorithm/string/split.hpp"
#include "boost/algorithm/string/trim.hpp"
#include "boost/config/warning_disable.hpp"
#include "boost/spirit/include/phoenix.hpp"
#include "boost/spirit/include/qi.hpp"

NoaaCoOps::NoaaCoOps(Station &station, QDateTime startDate, QDateTime endDate,
QString product, QString datum, bool useVdatum,
QString units, QObject *parent)
NoaaCoOps::NoaaCoOps(const Station &station, const QDateTime startDate,
const QDateTime endDate, const QString &product,
const QString &datum, const bool useVdatum,
const QString &units, QObject *parent)
: WaterData(station, startDate, endDate, parent),
m_product(product),
m_units(units),
Expand Down Expand Up @@ -324,6 +327,7 @@ int NoaaCoOps::formatNoaaResponseJson(std::vector<std::string> &downloadedData,
}

if (station->numSnaps() > 3) {
station->setIsNull(false);
outputData->addStation(station);
return 0;
} else {
Expand Down
4 changes: 2 additions & 2 deletions libraries/libmetocean/noaacoops.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
class NoaaCoOps : public WaterData {
Q_OBJECT
public:
NoaaCoOps(Station &station, QDateTime startDate, QDateTime endDate,
QString product, QString datum, bool useVdatum, QString units,
NoaaCoOps(const Station &station, const QDateTime startDate, const QDateTime endDate,
const QString &product, const QString &datum, const bool useVdatum,const QString &units,
QObject *parent = nullptr);

private:
Expand Down
15 changes: 13 additions & 2 deletions libraries/libmetocean/station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
//
//-----------------------------------------------------------------------*/
#include "station.h"

#include <cmath>

Station::Station()
: m_coordinate(QGeoCoordinate()),
m_id(QString()),
m_name(QString()),
m_id("null"),
m_name("null"),
m_measured(0.0),
m_modeled(0.0),
m_selected(false),
Expand Down Expand Up @@ -62,6 +63,16 @@ Station::Station(QGeoCoordinate coordinate, QString id, QString name,

Station::~Station() {}

bool Station::operator==(const Station &s) {
if (this->id() == s.id() &&
this->coordinate().latitude() == s.coordinate().latitude() &&
this->coordinate().longitude() == s.coordinate().longitude() &&
this->name() == s.name()) {
return true;
}
return false;
}

QGeoCoordinate Station::coordinate() const { return this->m_coordinate; }

void Station::setLatitude(const double latitude) {
Expand Down
2 changes: 2 additions & 0 deletions libraries/libmetocean/station.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Station {

~Station();

bool operator==(const Station &s);

QGeoCoordinate coordinate() const;
void setCoordinate(const QGeoCoordinate &coordinate);
void setLatitude(const double latitude);
Expand Down
2 changes: 1 addition & 1 deletion libraries/libmetocean/tideprediction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int TidePrediction::get(Station &s, QDateTime startDate, QDateTime endDate,
.getStationRefByName(s.name().toStdString().c_str());

if (sr) {
std::auto_ptr<libxtide::Station> station(sr->load());
std::unique_ptr<libxtide::Station> station(sr->load());

station->step = interval;

Expand Down
2 changes: 1 addition & 1 deletion libraries/libmetocean/waterdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//-----------------------------------------------------------------------*/
#include "waterdata.h"

WaterData::WaterData(Station &station, QDateTime startDate, QDateTime endDate,
WaterData::WaterData(const Station &station, const QDateTime startDate, const QDateTime endDate,
QObject *parent)
: QObject(parent) {
this->m_errorString = QString();
Expand Down
7 changes: 4 additions & 3 deletions libraries/libmetocean/waterdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@

#include <QNetworkReply>
#include <QObject>

#include "datum.h"
#include "hmdf.h"
#include "metocean_global.h"
#include "station.h"
#include "timezone.h"
#include "datum.h"

class WaterData : public QObject {
Q_OBJECT
public:
explicit WaterData(Station &station, QDateTime startDate, QDateTime endDate,
QObject *parent = nullptr);
explicit WaterData(const Station &station, const QDateTime startDate,
const QDateTime endDate, QObject *parent = nullptr);

int get(Hmdf *data, Datum::VDatum datum = Datum::VDatum::NullDatum);

Expand Down
Loading

0 comments on commit 3471e13

Please sign in to comment.