From 5c529e4cd70a8634fed97f51a86d053685e99cde Mon Sep 17 00:00:00 2001 From: Hugo Van Ruyskensvelde Date: Sun, 22 Nov 2020 15:46:45 +0100 Subject: [PATCH] Solved some bugs in the display of MERSI images. Added the Oblique Mercator projection for VIIRS M, MERSI and Metop images. --- core/avhrrsatellite.cpp | 12 +- core/core.pro | 2 + core/dialogpreferences.cpp | 11 + core/dialogpreferences.h | 3 + core/formephem.cpp | 11 +- core/formimage.cpp | 218 +++++- core/formtoolbox.cpp | 1062 ++++++++++++++++----------- core/formtoolbox.h | 16 + core/formtoolbox.ui | 146 +++- core/generalverticalperspective.cpp | 7 +- core/globals.cpp | 302 +++++--- core/globals.h | 6 +- core/lambertconformalconic.cpp | 7 +- core/main.cpp | 3 +- core/mainwindow.cpp | 23 +- core/obliquemercator.cpp | 949 ++++++++++++++++++++++++ core/obliquemercator.h | 90 +++ core/satgl.cpp | 38 +- core/segment.cpp | 16 +- core/segment.h | 8 +- core/segmentgl.cpp | 19 +- core/segmentimage.h | 3 + core/segmentlist.cpp | 163 +++- core/segmentlist.h | 4 + core/segmentlistmersi.cpp | 212 +++++- core/segmentlistmersi.h | 10 +- core/segmentlistmetop.cpp | 53 +- core/segmentlistmetop.h | 1 + core/segmentlistviirsm.cpp | 130 ++++ core/segmentlistviirsm.h | 8 +- core/segmentmersi.cpp | 282 +++++-- core/segmentmersi.h | 12 +- core/segmentmetop.cpp | 179 +++-- core/segmentmetop.h | 5 + core/segmentnoaa.cpp | 14 +- core/segmentviirsm.cpp | 242 ++++-- core/segmentviirsm.h | 6 + core/stereographic.cpp | 3 + 38 files changed, 3418 insertions(+), 858 deletions(-) create mode 100644 core/obliquemercator.cpp create mode 100644 core/obliquemercator.h diff --git a/core/avhrrsatellite.cpp b/core/avhrrsatellite.cpp index e0ce15b..d454bce 100644 --- a/core/avhrrsatellite.cpp +++ b/core/avhrrsatellite.cpp @@ -379,12 +379,13 @@ void AVHRRSatellite::AddSegmentsToList(QFileInfoList fileinfolist) } else delete segslstr; - } else if (fileInfo.fileName().mid( 0, 4) == "FY3D" && fileInfo.fileName().mid(40, 5) == "1000M") + } else if (fileInfo.fileName().mid( 0, 4) == "FY3D" && (fileInfo.fileName().mid(39, 5) == "1000M" || fileInfo.fileName().mid(40, 5) == "1000M")) { //012345678901234567890123456789012345678901234567890 //0 1 2 3 4 5 6 7 8 9 10 //FY3D_20200113_113000_113100_11206_MERSI_1000M_L1B.HDF //FY3D_20200113_113000_113100_11206_MERSI_GEO1K_L1B.HDF + //FY3D_20191007_193900_194000_9821_MERSI_1000M_L1B.HDF seglmersi->SetDirectoryName(fileInfo.absolutePath()); segmersi = new SegmentMERSI(fileInfo, satlist); if(segmersi->segmentok == true) @@ -709,8 +710,8 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) qDebug() << QString("fileinfolist.size = %1 in subdir %2").arg(fileinfolist.size()).arg(thepathYYYYMMDD); } -// for(int i= 0; i < fileinfolist.size(); i++) -// qDebug() << "list = " << fileinfolist.at(i).absoluteFilePath(); + for(int i= 0; i < fileinfolist.size(); i++) + qDebug() << "list = " << fileinfolist.at(i).absoluteFilePath(); QMap map; @@ -820,8 +821,8 @@ void AVHRRSatellite::ReadDirectories(QDate seldate, int hoursbefore) fileinfolist = map.values(); -// for(int i = 0; i < fileinfolist.count(); i++) -// qDebug() << "map values = " << fileinfolist.at(i).absoluteFilePath(); + for(int i = 0; i < fileinfolist.count(); i++) + qDebug() << "map values = " << fileinfolist.at(i).absoluteFilePath(); emit signalResetProgressbar(fileinfolist.size(), (*its)); @@ -1205,6 +1206,7 @@ void AVHRRSatellite::InsertToMap(QFileInfoList fileinfolist, QMapinsertRows(myVIIRSMConfigModel->rowCount(), 1, QModelIndex()); } +void DialogPreferences::addMERSIConfigRow() +{ + myMERSIConfigModel->insertRows(myMERSIConfigModel->rowCount(), 1, QModelIndex()); +} + void DialogPreferences::deleteVIIRSMConfigRow() { int row = ui->tbvVIIRSMConfig->currentIndex().row(); myVIIRSMConfigModel->removeRow(row, QModelIndex()); } +void DialogPreferences::deleteMERSIConfigRow() +{ + int row = ui->tbvMERSIConfig->currentIndex().row(); + myMERSIConfigModel->removeRow(row, QModelIndex()); +} + void DialogPreferences::addGeoConfigRow() { diff --git a/core/dialogpreferences.h b/core/dialogpreferences.h index b9757a2..b13129b 100644 --- a/core/dialogpreferences.h +++ b/core/dialogpreferences.h @@ -57,6 +57,9 @@ private slots: void deleteOLCIefrConfigRow(); void addSLSTRConfigRow(); void deleteSLSTRConfigRow(); + void addMERSIConfigRow(); + void deleteMERSIConfigRow(); + void on_btnLocalDirRemote_clicked(); diff --git a/core/formephem.cpp b/core/formephem.cpp index 8d1fef9..178ba68 100644 --- a/core/formephem.cpp +++ b/core/formephem.cpp @@ -21,10 +21,10 @@ FormEphem::FormEphem(QWidget *parent, SatelliteList *satlist, AVHRRSatellite *se { ui->setupUi(this); -// if(ui->splitter->restoreState( opts.ephemsplittersizes )) -// qDebug() << "splitter ok"; -// else -// qDebug() << "splitter not ok"; + if(ui->splitter->restoreState( opts.ephemsplittersizes )) + qDebug() << "splitter ok"; + else + qDebug() << "splitter not ok"; sats = satlist; @@ -190,8 +190,7 @@ void FormEphem::on_btnDel_clicked() if ( (*it1)->isSelected() ) { if( (*it1)->parent() ) - QMessageBox::information( this, "QtTrack", - "Only Tle files can be removed !" ); + QMessageBox::information( this, "QtTrack", "Only Tle files can be removed !" ); else sel = (*it1)->text( 0 ); break; diff --git a/core/formimage.cpp b/core/formimage.cpp index 361cf6c..0ab59e8 100644 --- a/core/formimage.cpp +++ b/core/formimage.cpp @@ -141,8 +141,8 @@ bool FormImage::toggleOverlayProjection() void FormImage::setPixmapToLabel(bool settoolboxbuttons) { - qDebug() << "FormImage::setPixmapToLabel(bool settoolboxbuttons) width = " << imageptrs->ptrimageMERSI->size().width() << " height = " - << imageptrs->ptrimageMERSI->size().height() << " channelshown = " << channelshown; +// qDebug() << "FormImage::setPixmapToLabel(bool settoolboxbuttons) width = " << imageptrs->ptrimageMERSI->size().width() << " height = " +// << imageptrs->ptrimageMERSI->size().height() << " channelshown = " << channelshown; refreshoverlay = true; @@ -231,13 +231,13 @@ void FormImage::setPixmapToLabelDNB(bool settoolboxbuttons) void FormImage::displayImage(eImageType channel) { - qDebug() << QString("FormImage::displayImage(eImageType channel) channel = %1").arg(channel); - qDebug() << QString("FormImage ptrimagecomp[0] bytecount = %1").arg(imageptrs->ptrimagecomp_ch[0]->byteCount()); - qDebug() << QString("FormImage ptrimageviirsm bytecount = %1").arg(imageptrs->ptrimageViirsM->byteCount()); - qDebug() << QString("FormImage ptrimageviirsdnb bytecount = %1").arg(imageptrs->ptrimageViirsDNB->byteCount()); - qDebug() << QString("FormImage ptrimageolci bytecount = %1").arg(imageptrs->ptrimageOLCI->byteCount()); - qDebug() << QString("FormImage ptrimageslstr bytecount = %1").arg(imageptrs->ptrimageSLSTR->byteCount()); - qDebug() << QString("FormImage ptrimagemersi bytecount = %1").arg(imageptrs->ptrimageMERSI->byteCount()); +// qDebug() << QString("FormImage::displayImage(eImageType channel) channel = %1").arg(channel); +// qDebug() << QString("FormImage ptrimagecomp[0] bytecount = %1").arg(imageptrs->ptrimagecomp_ch[0]->byteCount()); +// qDebug() << QString("FormImage ptrimageviirsm bytecount = %1").arg(imageptrs->ptrimageViirsM->byteCount()); +// qDebug() << QString("FormImage ptrimageviirsdnb bytecount = %1").arg(imageptrs->ptrimageViirsDNB->byteCount()); +// qDebug() << QString("FormImage ptrimageolci bytecount = %1").arg(imageptrs->ptrimageOLCI->byteCount()); +// qDebug() << QString("FormImage ptrimageslstr bytecount = %1").arg(imageptrs->ptrimageSLSTR->byteCount()); +// qDebug() << QString("FormImage ptrimagemersi bytecount = %1").arg(imageptrs->ptrimageMERSI->byteCount()); this->channelshown = channel; @@ -447,13 +447,14 @@ void FormImage::displayImage(eImageType channel) } } + refreshoverlay = true; this->update(); this->adjustImage(); - qDebug() << QString("after FormImage::displayImage(eImageType channel) channel = %1").arg(channel); +// qDebug() << QString("after FormImage::displayImage(eImageType channel) channel = %1").arg(channel); } @@ -1092,9 +1093,22 @@ bool FormImage::ShowMERSIImage() this->kindofimage = "MERSI"; - bandlist = formtoolbox->getMERSIBandList(); - colorlist = formtoolbox->getMERSIColorList(); + bandlist = formtoolbox->getMERSIBandList(); // 16 items + colorlist = formtoolbox->getMERSIColorList(); // 15 items invertlist = formtoolbox->getMERSIInvertList(); + +// qDebug()<< "FormImage::ShowMERSIImage() bandlist"; +// for(int i = 0; i < 16; i++) +// { +// qDebug() << bandlist.at(i); +// } + +// qDebug()<< "FormImage::ShowMERSIImage() colorlist"; +// for(int i = 0; i < 15; i++) +// { +// qDebug() << colorlist.at(i); +// } + //segs->seglmersi->setHistogramMethod(histogrammethod); segs->seglmersi->ComposeMERSIImage(bandlist, colorlist, invertlist, false); } @@ -3748,6 +3762,8 @@ void FormImage::OverlayAVHRRImage(QPainter *paint) void FormImage::OverlayProjection(QPainter *paint) { qDebug() << QString("FormImage::OverlayProjection(QPainter *paint, SegmentListGeostationary *sl) opts.currenttoolbox = %1").arg(opts.currenttoolbox); + if(!paint->isActive()) + return; double lat_deg; double lon_deg; @@ -3765,8 +3781,12 @@ void FormImage::OverlayProjection(QPainter *paint) bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); else if (opts.currenttoolbox == 1) // GVP bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else //SG + else if (opts.currenttoolbox == 2) //SG bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else + bret = false; if(bret) { @@ -3803,9 +3823,12 @@ void FormImage::OverlayProjection(QPainter *paint) bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); else if (opts.currenttoolbox == 1) //GVP bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - else //SG + else if (opts.currenttoolbox == 2) //SG bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); - + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); + else + bret = false; if(bret) { @@ -3817,8 +3840,11 @@ void FormImage::OverlayProjection(QPainter *paint) } else { - paint->setPen(QColor(opts.projectionoverlaycolor1)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); + if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) + { + paint->setPen(QColor(opts.projectionoverlaycolor1)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + } save_map_x = map_x; save_map_y = map_y; } @@ -3847,8 +3873,12 @@ void FormImage::OverlayProjection(QPainter *paint) bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); else if (opts.currenttoolbox == 1) //GVP bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else //SG + else if (opts.currenttoolbox == 2) //SG bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else + bret = false; if(bret) { @@ -3860,8 +3890,11 @@ void FormImage::OverlayProjection(QPainter *paint) } else { - paint->setPen(QColor(opts.projectionoverlaycolor2)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); + if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) + { + paint->setPen(QColor(opts.projectionoverlaycolor2)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + } save_map_x = map_x; save_map_y = map_y; } @@ -3890,8 +3923,12 @@ void FormImage::OverlayProjection(QPainter *paint) bret = imageptrs->lcc->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y); else if (opts.currenttoolbox == 1) //GVP bret = imageptrs->gvp->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; - else //SG + else if (opts.currenttoolbox == 2) //SG bret = imageptrs->sg->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_forward( lon_deg*PI/180, lat_deg*PI/180, map_x, map_y) ; + else + bret = false; if(bret) { @@ -3903,8 +3940,11 @@ void FormImage::OverlayProjection(QPainter *paint) } else { - paint->setPen(QColor(opts.projectionoverlaycolor3)); - paint->drawLine(save_map_x, save_map_y, map_x, map_y); + if(abs(save_map_y - map_y) < 100 && (abs(save_map_x - map_x) < 100)) + { + paint->setPen(QColor(opts.projectionoverlaycolor3)); + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + } save_map_x = map_x; save_map_y = map_y; } @@ -4115,7 +4155,130 @@ void FormImage::OverlayProjection(QPainter *paint) } } - qDebug() << QString("End FormImage::OverlayProjection(QPainter *paint, SegmentListGeostationary *sl)"); + if (opts.currenttoolbox == 3) //OM + { + QPolygonF poly; + if(opts.buttonMERSI) + segs->seglmersi->GetContourPolygon(&poly); + else if(opts.buttonVIIRSM) + segs->seglviirsm->GetContourPolygon(&poly); + else if(opts.buttonVIIRSMNOAA20) + segs->seglviirsmnoaa20->GetContourPolygon(&poly); + else if(opts.buttonMetop) + segs->seglmetop->GetContourPolygonAVHRR(&poly); + + for(int i = 0; i < poly.size(); i++) + { + bret = imageptrs->om->map_forward( poly.at(i).x()*PI/180, poly.at(i).y()*PI/180, map_x, map_y); + if(bret) + { + paint->setPen(QColor(255, 0, 255)); + paint->drawPoint(map_x, map_y); + } + } + } + +// QPolygonF track; +// if(opts.buttonMERSI) +// segs->seglmersi->GetTrackPolygon(&track); +// else if(opts.buttonVIIRSMNOAA20) +// segs->seglviirsmnoaa20->GetTrackPolygon(&track); + +// first = true; +// for(int i = 0; i < track.size(); i++) +// { +// bret = imageptrs->om->map_forward( track.at(i).x()*PI/180, track.at(i).y()*PI/180, map_x, map_y); +// if(bret) +// { +// if (first) +// { +// first = false; +// save_map_x = map_x; +// save_map_y = map_y; +// } +// else +// { +// paint->setPen(QColor(0, 0, 255)); +// paint->drawLine(save_map_x, save_map_y, map_x, map_y); +// save_map_x = map_x; +// save_map_y = map_y; +// } +// } +// } + + if (opts.currenttoolbox == 3 && formtoolbox->GridOnProjOM() ) //OM + { + + first = true; + + for(double lon = -180.0; lon < 180.0; lon+=10.0) + { + first = true; + { + for(double lat = -80.0; lat < 81.0; lat+=0.5) + { + bret = imageptrs->om->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); + + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); +// paint->drawPoint(map_x, map_y); + if(abs(save_map_x - map_x) < 200 && abs(save_map_y - map_y) < 200) + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + + } + } + } + for(double lat = -80.0; lat < 81.0; lat+=10.0) + { + first = true; + { + for(double lon = -180.0; lon < 180.0; lon+=1.0) + { + bret = imageptrs->om->map_forward( lon*PI/180, lat*PI/180, map_x, map_y); + + if(bret) + { + if (first) + { + first = false; + save_map_x = map_x; + save_map_y = map_y; + } + else + { + paint->setPen(QColor(opts.projectionoverlaylonlatcolor)); + //paint->drawPoint(map_x, map_y); + if(abs(save_map_x - map_x) < 200 && abs(save_map_y - map_y) < 200) + paint->drawLine(save_map_x, save_map_y, map_x, map_y); + save_map_x = map_x; + save_map_y = map_y; + } + } + else + first = true; + + } + } + } + + + + } } @@ -4128,6 +4291,7 @@ void FormImage::OverlayOLCI(QPainter *paint) int width = imageptrs->ptrimageOLCI->width(); if( height == 0 || width == 0) return; + qDebug() << "FormImage::OverlayOLCI(QPainter *paint) 1"; qDebug() << "opts.buttonOLCIefr = " << opts.buttonOLCIefr; qDebug() << "opts.buttonOLCIerr = " << opts.buttonOLCIerr; @@ -4440,8 +4604,12 @@ void ImageLabel::mouseMoveEvent(QMouseEvent *event) bret = imageptrs->lcc->map_inverse(xpos, ypos, lon, lat); else if (opts.currenttoolbox == 1) //GVP bret = imageptrs->gvp->map_inverse(xpos, ypos, lon, lat); - else //SG + else if (opts.currenttoolbox == 2) //SG bret = imageptrs->sg->map_inverse(xpos, ypos, lon, lat); + else if (opts.currenttoolbox == 3) //OM + bret = imageptrs->om->map_inverse(xpos, ypos, lon, lat); + else + bret = false; if(bret) emit coordinateChanged(QString("longitude = %1 latitude = %2 ") diff --git a/core/formtoolbox.cpp b/core/formtoolbox.cpp index f466a97..d5ce6c0 100644 --- a/core/formtoolbox.cpp +++ b/core/formtoolbox.cpp @@ -20,7 +20,7 @@ class SignalsBlocker { public: SignalsBlocker(QObject* ptr): - _ptr(ptr) + _ptr(ptr) { _b = ptr->blockSignals(true); } @@ -93,21 +93,45 @@ FormToolbox::FormToolbox(QWidget *parent, FormImage *p_formimage, FormGeostation ui->btnOverlayProjectionSG->setText(("Overlay On")); if(opts.lastinputprojection == 0) + { ui->rdbAVHRRin->setChecked(true); + this->currentProjectionType = PROJ_AVHRR; + } else if(opts.lastinputprojection == 1) + { ui->rdbVIIRSMin->setChecked(true); + this->currentProjectionType = PROJ_VIIRSM; + } else if(opts.lastinputprojection == 2) + { ui->rdbVIIRSDNBin->setChecked(true); + this->currentProjectionType = PROJ_VIIRSDNB; + } else if(opts.lastinputprojection == 3) + { ui->rdbOLCIefrin->setChecked(true); + this->currentProjectionType = PROJ_OLCI_EFR; + } else if(opts.lastinputprojection == 4) + { ui->rdbOLCIerrin->setChecked(true); + this->currentProjectionType = PROJ_OLCI_ERR; + } else if(opts.lastinputprojection == 5) + { ui->rdbMERSIin->setChecked(true); + this->currentProjectionType = PROJ_MERSI; + } else if(opts.lastinputprojection == 6) + { ui->rdbMeteosatin->setChecked(true); + this->currentProjectionType = PROJ_GEOSTATIONARY; + } else + { ui->rdbAVHRRin->setChecked(true); + this->currentProjectionType = PROJ_AVHRR; + } ui->cmbHRVtype->addItem("Europe"); ui->cmbHRVtype->addItem("Full"); @@ -393,6 +417,7 @@ FormToolbox::FormToolbox(QWidget *parent, FormImage *p_formimage, FormGeostation { QListWidgetItem* item = new QListWidgetItem(imageptrs->rgbrecipes.at(i).Name, ui->lstRGB); } + qDebug() << "Width of formtoolbox = " << this->width(); } @@ -669,38 +694,38 @@ void FormToolbox::setChannelComboBoxes() ui->comboCh5->setCurrentIndex(opts.channellistmetop.at(4).toInt()); } else - if (opts.buttonNoaa || opts.buttonNoaa19hrpt) - { - qDebug() << "noaa"; + if (opts.buttonNoaa || opts.buttonNoaa19hrpt) + { + qDebug() << "noaa"; - ui->comboCh1->setCurrentIndex(opts.channellistnoaa.at(0).toInt()); - ui->comboCh2->setCurrentIndex(opts.channellistnoaa.at(1).toInt()); - ui->comboCh3->setCurrentIndex(opts.channellistnoaa.at(2).toInt()); - ui->comboCh4->setCurrentIndex(opts.channellistnoaa.at(3).toInt()); - ui->comboCh5->setCurrentIndex(opts.channellistnoaa.at(4).toInt()); + ui->comboCh1->setCurrentIndex(opts.channellistnoaa.at(0).toInt()); + ui->comboCh2->setCurrentIndex(opts.channellistnoaa.at(1).toInt()); + ui->comboCh3->setCurrentIndex(opts.channellistnoaa.at(2).toInt()); + ui->comboCh4->setCurrentIndex(opts.channellistnoaa.at(3).toInt()); + ui->comboCh5->setCurrentIndex(opts.channellistnoaa.at(4).toInt()); - } else - if (opts.buttonGAC) - { - qDebug() << "GAC"; + } else + if (opts.buttonGAC) + { + qDebug() << "GAC"; - ui->comboCh1->setCurrentIndex(opts.channellistgac.at(0).toInt()); - ui->comboCh2->setCurrentIndex(opts.channellistgac.at(1).toInt()); - ui->comboCh3->setCurrentIndex(opts.channellistgac.at(2).toInt()); - ui->comboCh4->setCurrentIndex(opts.channellistgac.at(3).toInt()); - ui->comboCh5->setCurrentIndex(opts.channellistgac.at(4).toInt()); + ui->comboCh1->setCurrentIndex(opts.channellistgac.at(0).toInt()); + ui->comboCh2->setCurrentIndex(opts.channellistgac.at(1).toInt()); + ui->comboCh3->setCurrentIndex(opts.channellistgac.at(2).toInt()); + ui->comboCh4->setCurrentIndex(opts.channellistgac.at(3).toInt()); + ui->comboCh5->setCurrentIndex(opts.channellistgac.at(4).toInt()); - } else - if (opts.buttonHRP) - { - qDebug() << "HRP"; + } else + if (opts.buttonHRP) + { + qDebug() << "HRP"; - ui->comboCh1->setCurrentIndex(opts.channellisthrp.at(0).toInt()); - ui->comboCh2->setCurrentIndex(opts.channellisthrp.at(1).toInt()); - ui->comboCh3->setCurrentIndex(opts.channellisthrp.at(2).toInt()); - ui->comboCh4->setCurrentIndex(opts.channellisthrp.at(3).toInt()); - ui->comboCh5->setCurrentIndex(opts.channellisthrp.at(4).toInt()); - } + ui->comboCh1->setCurrentIndex(opts.channellisthrp.at(0).toInt()); + ui->comboCh2->setCurrentIndex(opts.channellisthrp.at(1).toInt()); + ui->comboCh3->setCurrentIndex(opts.channellisthrp.at(2).toInt()); + ui->comboCh4->setCurrentIndex(opts.channellisthrp.at(3).toInt()); + ui->comboCh5->setCurrentIndex(opts.channellisthrp.at(4).toInt()); + } setInverseCheckBoxes(); @@ -729,8 +754,8 @@ QList FormToolbox::getVIIRSMBandList() { QList viirslist; viirslist << ui->rbColorVIIRS->isChecked() << ui->rbM1->isChecked() << ui->rbM2->isChecked() << ui->rbM3->isChecked() << ui->rbM4->isChecked() << ui->rbM5->isChecked() << ui->rbM6->isChecked() - << ui->rbM7->isChecked() << ui->rbM8->isChecked() << ui->rbM9->isChecked() << ui->rbM10->isChecked() << ui->rbM11->isChecked() << ui->rbM12->isChecked() - << ui->rbM13->isChecked() << ui->rbM14->isChecked() << ui->rbM15->isChecked() << ui->rbM16->isChecked(); + << ui->rbM7->isChecked() << ui->rbM8->isChecked() << ui->rbM9->isChecked() << ui->rbM10->isChecked() << ui->rbM11->isChecked() << ui->rbM12->isChecked() + << ui->rbM13->isChecked() << ui->rbM14->isChecked() << ui->rbM15->isChecked() << ui->rbM16->isChecked(); return(viirslist); } @@ -738,9 +763,9 @@ QList FormToolbox::getVIIRSMColorList() { QList viirslist; viirslist << ui->comboM1->currentIndex() << ui->comboM2->currentIndex() << ui->comboM3->currentIndex() << ui->comboM4->currentIndex() << ui->comboM5->currentIndex() - << ui->comboM6->currentIndex() << ui->comboM7->currentIndex() << ui->comboM8->currentIndex() << ui->comboM9->currentIndex() << ui->comboM10->currentIndex() - << ui->comboM11->currentIndex() << ui->comboM12->currentIndex() << ui->comboM13->currentIndex() << ui->comboM14->currentIndex() << ui->comboM15->currentIndex() - << ui->comboM16->currentIndex(); + << ui->comboM6->currentIndex() << ui->comboM7->currentIndex() << ui->comboM8->currentIndex() << ui->comboM9->currentIndex() << ui->comboM10->currentIndex() + << ui->comboM11->currentIndex() << ui->comboM12->currentIndex() << ui->comboM13->currentIndex() << ui->comboM14->currentIndex() << ui->comboM15->currentIndex() + << ui->comboM16->currentIndex(); return(viirslist); } @@ -748,9 +773,9 @@ QList FormToolbox::getVIIRSMInvertList() { QList viirslist; viirslist << ui->chkInverseM1->isChecked() << ui->chkInverseM2->isChecked() << ui->chkInverseM3->isChecked() << ui->chkInverseM4->isChecked() << ui->chkInverseM5->isChecked() - << ui->chkInverseM6->isChecked() << ui->chkInverseM7->isChecked() << ui->chkInverseM8->isChecked() << ui->chkInverseM9->isChecked() << ui->chkInverseM10->isChecked() - << ui->chkInverseM11->isChecked() << ui->chkInverseM12->isChecked() << ui->chkInverseM13->isChecked() << ui->chkInverseM14->isChecked() << ui->chkInverseM15->isChecked() - << ui->chkInverseM16->isChecked(); + << ui->chkInverseM6->isChecked() << ui->chkInverseM7->isChecked() << ui->chkInverseM8->isChecked() << ui->chkInverseM9->isChecked() << ui->chkInverseM10->isChecked() + << ui->chkInverseM11->isChecked() << ui->chkInverseM12->isChecked() << ui->chkInverseM13->isChecked() << ui->chkInverseM14->isChecked() << ui->chkInverseM15->isChecked() + << ui->chkInverseM16->isChecked(); return(viirslist); } @@ -788,11 +813,11 @@ QList FormToolbox::getOLCIInvertList() { QList olcilist; olcilist << ui->chkInverseOLCI01->isChecked() << ui->chkInverseOLCI02->isChecked() << ui->chkInverseOLCI03->isChecked() << ui->chkInverseOLCI04->isChecked() - << ui->chkInverseOLCI05->isChecked() << ui->chkInverseOLCI06->isChecked() << ui->chkInverseOLCI07->isChecked() << ui->chkInverseOLCI08->isChecked() - << ui->chkInverseOLCI09->isChecked() << ui->chkInverseOLCI10->isChecked() << ui->chkInverseOLCI11->isChecked() << ui->chkInverseOLCI12->isChecked() - << ui->chkInverseOLCI13->isChecked() << ui->chkInverseOLCI14->isChecked() << ui->chkInverseOLCI15->isChecked() << ui->chkInverseOLCI16->isChecked() - << ui->chkInverseOLCI17->isChecked() << ui->chkInverseOLCI18->isChecked() << ui->chkInverseOLCI19->isChecked() << ui->chkInverseOLCI20->isChecked() - << ui->chkInverseOLCI21->isChecked(); + << ui->chkInverseOLCI05->isChecked() << ui->chkInverseOLCI06->isChecked() << ui->chkInverseOLCI07->isChecked() << ui->chkInverseOLCI08->isChecked() + << ui->chkInverseOLCI09->isChecked() << ui->chkInverseOLCI10->isChecked() << ui->chkInverseOLCI11->isChecked() << ui->chkInverseOLCI12->isChecked() + << ui->chkInverseOLCI13->isChecked() << ui->chkInverseOLCI14->isChecked() << ui->chkInverseOLCI15->isChecked() << ui->chkInverseOLCI16->isChecked() + << ui->chkInverseOLCI17->isChecked() << ui->chkInverseOLCI18->isChecked() << ui->chkInverseOLCI19->isChecked() << ui->chkInverseOLCI20->isChecked() + << ui->chkInverseOLCI21->isChecked(); Q_ASSERT(olcilist.count() == 21); return(olcilist); } @@ -801,8 +826,8 @@ QList FormToolbox::getSLSTRBandList() { QList slstrlist; slstrlist << ui->rbColorSLSTR->isChecked() << ui->rbS1->isChecked() << ui->rbS2->isChecked() << ui->rbS3->isChecked() - << ui->rbS4->isChecked() << ui->rbS5->isChecked() << ui->rbS6->isChecked() << ui->rbS7->isChecked() - << ui->rbS8->isChecked() << ui->rbS9->isChecked() << ui->rbF1->isChecked() << ui->rbF2->isChecked(); + << ui->rbS4->isChecked() << ui->rbS5->isChecked() << ui->rbS6->isChecked() << ui->rbS7->isChecked() + << ui->rbS8->isChecked() << ui->rbS9->isChecked() << ui->rbF1->isChecked() << ui->rbF2->isChecked(); Q_ASSERT(slstrlist.count() == 12); @@ -813,8 +838,8 @@ QList FormToolbox::getSLSTRColorList() { QList slstrlist; slstrlist << ui->cmbS1->currentIndex() << ui->cmbS2->currentIndex() << ui->cmbS3->currentIndex() << ui->cmbS4->currentIndex() - << ui->cmbS5->currentIndex() << ui->cmbS6->currentIndex() << ui->cmbS7->currentIndex() << ui->cmbS8->currentIndex() - << ui->cmbS9->currentIndex() << ui->cmbF1->currentIndex() << ui->cmbF2->currentIndex(); + << ui->cmbS5->currentIndex() << ui->cmbS6->currentIndex() << ui->cmbS7->currentIndex() << ui->cmbS8->currentIndex() + << ui->cmbS9->currentIndex() << ui->cmbF1->currentIndex() << ui->cmbF2->currentIndex(); Q_ASSERT(slstrlist.count() == 11); return(slstrlist); @@ -842,10 +867,15 @@ QList FormToolbox::getMERSIBandList() { QList mersilist; mersilist << ui->rbColorMERSI->isChecked() << ui->rbMERSI5->isChecked() << ui->rbMERSI6->isChecked() << ui->rbMERSI7->isChecked() - << ui->rbMERSI8->isChecked() << ui->rbMERSI9->isChecked() << ui->rbMERSI10->isChecked() << ui->rbMERSI11->isChecked() - << ui->rbMERSI12->isChecked() << ui->rbMERSI13->isChecked() << ui->rbMERSI14->isChecked() << ui->rbMERSI15->isChecked() - << ui->rbMERSI16->isChecked() << ui->rbMERSI17->isChecked() << ui->rbMERSI18->isChecked() << ui->rbMERSI19->isChecked(); + << ui->rbMERSI8->isChecked() << ui->rbMERSI9->isChecked() << ui->rbMERSI10->isChecked() << ui->rbMERSI11->isChecked() + << ui->rbMERSI12->isChecked() << ui->rbMERSI13->isChecked() << ui->rbMERSI14->isChecked() << ui->rbMERSI15->isChecked() + << ui->rbMERSI16->isChecked() << ui->rbMERSI17->isChecked() << ui->rbMERSI18->isChecked() << ui->rbMERSI19->isChecked(); + // qDebug() << "FormToolbox::getMERSIBandList()"; + // for(int i = 0; i < 16; i++) + // { + // qDebug() << i << " " << mersilist.at(i); + // } Q_ASSERT(mersilist.count() == 16); @@ -856,9 +886,9 @@ QList FormToolbox::getMERSIColorList() { QList mersilist; mersilist << ui->cmbMERSI5->currentIndex() << ui->cmbMERSI6->currentIndex() << ui->cmbMERSI7->currentIndex() << ui->cmbMERSI8->currentIndex() - << ui->cmbMERSI9->currentIndex() << ui->cmbMERSI10->currentIndex() << ui->cmbMERSI11->currentIndex() << ui->cmbMERSI12->currentIndex() - << ui->cmbMERSI13->currentIndex() << ui->cmbMERSI14->currentIndex() << ui->cmbMERSI15->currentIndex() << ui->cmbMERSI16->currentIndex() - << ui->cmbMERSI17->currentIndex() << ui->cmbMERSI18->currentIndex() << ui->cmbMERSI19->currentIndex(); + << ui->cmbMERSI9->currentIndex() << ui->cmbMERSI10->currentIndex() << ui->cmbMERSI11->currentIndex() << ui->cmbMERSI12->currentIndex() + << ui->cmbMERSI13->currentIndex() << ui->cmbMERSI14->currentIndex() << ui->cmbMERSI15->currentIndex() << ui->cmbMERSI16->currentIndex() + << ui->cmbMERSI17->currentIndex() << ui->cmbMERSI18->currentIndex() << ui->cmbMERSI19->currentIndex(); Q_ASSERT(mersilist.count() == 15); return(mersilist); @@ -878,18 +908,18 @@ QList FormToolbox::getMERSIInvertList() int FormToolbox::searchResolution(int mapwidth, int mapheight) { - int index = -1; + int index = -1; - for(int i = 0; i < resolutionX.size(); i++) - { - if(resolutionX.at(i) == mapwidth && resolutionY.at(i) == mapheight ) - { - index = i; - break; - } - } + for(int i = 0; i < resolutionX.size(); i++) + { + if(resolutionX.at(i) == mapwidth && resolutionY.at(i) == mapheight ) + { + index = i; + break; + } + } - return(index+1); + return(index+1); } @@ -933,65 +963,65 @@ void FormToolbox::setInverseCheckBoxes() } } else - if (opts.buttonNoaa || opts.buttonNoaa19hrpt) - { - if (opts.noaa_invlist.count() == 5) - { - ui->chkInverseCh1->setChecked(opts.noaa_invlist.at(0) == "1" ? true : false); - ui->chkInverseCh2->setChecked(opts.noaa_invlist.at(1) == "1" ? true : false); - ui->chkInverseCh3->setChecked(opts.noaa_invlist.at(2) == "1" ? true : false); - ui->chkInverseCh4->setChecked(opts.noaa_invlist.at(3) == "1" ? true : false); - ui->chkInverseCh5->setChecked(opts.noaa_invlist.at(4) == "1" ? true : false); - } - else + if (opts.buttonNoaa || opts.buttonNoaa19hrpt) { - ui->chkInverseCh1->setChecked(false); - ui->chkInverseCh2->setChecked(false); - ui->chkInverseCh3->setChecked(false); - ui->chkInverseCh4->setChecked(false); - ui->chkInverseCh5->setChecked(false); - } + if (opts.noaa_invlist.count() == 5) + { + ui->chkInverseCh1->setChecked(opts.noaa_invlist.at(0) == "1" ? true : false); + ui->chkInverseCh2->setChecked(opts.noaa_invlist.at(1) == "1" ? true : false); + ui->chkInverseCh3->setChecked(opts.noaa_invlist.at(2) == "1" ? true : false); + ui->chkInverseCh4->setChecked(opts.noaa_invlist.at(3) == "1" ? true : false); + ui->chkInverseCh5->setChecked(opts.noaa_invlist.at(4) == "1" ? true : false); + } + else + { + ui->chkInverseCh1->setChecked(false); + ui->chkInverseCh2->setChecked(false); + ui->chkInverseCh3->setChecked(false); + ui->chkInverseCh4->setChecked(false); + ui->chkInverseCh5->setChecked(false); + } - } else - if (opts.buttonGAC) - { - if (opts.gac_invlist.count() == 5) - { - ui->chkInverseCh1->setChecked(opts.gac_invlist.at(0) == "1" ? true : false); - ui->chkInverseCh2->setChecked(opts.gac_invlist.at(1) == "1" ? true : false); - ui->chkInverseCh3->setChecked(opts.gac_invlist.at(2) == "1" ? true : false); - ui->chkInverseCh4->setChecked(opts.gac_invlist.at(3) == "1" ? true : false); - ui->chkInverseCh5->setChecked(opts.gac_invlist.at(4) == "1" ? true : false); - } - else - { - ui->chkInverseCh1->setChecked(false); - ui->chkInverseCh2->setChecked(false); - ui->chkInverseCh3->setChecked(false); - ui->chkInverseCh4->setChecked(false); - ui->chkInverseCh5->setChecked(false); - } + } else + if (opts.buttonGAC) + { + if (opts.gac_invlist.count() == 5) + { + ui->chkInverseCh1->setChecked(opts.gac_invlist.at(0) == "1" ? true : false); + ui->chkInverseCh2->setChecked(opts.gac_invlist.at(1) == "1" ? true : false); + ui->chkInverseCh3->setChecked(opts.gac_invlist.at(2) == "1" ? true : false); + ui->chkInverseCh4->setChecked(opts.gac_invlist.at(3) == "1" ? true : false); + ui->chkInverseCh5->setChecked(opts.gac_invlist.at(4) == "1" ? true : false); + } + else + { + ui->chkInverseCh1->setChecked(false); + ui->chkInverseCh2->setChecked(false); + ui->chkInverseCh3->setChecked(false); + ui->chkInverseCh4->setChecked(false); + ui->chkInverseCh5->setChecked(false); + } - } else - if (opts.buttonHRP) - { - if (opts.hrp_invlist.count() == 5) - { - ui->chkInverseCh1->setChecked(opts.hrp_invlist.at(0) == "1" ? true : false); - ui->chkInverseCh2->setChecked(opts.hrp_invlist.at(1) == "1" ? true : false); - ui->chkInverseCh3->setChecked(opts.hrp_invlist.at(2) == "1" ? true : false); - ui->chkInverseCh4->setChecked(opts.hrp_invlist.at(3) == "1" ? true : false); - ui->chkInverseCh5->setChecked(opts.hrp_invlist.at(4) == "1" ? true : false); - } - else - { - ui->chkInverseCh1->setChecked(false); - ui->chkInverseCh2->setChecked(false); - ui->chkInverseCh3->setChecked(false); - ui->chkInverseCh4->setChecked(false); - ui->chkInverseCh5->setChecked(false); - } - } + } else + if (opts.buttonHRP) + { + if (opts.hrp_invlist.count() == 5) + { + ui->chkInverseCh1->setChecked(opts.hrp_invlist.at(0) == "1" ? true : false); + ui->chkInverseCh2->setChecked(opts.hrp_invlist.at(1) == "1" ? true : false); + ui->chkInverseCh3->setChecked(opts.hrp_invlist.at(2) == "1" ? true : false); + ui->chkInverseCh4->setChecked(opts.hrp_invlist.at(3) == "1" ? true : false); + ui->chkInverseCh5->setChecked(opts.hrp_invlist.at(4) == "1" ? true : false); + } + else + { + ui->chkInverseCh1->setChecked(false); + ui->chkInverseCh2->setChecked(false); + ui->chkInverseCh3->setChecked(false); + ui->chkInverseCh4->setChecked(false); + ui->chkInverseCh5->setChecked(false); + } + } qDebug() << QString("chkInverse = %1 %2 %3 %4 %5").arg(opts.noaa_invlist.at(0)).arg(opts.noaa_invlist.at(1)).arg(opts.noaa_invlist.at(2)).arg(opts.noaa_invlist.at(3)).arg(opts.noaa_invlist.at(4)); } @@ -1009,36 +1039,36 @@ void FormToolbox::setChannelInverse() opts.metop_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); opts.metop_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); } else - if (opts.buttonNoaa || opts.buttonNoaa19hrpt) - { - opts.noaa_invlist.clear(); - - opts.noaa_invlist << (ui->chkInverseCh1->isChecked() ? "1" : "0"); - opts.noaa_invlist << (ui->chkInverseCh2->isChecked() ? "1" : "0"); - opts.noaa_invlist << (ui->chkInverseCh3->isChecked() ? "1" : "0"); - opts.noaa_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); - opts.noaa_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); - } else - if (opts.buttonGAC) - { - opts.gac_invlist.clear(); - - opts.gac_invlist << (ui->chkInverseCh1->isChecked() ? "1" : "0"); - opts.gac_invlist << (ui->chkInverseCh2->isChecked() ? "1" : "0"); - opts.gac_invlist << (ui->chkInverseCh3->isChecked() ? "1" : "0"); - opts.gac_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); - opts.gac_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); - } else - if (opts.buttonHRP) - { - opts.hrp_invlist.clear(); + if (opts.buttonNoaa || opts.buttonNoaa19hrpt) + { + opts.noaa_invlist.clear(); + + opts.noaa_invlist << (ui->chkInverseCh1->isChecked() ? "1" : "0"); + opts.noaa_invlist << (ui->chkInverseCh2->isChecked() ? "1" : "0"); + opts.noaa_invlist << (ui->chkInverseCh3->isChecked() ? "1" : "0"); + opts.noaa_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); + opts.noaa_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); + } else + if (opts.buttonGAC) + { + opts.gac_invlist.clear(); + + opts.gac_invlist << (ui->chkInverseCh1->isChecked() ? "1" : "0"); + opts.gac_invlist << (ui->chkInverseCh2->isChecked() ? "1" : "0"); + opts.gac_invlist << (ui->chkInverseCh3->isChecked() ? "1" : "0"); + opts.gac_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); + opts.gac_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); + } else + if (opts.buttonHRP) + { + opts.hrp_invlist.clear(); - opts.hrp_invlist << (ui->chkInverseCh1->isChecked() ? "1" : "0"); - opts.hrp_invlist << (ui->chkInverseCh2->isChecked() ? "1" : "0"); - opts.hrp_invlist << (ui->chkInverseCh3->isChecked() ? "1" : "0"); - opts.hrp_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); - opts.hrp_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); - } + opts.hrp_invlist << (ui->chkInverseCh1->isChecked() ? "1" : "0"); + opts.hrp_invlist << (ui->chkInverseCh2->isChecked() ? "1" : "0"); + opts.hrp_invlist << (ui->chkInverseCh3->isChecked() ? "1" : "0"); + opts.hrp_invlist << (ui->chkInverseCh4->isChecked() ? "1" : "0"); + opts.hrp_invlist << (ui->chkInverseCh5->isChecked() ? "1" : "0"); + } } @@ -1056,36 +1086,36 @@ void FormToolbox::setChannelIndex() opts.channellistmetop << QString("%1").arg(ui->comboCh5->currentIndex()); } else - if (opts.buttonNoaa || opts.buttonNoaa19hrpt) - { - opts.channellistnoaa.clear(); - opts.channellistnoaa << QString("%1").arg(ui->comboCh1->currentIndex()); - opts.channellistnoaa << QString("%1").arg(ui->comboCh2->currentIndex()); - opts.channellistnoaa << QString("%1").arg(ui->comboCh3->currentIndex()); - opts.channellistnoaa << QString("%1").arg(ui->comboCh4->currentIndex()); - opts.channellistnoaa << QString("%1").arg(ui->comboCh5->currentIndex()); - } - else - if (opts.buttonGAC) - { - opts.channellistgac.clear(); - opts.channellistgac << QString("%1").arg(ui->comboCh1->currentIndex()); - opts.channellistgac << QString("%1").arg(ui->comboCh2->currentIndex()); - opts.channellistgac << QString("%1").arg(ui->comboCh3->currentIndex()); - opts.channellistgac << QString("%1").arg(ui->comboCh4->currentIndex()); - opts.channellistgac << QString("%1").arg(ui->comboCh5->currentIndex()); + if (opts.buttonNoaa || opts.buttonNoaa19hrpt) + { + opts.channellistnoaa.clear(); + opts.channellistnoaa << QString("%1").arg(ui->comboCh1->currentIndex()); + opts.channellistnoaa << QString("%1").arg(ui->comboCh2->currentIndex()); + opts.channellistnoaa << QString("%1").arg(ui->comboCh3->currentIndex()); + opts.channellistnoaa << QString("%1").arg(ui->comboCh4->currentIndex()); + opts.channellistnoaa << QString("%1").arg(ui->comboCh5->currentIndex()); + } + else + if (opts.buttonGAC) + { + opts.channellistgac.clear(); + opts.channellistgac << QString("%1").arg(ui->comboCh1->currentIndex()); + opts.channellistgac << QString("%1").arg(ui->comboCh2->currentIndex()); + opts.channellistgac << QString("%1").arg(ui->comboCh3->currentIndex()); + opts.channellistgac << QString("%1").arg(ui->comboCh4->currentIndex()); + opts.channellistgac << QString("%1").arg(ui->comboCh5->currentIndex()); - } - else - if (opts.buttonHRP) - { - opts.channellisthrp.clear(); - opts.channellisthrp << QString("%1").arg(ui->comboCh1->currentIndex()); - opts.channellisthrp << QString("%1").arg(ui->comboCh2->currentIndex()); - opts.channellisthrp << QString("%1").arg(ui->comboCh3->currentIndex()); - opts.channellisthrp << QString("%1").arg(ui->comboCh4->currentIndex()); - opts.channellisthrp << QString("%1").arg(ui->comboCh5->currentIndex()); - } + } + else + if (opts.buttonHRP) + { + opts.channellisthrp.clear(); + opts.channellisthrp << QString("%1").arg(ui->comboCh1->currentIndex()); + opts.channellisthrp << QString("%1").arg(ui->comboCh2->currentIndex()); + opts.channellisthrp << QString("%1").arg(ui->comboCh3->currentIndex()); + opts.channellisthrp << QString("%1").arg(ui->comboCh4->currentIndex()); + opts.channellisthrp << QString("%1").arg(ui->comboCh5->currentIndex()); + } qDebug() << QString("setChannelIndex combo 1 channelindex = %1 %2").arg(ui->comboCh1->currentIndex()).arg(ui->comboCh1->currentText()); qDebug() << QString("setChannelIndex combo 2 channelindex = %1 %2").arg(ui->comboCh2->currentIndex()).arg(ui->comboCh2->currentText()); @@ -1417,6 +1447,11 @@ bool FormToolbox::GridOnProjSG() return ui->chkSGGridOnProj->isChecked(); } +bool FormToolbox::GridOnProjOM() +{ + return ui->chkOMGridOnProj->isChecked(); +} + void FormToolbox::on_btnCol_clicked() { formimage->setKindOfImage("AVHRR Color"); @@ -1518,6 +1553,15 @@ void FormToolbox::on_btnOverlayProjectionSG_clicked() } +void FormToolbox::on_btnOverlayProjectionOM_clicked() +{ + if(formimage->toggleOverlayProjection()) + ui->btnOverlayProjectionOM->setText("Overlay On"); + else + ui->btnOverlayProjectionOM->setText("Overlay Off"); + +} + void FormToolbox::geostationarysegmentsChosen(int geoindex, QStringList tex) { qDebug() << "FormToolbox::geostationarysegmentsChosen " << tex; @@ -1694,7 +1738,7 @@ void FormToolbox::setToolboxButtons(bool state) { ui->btnHRV->setEnabled(state); if(opts.geosatellites.at(geoindex).color) - ui->chkColorHRV->setEnabled(state); + ui->chkColorHRV->setEnabled(state); } if(opts.geosatellites.at(geoindex).startsegmentnbrtype1 > 0) @@ -1718,9 +1762,12 @@ void FormToolbox::setToolboxButtons(bool state) ui->btnCreateLambert->setEnabled(state); ui->btnCreatePerspective->setEnabled(state); ui->btnCreateStereo->setEnabled(state); + ui->btnCreateOM->setEnabled(state); + ui->btnLCCClearMap->setEnabled(state); ui->btnGVPClearMap->setEnabled(state); ui->btnSGClearMap->setEnabled(state); + ui->btnOMClearMap->setEnabled(state); ui->rbColorVIIRS->setEnabled(state); ui->rbM1->setEnabled(state); @@ -1803,34 +1850,34 @@ void FormToolbox::setToolboxButtonLabels(int geoindex) qDebug() << QString("FormToolbox::setToolboxButtonLabels geoindex = %1").arg(geoindex); -// ui->btnCh1->setEnabled(false); -// ui->btnCh2->setEnabled(false); -// ui->btnCh3->setEnabled(false); -// ui->btnCh4->setEnabled(false); -// ui->btnCh5->setEnabled(false); -// ui->btnCol->setEnabled(false); - -// ui->btnGeoColor->setEnabled(false); -// ui->btnGeo1->setEnabled(false); -// ui->btnGeo2->setEnabled(false); -// ui->btnGeo3->setEnabled(false); -// ui->btnGeo4->setEnabled(false); -// ui->btnGeo5->setEnabled(false); -// ui->btnGeo6->setEnabled(false); -// ui->btnGeo7->setEnabled(false); -// ui->btnGeo8->setEnabled(false); -// ui->btnGeo9->setEnabled(false); -// ui->btnGeo10->setEnabled(false); -// ui->btnGeo11->setEnabled(false); -// ui->btnGeo12->setEnabled(false); -// ui->btnGeo13->setEnabled(false); -// ui->btnGeo14->setEnabled(false); -// ui->btnGeo15->setEnabled(false); -// ui->btnGeo16->setEnabled(false); - -// ui->btnHRV->setEnabled(false); -// ui->cmbHRVtype->setEnabled(false); -// ui->chkColorHRV->setEnabled(false); + // ui->btnCh1->setEnabled(false); + // ui->btnCh2->setEnabled(false); + // ui->btnCh3->setEnabled(false); + // ui->btnCh4->setEnabled(false); + // ui->btnCh5->setEnabled(false); + // ui->btnCol->setEnabled(false); + + // ui->btnGeoColor->setEnabled(false); + // ui->btnGeo1->setEnabled(false); + // ui->btnGeo2->setEnabled(false); + // ui->btnGeo3->setEnabled(false); + // ui->btnGeo4->setEnabled(false); + // ui->btnGeo5->setEnabled(false); + // ui->btnGeo6->setEnabled(false); + // ui->btnGeo7->setEnabled(false); + // ui->btnGeo8->setEnabled(false); + // ui->btnGeo9->setEnabled(false); + // ui->btnGeo10->setEnabled(false); + // ui->btnGeo11->setEnabled(false); + // ui->btnGeo12->setEnabled(false); + // ui->btnGeo13->setEnabled(false); + // ui->btnGeo14->setEnabled(false); + // ui->btnGeo15->setEnabled(false); + // ui->btnGeo16->setEnabled(false); + + // ui->btnHRV->setEnabled(false); + // ui->cmbHRVtype->setEnabled(false); + // ui->chkColorHRV->setEnabled(false); ui->btnGeo1->setText(""); ui->btnGeo2->setText(""); @@ -1870,19 +1917,19 @@ void FormToolbox::setToolboxButtonLabels(int geoindex) if(opts.geosatellites.at(geoindex).spectrumhrv.length() > 0) { ui->btnHRV->setText(opts.geosatellites.at(geoindex).spectrumhrv); -// if(opts.geosatellites.at(geoindex).color) -// ui->chkColorHRV->setEnabled(true); + // if(opts.geosatellites.at(geoindex).color) + // ui->chkColorHRV->setEnabled(true); } -// if(opts.geosatellites.at(geoindex).color) -// { -// ui->btnGeoColor->setEnabled(true); -// } + // if(opts.geosatellites.at(geoindex).color) + // { + // ui->btnGeoColor->setEnabled(true); + // } -// if(opts.geosatellites.at(geoindex).startsegmentnbrtype1 > 0) -// { -// ui->cmbHRVtype->setEnabled(true); -// } + // if(opts.geosatellites.at(geoindex).startsegmentnbrtype1 > 0) + // { + // ui->cmbHRVtype->setEnabled(true); + // } for(int i = 0; i < opts.geosatellites.at(geoindex).spectrumlist.count(); i++) { @@ -2025,113 +2072,113 @@ void FormToolbox::setComboGeo(int geoindex) void FormToolbox::on_btnGeo1_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo1->text().length() != 0 ) - onButtonChannel(ui->btnGeo1->text(), ui->chkInverseGeo1->isChecked()); + if(ui->btnGeo1->text().length() != 0 ) + onButtonChannel(ui->btnGeo1->text(), ui->chkInverseGeo1->isChecked()); } void FormToolbox::on_btnGeo2_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo2->text().length() != 0 ) - onButtonChannel(ui->btnGeo2->text(), ui->chkInverseGeo2->isChecked()); + if(ui->btnGeo2->text().length() != 0 ) + onButtonChannel(ui->btnGeo2->text(), ui->chkInverseGeo2->isChecked()); } void FormToolbox::on_btnGeo3_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo3->text().length() != 0 ) - onButtonChannel(ui->btnGeo3->text(), ui->chkInverseGeo3->isChecked()); + if(ui->btnGeo3->text().length() != 0 ) + onButtonChannel(ui->btnGeo3->text(), ui->chkInverseGeo3->isChecked()); } void FormToolbox::on_btnGeo4_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo4->text().length() != 0 ) - onButtonChannel(ui->btnGeo4->text(), ui->chkInverseGeo4->isChecked()); + if(ui->btnGeo4->text().length() != 0 ) + onButtonChannel(ui->btnGeo4->text(), ui->chkInverseGeo4->isChecked()); } void FormToolbox::on_btnGeo5_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo5->text().length() != 0 ) - onButtonChannel(ui->btnGeo5->text(), ui->chkInverseGeo5->isChecked()); + if(ui->btnGeo5->text().length() != 0 ) + onButtonChannel(ui->btnGeo5->text(), ui->chkInverseGeo5->isChecked()); } void FormToolbox::on_btnGeo6_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo6->text().length() != 0 ) - onButtonChannel(ui->btnGeo6->text(), ui->chkInverseGeo6->isChecked()); + if(ui->btnGeo6->text().length() != 0 ) + onButtonChannel(ui->btnGeo6->text(), ui->chkInverseGeo6->isChecked()); } void FormToolbox::on_btnGeo7_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo7->text().length() != 0 ) - onButtonChannel(ui->btnGeo7->text(), ui->chkInverseGeo7->isChecked()); + if(ui->btnGeo7->text().length() != 0 ) + onButtonChannel(ui->btnGeo7->text(), ui->chkInverseGeo7->isChecked()); } void FormToolbox::on_btnGeo8_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo8->text().length() != 0 ) - onButtonChannel(ui->btnGeo8->text(), ui->chkInverseGeo8->isChecked()); + if(ui->btnGeo8->text().length() != 0 ) + onButtonChannel(ui->btnGeo8->text(), ui->chkInverseGeo8->isChecked()); } void FormToolbox::on_btnGeo9_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo9->text().length() != 0 ) - onButtonChannel(ui->btnGeo9->text(), ui->chkInverseGeo9->isChecked()); + if(ui->btnGeo9->text().length() != 0 ) + onButtonChannel(ui->btnGeo9->text(), ui->chkInverseGeo9->isChecked()); } void FormToolbox::on_btnGeo10_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo10->text().length() != 0 ) - onButtonChannel(ui->btnGeo10->text(), ui->chkInverseGeo10->isChecked()); + if(ui->btnGeo10->text().length() != 0 ) + onButtonChannel(ui->btnGeo10->text(), ui->chkInverseGeo10->isChecked()); } void FormToolbox::on_btnGeo11_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo11->text().length() != 0 ) - onButtonChannel(ui->btnGeo11->text(), ui->chkInverseGeo11->isChecked()); + if(ui->btnGeo11->text().length() != 0 ) + onButtonChannel(ui->btnGeo11->text(), ui->chkInverseGeo11->isChecked()); } void FormToolbox::on_btnGeo12_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo12->text().length() != 0 ) - onButtonChannel(ui->btnGeo12->text(), ui->chkInverseGeo12->isChecked()); + if(ui->btnGeo12->text().length() != 0 ) + onButtonChannel(ui->btnGeo12->text(), ui->chkInverseGeo12->isChecked()); } void FormToolbox::on_btnGeo13_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo13->text().length() != 0 ) - onButtonChannel(ui->btnGeo13->text(), ui->chkInverseGeo13->isChecked()); + if(ui->btnGeo13->text().length() != 0 ) + onButtonChannel(ui->btnGeo13->text(), ui->chkInverseGeo13->isChecked()); } void FormToolbox::on_btnGeo14_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo14->text().length() != 0 ) - onButtonChannel(ui->btnGeo14->text(), ui->chkInverseGeo14->isChecked()); + if(ui->btnGeo14->text().length() != 0 ) + onButtonChannel(ui->btnGeo14->text(), ui->chkInverseGeo14->isChecked()); } void FormToolbox::on_btnGeo15_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo15->text().length() != 0 ) - onButtonChannel(ui->btnGeo15->text(), ui->chkInverseGeo15->isChecked()); + if(ui->btnGeo15->text().length() != 0 ) + onButtonChannel(ui->btnGeo15->text(), ui->chkInverseGeo15->isChecked()); } void FormToolbox::on_btnGeo16_clicked() { if(checkSegmentDateTime()) - if(ui->btnGeo16->text().length() != 0 ) - onButtonChannel(ui->btnGeo16->text(), ui->chkInverseGeo16->isChecked()); + if(ui->btnGeo16->text().length() != 0 ) + onButtonChannel(ui->btnGeo16->text(), ui->chkInverseGeo16->isChecked()); } @@ -2798,13 +2845,17 @@ void FormToolbox::on_tabWidget_currentChanged(int index) ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); else if( ui->toolBox->currentIndex() == 1) imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPMapWidth->value(), ui->spbGVPMapHeight->value()); - else + else if( ui->toolBox->currentIndex() == 2) imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), ui->spbSGMapWidth->value(), ui->spbSGMapHeight->value(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); + else + imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType); + formimage->UpdateProjection(); + formimage->adjustPicSize(false); } -// opts.currenttabwidget = ui->tabWidget->currentIndex(); -// opts.currenttoolbox = ui->toolBox->currentIndex(); + // opts.currenttabwidget = ui->tabWidget->currentIndex(); + // opts.currenttoolbox = ui->toolBox->currentIndex(); } void FormToolbox::on_tabWidgetVIIRS_currentChanged(int index) @@ -2974,18 +3025,18 @@ void FormToolbox::on_btnCreatePerspective_clicked() if(ui->rdbAVHRRin->isChecked()) { if(!(opts.buttonMetop || opts.buttonNoaa || opts.buttonHRP || opts.buttonGAC || opts.buttonMetopAhrpt || opts.buttonMetopBhrpt || opts.buttonNoaa19hrpt || - opts.buttonM01hrpt || opts.buttonM02hrpt) || !segs->SelectedAVHRRSegments()) + opts.buttonM01hrpt || opts.buttonM02hrpt) || !segs->SelectedAVHRRSegments()) { - QMessageBox::information( this, "AVHHR", "No selected AVHRR segments !" ); - return; + QMessageBox::information( this, "AVHHR", "No selected AVHRR segments !" ); + return; } } else if(ui->rdbVIIRSMin->isChecked()) { if(!(opts.buttonVIIRSM || opts.buttonVIIRSMNOAA20) || !segs->SelectedVIIRSMSegments()) { - QMessageBox::information( this, "VIIRS M", "No selected VIIRS M segments !" ); - return; + QMessageBox::information( this, "VIIRS M", "No selected VIIRS M segments !" ); + return; } } @@ -2993,32 +3044,32 @@ void FormToolbox::on_btnCreatePerspective_clicked() { if(!(opts.buttonVIIRSDNB || opts.buttonVIIRSDNBNOAA20) || !segs->SelectedVIIRSDNBSegments()) { - QMessageBox::information( this, "VIIRS DNB", "No selected VIIRS DNB segments !" ); - return; + QMessageBox::information( this, "VIIRS DNB", "No selected VIIRS DNB segments !" ); + return; } } else if(ui->rdbOLCIefrin->isChecked()) { if(!opts.buttonOLCIefr || !segs->SelectedOLCIefrSegments()) { - QMessageBox::information( this, "OLCI EFR", "No selected OLCI EFR segments !" ); - return; + QMessageBox::information( this, "OLCI EFR", "No selected OLCI EFR segments !" ); + return; } } else if(ui->rdbOLCIerrin->isChecked()) { if(!opts.buttonOLCIerr || !segs->SelectedOLCIerrSegments()) { - QMessageBox::information( this, "OLCI ERR", "No selected OLCI ERR segments !" ); - return; + QMessageBox::information( this, "OLCI ERR", "No selected OLCI ERR segments !" ); + return; } } else if(ui->rdbMERSIin->isChecked()) { if(!opts.buttonMERSI || !segs->SelectedMERSISegments()) { - QMessageBox::information( this, "MERSI", "No selected MERSI segments !" ); - return; + QMessageBox::information( this, "MERSI", "No selected MERSI segments !" ); + return; } } else if(ui->rdbMeteosatin->isChecked()) @@ -3194,8 +3245,8 @@ void FormToolbox::on_btnCreateLambert_clicked() { if(!(opts.buttonVIIRSM || opts.buttonVIIRSMNOAA20) || !segs->SelectedVIIRSMSegments()) { - QMessageBox::information( this, "VIIRS M", "No selected VIIRS M segments !" ); - return; + QMessageBox::information( this, "VIIRS M", "No selected VIIRS M segments !" ); + return; } } @@ -3203,8 +3254,8 @@ void FormToolbox::on_btnCreateLambert_clicked() { if(!(opts.buttonVIIRSDNB || opts.buttonVIIRSDNBNOAA20) || !segs->SelectedVIIRSDNBSegments()) { - QMessageBox::information( this, "VIIRS DNB", "No selected VIIRS DNB segments !" ); - return; + QMessageBox::information( this, "VIIRS DNB", "No selected VIIRS DNB segments !" ); + return; } } @@ -3482,29 +3533,91 @@ void FormToolbox::on_btnCreateStereo_clicked() } -void FormToolbox::on_spbParallel1_valueChanged(int arg1) +void FormToolbox::on_btnCreateOM_clicked() { - opts.parallel1 = arg1; - if(imageptrs->ptrimageProjection->width() > 0) + // if(!opts.buttonVIIRSM) + // { + // QMessageBox msgBox; + // msgBox.setText("Only possible for VIIRS images."); + // msgBox.exec(); + // return; + // } + + ui->pbProgress->reset(); + + if(ui->rdbVIIRSMin->isChecked()) + { + if(!(opts.buttonVIIRSM || opts.buttonVIIRSMNOAA20) || !segs->SelectedVIIRSMSegments()) { - imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), - ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); + QMessageBox::information( this, "VIIRS M", "No selected VIIRS M segments !" ); + return; } + } + else if(ui->rdbMERSIin->isChecked()) + { + if(!opts.buttonMERSI || !segs->SelectedMERSISegments()) + { + QMessageBox::information( this, "MERSI", "No selected MERSI segments !" ); + return; + } + } + else if(ui->rdbAVHRRin->isChecked()) + { + if(!opts.buttonMetop || !segs->SelectedAVHRRSegments()) + { + QMessageBox::information( this, "MERSI", "No selected Metop segments !" ); + return; + } + } + + QApplication::setOverrideCursor( Qt::WaitCursor ); + imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType); + + if(ui->rdbVIIRSMin->isChecked()) + { + currentProjectionType = PROJ_VIIRSM; + if(opts.buttonVIIRSM) + imageptrs->om->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSM, false); + else if(opts.buttonVIIRSMNOAA20) + imageptrs->om->CreateMapFromVIIRS(eSegmentType::SEG_VIIRSMNOAA20, false); + } + else if(ui->rdbMERSIin->isChecked()) + { + currentProjectionType = PROJ_MERSI; + imageptrs->om->CreateMapFromMERSI(eSegmentType::SEG_MERSI, false); + } + else if(ui->rdbAVHRRin->isChecked()) + { + currentProjectionType = PROJ_AVHRR; + imageptrs->om->CreateMapFromAVHRR(eSegmentType::SEG_METOP, ui->cmbInputAVHRRChannel->currentIndex()); + } + + formimage->setPixmapToLabel(true); + QApplication::restoreOverrideCursor(); + } -void FormToolbox::on_spbParallel2_valueChanged(int arg1) +void FormToolbox::on_spbParallel1_valueChanged(int arg1) { - opts.parallel2 = arg1; - - if(imageptrs->ptrimageProjection->width() > 0) - { - imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), - ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); - } + opts.parallel1 = arg1; + if(imageptrs->ptrimageProjection->width() > 0) + { + imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), + ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); + formimage->UpdateProjection(); + } +} +void FormToolbox::on_spbParallel2_valueChanged(int arg1) +{ + opts.parallel2 = arg1; + if(imageptrs->ptrimageProjection->width() > 0) + { + imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), + ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); + formimage->UpdateProjection(); + } } void FormToolbox::on_spbCentral_valueChanged(int arg1) @@ -3524,16 +3637,16 @@ void FormToolbox::on_spbCentral_valueChanged(int arg1) void FormToolbox::on_spbLatOrigin_valueChanged(int arg1) { - opts.latitudeoforigin = arg1; + opts.latitudeoforigin = arg1; - qDebug() << QString("FormToolbox::on_spbOrigin_valueChanged(int arg1) origin value = %1").arg(arg1); + qDebug() << QString("FormToolbox::on_spbOrigin_valueChanged(int arg1) origin value = %1").arg(arg1); - if(imageptrs->ptrimageProjection->width() > 0) - { - imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), - ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); - } + if(imageptrs->ptrimageProjection->width() > 0) + { + imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), + ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); + formimage->UpdateProjection(); + } } @@ -3615,31 +3728,39 @@ void FormToolbox::on_spbEast_valueChanged(int arg1) return; } - opts.mapextenteast = arg1; + opts.mapextenteast = arg1; - int central = ui->spbWest->value() + longitudediffdeg( ui->spbEast->value(), ui->spbWest->value())/2; - qDebug() << QString("FormToolbox::on_spbEast_valueChanged(int arg1) central = %1").arg(central); + int central = ui->spbWest->value() + longitudediffdeg( ui->spbEast->value(), ui->spbWest->value())/2; + qDebug() << QString("FormToolbox::on_spbEast_valueChanged(int arg1) central = %1").arg(central); - ui->spbCentral->setValue(adjust_lon_deg(central)); + ui->spbCentral->setValue(adjust_lon_deg(central)); - if(imageptrs->ptrimageProjection->width() > 0) - { - imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), - ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); - formimage->UpdateProjection(); - } + if(imageptrs->ptrimageProjection->width() > 0) + { + imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), + ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); + formimage->UpdateProjection(); + } } - +eProjectionType FormToolbox::getCurrentProjectionType() +{ + return this->currentProjectionType; +} int FormToolbox::getTabWidgetIndex() { return ui->tabWidget->currentIndex(); } +int FormToolbox::getToolboxIndex() +{ + return ui->toolBox->currentIndex(); +} + int FormToolbox::getTabWidgetVIIRSIndex() { return ui->tabWidgetVIIRS->currentIndex(); @@ -3657,8 +3778,8 @@ void FormToolbox::on_toolBox_currentChanged(int index) ui->comboPOI->blockSignals(true); ui->comboPOI->clear(); -// if(!dockinfrascales->isHidden()) -// dockinfrascales->hide(); + // if(!dockinfrascales->isHidden()) + // dockinfrascales->hide(); imageptrs->ptrProjectionInfra.reset(); imageptrs->ptrProjectionBrightnessTemp.reset(); @@ -3667,7 +3788,7 @@ void FormToolbox::on_toolBox_currentChanged(int index) if (index == 0) { ui->comboPOI->addItems(poi.strlLCCName); -// on_comboPOI_currentIndexChanged(0); + // on_comboPOI_currentIndexChanged(0); ui->cbProjResolutions->setCurrentIndex(searchResolution(ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value())); imageptrs->lcc->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, ui->spbParallel1->value(), ui->spbParallel2->value(), ui->spbCentral->value(), ui->spbLatOrigin->value(), ui->spbLCCMapWidth->value(), ui->spbLCCMapHeight->value(), ui->spbLCCCorrX->value(), ui->spbLCCCorrY->value()); @@ -3675,20 +3796,26 @@ void FormToolbox::on_toolBox_currentChanged(int index) else if(index == 1) { ui->comboPOI->addItems(poi.strlGVPName); -// on_comboPOI_currentIndexChanged(0); + // on_comboPOI_currentIndexChanged(0); ui->cbProjResolutions->setCurrentIndex(searchResolution(ui->spbGVPMapWidth->value(), ui->spbGVPMapHeight->value())); imageptrs->gvp->Initialize(ui->spbGVPlon->value(), ui->spbGVPlat->value(), ui->spbGVPheight->value(), ui->spbGVPscale->value(), ui->spbGVPMapWidth->value(), ui->spbGVPMapHeight->value()); } - else + else if(index == 2) { ui->comboPOI->addItems(poi.strlSGName); -// on_comboPOI_currentIndexChanged(0); + // on_comboPOI_currentIndexChanged(0); ui->cbProjResolutions->setCurrentIndex(searchResolution(ui->spbSGMapWidth->value(), ui->spbSGMapHeight->value())); imageptrs->sg->Initialize(ui->spbSGlon->value(), ui->spbSGlat->value(), ui->spbSGScale->value(), ui->spbSGMapWidth->value(), ui->spbSGMapHeight->value(), ui->spbSGPanHorizon->value(), ui->spbSGPanVert->value()); } + else + { + imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, currentProjectionType); + + } ui->comboPOI->blockSignals(false); formimage->UpdateProjection(); + formimage->adjustPicSize(false); } @@ -5053,6 +5180,12 @@ void FormToolbox::on_chkSGGridOnProj_clicked() formimage->UpdateProjection(); } +void FormToolbox::on_chkOMGridOnProj_clicked() +{ + qDebug() << "FormToolbox::on_chkOMGridOnProjection_clicked()"; + formimage->UpdateProjection(); +} + void FormToolbox::on_btnAddPOI_clicked() { if(ui->lePOI->text().length() == 0) @@ -5192,24 +5325,24 @@ void FormToolbox::on_btnAddMConfig_clicked() else if(ui->rbM16->isChecked()) poi.strlColorBandM.append("16"); -// poi.strlColorsM.append(QString("%1").arg(ui->rbColorVIIRS->isChecked())); - -// poi.strlBandM1.append(QString("%1").arg(ui->rbM1->isChecked())); -// poi.strlBandM2.append(QString("%1").arg(ui->rbM2->isChecked())); -// poi.strlBandM3.append(QString("%1").arg(ui->rbM3->isChecked())); -// poi.strlBandM4.append(QString("%1").arg(ui->rbM4->isChecked())); -// poi.strlBandM5.append(QString("%1").arg(ui->rbM5->isChecked())); -// poi.strlBandM6.append(QString("%1").arg(ui->rbM6->isChecked())); -// poi.strlBandM7.append(QString("%1").arg(ui->rbM7->isChecked())); -// poi.strlBandM8.append(QString("%1").arg(ui->rbM8->isChecked())); -// poi.strlBandM9.append(QString("%1").arg(ui->rbM9->isChecked())); -// poi.strlBandM10.append(QString("%1").arg(ui->rbM10->isChecked())); -// poi.strlBandM11.append(QString("%1").arg(ui->rbM11->isChecked())); -// poi.strlBandM12.append(QString("%1").arg(ui->rbM12->isChecked())); -// poi.strlBandM13.append(QString("%1").arg(ui->rbM13->isChecked())); -// poi.strlBandM14.append(QString("%1").arg(ui->rbM14->isChecked())); -// poi.strlBandM15.append(QString("%1").arg(ui->rbM15->isChecked())); -// poi.strlBandM16.append(QString("%1").arg(ui->rbM16->isChecked())); + // poi.strlColorsM.append(QString("%1").arg(ui->rbColorVIIRS->isChecked())); + + // poi.strlBandM1.append(QString("%1").arg(ui->rbM1->isChecked())); + // poi.strlBandM2.append(QString("%1").arg(ui->rbM2->isChecked())); + // poi.strlBandM3.append(QString("%1").arg(ui->rbM3->isChecked())); + // poi.strlBandM4.append(QString("%1").arg(ui->rbM4->isChecked())); + // poi.strlBandM5.append(QString("%1").arg(ui->rbM5->isChecked())); + // poi.strlBandM6.append(QString("%1").arg(ui->rbM6->isChecked())); + // poi.strlBandM7.append(QString("%1").arg(ui->rbM7->isChecked())); + // poi.strlBandM8.append(QString("%1").arg(ui->rbM8->isChecked())); + // poi.strlBandM9.append(QString("%1").arg(ui->rbM9->isChecked())); + // poi.strlBandM10.append(QString("%1").arg(ui->rbM10->isChecked())); + // poi.strlBandM11.append(QString("%1").arg(ui->rbM11->isChecked())); + // poi.strlBandM12.append(QString("%1").arg(ui->rbM12->isChecked())); + // poi.strlBandM13.append(QString("%1").arg(ui->rbM13->isChecked())); + // poi.strlBandM14.append(QString("%1").arg(ui->rbM14->isChecked())); + // poi.strlBandM15.append(QString("%1").arg(ui->rbM15->isChecked())); + // poi.strlBandM16.append(QString("%1").arg(ui->rbM16->isChecked())); poi.strlInverseM1.append(QString("%1").arg(ui->chkInverseM1->isChecked())); poi.strlInverseM2.append(QString("%1").arg(ui->chkInverseM2->isChecked())); @@ -5270,7 +5403,7 @@ void FormToolbox::on_btnGVPFalseColor_clicked() if(forminfrascales->isHidden()) { QList blist = this->getVIIRSMBandList(); -// if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && + // if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && if(ui->rdbVIIRSMin->isChecked() && (blist.at(12) == true || blist.at(13) == true || blist.at(14) == true || blist.at(15) == true || blist.at(16) == true )) { @@ -5314,7 +5447,7 @@ void FormToolbox::on_btnLCCFalseColor_clicked() if(forminfrascales->isHidden()) { QList blist = this->getVIIRSMBandList(); -// if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && + // if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && if(ui->rdbVIIRSMin->isChecked() && (blist.at(12) == true || blist.at(13) == true || blist.at(14) == true || blist.at(15) == true || blist.at(16) == true )) { @@ -5358,7 +5491,7 @@ void FormToolbox::on_btnSGFalseColor_clicked() if(forminfrascales->isHidden()) { QList blist = this->getVIIRSMBandList(); -// if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && + // if(formimage->getSegmentType() == eSegmentType::SEG_VIIRSM && if(ui->rdbVIIRSMin->isChecked() && (blist.at(12) == true || blist.at(13) == true || blist.at(14) == true || blist.at(15) == true || blist.at(16) == true )) { @@ -5460,62 +5593,62 @@ void FormToolbox::fitCurve() { -// QVector xmax(180), ymax(180); // initialize with entries 0..100 -// QVector x, y; - -//// for(int i = 149; i >= 0; i--) -//// { - -//// double lowind = (double)(i % 10 + 1)/10.0; -//// double upperind = (double)(i % 10)/10.0; -//// double lowerlimit2 = pow(10, -lowind - (int)(i/10.0)); -//// double upperlimit2 = pow(10, -upperind - (int)(i/10.0)); -//// int index = 149 - i; -//// qDebug() << QString("---- index = %1 lowelimit2 = %2 upperlimit2 = %3") -//// .arg(index).arg(lowerlimit2).arg(upperlimit2); -//// } - - -// for(int xzenith = 0; xzenith < 180; xzenith++) -// { -// xmax[xzenith] = xzenith; -// ymax[xzenith] = 0; -// double radval = 0; -// long maxval = 0; -// int jmax = 0; - -// for(int j = 149; j >= 0; j--) -// { -// int index = j * 180 + xzenith; -// long val = segs->seglviirsdnb->graphvalues.operator [](index); -// if(val > maxval) -// { -// maxval = val; -// jmax = 149 - j; -// } -// } -// //qDebug() << QString("maxval = %1 jmax = %2").arg(maxval).arg(jmax); - -// if(maxval > 0) -// { -// double lowind = (double)((jmax % 10) + 1)/10.0; -// double upperind = (double)(jmax % 10)/10.0; -// double lowerlimit = pow(10, -lowind - (int)(jmax/10)); -// double upperlimit = pow(10, -upperind - (int)(jmax/10)); - -// ymax[xzenith] = upperlimit; -// // qDebug() << QString("lowlimit = %1 upperlimit = %2").arg(lowerlimit, 0, 'E', 3).arg(upperlimit, 0, 'E', 3); -// } -// } - -// for(int i = 0; i < 180; i++) -// { -// if(ymax[i] > 0) -// { -// x.append(xmax.at(i)); -// y.append(ymax.at(i)); -// } -// } + // QVector xmax(180), ymax(180); // initialize with entries 0..100 + // QVector x, y; + + //// for(int i = 149; i >= 0; i--) + //// { + + //// double lowind = (double)(i % 10 + 1)/10.0; + //// double upperind = (double)(i % 10)/10.0; + //// double lowerlimit2 = pow(10, -lowind - (int)(i/10.0)); + //// double upperlimit2 = pow(10, -upperind - (int)(i/10.0)); + //// int index = 149 - i; + //// qDebug() << QString("---- index = %1 lowelimit2 = %2 upperlimit2 = %3") + //// .arg(index).arg(lowerlimit2).arg(upperlimit2); + //// } + + + // for(int xzenith = 0; xzenith < 180; xzenith++) + // { + // xmax[xzenith] = xzenith; + // ymax[xzenith] = 0; + // double radval = 0; + // long maxval = 0; + // int jmax = 0; + + // for(int j = 149; j >= 0; j--) + // { + // int index = j * 180 + xzenith; + // long val = segs->seglviirsdnb->graphvalues.operator [](index); + // if(val > maxval) + // { + // maxval = val; + // jmax = 149 - j; + // } + // } + // //qDebug() << QString("maxval = %1 jmax = %2").arg(maxval).arg(jmax); + + // if(maxval > 0) + // { + // double lowind = (double)((jmax % 10) + 1)/10.0; + // double upperind = (double)(jmax % 10)/10.0; + // double lowerlimit = pow(10, -lowind - (int)(jmax/10)); + // double upperlimit = pow(10, -upperind - (int)(jmax/10)); + + // ymax[xzenith] = upperlimit; + // // qDebug() << QString("lowlimit = %1 upperlimit = %2").arg(lowerlimit, 0, 'E', 3).arg(upperlimit, 0, 'E', 3); + // } + // } + + // for(int i = 0; i < 180; i++) + // { + // if(ymax[i] > 0) + // { + // x.append(xmax.at(i)); + // y.append(ymax.at(i)); + // } + // } // create graph and assign data to it: ui->graph->addGraph(); if(opts.buttonVIIRSDNB) @@ -5617,48 +5750,48 @@ void FormToolbox::setAllWhatsThis() { const QString htmlText1 = - "None 95%
" - "Linear mapping of 95% of the pixels to 0 - 255. The lower 2.5% of the pixel values are set to 0 and the higher 2.5% of the pixel values are set to 255.

" - "None 100%
" - "Linear mapping of 100% of the pixels to 0 - 255

" - "Equalize%
" - "Histogram equalization of the projected image.
The LUT is calculated over the complete input image.

" - "Equalize Projection
" - "Histogram equalization of the projected image.
The LUT is calculated only over the pixels of the projected image."; + "None 95%
" + "Linear mapping of 95% of the pixels to 0 - 255. The lower 2.5% of the pixel values are set to 0 and the higher 2.5% of the pixel values are set to 255.

" + "None 100%
" + "Linear mapping of 100% of the pixels to 0 - 255

" + "Equalize%
" + "Histogram equalization of the projected image.
The LUT is calculated over the complete input image.

" + "Equalize Projection
" + "Histogram equalization of the projected image.
The LUT is calculated only over the pixels of the projected image."; ui->cmbHistogramProj->setWhatsThis(htmlText1); ui->cmbHistogram->setWhatsThis(htmlText1); const QString htmlText2 = - "Normalized
" - "The values of the radiances are divided with the cosine of the Sun Zenith Angle."; + "Normalized
" + "The values of the radiances are divided with the cosine of the Sun Zenith Angle."; ui->rdbOLCINormalized->setWhatsThis(htmlText2); ui->rdbOLCIprojNormalized->setWhatsThis(htmlText2); const QString htmlText3 = - "A 48bit RGB PNG image as 16 bits per colorchannel. The RGB values of the PNG contains the radiances multiplied by 10"; + "A 48bit RGB PNG image as 16 bits per colorchannel. The RGB values of the PNG contains the radiances multiplied by 10"; ui->btnSaveAsPNG48bits->setWhatsThis(htmlText3); const QString htmlText31 = - "When set the radiances will be linear mapped to 0 - 65535."; + "When set the radiances will be linear mapped to 0 - 65535."; ui->rdbMapTo65535->setWhatsThis(htmlText31); const QString htmlText4 = - "A Lambert conformal conic projection (LCC) is a conic map projection used for aeronautical charts, portions of the State Plane Coordinate System, and many national and regional mapping systems."; + "A Lambert conformal conic projection (LCC) is a conic map projection used for aeronautical charts, portions of the State Plane Coordinate System, and many national and regional mapping systems."; ui->pageLambert->setWhatsThis(htmlText4); const QString htmlText5 = - "The point of perspective for the General Vertical Perspective Projection (GVP) is a finite distance." - "It depicts the earth as it appears from some relatively short distance above the surface, typically a few hundred to a few tens of thousands of kilometers."; + "The point of perspective for the General Vertical Perspective Projection (GVP) is a finite distance." + "It depicts the earth as it appears from some relatively short distance above the surface, typically a few hundred to a few tens of thousands of kilometers."; ui->pagePerspective->setWhatsThis(htmlText5); const QString htmlText6 = - "The stereographic projection was known to Hipparchus, Ptolemy and probably earlier to the Egyptians. It was originally known as the planisphere projection. One of its most important uses was the representation of celestial charts."; + "The stereographic projection was known to Hipparchus, Ptolemy and probably earlier to the Egyptians. It was originally known as the planisphere projection. One of its most important uses was the representation of celestial charts."; ui->pageStereographic->setWhatsThis(htmlText6); const QString htmlText7 = - "For making a projection (LCC, GVP or SG) select one of the input images.

" + "For making a projection (LCC, GVP or SG) select one of the input images.

" "AVHRR image
" "Input Images from the NOAA-19, Metop-A and B satellite

" "VIIRS M and DNB image
" @@ -5678,7 +5811,7 @@ void FormToolbox::on_btnSaveAsPNG48bits_clicked() if(!formimage->SaveAsPNG48bits(ui->rdbMapTo65535->isChecked())) { QMessageBox::information( this, "Save 48bit PNG", - "There is no input file !" ); + "There is no input file !" ); } } @@ -5760,35 +5893,35 @@ void FormToolbox::on_btnSaveProjectionAsPNG48bits_clicked() return; else { - QApplication::setOverrideCursor(Qt::WaitCursor); - if(fileName.mid(fileName.length()-4) != ".png" && fileName.mid(fileName.length()-4) != ".PNG") - fileName.append(".png"); - switch(currentProjectionType) - { - case PROJ_AVHRR: - break; - case PROJ_GEOSTATIONARY: - break; - case PROJ_OLCI_EFR: - segs->seglolciefr->SmoothOLCIImage12bits(); - segs->seglolciefr->Compose48bitProjectionPNG(fileName, ui->rdbMapTo65535Proj->isChecked()); - break; - case PROJ_OLCI_ERR: - segs->seglolcierr->SmoothOLCIImage12bits(); - segs->seglolcierr->Compose48bitProjectionPNG(fileName, ui->rdbMapTo65535Proj->isChecked()); - break; - case PROJ_SLSTR: - break; - case PROJ_VIIRSM: - segs->seglviirsm->SmoothVIIRSImage12bits(); - segs->seglviirsm->Compose48bitProjectionPNG(fileName, ui->rdbMapTo65535Proj->isChecked()); - break; - case PROJ_VIIRSDNB: - break; - default: - return; - } - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + if(fileName.mid(fileName.length()-4) != ".png" && fileName.mid(fileName.length()-4) != ".PNG") + fileName.append(".png"); + switch(currentProjectionType) + { + case PROJ_AVHRR: + break; + case PROJ_GEOSTATIONARY: + break; + case PROJ_OLCI_EFR: + segs->seglolciefr->SmoothOLCIImage12bits(); + segs->seglolciefr->Compose48bitProjectionPNG(fileName, ui->rdbMapTo65535Proj->isChecked()); + break; + case PROJ_OLCI_ERR: + segs->seglolcierr->SmoothOLCIImage12bits(); + segs->seglolcierr->Compose48bitProjectionPNG(fileName, ui->rdbMapTo65535Proj->isChecked()); + break; + case PROJ_SLSTR: + break; + case PROJ_VIIRSM: + segs->seglviirsm->SmoothVIIRSImage12bits(); + segs->seglviirsm->Compose48bitProjectionPNG(fileName, ui->rdbMapTo65535Proj->isChecked()); + break; + case PROJ_VIIRSDNB: + break; + default: + return; + } + QApplication::restoreOverrideCursor(); } } @@ -5881,13 +6014,13 @@ void FormToolbox::on_cmbHistogramGeo_activated(int index) void FormToolbox::on_btnCLAHE_RGBRecipe_clicked() { - QApplication::setOverrideCursor(Qt::WaitCursor); - this->setToolboxButtons(false); - QApplication::processEvents(); - qDebug() << QString("ui->sliCLAHE_RGBRecipe value = %1").arg((float)ui->sliCLAHE_RGBRecipe->value()/10.0); - formimage->CLAHERGBRecipe((float)ui->sliCLAHE_RGBRecipe->value()/10.0); - formimage->slotUpdateGeosat(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + this->setToolboxButtons(false); + QApplication::processEvents(); + qDebug() << QString("ui->sliCLAHE_RGBRecipe value = %1").arg((float)ui->sliCLAHE_RGBRecipe->value()/10.0); + formimage->CLAHERGBRecipe((float)ui->sliCLAHE_RGBRecipe->value()/10.0); + formimage->slotUpdateGeosat(); + QApplication::restoreOverrideCursor(); } @@ -5985,3 +6118,58 @@ void FormToolbox::on_btnAddMERSIConfig_clicked() ui->leMERSIConfig->setText(""); } + + +void FormToolbox::on_rdbAVHRRin_clicked() +{ + this->currentProjectionType = PROJ_AVHRR; +} + +void FormToolbox::on_rdbVIIRSMin_clicked() +{ + this->currentProjectionType = PROJ_VIIRSM; + if( this->getToolboxIndex() == 3) + imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType); + + formimage->UpdateProjection(); + +} + +void FormToolbox::on_rdbVIIRSDNBin_clicked() +{ + this->currentProjectionType = PROJ_VIIRSDNB; +} + +void FormToolbox::on_rdbOLCIefrin_clicked() +{ + this->currentProjectionType = PROJ_OLCI_EFR; +} + +void FormToolbox::on_rdbOLCIerrin_clicked() +{ + this->currentProjectionType = PROJ_OLCI_ERR; +} + +void FormToolbox::on_rdbMERSIin_clicked() +{ + this->currentProjectionType = PROJ_MERSI; + if( this->getToolboxIndex() == 3) + imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, this->currentProjectionType); + + formimage->UpdateProjection(); + +} + +void FormToolbox::on_rdbMeteosatin_clicked() +{ + this->currentProjectionType = PROJ_GEOSTATIONARY; +} + + + +void FormToolbox::on_btnOMClearMap_clicked() +{ + imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); + formimage->displayImage(IMAGE_PROJECTION); +} + diff --git a/core/formtoolbox.h b/core/formtoolbox.h index e0470d8..4c58188 100644 --- a/core/formtoolbox.h +++ b/core/formtoolbox.h @@ -24,8 +24,10 @@ class FormToolbox : public QWidget public: explicit FormToolbox(QWidget *parent = 0, FormImage *p_formimage = 0, FormGeostationary *p_formgeostationary = 0, FormInfraScales *p_forminfrascales = 0, AVHRRSatellite *seglist = 0); int getTabWidgetIndex(); + int getToolboxIndex(); int getTabWidgetVIIRSIndex(); int getTabWidgetSentinelIndex(); + eProjectionType getCurrentProjectionType(); int getGeoIndex() { return geoindex; } void setGeoIndex(int geo) { this->geoindex = geo; } @@ -58,6 +60,7 @@ class FormToolbox : public QWidget bool GridOnProjLCC(); bool GridOnProjGVP(); bool GridOnProjSG(); + bool GridOnProjOM(); void setPOIsettings(); void setMConfigsettings(); void setOLCIefrConfigsettings(); @@ -224,6 +227,7 @@ private slots: void on_spbSGRadius_valueChanged(double arg1); void on_btnSGClearMap_clicked(); void on_btnOverlayProjectionSG_clicked(); + void on_btnOverlayProjectionOM_clicked(); void on_spbLCCCorrX_valueChanged(int arg1); void on_spbLCCCorrY_valueChanged(int arg1); void on_btnUpdateVIIRSImage_clicked(); @@ -294,6 +298,18 @@ private slots: void on_btnUpdateMERSIImage_clicked(); void on_comboMERSIConfig_currentIndexChanged(int index); void on_btnAddMERSIConfig_clicked(); + void on_btnCreateOM_clicked(); + + void on_rdbAVHRRin_clicked(); + void on_rdbVIIRSMin_clicked(); + void on_rdbVIIRSDNBin_clicked(); + void on_rdbOLCIefrin_clicked(); + void on_rdbOLCIerrin_clicked(); + void on_rdbMERSIin_clicked(); + void on_rdbMeteosatin_clicked(); + + void on_btnOMClearMap_clicked(); + void on_chkOMGridOnProj_clicked(); }; diff --git a/core/formtoolbox.ui b/core/formtoolbox.ui index 7c4c9ea..56c8d0b 100644 --- a/core/formtoolbox.ui +++ b/core/formtoolbox.ui @@ -9,8 +9,8 @@ 0 0 - 821 - 1385 + 813 + 1767 @@ -38,7 +38,7 @@ QTabWidget::West - 3 + 5 Qt::ElideNone @@ -6979,7 +6979,7 @@ - + QFrame::StyledPanel @@ -6992,14 +6992,14 @@ - 0 + 3 0 0 - 685 + 429 685 @@ -7879,9 +7879,15 @@ + + + 0 + 0 + + - 70 + 80 16777215 @@ -7936,6 +7942,12 @@ + + + 0 + 0 + + 70 @@ -7944,7 +7956,7 @@ - 80 + 140 16777215 @@ -8432,6 +8444,120 @@ + + + + 0 + 0 + 696 + 406 + + + + Oblique Mercator + + + + + + Only possible for AVHRR(Metop), VIIRS M and MERSI images + + + + + + + + + Create Map + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Overlay + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Grid on Projection + + + + + + + Clear + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 253 + + + + + + @@ -8484,7 +8610,7 @@ - Point of interest : + Area of interest : @@ -8505,7 +8631,7 @@ - Add POI : + Add AOI : diff --git a/core/generalverticalperspective.cpp b/core/generalverticalperspective.cpp index 5918a7d..b4f7caf 100644 --- a/core/generalverticalperspective.cpp +++ b/core/generalverticalperspective.cpp @@ -16,6 +16,9 @@ GeneralVerticalPerspective::GeneralVerticalPerspective(QObject *parent, AVHRRSat { segs = seglist; qDebug() << QString("constructor GeneralVerticalPerspective"); + image_width = 0; + image_height = 0; + Initialize(opts.mapgvplon, opts.mapgvplat, opts.mapgvpheight, opts.mapgvpscale, opts.mapwidth, opts.mapheight); } @@ -82,10 +85,10 @@ double GeneralVerticalPerspective::Initialize(double lonmapdeg, double latmapdeg map_radius = R*sqrt((p-1)/(p+1)); scale = scaling; - qDebug() << QString("-------> Map radius = %1 scale = %2").arg(map_radius).arg(scale); +// qDebug() << QString("-------> Map radius = %1 scale = %2").arg(map_radius).arg(scale); -#ifdef WIN32 && __GNUC__ +#ifdef WIN32 //&& __GNUC__ sin_lat_o = sin(lat_center); cos_lat_o = cos(lat_center); #else diff --git a/core/globals.cpp b/core/globals.cpp index 8cddf43..1a7f730 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -8,18 +8,18 @@ ////////////////////////////////////////////////////////////////////////////// double sqr(const double x) { - return (x * x); + return (x * x); } ////////////////////////////////////////////////////////////////////////////// double Fmod2p(const double arg) { - double modu = fmod(arg, TWOPI); + double modu = fmod(arg, TWOPI); - if (modu < 0.0) - modu += TWOPI; + if (modu < 0.0) + modu += TWOPI; - return modu; + return modu; } ////////////////////////////////////////////////////////////////////////////// @@ -28,76 +28,76 @@ double Fmod2p(const double arg) // is that it returns the correct quadrant of the angle. double AcTan(const double sinx, const double cosx) { - double ret; - - if (cosx == 0.0) - { - if (sinx > 0.0) - ret = PI / 2.0; - else - ret = 3.0 * PI / 2.0; - } - else - { - if (cosx > 0.0) - ret = atan(sinx / cosx); - else - ret = PI + atan(sinx / cosx); - } - - return ret; + double ret; + + if (cosx == 0.0) + { + if (sinx > 0.0) + ret = PI / 2.0; + else + ret = 3.0 * PI / 2.0; + } + else + { + if (cosx > 0.0) + ret = atan(sinx / cosx); + else + ret = PI + atan(sinx / cosx); + } + + return ret; } ////////////////////////////////////////////////////////////////////////////// double rad2deg(const double r) { - const double DEG_PER_RAD = 180.0 / PI; - return r * DEG_PER_RAD; + const double DEG_PER_RAD = 180.0 / PI; + return r * DEG_PER_RAD; } ////////////////////////////////////////////////////////////////////////////// double deg2rad(const double d) { - const double RAD_PER_DEG = PI / 180.0; - return d * RAD_PER_DEG; + const double RAD_PER_DEG = PI / 180.0; + return d * RAD_PER_DEG; } /* Returns orccosine of rgument */ double ArcCos(double arg) { - return( (PI/2) - ArcSin(arg) ); + return( (PI/2) - ArcSin(arg) ); } /*Function ArcCos*/ /* Returns sign of a double */ int Sign(double arg) { - if( arg > 0 ) - return( 1 ); - else if( arg < 0 ) - return( -1 ); - else - return( 0 ); + if( arg > 0 ) + return( 1 ); + else if( arg < 0 ) + return( -1 ); + else + return( 0 ); } /* Function Sign*/ /* Returns the arcsine of the argument */ double ArcSin(double arg) { - if( fabs(arg) >= 1 ) - return( Sign(arg)*(PI/2) ); - else - return( atan(arg/sqrt(1-arg*arg)) ); + if( fabs(arg) >= 1 ) + return( Sign(arg)*(PI/2) ); + else + return( atan(arg/sqrt(1-arg*arg)) ); } /*Function ArcSin*/ float ArcSinf(float arg) { - if( fabs(arg) >= 1 ) - return( Sign(arg)*(PI/2) ); - else - return( atan(arg/sqrt(1-arg*arg)) ); + if( fabs(arg) >= 1 ) + return( Sign(arg)*(PI/2) ); + else + return( atan(arg/sqrt(1-arg*arg)) ); } /*Function ArcSinf*/ /*------------------------------------------------------------------*/ @@ -110,57 +110,57 @@ static int Flags = 0; int isFlagSet(int flag) { - return (Flags & flag); + return (Flags & flag); } int isFlagClear(int flag) { - return (~Flags & flag); + return (~Flags & flag); } void SetFlag(int flag) { - Flags |= flag; + Flags |= flag; } void ClearFlag(int flag) { - Flags &= ~flag; + Flags &= ~flag; } void LonLat2Point(float lat, float lon, QVector3D *pos, float radius) { - // lon -90..90 - // lat -180..180 + // lon -90..90 + // lat -180..180 - float angX, angY; + float angX, angY; - angX = lon * PI / 180.f; - angY = lat * PI / 180.f; + angX = lon * PI / 180.f; + angY = lat * PI / 180.f; -/* pos->x = fabsf(cosf(angY)) * sinf(angX) * radius; + /* pos->x = fabsf(cosf(angY)) * sinf(angX) * radius; pos->y = sinf(angY) * radius; pos->z = fabsf(cosf(angY)) * cosf(angX) * radius; */ - pos->setX(cosf(angY) * sinf(angX) * radius); - pos->setY(sinf(angY) * radius); - pos->setZ(cosf(angY) * cosf(angX) * radius); + pos->setX(cosf(angY) * sinf(angX) * radius); + pos->setY(sinf(angY) * radius); + pos->setZ(cosf(angY) * cosf(angX) * radius); } void LonLat2PointRad(float lat, float lon, QVector3D *pos, float radius) { - // lon -pi/2..pi/2 - // lat -pi..pi + // lon -pi/2..pi/2 + // lat -pi..pi - pos->setX(cosf(lat) * sinf(lon) * radius); - pos->setY(sinf(lat) * radius); - pos->setZ(cosf(lat) * cosf(lon) * radius); + pos->setX(cosf(lat) * sinf(lon) * radius); + pos->setY(sinf(lat) * radius); + pos->setZ(cosf(lat) * cosf(lon) * radius); } @@ -177,61 +177,61 @@ Point2LonLat(double *lat_rad, double *lon_rad, double *radius, QVector3D pos ) void Pos2LatLonAlt(double *lat_rad, double *lon_rad, double *radius, QVector3D pos) { - /* Reference: The 1992 Astronomical Almanac, page K12. */ + /* Reference: The 1992 Astronomical Almanac, page K12. */ - double r,e2,phi,c; - double sinphi; + double r,e2,phi,c; + double sinphi; - *lon_rad = AcTan(pos.y(),pos.x());/*radians*/ - r = sqrt(pos.x()*pos.x() + pos.y()*pos.y()); - e2 = F*(2 - F); - *lat_rad = AcTan(pos.z(),r);/*radians*/ + *lon_rad = AcTan(pos.y(),pos.x());/*radians*/ + r = sqrt(pos.x()*pos.x() + pos.y()*pos.y()); + e2 = F*(2 - F); + *lat_rad = AcTan(pos.z(),r);/*radians*/ - do + do { - phi = *lat_rad; - sinphi = sin(phi); - c = 1/sqrt(1 - e2*sinphi*sinphi); - *lat_rad = AcTan(pos.z() + XKMPER_WGS72*c*e2*sin(phi),r); + phi = *lat_rad; + sinphi = sin(phi); + c = 1/sqrt(1 - e2*sinphi*sinphi); + *lat_rad = AcTan(pos.z() + XKMPER_WGS72*c*e2*sin(phi),r); } - while(fabs(*lat_rad - phi) >= 1E-10); + while(fabs(*lat_rad - phi) >= 1E-10); - *radius = XKMPER_WGS72 + r/cos(*lat_rad) - XKMPER_WGS72*c;/*kilometers*/ + *radius = XKMPER_WGS72 + r/cos(*lat_rad) - XKMPER_WGS72*c;/*kilometers*/ - if( *lat_rad > PI/2 ) *lat_rad -= TWOPI; + if( *lat_rad > PI/2 ) *lat_rad -= TWOPI; } /*Procedure Calculate_LatLonAlt*/ void LonLat2Vector(float lat, float lon, QVector3D *pos, float radius) { - // lon -90..90 - // lat -180..180 + // lon -90..90 + // lat -180..180 - float angX, angY; + float angX, angY; - angX = lon * PI / 180.f; - angY = lat * PI / 180.f; + angX = lon * PI / 180.f; + angY = lat * PI / 180.f; - pos->setX(fabsf(cosf(angY)) * sinf(angX) * radius); - pos->setY(sinf(angY) * radius); - pos->setZ(fabsf(cosf(angY)) * cosf(angX) * radius); + pos->setX(fabsf(cosf(angY)) * sinf(angX) * radius); + pos->setY(sinf(angY) * radius); + pos->setZ(fabsf(cosf(angY)) * cosf(angX) * radius); } void sphericalToPixel(double lon, double lat, int &x, int &y, int devwidth, int devheight) { - if (lon > PI) lon -= TWOPI; - else if (lon < -PI) lon += TWOPI; + if (lon > PI) lon -= TWOPI; + else if (lon < -PI) lon += TWOPI; - x = (int) ((lon - (-PI)) * devwidth/TWOPI + 0.5); + x = (int) ((lon - (-PI)) * devwidth/TWOPI + 0.5); - if (x >= devwidth) x -= devwidth; - else if (x < 0) x += devwidth; + if (x >= devwidth) x -= devwidth; + else if (x < 0) x += devwidth; - y = (int) ((PI/2 - lat) * devheight/PI + 0.5); - if (y >= devheight) y = devheight - 1; + y = (int) ((PI/2 - lat) * devheight/PI + 0.5); + if (y >= devheight) y = devheight - 1; } @@ -253,42 +253,42 @@ int intersect(struct line l1, struct line l2) { return ((ccw(l1.p1, l1.p2, l2.p1) - *ccw(l1.p1, l1.p2, l2.p2)) <= 0) - && ((ccw(l2.p1, l2.p2, l1.p1) - *ccw(l2.p1, l2.p2, l1.p2)) <= 0); + *ccw(l1.p1, l1.p2, l2.p2)) <= 0) + && ((ccw(l2.p1, l2.p2, l1.p1) + *ccw(l2.p1, l2.p2, l1.p2)) <= 0); } int pnpoly(int nvert, const QPoint *points, int testx, int testy) // { - int i, j, c = 0; + int i, j, c = 0; - for (i = 0, j = nvert-1; i < nvert; j = i++) { - if ( ((points[i].y() > testy) != (points[j].y() > testy)) && - (testx < (points[j].x() - points[i].x() ) * (testy-points[i].y()) / (points[j].y() - points[i].y()) + points[i].x()) ) - c = !c; - } + for (i = 0, j = nvert-1; i < nvert; j = i++) { + if ( ((points[i].y() > testy) != (points[j].y() > testy)) && + (testx < (points[j].x() - points[i].x() ) * (testy-points[i].y()) / (points[j].y() - points[i].y()) + points[i].x()) ) + c = !c; + } - return c; + return c; } void sortSphericalVectorLon(SphericalVector arr[], int size) { - SphericalVector temp; + SphericalVector temp; - for(int i = 0; i < size; i++) + for(int i = 0; i < size; i++) + { + for(int j = 0;j < size - 1; j++) { - for(int j = 0;j < size - 1; j++) - { - if(arr[j].lon > arr[j+1].lon) - { - //we need to swap - temp = arr[j]; - arr[j] = arr[j+1]; - arr[j+1] = temp; - } - } + if(arr[j].lon > arr[j+1].lon) + { + //we need to swap + temp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = temp; + } } + } } double adjust_lon_rad(double x) @@ -301,7 +301,7 @@ double adjust_lon_rad(double x) return (x + TWOPI); else return (x - TWOPI); - } + } } double adjust_lon_deg(double x) @@ -314,7 +314,7 @@ double adjust_lon_deg(double x) return (x + 360.0); else return (x - 360.0); - } + } } double longitudediffdeg( double lon1, double lon2) @@ -336,9 +336,9 @@ double longitudediffdeg( double lon1, double lon2) } else { - deltalon = lon1 + fabs(lon2); - if(deltalon > 180.0) - deltalon = 360 - deltalon; + deltalon = lon1 + fabs(lon2); + if(deltalon > 180.0) + deltalon = 360 - deltalon; } return deltalon; @@ -379,5 +379,73 @@ int Max(const int *Numbers, const int Count) return Maximum; } +/* Function to eliminate roundoff errors in asin +----------------------------------------------*/ +double asinz (double con) +{ + if (fabs(con) > 1.0) + { + if (con > 1.0) + con = 1.0; + else + con = -1.0; + } + return(asin(con)); +} +float Minf(const float v11, const float v12, const float v21, const float v22) +{ + float Minimum = v11; + + if( Minimum > v12 ) + Minimum = v12; + if( Minimum > v21 ) + Minimum = v21; + if( Minimum > v22 ) + Minimum = v22; + + return Minimum; +} + +float Maxf(const float v11, const float v12, const float v21, const float v22) +{ + int Maximum = v11; + + if( Maximum < v12 ) + Maximum = v12; + if( Maximum < v21 ) + Maximum = v21; + if( Maximum < v22 ) + Maximum = v22; + + return Maximum; +} + +double Mind(const double v11, const double v12, const double v21, const double v22) +{ + double Minimum = v11; + + if( Minimum > v12 ) + Minimum = v12; + if( Minimum > v21 ) + Minimum = v21; + if( Minimum > v22 ) + Minimum = v22; + + return Minimum; +} + +double Maxd(const double v11, const double v12, const double v21, const double v22) +{ + int Maximum = v11; + + if( Maximum < v12 ) + Maximum = v12; + if( Maximum < v21 ) + Maximum = v21; + if( Maximum < v22 ) + Maximum = v22; + + return Maximum; +} /*------------------------------------------------------------------*/ diff --git a/core/globals.h b/core/globals.h index 3be56a4..3cc598c 100644 --- a/core/globals.h +++ b/core/globals.h @@ -227,7 +227,11 @@ void sortSphericalVectorLon(SphericalVector arr[], int size); int Min(const int *Numbers, const int Count); int Max(const int *Numbers, const int Count); +float Minf(const float v11, const float v12, const float v21, const float v22); +float Maxf(const float v11, const float v12, const float v21, const float v22); +double Mind(const double v11, const double v12, const double v21, const double v22); +double Maxd(const double v11, const double v12, const double v21, const double v22); - +double asinz(double con); #endif diff --git a/core/lambertconformalconic.cpp b/core/lambertconformalconic.cpp index d2b93ad..661bd1b 100644 --- a/core/lambertconformalconic.cpp +++ b/core/lambertconformalconic.cpp @@ -18,6 +18,9 @@ LambertConformalConic::LambertConformalConic(QObject *parent, AVHRRSatellite *se min_y = 9999999999.0; max_y = 0.0; + image_width = 0; + image_height = 0; + qDebug() << QString("constructor LambertConformalConic"); } @@ -136,7 +139,7 @@ void LambertConformalConic::Initialize(double r_maj, double r_min, double stdlat es = 1.0 - temp*temp; e = sqrt(es); -#ifdef WIN32 && __GNUC__ +#ifdef WIN32 // && __GNUC__ sin_po = sin(lat1); cos_po = cos(lat1); #else @@ -147,7 +150,7 @@ void LambertConformalConic::Initialize(double r_maj, double r_min, double stdlat ms1 = msfnz(e,sin_po,cos_po); ts1 = tsfnz(e,lat1,sin_po); -#ifdef WIN32 && __GNUC__ +#ifdef WIN32 //&& __GNUC__ sin_po = sin(lat2); cos_po = cos(lat2); #else diff --git a/core/main.cpp b/core/main.cpp index 4de5167..976198e 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -12,7 +12,7 @@ #include -#define APPVERSION "1.4.8" +#define APPVERSION "1.4.9" using namespace std; @@ -29,6 +29,7 @@ QNetworkAccessManager networkaccessmanager; bool doLogging; bool ptrimagebusy; +// Every now and then a masterpiece like this comes out, and the world is gifted with a few hours of hope for the human race, before dropping back into it's usual chaos. void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { diff --git a/core/mainwindow.cpp b/core/mainwindow.cpp index a1b324d..e640666 100644 --- a/core/mainwindow.cpp +++ b/core/mainwindow.cpp @@ -54,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent) : imageptrs->gvp = new GeneralVerticalPerspective(this, seglist); imageptrs->lcc = new LambertConformalConic(this, seglist); imageptrs->sg = new StereoGraphic(this, seglist); + imageptrs->om = new ObliqueMercator(this, seglist); QMainWindow::setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); QMainWindow::setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); @@ -142,6 +143,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(seglist->seglviirsm, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); connect(seglist->seglviirsdnb, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); + connect(seglist->seglviirsmnoaa20, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); + connect(seglist->seglviirsdnbnoaa20, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); connect(seglist->seglolciefr, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); connect(seglist->seglolcierr, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); connect(seglist->seglmersi, SIGNAL(segmentprojectionfinished(bool)), formimage, SLOT(setPixmapToLabel(bool))); @@ -199,6 +202,9 @@ MainWindow::MainWindow(QWidget *parent) : restoreGeometry(opts.mainwindowgeometry); restoreState(opts.mainwindowstate); //QMainWindow::resizeDocks({dockwidget}, {1000}, Qt::Horizontal); + bool restored = QMainWindow::restoreDockWidget(dockwidget); + qDebug() << "restoredockwidget = " << restored << " width of toolbox = " << formtoolbox->width(); + seglist->ReadXMLfiles(); @@ -228,7 +234,7 @@ void MainWindow::createDockWidget() dockwidget = new QDockWidget(tr("Toolbox"),this,Qt::Widget|Qt::WindowStaysOnTopHint|Qt::X11BypassWindowManagerHint); dockwidget->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea); dockwidget->setObjectName("Toolbox"); - QScrollArea * scrollArea = new QScrollArea(this); + QScrollArea * scrollArea = new QScrollArea; scrollArea->setWidget(formtoolbox); scrollArea->setWidgetResizable(true); scrollArea->resize(700, MainWindow::height()); @@ -236,7 +242,7 @@ void MainWindow::createDockWidget() dockwidget->resize(700, MainWindow::height()); addDockWidget(Qt::LeftDockWidgetArea,dockwidget); // QMainWindow::resizeDocks({dockwidget}, {opts.toolboxwidth}, Qt::Horizontal); -// QMainWindow::resizeDocks({dockwidget}, {1000}, Qt::Horizontal); + //QMainWindow::resizeDocks({dockwidget}, {1000}, Qt::Horizontal); } @@ -264,7 +270,9 @@ void MainWindow::closeEvent(QCloseEvent *event) opts.mainwindowstate = saveState(0); opts.toolboxwidth = formtoolbox->width(); - forminfrascales->close(); + qDebug() << "Width of toolbox = " << formtoolbox->width(); + + //forminfrascales->close(); delete timer; delete formtoolbox; @@ -507,7 +515,14 @@ void MainWindow::on_actionImage_triggered() formimage->displayImage(IMAGE_GEOSTATIONARY); //Geostationary image } else if(index == TAB_PROJECTION) - formimage->displayImage(IMAGE_PROJECTION); //Projection image + { + if( formtoolbox->getToolboxIndex() == 3) + imageptrs->om->Initialize(R_MAJOR_A_WGS84, R_MAJOR_B_WGS84, formtoolbox->getCurrentProjectionType()); + + formimage->UpdateProjection(); + + // formimage->displayImage(IMAGE_PROJECTION); //Projection image + } ui->actionSatSelection->setChecked(false); ui->actionMeteosat->setChecked(false); diff --git a/core/obliquemercator.cpp b/core/obliquemercator.cpp new file mode 100644 index 0000000..f223f2a --- /dev/null +++ b/core/obliquemercator.cpp @@ -0,0 +1,949 @@ +#include +#include + +#include "obliquemercator.h" +#include "globals.h" +#include "options.h" +#include "pixgeoconversion.h" +#include +#include + +#include + +extern Options opts; +extern SegmentImage *imageptrs; +extern gshhsData *gshhsdata; + +ObliqueMercator::ObliqueMercator(QObject *parent, AVHRRSatellite *seglist) : + QObject(parent) +{ + segs = seglist; + image_width = 0; + image_height = 0; + + + deltaboundingboxX = 0.0; + deltaboundingboxY = 0.0; + + qDebug() << QString("constructor ObliqueMercator"); +} + +ObliqueMercator::~ObliqueMercator() +{ +} + +void ObliqueMercator::Initialize(double r_maj, double r_min, eProjectionType projtype) +{ + double temp; /* temporary variable */ + double con,com; + double ts; + double ts1,ts2; + double h,l; + double j,p,dlon; + double f,g,gama; + double sinphi; + double lon1_r; /* fist point to define central line in rad */ + double lat1_r; /* fist point to define central line */ + double lon2_r; /* second point to define central line */ + double lat2_r; /* second point to define central line */ + + double lon1_d; /* fist point to define central line in deg */ + double lat1_d; /* fist point to define central line */ + double lon2_d; /* second point to define central line */ + double lat2_d; /* second point to define central line */ + + lon1_d = 65535.0; + lat1_d = 65535.0; + lon2_d = 65535.0; + lat2_d = 65535.0; + + qDebug() << "ObliqueMercator::Initialize input image = " << projtype; + + if(projtype != PROJ_AVHRR && projtype != PROJ_MERSI && projtype != PROJ_VIIRSM ) + { + QMessageBox msgBox; + msgBox.setText("Only possible for MERSI and VIIRS M projections !"); + msgBox.exec(); + return; + } + + if(projtype == PROJ_VIIRSM) + { + if(opts.buttonVIIRSM) + segs->seglviirsm->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); + else if(opts.buttonVIIRSMNOAA20) + segs->seglviirsmnoaa20->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); + } + else if(projtype == PROJ_MERSI) + { + segs->seglmersi->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); + } + else if(projtype == PROJ_AVHRR) + { + if(opts.buttonMetop) + segs->seglmetop->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); + } + + qDebug() << "lon1_d = " << lon1_d << " lat1_d = " << lat1_d << " lon2_d = " << lon2_d << " lat2_d = " << lat2_d; + lon1_r = deg2rad(lon1_d); + lat1_r = deg2rad(lat1_d); + lon2_r = deg2rad(lon2_d); + lat2_r = deg2rad(lat2_d); + +// double lat_origin_deg = (lat2_d - lat1_d)/2 + lat1_d; + double lat_origin_deg = lat2_d; + lat_origin = deg2rad(lat_origin_deg); + qDebug() << "latitude origin = " << lat_origin_deg; + + /////////////////////////////////////// + double P1 = cos(lat1_r)*sin(lat2_r)*cos(lon1_r) - sin(lat1_r)*cos(lat2_r)*cos(lon2_r); + double P2 = sin(lat1_r)*cos(lat2_r)*sin(lon2_r) - cos(lat1_r)*cos(lat2_r)*sin(lon1_r); + double lon_p1 = atan(P1/P2); + double lat_p1 = atan( - cos(lon_p1 - lon1_r)/tan(lat1_r)); + + qDebug() << "Pole 1 = (" << rad2deg(lat_p1) << ", " << rad2deg(lon_p1) << ") Pole 2 = (" << rad2deg(-lat_p1) << ", " << rad2deg(lon_p1 + PI) << ")"; + qDebug() << "Pole 1 = (" << rad2deg(lat_p1) << ", " << rad2deg(lon_p1) << ") Pole 2 = (" << rad2deg(-lat_p1) << ", " << rad2deg(lon_p1 - PI) << ")"; + + if(lat_p1 < 0) + { + lat_p1 = - lat_p1; + if(lon_p1 + PI > PI) + lon_p1 = lon_p1 - PI; + else + lon_p1 = lon_p1 + PI; + } + + qDebug() << "Pole = (" << rad2deg(lat_p1) << ", " << rad2deg(lon_p1) << ")"; + + //////////////////////////////////////////////////////////// + + if(projtype == PROJ_VIIRSM) + { + image_width = imageptrs->ptrimageViirsM->width(); + image_height = imageptrs->ptrimageViirsM->height(); + } + else if(projtype == PROJ_MERSI) + { + image_width = imageptrs->ptrimageMERSI->width(); + image_height = imageptrs->ptrimageMERSI->height(); + + } + else if(projtype == PROJ_AVHRR) + { + if(opts.buttonMetop) + { + image_width = imageptrs->ptrimagecomp_ch[0]->width(); + image_height = imageptrs->ptrimagecomp_ch[0]->height(); + } + } + + if (image_width != imageptrs->ptrimageProjection->width() || image_height != imageptrs->ptrimageProjection->height()) + { + delete imageptrs->ptrimageProjection; + imageptrs->ptrimageProjection = new QImage(image_width, image_height, QImage::Format_ARGB32); + imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); + } + + imageptrs->ptrimageProjectionRed.reset(new quint16[image_width * image_height]); + imageptrs->ptrimageProjectionGreen.reset(new quint16[image_width * image_height]); + imageptrs->ptrimageProjectionBlue.reset(new quint16[image_width * image_height]); + imageptrs->ptrimageProjectionAlpha.reset(new quint16[image_width * image_height]); + + for(int i = 0; i < image_width * image_height; i++) + { + imageptrs->ptrimageProjectionRed[i] = 0; + imageptrs->ptrimageProjectionGreen[i] = 0; + imageptrs->ptrimageProjectionBlue[i] = 0; + imageptrs->ptrimageProjectionAlpha[i] = 0; + } + + r_major = r_maj; + r_minor = r_min; + scale_factor = 1; + + false_northing = 0; + false_easting = 0; + + temp = r_minor / r_major; + es = 1.0 - temp*temp; + e = sqrt(es); // eccentricity e^2 = es + +#ifdef WIN32 //&& __GNUC__ + sin_p20 = sin(lat_origin); + cos_p20 = cos(lat_origin); +#else + sincos(lat_origin, &sin_p20,&cos_p20); +#endif + + con = 1.0 - es * sin_p20 * sin_p20; + com = sqrt(1.0 - es); + bl = sqrt(1.0 + es * pow(cos_p20,4.0)/(1.0 - es)); + al = r_major * bl * scale_factor * com / con; + if (fabs(lat_origin) < EPSLN) + { + ts = 1.0; + d = 1.0; + el = 1.0; + } + else + { + ts = tsfnz(e,lat_origin,sin_p20); + con = sqrt(con); + d = bl * com / (cos_p20 * con); + if ((d * d - 1.0) > 0.0) + { + if (lat_origin >= 0.0) + f = d + sqrt(d * d - 1.0); + else + f = d - sqrt(d * d - 1.0); + } + else + f = d; + el = f * pow(ts,bl); + } + + sinphi = sin(lat1_r); + ts1 = tsfnz(e,lat1_r,sinphi); + sinphi = sin(lat2_r); + ts2 = tsfnz(e,lat2_r,sinphi); + h = pow(ts1,bl); + l = pow(ts2,bl); + f = el/h; + g = .5 * (f - 1.0/f); + j = (el * el - l * h)/(el * el + l * h); + p = (l - h) / (l + h); + dlon = lon1_r - lon2_r; + if (dlon < -PI) + lon2_r = lon2_r - 2.0 * PI; + if (dlon > PI) + lon2_r = lon2_r + 2.0 * PI; + dlon = lon1_r - lon2_r; + lon_origin = .5 * (lon1_r + lon2_r) - atan(j * tan(.5 * bl * dlon)/p)/bl; + dlon = adjust_lon_rad(lon1_r - lon_origin); + gama = atan(sin(bl * dlon)/g); + azimuth = asinz(d * sin(gama)); + + qDebug() << "Azimuth = " << rad2deg(azimuth); + + if (fabs(lat1_r - lat2_r) <= EPSLN) + { + qDebug() << "Input data error","omer-init"; + return; + } + else + con = fabs(lat1_r); + if ((con <= EPSLN) || (fabs(con - HALF_PI) <= EPSLN)) + { + qDebug() << "Input data error","omer-init"; + return; + } + else if (fabs(fabs(lat_origin) - HALF_PI) <= EPSLN) + { + qDebug() << "Input data error","omer-init"; + return; + } + + sincos(gama,&singam,&cosgam); + sincos(azimuth,&sinaz,&cosaz); + if (lat_origin >= 0) + u = (al/bl) * atan(sqrt(d * d - 1.0)/cosaz); + else + u = -(al/bl) * atan(sqrt(d * d - 1.0)/cosaz); + + + //////////////////////////////////////////// + + double map_x_1, map_y_1; + double map_x_2, map_y_2; + + omerfor(lon1_r, lat1_r, &map_x_1, &map_y_1); + qDebug() << "For central 1 : map_x_1 =" << map_x_1 << " map_y_1 = " << map_y_1; + omerfor(lon2_r, lat2_r, &map_x_2, &map_y_2); + qDebug() << "For central 2 : map_x_2 =" << map_x_2 << " map_y_2 = " << map_y_2; + + + deltaboundingboxY = 0; + deltaboundingboxX = 0; + + if(projtype == PROJ_VIIRSM) + { + if(opts.buttonVIIRSM) + GetMinMaxXBoundingBox(SEG_VIIRSM, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); + else if(opts.buttonVIIRSMNOAA20) + GetMinMaxXBoundingBox(SEG_VIIRSMNOAA20, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); + } else if(projtype == PROJ_MERSI) + { + GetMinMaxXBoundingBox(SEG_MERSI, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); + } + else if(projtype == PROJ_AVHRR) + { + if(opts.buttonMetop) + GetMinMaxXBoundingBoxAVHRR(SEG_METOP, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); + } + + + qDebug() << "bounding box max_x = " << boundingbox_max_x << " min_x = " << boundingbox_min_x; + qDebug() << "bounding box max_y = " << boundingbox_max_y << " min_y = " << boundingbox_min_y; + + map_extend_x = abs(boundingbox_max_x - boundingbox_min_x); + map_extend_y = abs(boundingbox_max_y - boundingbox_min_y); + + qDebug() << "map_extend_x = " << map_extend_x; + qDebug() << "map_extend_y = " << map_extend_y; + +} + +//void ObliqueMercator::InitializeSpherical(eProjectionType projtype) +//{ + +// double temp; /* temporary variable */ +// double con,com; +// double ts; +// double ts1,ts2; +// double h,l; +// double j,p,dlon; +// double f,g,gama; +// double sinphi; +// double lon1_r; /* fist point to define central line in rad */ +// double lat1_r; /* fist point to define central line */ +// double lon2_r; /* second point to define central line */ +// double lat2_r; /* second point to define central line */ + +// double lon1_d; /* fist point to define central line in deg */ +// double lat1_d; /* fist point to define central line */ +// double lon2_d; /* second point to define central line */ +// double lat2_d; /* second point to define central line */ + +// lon1_d = 65535.0; +// lat1_d = 65535.0; +// lon2_d = 65535.0; +// lat2_d = 65535.0; + +// qDebug() << "ObliqueMercator::Initialize input image = " << projtype; + +// if(projtype != PROJ_AVHRR && projtype != PROJ_MERSI && projtype != PROJ_VIIRSM ) +// { +// QMessageBox msgBox; +// msgBox.setText("Only possible for MERSI and VIIRS M projections !"); +// msgBox.exec(); +// return; +// } + +// if(projtype == PROJ_VIIRSM) +// { +// if(opts.buttonVIIRSM) +// segs->seglviirsm->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); +// else if(opts.buttonVIIRSMNOAA20) +// segs->seglviirsmnoaa20->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); +// } +// else if(projtype == PROJ_MERSI) +// { +// segs->seglmersi->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); +// } +// else if(projtype == PROJ_AVHRR) +// { +// if(opts.buttonMetop) +// segs->seglmetop->GetCentralCoords(&lon1_d, &lat1_d, &lon2_d, &lat2_d); +// } + +// qDebug() << "lon1_d = " << lon1_d << " lat1_d = " << lat1_d << " lon2_d = " << lon2_d << " lat2_d = " << lat2_d; +// lon1_r = deg2rad(lon1_d); +// lat1_r = deg2rad(lat1_d); +// lon2_r = deg2rad(lon2_d); +// lat2_r = deg2rad(lat2_d); + +// double lat_origin_deg = (lat2_d - lat1_d)/2 + lat1_d; +// lat_origin = deg2rad(lat2_d); +// qDebug() << "latitude origin = " << lat_origin_deg; + +// double P1 = cos(lat1_r)*sin(lat2_r)*cos(lon1_r) - sin(lat1_r)*cos(lat2_r)*cos(lon2_r); +// double P2 = sin(lat1_r)*cos(lat2_r)*sin(lon2_r) - cos(lat1_r)*cos(lat2_r)*sin(lon1_r); +// lon_p1 = atan(P1/P2); +// lat_p1 = atan( - cos(lon_p1 - lon1_r)/tan(lat1_r)); + +// if(lat_p1 < 0) +// { +// lat_p1 = - lat_p1; +// if(lon_p1 + PI > PI) +// lon_p1 = lon_p1 - PI; +// else +// lon_p1 = lon_p1 + PI; +// } + +// qDebug() << "Pole 1 = (" << rad2deg(lat_p1) << ", " << rad2deg(lon_p1) << ") Pole 2 = (" << rad2deg(-lat_p1) << ", " << rad2deg(lon_p1 + PI) << ")"; +// qDebug() << "Pole 1 = (" << rad2deg(lat_p1) << ", " << rad2deg(lon_p1) << ") Pole 2 = (" << rad2deg(-lat_p1) << ", " << rad2deg(lon_p1 - PI) << ")"; +// sinazimuth = sin(lat_p1); +// cosazimuth = cos(lat_p1); + +// if(projtype == PROJ_VIIRSM) +// { +// image_width = imageptrs->ptrimageViirsM->width(); +// image_height = imageptrs->ptrimageViirsM->height(); +// } +// else if(projtype == PROJ_MERSI) +// { +// image_width = imageptrs->ptrimageMERSI->width(); +// image_height = imageptrs->ptrimageMERSI->height(); + +// } +// else if(projtype == PROJ_AVHRR) +// { +// if(opts.buttonMetop) +// { +// image_width = imageptrs->ptrimagecomp_ch[0]->width(); +// image_height = imageptrs->ptrimagecomp_ch[0]->height(); +// } +// } + +// if (image_width != imageptrs->ptrimageProjection->width() || image_height != imageptrs->ptrimageProjection->height()) +// { +// delete imageptrs->ptrimageProjection; +// imageptrs->ptrimageProjection = new QImage(image_width, image_height, QImage::Format_ARGB32); +// imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250)); +// } + +// imageptrs->ptrimageProjectionRed.reset(new quint16[image_width * image_height]); +// imageptrs->ptrimageProjectionGreen.reset(new quint16[image_width * image_height]); +// imageptrs->ptrimageProjectionBlue.reset(new quint16[image_width * image_height]); +// imageptrs->ptrimageProjectionAlpha.reset(new quint16[image_width * image_height]); + +// for(int i = 0; i < image_width * image_height; i++) +// { +// imageptrs->ptrimageProjectionRed[i] = 0; +// imageptrs->ptrimageProjectionGreen[i] = 0; +// imageptrs->ptrimageProjectionBlue[i] = 0; +// imageptrs->ptrimageProjectionAlpha[i] = 0; +// } + + + +// //////////////////////////////////////////// + +// double map_x_1, map_y_1; +// double map_x_2, map_y_2; + +// omerforspherical(lon1_r, lat1_r, &map_x_1, &map_y_1); +// qDebug() << "For central 1 : map_x_1 =" << map_x_1 << " map_y_1 = " << map_y_1; +// omerforspherical(lon2_r, lat2_r, &map_x_2, &map_y_2); +// qDebug() << "For central 2 : map_x_2 =" << map_x_2 << " map_y_2 = " << map_y_2; + + +// deltaboundingboxY = 0; +// deltaboundingboxX = 0; + +// if(projtype == PROJ_VIIRSM) +// { +// if(opts.buttonVIIRSM) +// GetMinMaxXBoundingBox(SEG_VIIRSM, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); +// else if(opts.buttonVIIRSMNOAA20) +// GetMinMaxXBoundingBox(SEG_VIIRSMNOAA20, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); +// } else if(projtype == PROJ_MERSI) +// { +// GetMinMaxXBoundingBox(SEG_MERSI, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); +// } +// else if(projtype == PROJ_AVHRR) +// { +// if(opts.buttonMetop) +// GetMinMaxXBoundingBoxAVHRRSpherical(SEG_METOP, &boundingbox_min_x, &boundingbox_max_x, &boundingbox_min_y, &boundingbox_max_y); +// } + + +// qDebug() << "bounding box max_x = " << boundingbox_max_x << " min_x = " << boundingbox_min_x; +// qDebug() << "bounding box max_y = " << boundingbox_max_y << " min_y = " << boundingbox_min_y; + +// map_extend_x = abs(boundingbox_max_x - boundingbox_min_x); +// map_extend_y = abs(boundingbox_max_y - boundingbox_min_y); + +// qDebug() << "map_extend_x = " << map_extend_x; +// qDebug() << "map_extend_y = " << map_extend_y; + +//} + +void ObliqueMercator::GetMinMaxXBoundingBox(eSegmentType type, double *boundingbox_min_x, double *boundingbox_max_x, double *boundingbox_min_y, double *boundingbox_max_y) +{ + SegmentList *seglist; + double min_x, max_x; + double min_y, max_y; + double map_x, map_y; + float geolon_d, geolat_d; + float geolon_r, geolat_r; + bool ret; + + min_x = DBL_MAX; + max_x = -DBL_MAX; + min_y = DBL_MAX; + max_y = -DBL_MAX; + + if(type == SEG_VIIRSM) + { + seglist = (SegmentList *)segs->seglviirsm; + } + else if( type == SEG_VIIRSMNOAA20) + { + seglist = (SegmentList *)segs->seglviirsmnoaa20; + } + else if( type == SEG_MERSI) + { + seglist = (SegmentList *)segs->seglmersi; + } + else + seglist = NULL; + + QList::iterator segsel; + segsel = seglist->GetSegsSelectedptr()->begin(); + while ( segsel != seglist->GetSegsSelectedptr()->end() ) + { + Segment *segm = (Segment *)(*segsel); + for(int i = 0; i < segm->NbrOfLines; i++) + { + for(int j = 0; j < segm->earth_views_per_scanline; j++) + { + geolon_d = segm->geolongitude[i * segm->earth_views_per_scanline + j]; + geolat_d = segm->geolatitude[i * segm->earth_views_per_scanline + j]; + if(abs(geolon_d) <= 180.0 && abs(geolat_d) <= 90.0) + { + geolon_r = deg2rad(geolon_d); + geolat_r = deg2rad(geolat_d); + ret = omerfor(geolon_r, geolat_r, &map_x, &map_y); + + if(ret) + { + if(map_x < min_x) + min_x = map_x; + if(map_x > max_x) + max_x = map_x; + if(map_y < min_y) + min_y = map_y; + if(map_y > max_y) + max_y = map_y; + } + break; + } + } + for(int j = segm->earth_views_per_scanline - 1; j >= 0; j--) + { + geolon_d = segm->geolongitude[i * segm->earth_views_per_scanline + j]; + geolat_d = segm->geolatitude[i * segm->earth_views_per_scanline + j]; + if(abs(geolon_d) <= 180.0 && abs(geolat_d) <= 90.0) + { + geolon_r = deg2rad(geolon_d); + geolat_r = deg2rad(geolat_d); + ret = omerfor(geolon_r, geolat_r, &map_x, &map_y); + + if(ret) + { + if(map_x < min_x) + min_x = map_x; + if(map_x > max_x) + max_x = map_x; + if(map_y < min_y) + min_y = map_y; + if(map_y > max_y) + max_y = map_y; + + } + break; + } + } + + } + + ++segsel; + } + + *boundingbox_min_x = min_x; + *boundingbox_max_x = max_x; + *boundingbox_min_y = min_y; + *boundingbox_max_y = max_y; + +} + +void ObliqueMercator::GetMinMaxXBoundingBoxAVHRR(eSegmentType type, double *boundingbox_min_x, double *boundingbox_max_x, double *boundingbox_min_y, double *boundingbox_max_y) +{ + + SegmentList *seglist; + double min_x, max_x; + double min_y, max_y; + double map_x, map_y; + float geolon_d, geolat_d; + float geolon_r, geolat_r; + bool ret; + + min_x = DBL_MAX; + max_x = -DBL_MAX; + min_y = DBL_MAX; + max_y = -DBL_MAX; + + if( type == SEG_METOP) + { + seglist = (SegmentList *)segs->seglmetop; + } + else + seglist = NULL; + + QList::iterator segsel; + segsel = seglist->GetSegsSelectedptr()->begin(); + while ( segsel != seglist->GetSegsSelectedptr()->end() ) + { + Segment *segm = (Segment *)(*segsel); + for(int i = 0; i < segm->NbrOfLines; i++) + { + for(int j = 0; j < 103; j++) + { + geolon_d = segm->earthloc_lon[i * 103 + j]; + geolat_d = segm->earthloc_lat[i * 103 + j]; + if(abs(geolon_d) <= 180.0 && abs(geolat_d) <= 90.0) + { + geolon_r = deg2rad(geolon_d); + geolat_r = deg2rad(geolat_d); + ret = omerfor(geolon_r, geolat_r, &map_x, &map_y); + + if(ret) + { + if(map_x < min_x) + min_x = map_x; + if(map_x > max_x) + max_x = map_x; + if(map_y < min_y) + min_y = map_y; + if(map_y > max_y) + max_y = map_y; + } + break; + } + } + for(int j = 103 - 1; j >= 0; j--) + { + geolon_d = segm->earthloc_lon[i * 103 + j]; + geolat_d = segm->earthloc_lat[i * 103 + j]; + if(abs(geolon_d) <= 180.0 && abs(geolat_d) <= 90.0) + { + geolon_r = deg2rad(geolon_d); + geolat_r = deg2rad(geolat_d); + ret = omerfor(geolon_r, geolat_r, &map_x, &map_y); + + if(ret) + { + if(map_x < min_x) + min_x = map_x; + if(map_x > max_x) + max_x = map_x; + if(map_y < min_y) + min_y = map_y; + if(map_y > max_y) + max_y = map_y; + + } + break; + } + } + + } + + ++segsel; + } + + + + *boundingbox_min_x = min_x; + *boundingbox_max_x = max_x; + *boundingbox_min_y = min_y; + *boundingbox_max_y = max_y; + +} + +//void ObliqueMercator::GetMinMaxXBoundingBoxAVHRRSpherical(eSegmentType type, double *boundingbox_min_x, double *boundingbox_max_x, double *boundingbox_min_y, double *boundingbox_max_y) +//{ + +// SegmentList *seglist; +// double min_x, max_x; +// double min_y, max_y; +// double map_x, map_y; +// float geolon_d, geolat_d; +// float geolon_r, geolat_r; +// bool ret; + +// min_x = DBL_MAX; +// max_x = -DBL_MAX; +// min_y = DBL_MAX; +// max_y = -DBL_MAX; + +// if( type == SEG_METOP) +// { +// seglist = (SegmentList *)segs->seglmetop; +// } +// else +// seglist = NULL; + +// QList::iterator segsel; +// segsel = seglist->GetSegsSelectedptr()->begin(); +// while ( segsel != seglist->GetSegsSelectedptr()->end() ) +// { +// Segment *segm = (Segment *)(*segsel); +// for(int i = 0; i < segm->NbrOfLines; i++) +// { +// for(int j = 0; j < 103; j++) +// { +// geolon_d = segm->earthloc_lon[i * 103 + j]; +// geolat_d = segm->earthloc_lat[i * 103 + j]; +// if(abs(geolon_d) <= 180.0 && abs(geolat_d) <= 90.0) +// { +// geolon_r = deg2rad(geolon_d); +// geolat_r = deg2rad(geolat_d); +// ret = omerforspherical(geolon_r, geolat_r, &map_x, &map_y); + +// if(ret) +// { +// if(map_x < min_x) +// min_x = map_x; +// if(map_x > max_x) +// max_x = map_x; +// if(map_y < min_y) +// min_y = map_y; +// if(map_y > max_y) +// max_y = map_y; +// } +// break; +// } +// } +// for(int j = 103 - 1; j >= 0; j--) +// { +// geolon_d = segm->earthloc_lon[i * 103 + j]; +// geolat_d = segm->earthloc_lat[i * 103 + j]; +// if(abs(geolon_d) <= 180.0 && abs(geolat_d) <= 90.0) +// { +// geolon_r = deg2rad(geolon_d); +// geolat_r = deg2rad(geolat_d); +// ret = omerforspherical(geolon_r, geolat_r, &map_x, &map_y); + +// if(ret) +// { +// if(map_x < min_x) +// min_x = map_x; +// if(map_x > max_x) +// max_x = map_x; +// if(map_y < min_y) +// min_y = map_y; +// if(map_y > max_y) +// max_y = map_y; + +// } +// break; +// } +// } + +// } + +// ++segsel; +// } + + + +// *boundingbox_min_x = min_x; +// *boundingbox_max_x = max_x; +// *boundingbox_min_y = min_y; +// *boundingbox_max_y = max_y; + +//} + +void ObliqueMercator::CreateMapFromAVHRR(eSegmentType type, int inputchannel) +{ + + if( type == SEG_METOP) + segs->seglmetop->ComposeOMProjection(inputchannel); + + + if(opts.smoothprojectiontype == 1) + imageptrs->SmoothProjectionImage(); + else if(opts.smoothprojectiontype == 2) + { + if( type == SEG_METOP) + segs->seglmetop->SmoothProjectionImageBilinear(); + } +} + +void ObliqueMercator::CreateMapFromVIIRS(eSegmentType type, bool combine) +{ + if (type == SEG_VIIRSM) + segs->seglviirsm->ComposeOMProjection(0); + else if( type == SEG_VIIRSMNOAA20) + segs->seglviirsmnoaa20->ComposeOMProjection(0); + + if(opts.smoothprojectiontype == 1) + imageptrs->SmoothProjectionImage(); + else if(opts.smoothprojectiontype == 2) + { + if (type == SEG_VIIRSM) + { + segs->seglviirsm->SmoothVIIRSImage(combine); + } + else if (type == SEG_VIIRSMNOAA20) + { + segs->seglviirsmnoaa20->SmoothVIIRSImage(combine); + } + } + +} + +void ObliqueMercator::CreateMapFromMERSI(eSegmentType type, bool combine) +{ + + segs->seglmersi->ComposeOMProjection(0); + + if(opts.smoothprojectiontype == 1) + imageptrs->SmoothProjectionImage(); + else if(opts.smoothprojectiontype == 2) + { + segs->seglmersi->SmoothMERSIImage(combine); + } + +} + +bool ObliqueMercator::omerfor(double lon, double lat, double *x, double *y) +/* (I) Longitude */ +/* (I) Latitude */ +/* (O) X projection coordinate */ +/* (O) Y projection coordinate */ +{ + double sin_phi; + double t; + double con; + double q,us,vl; + double ul,vs; + double s; + double dlon; + double ts1; + + /* Forward equations + -----------------*/ + sin_phi = sin(lat); + dlon = adjust_lon_rad(lon - lon_origin); + vl = sin(bl * dlon); + if (fabs(fabs(lat) - HALF_PI) > EPSLN) + { + ts1 = tsfnz(e,lat,sin_phi); + q = el / (pow(ts1,bl)); + s = .5 * (q - 1.0 / q); + t = .5 * (q + 1.0/ q); + ul = (s * singam - vl * cosgam) / t; + con = cos(bl * dlon); + if (fabs(con) < .0000001) + { + us = al * bl * dlon; + } + else + { + us = al * atan((s * cosgam + vl * singam) / con)/bl; + if (con < 0) + us = us + PI * al / bl; + } + } + else + { + if (lat >= 0) + ul = singam; + else + ul = -singam; + us = al * lat / bl; + } + if (fabs(fabs(ul) - 1.0) <= EPSLN) + { + // qDebug() << "Point projects into infinity ; omer-for"; + return false; + } + vs = .5 * al * log((1.0 - ul)/(1.0 + ul)) / bl; + us = us - u; + + //2D Rotation over angle = azimuth + // *x = false_easting + vs * cosaz + us * sinaz; + // *y = false_northing + us * cosaz - vs * sinaz; + + double xx = false_easting + vs * cosaz + us * sinaz; + double yy = false_northing + us * cosaz - vs * sinaz; + + *x = xx * cosaz - yy * sinaz; + *y = xx * sinaz + yy * cosaz; + + return true; +} + +bool ObliqueMercator::map_forward(double lon_rad, double lat_rad, double &map_x, double &map_y) +{ + + + double x, y; + double x1, y1; + bool ret = this->omerfor(lon_rad, lat_rad, &x, &y); + + double scale_x, scale_y; + double map_x1, map_y1; + scale_x = 1; + scale_y = 1; + + if(ret) + { + + map_x = image_width * (x + abs(boundingbox_min_x))/map_extend_x; + map_y = image_height - image_height * (y + abs(boundingbox_min_y))/map_extend_y; + if(map_x < 0 || map_x > image_width || map_y < 0 || map_y > image_height) + ret = false; + + } + + return true; +} + +//bool ObliqueMercator::omerforspherical(double lon, double lat, double *x, double *y) +///* (I) Longitude */ +///* (I) Latitude */ +///* (O) X projection coordinate */ +///* (O) Y projection coordinate */ +//{ + + +// double K = tan(lat)*cos(lat_p1) + sin(lat_p1)*sin(lon - lon_p1); + +// double xx = atan(K/cos(lon - lon_p1)); +// double A = sin(lat_p1)*sin(lat) - cos(lat_p1)*cos(lat)*sin(lon - lon_p1); +// double yy = atanh(A); + +// //*x = xx * cosazimuth - yy * sinazimuth; +// //*y = xx * sinazimuth + yy * cosazimuth; + +// *x = xx; +// *y = yy; + +// return true; +//} + +double ObliqueMercator::tsfnz(double eccent, double phi, double sinphi) +{ + /* double eccent; Eccentricity of the spheroid*/ + /* double phi; Latitude phi */ + /* double sinphi; Sine of the latitude */ + double con; + double com; + + con = eccent * sinphi; + com = .5 * eccent; + con = pow(((1.0 - con) / (1.0 + con)),com); + return (tan(.5 * (PIO2 - phi))/con); + +} + +bool ObliqueMercator::map_inverse(double map_x, double map_y, double &lon_rad, double &lat_rad) +{ + // double x, y; + + + // y = map_radius * scale * (- 2*map_y + 2*(mapdeltay+false_northing) + map_height) / map_height; + // x = map_radius * scale * (2*map_x - 2*(mapdeltax+false_easting) - map_width) / map_width; + + // //qDebug() << QString("x=%1 y=%2 map_radius=%3 map_height=%4 map_width=%5").arg(x).arg(y).arg(map_radius).arg(map_height).arg(map_width); + + // bool ret = this->inverse(x, y, lon_rad, lat_rad); + // return ret; + + return false; +} + diff --git a/core/obliquemercator.h b/core/obliquemercator.h new file mode 100644 index 0000000..3765d67 --- /dev/null +++ b/core/obliquemercator.h @@ -0,0 +1,90 @@ +#ifndef OBLIQUEMERCATOR_H +#define OBLIQUEMERCATOR_H + +#include +#include "segmentimage.h" +#include "gshhsdata.h" +#include "avhrrsatellite.h" + +#define EPSLN 1.0e-3 +class AVHRRSatellite; + +class ObliqueMercator : public QObject +{ + Q_OBJECT + +public: + explicit ObliqueMercator(QObject *parent = 0, AVHRRSatellite *seglist = 0); + ~ObliqueMercator(); + + void Initialize(double r_maj, double r_min, eProjectionType projtype); + //void InitializeSpherical(eProjectionType projtype); + + void CreateMapFromVIIRS(eSegmentType type, bool combine); + void CreateMapFromMERSI(eSegmentType type, bool combine); + void CreateMapFromAVHRR(eSegmentType type, int inputchannel); + + + bool map_forward(double lon_rad, double lat_rad, double &map_x, double &map_y); + bool map_inverse(double map_x, double map_y, double &lon_rad, double &lat_rad); + + int getProjectionWidth() { return image_width; } + int getProjectionHeight() { return image_height; } + + +private: + double tsfnz(double eccent, double phi, double sinphi); + bool omerfor(double lon, double lat, double *x, double *y); + //bool omerforspherical(double lon, double lat, double *x, double *y); + + void GetMinMaxXBoundingBox(eSegmentType type, double *boundingbox_min_x, double *boundingbox_max_x, double *boundingbox_min_y, double *boundingbox_max_y); + void GetMinMaxXBoundingBoxAVHRR(eSegmentType type, double *boundingbox_min_x, double *boundingbox_max_x, double *boundingbox_min_y, double *boundingbox_max_y); + //void GetMinMaxXBoundingBoxAVHRRSpherical(eSegmentType type, double *boundingbox_min_x, double *boundingbox_max_x, double *boundingbox_min_y, double *boundingbox_max_y); + + AVHRRSatellite *segs; + + double azimuth; + double r_major; /* major axis */ + double r_minor; /* minor axis */ + double scale_factor; /* scale factor */ + double lon_origin; /* center longitude */ + double lat_origin; /* center latitude */ + double e,es; /* eccentricity constants */ + double false_northing; /* y offset in meters */ + double false_easting; /* x offset in meters */ + double sin_p20,cos_p20; /* sin and cos values */ + double bl; + double al; + double d; + double el,u; + double singam,cosgam; + double sinaz,cosaz; + + // spherical + double lon_p1, lat_p1; + double sinazimuth, cosazimuth; + + QPixmap pmGeneral; + QPixmap pmScaled_res; + + int map_width; + int map_height; + int image_width; + int image_height; + double map_extend_x, map_extend_y; + double boundingbox_max_x; + double boundingbox_min_x; + double boundingbox_max_y; + double boundingbox_min_y; + + + double deltaboundingboxX; + double deltaboundingboxY; + +signals: + +public slots: + +}; + +#endif // OBLIQUEMERCATOR_H diff --git a/core/satgl.cpp b/core/satgl.cpp index 48f5187..421bcb2 100644 --- a/core/satgl.cpp +++ b/core/satgl.cpp @@ -158,25 +158,25 @@ void SatGL::render(QMatrix4x4 projection, float distance, QQuaternion quat ) ++sat; } - // QMatrix4x4 mod; - // mod.setToIdentity(); - // mod.translate(0.0, 0.0, distance); - // mod.rotate(quat); - - // modelocta = mod; - // modelocta.translate(0.0, 1.0, 0.0); - // modelocta.scale(0.009f); - // octa->render(projection, modelocta, col); - - // modelocta = mod; - // modelocta.translate(0.0, 0.0, 1.0); - // modelocta.scale(0.009f); - // octa->render(projection, modelocta, col); - - // modelocta = mod; - // modelocta.translate(1.0, 0.0, 0.0); - // modelocta.scale(0.009f); - // octa->render(projection, modelocta, col); +// QMatrix4x4 mod; +// mod.setToIdentity(); +// mod.translate(0.0, 0.0, distance); +// mod.rotate(quat); + +// modelocta = mod; +// modelocta.translate(0.0, 1.0, 0.0); +// modelocta.scale(0.009f); +// octa->render(projection, modelocta, col); + +// modelocta = mod; +// modelocta.translate(0.0, 0.0, 1.0); +// modelocta.scale(0.009f); +// octa->render(projection, modelocta, col); + +// modelocta = mod; +// modelocta.translate(1.0, 0.0, 0.0); +// modelocta.scale(0.009f); +// octa->render(projection, modelocta, col); } diff --git a/core/segment.cpp b/core/segment.cpp index 5b8b8a9..9775f1d 100644 --- a/core/segment.cpp +++ b/core/segment.cpp @@ -109,7 +109,7 @@ void Segment::CalculateCornerPoints() //qDebug() << QString("minutes_since_state_vector = %1 in CalculateCornerPoints").arg(minutes_since_state_vector); if (segtype == SEG_HRP || segtype == SEG_METOP || segtype == SEG_OLCIEFR || segtype == SEG_OLCIERR || segtype == SEG_SLSTR || - segtype == SEG_HRPT_METOPA || segtype == SEG_HRPT_METOPB || segtype == SEG_HRPT_M01 || segtype == SEG_HRPT_M02 || segtype == SEG_HRPT_NOAA19 || + segtype == SEG_HRPT_METOPA || segtype == SEG_HRPT_METOPB || segtype == SEG_HRPT_M01 || segtype == SEG_HRPT_M02 || // segtype == SEG_HRPT_NOAA19 || segtype == SEG_DATAHUB_OLCIEFR || segtype == SEG_DATAHUB_OLCIERR || segtype == SEG_DATAHUB_SLSTR) // || segtype == SEG_MERSI ) { double pitch_steering_angle = - 0.002899 * sin( 2 * PSO); @@ -195,7 +195,7 @@ void Segment::CalculateCornerPoints() PSO = fmod(qtle->ArgumentPerigee() + trueAnomaly, TWOPI); if (segtype == SEG_HRP || segtype == SEG_METOP || segtype == SEG_OLCIEFR || segtype == SEG_OLCIERR || segtype == SEG_SLSTR || - segtype == SEG_HRPT_METOPA || segtype == SEG_HRPT_METOPB || segtype == SEG_HRPT_M01 || segtype == SEG_HRPT_M02 || segtype == SEG_HRPT_NOAA19 || + segtype == SEG_HRPT_METOPA || segtype == SEG_HRPT_METOPB || segtype == SEG_HRPT_M01 || segtype == SEG_HRPT_M02 || // segtype == SEG_HRPT_NOAA19 || segtype == SEG_DATAHUB_OLCIEFR || segtype == SEG_DATAHUB_OLCIERR || segtype == SEG_DATAHUB_SLSTR ) //|| segtype == SEG_MERSI ) { double pitch_steering_angle = - 0.002899 * sin( 2 * PSO); @@ -790,7 +790,8 @@ void Segment::RenderSegmentlineInTexture( int channel, int nbrLine, int nbrTotal double r = d3pos.length(); double sindelta = sin(-delta); double dd = r * cos(-delta) - sqrt(XKMPER * XKMPER - r * r * sindelta * sindelta); - QVector3D d3d = - d3posnorm * cos(-delta) * dd + d3scannorm * sin(-delta) * dd; +// QVector3D d3d = - d3posnorm * cos(-delta) * dd + d3scannorm * sin(-delta) * dd; + QVector3D d3d = - d3posnorm * cos(-delta) * dd + d3scannorm * sindelta * dd; //qDebug() << QString("a = %1 b = %2").arg(XKMPER * XKMPER).arg( r * r * sindelta * sindelta); QVector3D d3earthposfirst = d3pos + d3d; @@ -800,7 +801,8 @@ void Segment::RenderSegmentlineInTexture( int channel, int nbrLine, int nbrTotal sindelta = sin(delta); dd = r * cos(delta) - sqrt(XKMPER * XKMPER - r * r * sindelta * sindelta); - d3d = - d3posnorm * cos(delta) * dd + d3scannorm * sin(delta) * dd; +// d3d = - d3posnorm * cos(delta) * dd + d3scannorm * sin(delta) * dd; + d3d = - d3posnorm * cos(delta) * dd + d3scannorm * sindelta * dd; QVector3D d3earthposlast = d3pos + d3d; @@ -1125,6 +1127,11 @@ void Segment::ComposeSegmentSGProjection(int inputchannel, int histogrammethod, } +void Segment::ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized) +{ + +} + void Segment::RecalculateProjection() { @@ -1389,3 +1396,4 @@ qint32 Segment::Max(const qint32 v11, const qint32 v12, const qint32 v21, const return Maximum; } + diff --git a/core/segment.h b/core/segment.h index 6180829..50d6aa5 100644 --- a/core/segment.h +++ b/core/segment.h @@ -25,7 +25,8 @@ enum eProjections { LCC = 0, GVP, - SG + SG, + OM }; enum eSLSTRImageView @@ -62,6 +63,7 @@ class Segment : public QObject virtual void ComposeSegmentLCCProjection(int inputchannel, int histogrammethod, bool normalized); virtual void ComposeSegmentGVProjection(int inputchannel, int histogrammethod, bool normalized); virtual void ComposeSegmentSGProjection(int inputchannel, int histogrammethod, bool normalized); + virtual void ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized); virtual void RecalculateProjection(); @@ -80,6 +82,8 @@ class Segment : public QObject QString GetTle_line1() { return line1; } QString GetTle_line2() { return line2; } int GetNbrOfLines() { return NbrOfLines; } + int getEarthViewsPerScanline() { return this->earth_views_per_scanline; } + //void setImageReady() { image_ready = true; } //void resetImageReady() { image_ready = false; } //bool isImageReady() { return image_ready; } @@ -190,6 +194,8 @@ class Segment : public QObject QScopedArrayPointer solar_zenith; QScopedArrayPointer lunar_azimuth; QScopedArrayPointer solar_azimuth; + QScopedArrayPointer sc_position; + QScopedArrayPointer sc_velocity; protected: diff --git a/core/segmentgl.cpp b/core/segmentgl.cpp index 3d503c5..5aa7d8f 100644 --- a/core/segmentgl.cpp +++ b/core/segmentgl.cpp @@ -142,18 +142,12 @@ void SegmentGL::render(QMatrix4x4 projection, float dist, QQuaternion quat, int QList::iterator segit = sl->GetSegmentlistptr()->begin(); while ( segit != sl->GetSegmentlistptr()->end() ) { - if(segs->getShowAllSegments()) + if(segs->getShowAllSegments() || (*segit)->segmentshow) { RenderContourDetail(*segit, projection, modelview, width, height); } - else - { - if ((*segit)->segmentshow) - { - RenderContourDetail(*segit, projection, modelview, width, height); - } - } + ++segit; } @@ -162,18 +156,11 @@ void SegmentGL::render(QMatrix4x4 projection, float dist, QQuaternion quat, int QList::iterator segit = sl->GetSegmentlistptr()->begin(); while ( segit != sl->GetSegmentlistptr()->end() ) { - if(segs->getShowAllSegments()) + if(segs->getShowAllSegments() || (*segit)->segmentshow) { RenderContour(*segit, projection, modelview, width, height); } - else - { - if ((*segit)->segmentshow) - { - RenderContour(*segit, projection, modelview, width, height); - } - } ++segit; } } diff --git a/core/segmentimage.h b/core/segmentimage.h index bcce53e..20d9c43 100644 --- a/core/segmentimage.h +++ b/core/segmentimage.h @@ -11,6 +11,7 @@ #include "generalverticalperspective.h" #include "lambertconformalconic.h" #include "stereographic.h" +#include "obliquemercator.h" enum seviriunits { SEVIRI_UNIT_CNT, @@ -85,6 +86,7 @@ enum MapReturn class GeneralVerticalPerspective; class LambertConformalConic; class StereoGraphic; +class ObliqueMercator; class SegmentImage { @@ -147,6 +149,7 @@ class SegmentImage GeneralVerticalPerspective *gvp; LambertConformalConic *lcc; StereoGraphic *sg; + ObliqueMercator *om; quint16 lut_ch[5][1024]; quint16 lut_norm_ch[5][1024]; diff --git a/core/segmentlist.cpp b/core/segmentlist.cpp index d94a09f..817eb21 100644 --- a/core/segmentlist.cpp +++ b/core/segmentlist.cpp @@ -865,16 +865,6 @@ void SegmentList::ComposeGVProjection(int inputchannel) } -//void SegmentList::ComposeGVProjection(int inputchannel) -//{ -// projectioninputchannel = inputchannel; -// watchercomposeprojection = new QFutureWatcher(this); -// connect(watchercomposeprojection, SIGNAL(resultReadyAt(int)), SLOT(composeprojectionreadyat(int))); -// connect(watchercomposeprojection, SIGNAL(finished()), SLOT(composeprojectionfinished())); - -// watchercomposeprojection->setFuture(QtConcurrent::map(segsselected.begin(), segsselected.end(), &SegmentList::doComposeGVProjection)); -//} - void SegmentList::ComposeLCCProjection(int inputchannel) { @@ -902,6 +892,19 @@ void SegmentList::ComposeSGProjection(int inputchannel) } +void SegmentList::ComposeOMProjection(int inputchannel) +{ + qDebug() << "SegmentList::ComposeOMProjection()"; + QList::iterator segit = segsselected.begin(); + while ( segit != segsselected.end() ) + { + (*segit)->ComposeSegmentOMProjection(inputchannel, 0, false); + emit segmentprojectionfinished(false); + ++segit; + } + +} + void SegmentList::ClearSegments() { @@ -2614,3 +2617,143 @@ void SegmentList::Compose48bitProjectionPNG(QString fileName, bool mapto65535) } + +void SegmentList::GetContourPolygon(QPolygonF *poly) +{ + QList::iterator segsel; + segsel = segsselected.begin(); + int segscount = segsselected.size(); + int count = 0; + int nbroflines; + int earthviews; + + while ( segsel != segsselected.end() ) + { + Segment *segm = (Segment *)(*segsel); + nbroflines = segm->GetNbrOfLines(); + earthviews = segm->getEarthViewsPerScanline(); + count++; + if(count == 1) + { + for(int j = 0; j < nbroflines; j++) + { + if(segm->geolongitude[j*earthviews] < 180.0 && segm->geolatitude[j*earthviews] < 90.0) + { + for(int i = 0; i < earthviews; i += 10 ) + poly->append(QPointF(segm->geolongitude[i + j*earthviews], segm->geolatitude[i + j*earthviews] )); + break; + } + } + } + + for(int j = 0; j < nbroflines; j += 10) + { + if(segm->geolongitude[j*earthviews] < 180.0 && segm->geolatitude[j*earthviews] < 90.0 && + segm->geolongitude[j*earthviews + earthviews - 1] < 180.0 && segm->geolatitude[j*earthviews + earthviews - 1] < 90.0) + { + poly->append(QPointF(segm->geolongitude[j*earthviews + earthviews - 1], segm->geolatitude[j*earthviews + earthviews - 1] )); + poly->append(QPointF(segm->geolongitude[j*earthviews], segm->geolatitude[j*earthviews] )); + } + } + + + if(count == segscount) + { + for(int j = nbroflines - 1; j >= 0; j--) + { + if(segm->geolongitude[j*earthviews] < 180.0 && segm->geolatitude[j*earthviews] < 90.0) + { + for(int i = 0; i < earthviews; i += 10 ) + poly->append(QPointF(segm->geolongitude[i + j*earthviews], segm->geolatitude[i + j*earthviews] )); + break; + } + } + } + + ++segsel; + } + + +} + +void SegmentList::GetContourPolygonAVHRR(QPolygonF *poly) +{ + QList::iterator segsel; + segsel = segsselected.begin(); + int segscount = segsselected.size(); + int count = 0; + int nbroflines; + + while ( segsel != segsselected.end() ) + { + + Segment *segm = (Segment *)(*segsel); + nbroflines = segm->GetNbrOfLines(); + count++; + if(count == 1) + { + for(int j = 0; j < nbroflines; j++) + { + if(segm->earthloc_lon[j*103] < 180.0 && segm->earthloc_lat[j*103] < 90.0) + { + for(int i = 0; i < 103; i++ ) + poly->append(QPointF(segm->earthloc_lon[i + j*103], segm->earthloc_lat[i + j*103] )); + break; + } + } + } + + for(int j = 0; j < nbroflines; j += 10) + { + if(segm->earthloc_lon[j*103] < 180.0 && segm->earthloc_lat[j*103] < 90.0 && + segm->earthloc_lon[j*103 + 103 - 1] < 180.0 && segm->earthloc_lat[j*103 + 103 - 1] < 90.0) + { + poly->append(QPointF(segm->earthloc_lon[j*103 + 103 - 1], segm->earthloc_lat[j*103 + 103 - 1] )); + poly->append(QPointF(segm->earthloc_lon[j*103], segm->earthloc_lat[j*103] )); + } + } + + + if(count == segscount) + { + for(int j = nbroflines - 1; j >= 0; j--) + { + if(segm->earthloc_lon[j*103] < 180.0 && segm->earthloc_lat[j*103] < 90.0) + { + for(int i = 0; i < 103; i++ ) + poly->append(QPointF(segm->earthloc_lon[i + j*103], segm->earthloc_lat[i + j*103] )); + break; + } + } + } + + ++segsel; + } + + +} + +void SegmentList::GetTrackPolygon(QPolygonF *poly) +{ + QList::iterator segsel; + int nbroflines; + int earthviews; + segsel = segsselected.begin(); + + while ( segsel != segsselected.end() ) + { + Segment *segm = (Segment *)(*segsel); + nbroflines = segm->GetNbrOfLines(); + earthviews = segm->getEarthViewsPerScanline(); + + for(int j = 0; j < nbroflines; j=j+10) + { + if(segm->geolongitude[j*earthviews] < 180.0 && segm->geolatitude[j*earthviews] < 90.0) + { + poly->append(QPointF(segm->geolongitude[j*earthviews + (int)(earthviews/2)], segm->geolatitude[j*earthviews + (int)(earthviews/2)] )); + } + } + + ++segsel; + } +} diff --git a/core/segmentlist.h b/core/segmentlist.h index 57cc57e..5bb9a2a 100644 --- a/core/segmentlist.h +++ b/core/segmentlist.h @@ -51,6 +51,7 @@ class SegmentList : public QObject void ComposeGVProjection(int inputchannel); void ComposeLCCProjection(int inputchannel); void ComposeSGProjection(int inputchannel); + void ComposeOMProjection(int inputchannel); void SmoothProjectionImageBilinear(); void SmoothProjectionImageBicubic(); void Compose48bitProjectionPNG(QString fileName, bool mapto65535); @@ -62,6 +63,9 @@ class SegmentList : public QObject bool TestForSegmentGL(int x, int realy, float distance, const QMatrix4x4 &m, bool showallsegments, QString &segmentname); bool TestForSegmentGLextended(int x, int realy, float distance, const QMatrix4x4 &m, bool showallsegments, QString &segmentname); void setHistogramMethod(int histo); + void GetContourPolygon(QPolygonF *poly); + void GetContourPolygonAVHRR(QPolygonF *poly); + void GetTrackPolygon(QPolygonF *poly); protected: diff --git a/core/segmentlistmersi.cpp b/core/segmentlistmersi.cpp index 912947e..6fbb3e7 100644 --- a/core/segmentlistmersi.cpp +++ b/core/segmentlistmersi.cpp @@ -113,8 +113,8 @@ bool SegmentListMERSI::ComposeMERSIImageInThread(QList bandlist, QListsegmentselected) { - segsselected.append(segm); - totalnbrofsegments++; + segsselected.append(segm); + totalnbrofsegments++; } ++segit; } @@ -141,13 +141,26 @@ bool SegmentListMERSI::ComposeMERSIImageInThread(QList bandlist, QListsetBandandColor(bandlist, colorlist, invertlist); segm->initializeMemory(); - segm->ReadSegmentInMemory(composecolor, colorarrayindex); + segm->ReadSegmentInMemory(bandindex, colorarrayindex); totalprogress += deltaprogress; emit progressCounter(totalprogress); @@ -241,7 +254,7 @@ bool SegmentListMERSI::ComposeMERSIImageInThread(QList bandlist, QListComposeSegmentImage(colorarrayindex, invertarrayindex, this->histogrammethod, this->normalized, this->totalnbroflines); + segm->ComposeSegmentImage(bandindex, colorarrayindex, invertarrayindex, this->histogrammethod, this->normalized, this->totalnbroflines); totalprogress += deltaprogress; emit progressCounter(totalprogress); QApplication::processEvents(); @@ -468,4 +481,195 @@ void SegmentListMERSI::ComposeSGProjection(int inputchannel) } } +void SegmentListMERSI::ComposeOMProjection(int inputchannel) +{ + qDebug() << "SegmentListMERSI::ComposeOMProjection()"; + QList::iterator segit = segsselected.begin(); + while ( segit != segsselected.end() ) + { + (*segit)->ComposeSegmentOMProjection(inputchannel, 0, false); + emit segmentprojectionfinished(false); + ++segit; + } +} + +void SegmentListMERSI::GetCentralCoords(double *startcentrallon, double *startcentrallat, double *endcentrallon, double *endcentrallat) +{ + double slon, slat, elon, elat; + double save_slon, save_slat, save_elon, save_elat; + int startindex, endindex; + + save_slon = 65535.0; + save_slat = 65535.0; + save_elon = 65535.0; + save_elat = 65535.0; + + bool first = true; + + QList::iterator segsel; + segsel = segsselected.begin(); + + while ( segsel != segsselected.end() ) + { + SegmentMERSI *segm = (SegmentMERSI *)(*segsel); + segm->GetCentralCoords(&slon, &slat, &elon, &elat, &startindex, &endindex); + + if(abs(slon) < 180.0 && abs(slat) < 90.0 && abs(elon) < 180.0 && abs(elat) < 90.0) + { + if(first == true) + { + first = false; + save_slon = slon; + save_slat = slat; + save_elon = elon; + save_elat = elat; + } + else + { + save_elon = elon; + save_elat = elat; + } + + } + + QApplication::processEvents(); + ++segsel; + } + + *startcentrallon = save_slon; + *startcentrallat = save_slat; + *endcentrallon = save_elon; + *endcentrallat = save_elat; + +} + +void SegmentListMERSI::GetCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4) +{ + double save_cornerlon1, save_cornerlat1, save_cornerlon2, save_cornerlat2; + double save_cornerlon3, save_cornerlat3, save_cornerlon4, save_cornerlat4; + int Xcornerindex1, Xcornerindex2, Ycornerindex12; + int Xcornerindex3, Xcornerindex4, Ycornerindex34; + + save_cornerlon1 = 65535.0; + save_cornerlat1 = 65535.0; + save_cornerlon2 = 65535.0; + save_cornerlat2 = 65535.0; + + save_cornerlon3 = 65535.0; + save_cornerlat3 = 65535.0; + save_cornerlon4 = 65535.0; + save_cornerlat4 = 65535.0; + + QList::iterator segsel; + segsel = segsselected.begin(); + + int count = 0; + + while ( segsel != segsselected.end() ) + { + SegmentMERSI *segm = (SegmentMERSI *)(*segsel); + count++; + if(count == 1) + { + segm->GetStartCornerCoords(&save_cornerlon1, &save_cornerlat1, &save_cornerlon2, &save_cornerlat2, &Xcornerindex1, &Xcornerindex2, &Ycornerindex12 ); + if(abs(save_cornerlon1) < 180.0 && abs(save_cornerlat1) < 90.0 && abs(save_cornerlon2) < 180.0 && abs(save_cornerlat2) < 90.0) + break; + } + ++segsel; + } + + segsel = segsselected.begin(); + + while ( segsel != segsselected.end() ) + { + SegmentMERSI *segm = (SegmentMERSI *)(*segsel); + count++; + + if(count == segsselected.size()) + { + segm->GetEndCornerCoords(&save_cornerlon3, &save_cornerlat3, &save_cornerlon4, &save_cornerlat4, &Xcornerindex3, &Xcornerindex4, &Ycornerindex34 ); + if(abs(save_cornerlon3) < 180.0 && abs(save_cornerlat3) < 90.0 && abs(save_cornerlon4) < 180.0 && abs(save_cornerlat4) < 90.0) + break; + } + ++segsel; + } + + *cornerlon1 = save_cornerlon1; + *cornerlat1 = save_cornerlat1; + *cornerlon2 = save_cornerlon2; + *cornerlat2 = save_cornerlat2; + + *cornerlon3 = save_cornerlon3; + *cornerlat3 = save_cornerlat3; + *cornerlon4 = save_cornerlon4; + *cornerlat4 = save_cornerlat4; + +} + +//void SegmentListMERSI::GetContourPolygon(QPolygonF *poly) +//{ +// QList::iterator segsel; +// segsel = segsselected.begin(); +// int segscount = segsselected.size(); +// int count = 0; +// int nbroflines; + +// while ( segsel != segsselected.end() ) +// { +// SegmentMERSI *segm = (SegmentMERSI *)(*segsel); +// nbroflines = segm->GetNbrOfLines(); +// count++; +// if(count == 1) +// { +// for(int j = 0; j < nbroflines; j=j+10) +// { +// if(segm->geolongitude[j*segm->getEarthViewsPerScanline()] < 180.0 && segm->geolatitude[j*segm->getEarthViewsPerScanline()] < 90.0) +// { +// for(int i = 0; i < segm->getEarthViewsPerScanline(); i++ ) +// poly->append(QPointF(segm->geolongitude[i + j*segm->getEarthViewsPerScanline()], segm->geolatitude[i + j*segm->getEarthViewsPerScanline()] )); +// break; +// } +// } +// } +// if(count == segscount) +// { +// for(int j = nbroflines - 1; j >= 0; j=j-10) +// { +// if(segm->geolongitude[j*segm->getEarthViewsPerScanline()] < 180.0 && segm->geolatitude[j*segm->getEarthViewsPerScanline()] < 90.0) +// { +// for(int i = 0; i < segm->getEarthViewsPerScanline(); i++ ) +// poly->append(QPointF(segm->geolongitude[i + j*segm->getEarthViewsPerScanline()], segm->geolatitude[i + j*segm->getEarthViewsPerScanline()] )); +// break; +// } +// } +// } + +// QApplication::processEvents(); +// ++segsel; +// } +//} + +//void SegmentListMERSI::GetTrackPolygon(QPolygonF *poly) +//{ +// QList::iterator segsel; +// int nbroflines; + +// segsel = segsselected.begin(); + +// while ( segsel != segsselected.end() ) +// { +// SegmentMERSI *segm = (SegmentMERSI *)(*segsel); +// nbroflines = segm->GetNbrOfLines(); +// for(int j = 0; j < nbroflines; j=j+10) +// { +// if(segm->geolongitude[j*segm->getEarthViewsPerScanline()] < 180.0 && segm->geolatitude[j*segm->getEarthViewsPerScanline()] < 90.0) +// { +// poly->append(QPointF(segm->geolongitude[j*segm->getEarthViewsPerScanline() + (int)(segm->getEarthViewsPerScanline()/2)], segm->geolatitude[j*segm->getEarthViewsPerScanline() + (int)(segm->getEarthViewsPerScanline()/2)] )); +// } +// } + +// QApplication::processEvents(); +// ++segsel; +// } +//} diff --git a/core/segmentlistmersi.h b/core/segmentlistmersi.h index 37c6991..f918483 100644 --- a/core/segmentlistmersi.h +++ b/core/segmentlistmersi.h @@ -24,7 +24,9 @@ class SegmentListMERSI : public SegmentList void ComposeGVProjection(int inputchannel); void ComposeLCCProjection(int inputchannel); void ComposeSGProjection(int inputchannel); - + void ComposeOMProjection(int inputchannel); + void GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat); + void GetCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4); protected: QFutureWatcher *watchermersi; @@ -34,8 +36,11 @@ protected slots: void progressreadvalue(int progress); private: + int getIndexFromColor(int colorindex); + bool invertarrayindex[3]; int colorarrayindex[3]; + int bandindex; SatelliteList *satlist; bool normalized; @@ -43,9 +48,6 @@ protected slots: QList colorlist; QList invertlist; - int getIndexFromColor(int colorindex); - - }; diff --git a/core/segmentlistmetop.cpp b/core/segmentlistmetop.cpp index ba9c249..5a901ca 100644 --- a/core/segmentlistmetop.cpp +++ b/core/segmentlistmetop.cpp @@ -20,9 +20,6 @@ bool SegmentListMetop::GetGeoLocation(double lon_rad, double lat_rad, int *x, i { //qDebug() << QString("SegmentListMetop::GetGeoLocation segsselected count = %1").arg(segsselected.count()); - float flon; - float flat; - *x = 0; *y = 0; @@ -54,4 +51,54 @@ bool SegmentListMetop::GetGeoLocation(double lon_rad, double lat_rad, int *x, i return false; } +void SegmentListMetop::GetCentralCoords(double *startcentrallon, double *startcentrallat, double *endcentrallon, double *endcentrallat) +{ + + double slon, slat, elon, elat; + double save_slon, save_slat, save_elon, save_elat; + int startindex, endindex; + + save_slon = 65535.0; + save_slat = 65535.0; + save_elon = 65535.0; + save_elat = 65535.0; + + bool first = true; + + QList::iterator segsel; + segsel = segsselected.begin(); + + while ( segsel != segsselected.end() ) + { + SegmentMetop *segm = (SegmentMetop *)(*segsel); + segm->GetCentralCoords(&slon, &slat, &elon, &elat, &startindex, &endindex); + + if(abs(slon) < 180.0 && abs(slat) < 90.0 && abs(elon) < 180.0 && abs(elat) < 90.0) + { + if(first == true) + { + first = false; + save_slon = slon; + save_slat = slat; + save_elon = elon; + save_elat = elat; + } + else + { + save_elon = elon; + save_elat = elat; + } + + } + + QApplication::processEvents(); + ++segsel; + } + + *startcentrallon = save_slon; + *startcentrallat = save_slat; + *endcentrallon = save_elon; + *endcentrallat = save_elat; + +} diff --git a/core/segmentlistmetop.h b/core/segmentlistmetop.h index 9de71c2..fb998fd 100644 --- a/core/segmentlistmetop.h +++ b/core/segmentlistmetop.h @@ -13,6 +13,7 @@ class SegmentListMetop : public SegmentList public: explicit SegmentListMetop(QObject *parent = 0); bool GetGeoLocation(double lon_rad, double lat_rad, int *x, int *y); + void GetCentralCoords(double *startcentrallon, double *startcentrallat, double *endcentrallon, double *endcentrallat); }; diff --git a/core/segmentlistviirsm.cpp b/core/segmentlistviirsm.cpp index f808743..8d52722 100644 --- a/core/segmentlistviirsm.cpp +++ b/core/segmentlistviirsm.cpp @@ -136,6 +136,8 @@ bool SegmentListVIIRSM::ComposeVIIRSImageInThread(QList bandlist, QListptrimageViirsM = new QImage(earthviews, totalnbroflines, QImage::Format_ARGB32); + qDebug() << "bool SegmentListVIIRSM::ComposeVIIRSImageInThread ptrimageViirsM QImage created " << + imageptrs->ptrimageViirsM->width() << "X" << imageptrs->ptrimageViirsM->height(); int deltaprogress = 99 / (totalnbrofsegments*2); int totalprogress = 0; @@ -287,6 +289,22 @@ void SegmentListVIIRSM::ComposeSGProjection(int inputchannel) initBrightnessTemp(); } +void SegmentListVIIRSM::ComposeOMProjection(int inputchannel) +{ + + qDebug() << "SegmentListVIIRSM::ComposeOMProjection()"; + QList::iterator segit = segsselected.begin(); + while ( segit != segsselected.end() ) + { + (*segit)->ComposeSegmentOMProjection(inputchannel, 0, false); + emit segmentprojectionfinished(false); + QApplication::processEvents(); + + ++segit; + } + +} + void SegmentListVIIRSM::initBrightnessTemp() { int height = imageptrs->ptrimageProjection->height(); @@ -1358,3 +1376,115 @@ void SegmentListVIIRSM::MapCanvasFloat(float *canvas, int *canvas1, qint32 ancho } } +void SegmentListVIIRSM::GetCentralCoords(double *startcentrallon, double *startcentrallat, double *endcentrallon, double *endcentrallat) +{ + double slon, slat, elon, elat; + double save_slon, save_slat, save_elon, save_elat; + int startindex, endindex; + + save_slon = 65535.0; + save_slat = 65535.0; + save_elon = 65535.0; + save_elat = 65535.0; + + bool first = true; + + QList::iterator segsel = segsselected.begin(); + + while ( segsel != segsselected.end() ) + { + SegmentVIIRSM *segm = (SegmentVIIRSM *)(*segsel); + segm->GetCentralCoords(&slon, &slat, &elon, &elat, &startindex, &endindex); + + if(abs(slon) <= 180.0 && abs(slat) <= 90.0 && abs(elon) <= 180.0 && abs(elat) <= 90.0) + { + if(first == true) + { + first = false; + save_slon = slon; + save_slat = slat; + save_elon = elon; + save_elat = elat; + } + else + { + save_elon = elon; + save_elat = elat; + } + } + + QApplication::processEvents(); + ++segsel; + } + + *startcentrallon = save_slon; + *startcentrallat = save_slat; + *endcentrallon = save_elon; + *endcentrallat = save_elat; + +} + +void SegmentListVIIRSM::GetCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4) +{ + double save_cornerlon1, save_cornerlat1, save_cornerlon2, save_cornerlat2; + double save_cornerlon3, save_cornerlat3, save_cornerlon4, save_cornerlat4; + int Xcornerindex1, Xcornerindex2, Ycornerindex12; + int Xcornerindex3, Xcornerindex4, Ycornerindex34; + + save_cornerlon1 = 65535.0; + save_cornerlat1 = 65535.0; + save_cornerlon2 = 65535.0; + save_cornerlat2 = 65535.0; + + save_cornerlon3 = 65535.0; + save_cornerlat3 = 65535.0; + save_cornerlon4 = 65535.0; + save_cornerlat4 = 65535.0; + + QList::iterator segsel; + segsel = segsselected.begin(); + + int count = 0; + + while ( segsel != segsselected.end() ) + { + SegmentVIIRSM *segm = (SegmentVIIRSM *)(*segsel); + count++; + if(count == 1) + { + segm->GetStartCornerCoords(&save_cornerlon1, &save_cornerlat1, &save_cornerlon2, &save_cornerlat2, &Xcornerindex1, &Xcornerindex2, &Ycornerindex12 ); + if(abs(save_cornerlon1) <= 180.0 && abs(save_cornerlat1) <= 90.0 && abs(save_cornerlon2) <= 180.0 && abs(save_cornerlat2) <= 90.0) + break; + } + ++segsel; + } + + segsel = segsselected.begin(); + count = 0; + + while ( segsel != segsselected.end() ) + { + SegmentVIIRSM *segm = (SegmentVIIRSM *)(*segsel); + count++; + + if(count == segsselected.size()) + { + segm->GetEndCornerCoords(&save_cornerlon3, &save_cornerlat3, &save_cornerlon4, &save_cornerlat4, &Xcornerindex3, &Xcornerindex4, &Ycornerindex34 ); + if(abs(save_cornerlon3) <= 180.0 && abs(save_cornerlat3) <= 90.0 && abs(save_cornerlon4) <= 180.0 && abs(save_cornerlat4) <= 90.0) + break; + } + ++segsel; + } + + *cornerlon1 = save_cornerlon1; + *cornerlat1 = save_cornerlat1; + *cornerlon2 = save_cornerlon2; + *cornerlat2 = save_cornerlat2; + + *cornerlon3 = save_cornerlon3; + *cornerlat3 = save_cornerlat3; + *cornerlon4 = save_cornerlon4; + *cornerlat4 = save_cornerlat4; + +} + diff --git a/core/segmentlistviirsm.h b/core/segmentlistviirsm.h index 974139e..37221a4 100644 --- a/core/segmentlistviirsm.h +++ b/core/segmentlistviirsm.h @@ -26,6 +26,10 @@ class SegmentListVIIRSM : public SegmentList void ComposeGVProjection(int inputchannel); void ComposeLCCProjection(int inputchannel); void ComposeSGProjection(int inputchannel); + void ComposeOMProjection(int inputchannel); + + void GetCentralCoords(double *startcentrallon, double *startcentrallat, double *endcentrallon, double *endcentrallat); + void GetCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4); static void doComposeVIIRSMImageInThread(SegmentListVIIRSM *t, QList bandlist, QList colorlist, QList invertlist); @@ -54,9 +58,7 @@ class SegmentListVIIRSM : public SegmentList float maxBrightnessTemp; float minBrightnessTempProjection; float maxBrightnessTempProjection; -// QList bandlist; -// QList colorlist; -// QList inverselist; + protected: diff --git a/core/segmentmersi.cpp b/core/segmentmersi.cpp index ec7204d..f5f1ce1 100644 --- a/core/segmentmersi.cpp +++ b/core/segmentmersi.cpp @@ -142,7 +142,7 @@ void SegmentMERSI::initializeMemory() } } -void SegmentMERSI::ComposeSegmentImage(int colorarrayindex[], bool invertarrayindex[], int histogrammethod, bool normalized, int totallines) +void SegmentMERSI::ComposeSegmentImage(int bandindex, int colorarrayindex[], bool invertarrayindex[], int histogrammethod, bool normalized, int totallines) { QRgb *row; @@ -150,9 +150,9 @@ void SegmentMERSI::ComposeSegmentImage(int colorarrayindex[], bool invertarrayin qDebug() << QString("SegmentMERSI::ComposeSegmentImage() segm->startLineNbr = %1").arg(this->startLineNbr); qDebug() << QString("SegmentMERSI::ComposeSegmentImage() color = %1 ").arg(bandlist.at(0)); - qDebug() << QString("SegmentMERSI::ComposeSegmentImage() invertarrayindex[0] = %1").arg(invertarrayindex[0]); - qDebug() << QString("SegmentMERSI::ComposeSegmentImage() invertarrayindex[1] = %1").arg(invertarrayindex[1]); - qDebug() << QString("SegmentMERSI::ComposeSegmentImage() invertarrayindex[2] = %1").arg(invertarrayindex[2]); + qDebug() << QString("SegmentMERSI::ComposeSegmentImage() colorarrayindex[0] = %1").arg(colorarrayindex[0]); + qDebug() << QString("SegmentMERSI::ComposeSegmentImage() colorarrayindex[1] = %1").arg(colorarrayindex[1]); + qDebug() << QString("SegmentMERSI::ComposeSegmentImage() colorarrayindex[2] = %1").arg(colorarrayindex[2]); int pixval[3]; int r, g, b; @@ -166,24 +166,34 @@ void SegmentMERSI::ComposeSegmentImage(int colorarrayindex[], bool invertarrayin this->colorarrayindex[i] = colorarrayindex[i]; this->invertarrayindex[i] = invertarrayindex[i]; } + this->bandindex = bandindex; for (int line = 0; line < this->NbrOfLines; line++) -// for (int line = this->NbrOfLines - 1; line >= 0; line--) { row = (QRgb*)imageptrs->ptrimageMERSI->scanLine(totallines - 1 - this->startLineNbr - line); for (int pixelx = 0; pixelx < earth_views_per_scanline; pixelx++) -// for (int pixelx = earth_views_per_scanline - 1; pixelx >= 0; pixelx--) { - pixval[0] = *(this->ptrbaMERSI.data() + this->colorarrayindex[0] * oneblock + line * earth_views_per_scanline + earth_views_per_scanline - 1 - pixelx); if(color) { + pixval[0] = *(this->ptrbaMERSI.data() + this->colorarrayindex[0] * oneblock + line * earth_views_per_scanline + earth_views_per_scanline - 1 - pixelx); pixval[1] = *(this->ptrbaMERSI.data() + this->colorarrayindex[1] * oneblock + line * earth_views_per_scanline + earth_views_per_scanline - 1 - pixelx); pixval[2] = *(this->ptrbaMERSI.data() + this->colorarrayindex[2] * oneblock + line * earth_views_per_scanline + earth_views_per_scanline - 1 - pixelx); + + valok[0] = pixval[0] < 65528 && pixval[0] > 0; + valok[1] = pixval[1] < 65528 && pixval[1] > 0; + valok[2] = pixval[2] < 65528 && pixval[2] > 0; } + else + { + pixval[0] = *(this->ptrbaMERSI.data() + (this->bandindex - 1) * oneblock + line * earth_views_per_scanline + earth_views_per_scanline - 1 - pixelx); + pixval[1] = pixval[0]; + pixval[2] = pixval[0]; - valok[0] = pixval[0] < 65528 && pixval[0] > 0; - valok[1] = pixval[1] < 65528 && pixval[1] > 0; - valok[2] = pixval[2] < 65528 && pixval[2] > 0; + valok[0] = pixval[0] < 65528 && pixval[0] > 0; + valok[1] = valok[0]; + valok[2] = valok[0]; + + } if( valok[0] && (color ? valok[1] && valok[2] : true)) { @@ -332,7 +342,7 @@ void SegmentMERSI::RenderSegmentlineInTextureMERSI( int nbrLine, QRgb *row ) } -Segment *SegmentMERSI::ReadSegmentInMemory(bool composecolor, int colorarrayindex[]) +Segment *SegmentMERSI::ReadSegmentInMemory(int bandindex, int colorarrayindex[]) { QScopedArrayPointer ptrbaLongitude; QScopedArrayPointer ptrbaLatitude; @@ -340,6 +350,7 @@ Segment *SegmentMERSI::ReadSegmentInMemory(bool composecolor, int colorarrayinde int geoindex; qDebug() << "*SegmentMERSI::ReadSegmentInMemory() for " << fileInfo.filePath(); + qDebug() << "bandindex = " << bandindex << " colorarrayindex[0] = " << colorarrayindex[0]<< " colorarrayindex[1] = " << colorarrayindex[1]<< " colorarrayindex[2] = " << colorarrayindex[2]; hid_t h5_file_id, h5_filegeo_id, h5_Longitude_id, h5_Latitude_id; herr_t h5_status; @@ -347,7 +358,13 @@ Segment *SegmentMERSI::ReadSegmentInMemory(bool composecolor, int colorarrayinde qDebug() << "File " << fileInfo.filePath().toLatin1() << " not open !!"; - strgeofile = fileInfo.fileName().replace(40, 5, "GEO1K"); + if(fileInfo.fileName().indexOf("1000M") == 40) + strgeofile = fileInfo.fileName().replace(40, 5, "GEO1K"); + else if(fileInfo.fileName().indexOf("1000M") == 39) + strgeofile = fileInfo.fileName().replace(39, 5, "GEO1K"); + else + qDebug() << "Wrong filename = " << fileInfo.fileName(); + QString strgeofilepath = fileInfo.path() + "/" + strgeofile; QFile geofile(strgeofilepath); if (geofile.exists()) @@ -458,23 +475,44 @@ Segment *SegmentMERSI::ReadSegmentInMemory(bool composecolor, int colorarrayinde int oneblock = 400 * 2048; - for(int k = 0; k < (this->bandlist.at(0) ? 3 : 1); k++) + if(bandindex == 0) // color { - for (int j = 0; j < NbrOfLines; j++) { - for (int i = 0; i < earth_views_per_scanline; i++) + for(int k = 0; k < 3; k++) + { + for (int j = 0; j < NbrOfLines; j++) { - if(ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] > 0 && ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] < 65528) + for (int i = 0; i < earth_views_per_scanline; i++) { - if(ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] >= stat_max_ch[k]) - stat_max_ch[k] = ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i]; - if(ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] < stat_min_ch[k]) - stat_min_ch[k] = ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i]; - active_pixels[k]++; + if(ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] > 0 && ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] < 65528) + { + if(ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] >= stat_max_ch[k]) + stat_max_ch[k] = ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i]; + if(ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i] < stat_min_ch[k]) + stat_min_ch[k] = ptrbaMERSI[oneblock * colorarrayindex[k] + j * earth_views_per_scanline + i]; + active_pixels[k]++; + } } } } } + else + { + for (int j = 0; j < NbrOfLines; j++) + { + for (int i = 0; i < earth_views_per_scanline; i++) + { + if(ptrbaMERSI[oneblock * (bandindex-1) + j * earth_views_per_scanline + i] > 0 && ptrbaMERSI[oneblock * (bandindex-1) + j * earth_views_per_scanline + i] < 65528) + { + if(ptrbaMERSI[oneblock * (bandindex-1) + j * earth_views_per_scanline + i] >= stat_max_ch[0]) + stat_max_ch[0] = ptrbaMERSI[oneblock * (bandindex-1) + j * earth_views_per_scanline + i]; + if(ptrbaMERSI[oneblock * (bandindex-1) + j * earth_views_per_scanline + i] < stat_min_ch[0]) + stat_min_ch[0] = ptrbaMERSI[oneblock * (bandindex-1) + j * earth_views_per_scanline + i]; + active_pixels[0]++; + } + } + } + } qDebug() << QString("ptrbaMERSI min_ch[0] = %1 max_ch[0] = %2").arg(stat_min_ch[0]).arg(stat_max_ch[0]); if(this->bandlist.at(0)) @@ -520,6 +558,8 @@ void SegmentMERSI::ReadMERSI_1KM(hid_t h5_file_id) void SegmentMERSI::ReadGeoFile(hid_t h5_geofile_id) { + qDebug() << "SegmentMERSI::ReadGeoFile(hid_t h5_geofile_id)"; + hid_t h5_Longitude_id, h5_Latitude_id; herr_t h5_status; @@ -563,6 +603,11 @@ void SegmentMERSI::ComposeSegmentSGProjection(int inputchannel, int histogrammet ComposeProjection(SG, histogrammethod, normalized); } +void SegmentMERSI::ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized) +{ + ComposeProjection(OM, histogrammethod, normalized); +} + void SegmentMERSI::ComposeProjection(eProjections proj, int histogrammethod, bool normalized) { @@ -640,6 +685,13 @@ void SegmentMERSI::ComposeProjection(eProjections proj, int histogrammethod, boo MapPixel( i, j, map_x, map_y, color); } } + else if(proj == OM) // Oblique Mercator + { + if(imageptrs->om->map_forward(lonpos1 * PI / 180.0, latpos1 * PI / 180.0, map_x, map_y)) + { + MapPixel( i, j, map_x, map_y, color); + } + } } else { projectionCoordX[i * earth_views_per_scanline + j] = 65535; @@ -703,45 +755,169 @@ void SegmentMERSI::MapPixel(int lines, int views, double map_x, double map_y, bo } -// rgbvalue = qRgba(color8[0], iscolor ? color8[1] : color8[0], iscolor ? color8[2] : color8[0], 255 ); + // rgbvalue = qRgba(color8[0], iscolor ? color8[1] : color8[0], iscolor ? color8[2] : color8[0], 255 ); rgbvalue = qRgba(pixval256[0], iscolor ? pixval256[1] : pixval256[0], iscolor ? pixval256[2] : pixval256[0], 255 ); -// if(opts.sattrackinimage) -// { -// if(views == 1598 || views == 1599 || views == 1600 || views == 1601 ) -// { -// rgbvalue = qRgb(250, 0, 0); -// if (map_x >= 0 && map_x < imageptrs->ptrimageProjection->width() && map_y >= 0 && map_y < imageptrs->ptrimageProjection->height()) -// imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); -// } -// else -// { -// if (map_x >= 0 && map_x < imageptrs->ptrimageProjection->width() && map_y >= 0 && map_y < imageptrs->ptrimageProjection->height()) -// imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); -// projectionCoordValue[lines * earth_views_per_scanline + views] = rgbvalue; - -// } -// } -// else -// { - - - if (map_x >= 0 && map_x < imageptrs->ptrimageProjection->width() && map_y >= 0 && map_y < imageptrs->ptrimageProjection->height()) - imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); - - projectionCoordValue[lines * earth_views_per_scanline + views] = rgbvalue; - projectionCoordValueRed[lines * earth_views_per_scanline + views] = color12[0]; - if(iscolor) + if(opts.sattrackinimage) + { + if(views == 1023 || views == 1024 || views == 1025 ) { - projectionCoordValueGreen[lines * earth_views_per_scanline + views] = color12[1]; - projectionCoordValueBlue[lines * earth_views_per_scanline + views] = color12[2]; + rgbvalue = qRgb(250, 0, 0); + if (map_x >= 0 && map_x < imageptrs->ptrimageProjection->width() && map_y >= 0 && map_y < imageptrs->ptrimageProjection->height()) + imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); } else { - projectionCoordValueGreen[lines * earth_views_per_scanline + views] = color12[0]; - projectionCoordValueBlue[lines * earth_views_per_scanline + views] = color12[0]; + if (map_x >= 0 && map_x < imageptrs->ptrimageProjection->width() && map_y >= 0 && map_y < imageptrs->ptrimageProjection->height()) + imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); + projectionCoordValue[lines * earth_views_per_scanline + views] = rgbvalue; + } -// } + } + else + { + if (map_x >= 0 && map_x < imageptrs->ptrimageProjection->width() && map_y >= 0 && map_y < imageptrs->ptrimageProjection->height()) + imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); + } + + projectionCoordValue[lines * earth_views_per_scanline + views] = rgbvalue; + projectionCoordValueRed[lines * earth_views_per_scanline + views] = color12[0]; + if(iscolor) + { + projectionCoordValueGreen[lines * earth_views_per_scanline + views] = color12[1]; + projectionCoordValueBlue[lines * earth_views_per_scanline + views] = color12[2]; + } + else + { + projectionCoordValueGreen[lines * earth_views_per_scanline + views] = color12[0]; + projectionCoordValueBlue[lines * earth_views_per_scanline + views] = color12[0]; + } + // } + } +} + +void SegmentMERSI::GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat, int *startindex, int *endindex) +{ + if(geolatitude.isNull()) + { + *startlon = 0.0; + *startlat = 0.0; + *endlon = 0.0; + *endlat = 0.0; + return; + } + + for(int i = 0; i < NbrOfLines; i++) + { + *startindex = i; + *startlon = geolongitude[i * earth_views_per_scanline + (int)(earth_views_per_scanline/2)]; + *startlat = geolatitude[i * earth_views_per_scanline + (int)(earth_views_per_scanline/2)]; + if(*startlon != 65535 && *startlat != 65535) + break; + } + + for(int i = NbrOfLines - 1; i >= 0; i--) + { + *endindex = i; + *endlon = geolongitude[i * earth_views_per_scanline + (int)(earth_views_per_scanline/2)]; + *endlat = geolatitude[i * earth_views_per_scanline + (int)(earth_views_per_scanline/2)]; + if(*endlon != 65535 && *endlat != 65535) + break; + } + +// qDebug() << "SegmentMERSI::GetCentralCoords startindex = " << *startindex << " endindex = " << *endindex << " slon = " << *startlon << +// " slat = " << *startlat << " elon = " << *endlon << " elat = " << *endlat; + +} + +void SegmentMERSI::GetStartCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, + int *Xstartindex1, int *Xstartindex2, int *Ystartindex12) +{ + if(geolatitude.isNull()) + { + *cornerlon1 = 999.0; + *cornerlat1 = 999.0; + *cornerlon2 = 999.0; + *cornerlat2 = 999.0; + *Xstartindex1 = 0; + *Xstartindex2 = 0; + *Ystartindex12 = 0; + return; + } + + for(int i = 0; i < NbrOfLines; i++) + { + *Ystartindex12 = i; + + for(int j = 0; j < earth_views_per_scanline; j++) + { + *Xstartindex1 = j; + *cornerlon1 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat1 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon1) < 180.0 && abs(*cornerlat1) < 90.0) + break; + } + + for(int j = earth_views_per_scanline - 1; j >= 0; j--) + { + *Xstartindex2 = j; + *cornerlon2 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat2 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon2) < 180.0 && abs(*cornerlat2) < 90.0) + break; + } + + if(abs(*cornerlon1) < 180.0 && abs(*cornerlat1) < 90.0 && abs(*cornerlon2) < 180.0 && abs(*cornerlat2) < 90.0) + break; + } + + qDebug() << "SegmentMERSI::GetStartCornerCoords " << " cornerlon1 = " << *cornerlon1 << " cornerlat1 = " << *cornerlat1 << " cornerlon2 = " << *cornerlon2 << + " cornerlat2 = " << *cornerlat2 << " Xstartindex1 = " << *Xstartindex1 << " Xstartindex2 = " << *Xstartindex2 << " Ystartindex12 = " << *Ystartindex12; + +} +void SegmentMERSI::GetEndCornerCoords(double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4, + int *Xstartindex3, int *Xstartindex4, int *Ystartindex34) +{ + if(geolatitude.isNull()) + { + *cornerlon3 = 999.0; + *cornerlat3 = 999.0; + *cornerlon4 = 999.0; + *cornerlat4 = 999.0; + *Xstartindex3 = 0; + *Xstartindex4 = 0; + *Ystartindex34 = 0; + return; } + + for(int i = 399; i >= 0; i--) + { + *Ystartindex34 = i; + + for(int j = 0; j < 2048; j++) + { + *Xstartindex3 = j; + *cornerlon3 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat3 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon3) < 180.0 && abs(*cornerlat3) < 90.0) + break; + } + + for(int j = 2047; j >= 0; j--) + { + *Xstartindex4 = j; + *cornerlon4 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat4 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon4) < 180.0 && abs(*cornerlat4) < 90.0) + break; + } + + if(abs(*cornerlon3) < 180.0 && abs(*cornerlat3) < 90.0 && abs(*cornerlon4) < 180.0 && abs(*cornerlat4) < 90.0) + break; + } + + qDebug() << "SegmentMERSI::GetEndCornerCoords " << " cornerlon3 = " << *cornerlon3 << " cornerlat3 = " << *cornerlat3 << " cornerlon4 = " << *cornerlon4 << " cornerlat4 = " << *cornerlat4 << + " Xstartindex3 = " << *Xstartindex3 << " Xstartindex4 = " << *Xstartindex4 << " Ystartindex34 = " << *Ystartindex34; + } diff --git a/core/segmentmersi.h b/core/segmentmersi.h index 7ca09cc..2a52888 100644 --- a/core/segmentmersi.h +++ b/core/segmentmersi.h @@ -12,14 +12,19 @@ class SegmentMERSI : public Segment public: explicit SegmentMERSI(QFileInfo fileinfo, SatelliteList *satl = 0, QObject *parent = 0); - int getEarthViewsPerScanline() { return this->earth_views_per_scanline; } - void ComposeSegmentImage(int colorarrayindex[], bool invertarrayindex[], int histogrammethod, bool normalized, int totallines); - Segment *ReadSegmentInMemory(bool composecolor, int colorarrayindex[]); + void ComposeSegmentImage(int bandindex, int colorarrayindex[], bool invertarrayindex[], int histogrammethod, bool normalized, int totallines); + Segment *ReadSegmentInMemory(int bandindex, int colorarrayindex[]); void RenderSegmentlineInTextureMERSI(int nbrLine, QRgb *row ); void ComposeSegmentLCCProjection(int inputchannel, int histogrammethod, bool normalized); void ComposeSegmentGVProjection(int inputchannel, int histogrammethod, bool normalized); void ComposeSegmentSGProjection(int inputchannel, int histogrammethod, bool normalized); + void ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized); void ComposeProjection(eProjections proj, int histogrammethod, bool normalized); + void GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat, int *startindex, int *endindex); + void GetStartCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, + int *Xstartindex1, int *Xstartindex2, int *Ystartindex12); + void GetEndCornerCoords(double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4, + int *Xstartindex3, int *Xstartindex4, int *Ystartindex34); void initializeMemory(); @@ -35,6 +40,7 @@ class SegmentMERSI : public Segment int colorarrayindex[3]; bool invertarrayindex[3]; + int bandindex; diff --git a/core/segmentmetop.cpp b/core/segmentmetop.cpp index 9f84f20..4fa612a 100644 --- a/core/segmentmetop.cpp +++ b/core/segmentmetop.cpp @@ -791,7 +791,7 @@ Segment *SegmentMetop::ReadSegmentInMemory() QByteArray mdr_record = QByteArray::fromRawData(buf, nBuf); //qDebug() << QString("line at 0 = mdr heightintotalimage = %1").arg(heightintotalimage); //qDebug() << QString("mdr_record length = %1").arg(mdr_record.length()); - inspectSolarAngle(&mdr_record, heightinsegment); + //inspectSolarAngle(&mdr_record, heightinsegment); inspectEarthLocations(&mdr_record, heightinsegment); //mdr_record = QByteArray::fromRawData(buf, nBuf); @@ -949,6 +949,23 @@ void SegmentMetop::ComposeSegmentGVProjection(int inputchannel, int histogrammet } +void SegmentMetop::ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized) +{ + + qDebug() << QString("ComposeSegmentOMProjection startLineNbr = %1").arg(this->startLineNbr); + int startheight = this->startLineNbr; + + initializeProjectionCoord(); + + for (int line = 0; line < this->NbrOfLines; line++) + { + this->RenderSegmentlineInOM( (inputchannel == 0 ? 6 : inputchannel), line, startheight + line, normalized ); + } + + QApplication::processEvents(); + +} + void SegmentMetop::RenderSegmentlineInGVP(int channel, int nbrLine, int heightintotalimage , bool normalized) { double lonpos1, latpos1; @@ -977,10 +994,10 @@ void SegmentMetop::RenderSegmentlineInGVP(int channel, int nbrLine, int heightin to = 5 + 20 * 102 + 3 = 2048 */ - if(num_navigation_points == 103 && (nbrLine == 0 || nbrLine == 540 || nbrLine == 1079)) - { - qDebug() << QString("------>IEL nbrLine = %1 lon[0] = %2, lon[52] = %3, lon[102] = %4").arg(nbrLine).arg( earthloc_lon[nbrLine*103]).arg( earthloc_lon[nbrLine*103 + 52]).arg( earthloc_lon[nbrLine * 103 + 102]); - } +// if(num_navigation_points == 103 && (nbrLine == 0 || nbrLine == 540 || nbrLine == 1079)) +// { +// qDebug() << QString("------>IEL nbrLine = %1 lon[0] = %2, lon[52] = %3, lon[102] = %4").arg(nbrLine).arg( earthloc_lon[nbrLine*103]).arg( earthloc_lon[nbrLine*103 + 52]).arg( earthloc_lon[nbrLine * 103 + 102]); +// } if(num_navigation_points == 103) @@ -1095,59 +1112,6 @@ float SegmentMetop::getSolarZenith(int navpoint, int intpoint, int nbrLine, int } -//float SegmentMetop::getSolarZenith(int navpoint, int intpoint, int nbrLine) //navpoint = [0, 101] intpoint = [0, 19] nbrLine = [0, 1079] -//{ -// // second order Lagrange interpolation ==> 3 points -// // from pt 5 --> pt 2045 -// // = 5 + 20 * 102 total of 103 pts -// // to = 5 + 20 * 102 + 3 = 2048 -// // - -// float a, k, s, t; -// float x[3]; -// float y[3]; - -// int n = 3; -// if(navpoint == 0) -// { -// y[0] = solar_zenith_angle[nbrLine*103]; -// y[1] = solar_zenith_angle[nbrLine*103 + 1]; -// y[2] = solar_zenith_angle[nbrLine*103 + 2]; -// x[0] = 4; -// x[1] = 24; -// x[2] = 44; -// } -// else -// { -// y[0] = solar_zenith_angle[nbrLine*103 + navpoint - 1]; -// y[1] = solar_zenith_angle[nbrLine*103 + navpoint]; -// y[2] = solar_zenith_angle[nbrLine*103 + navpoint + 1]; -// x[0] = (navpoint-1) * 20 + 4; -// x[1] = navpoint * 20 + 4; -// x[2] = (navpoint+1) * 20 + 4; -// } - -// k = 0; -// a = navpoint * 20 + intpoint + 4; - -// for(int i=0; iptrimagecomp_col->scanLine(heightintotalimage); + else if (channel == 1) + row_col = (QRgb*)imageptrs->ptrimagecomp_ch[0]->scanLine(heightintotalimage); + else if (channel == 2) + row_col = (QRgb*)imageptrs->ptrimagecomp_ch[1]->scanLine(heightintotalimage); + else if (channel == 3) + row_col = (QRgb*)imageptrs->ptrimagecomp_ch[2]->scanLine(heightintotalimage); + else if (channel == 4) + row_col = (QRgb*)imageptrs->ptrimagecomp_ch[3]->scanLine(heightintotalimage); + else if (channel == 5) + row_col = (QRgb*)imageptrs->ptrimagecomp_ch[4]->scanLine(heightintotalimage); + + + if(num_navigation_points == 103) + { + for( int i = 0; i < num_navigation_points-1; i++) + { + dtot = 2 * asin(sqrt(pow((sin((earthloc_lat[nbrLine*103 + i]*PI/180.0 - earthloc_lat[nbrLine*103 + i+1]*PI/180.0) / 2)), 2) + cos(earthloc_lat[nbrLine*103 + i]*PI/180.0) * cos(earthloc_lat[nbrLine*103 + i+1]*PI/180.0) * pow(sin((earthloc_lon[nbrLine*103 + i]*PI/180.0-earthloc_lon[nbrLine*103 + i+1]*PI/180.0) / 2), 2))); + for( int j = 0; j < 20 ; j++ ) + { + intermediatePoint(earthloc_lat[nbrLine*103 + i]*PI/180.0, earthloc_lon[nbrLine*103 + i]*PI/180.0, earthloc_lat[nbrLine*103 + i+1]*PI/180.0, earthloc_lon[nbrLine*103 + i+1]*PI/180.0, imageptrs->fraction[4 + i*20 + j], &latpos1, &lonpos1, dtot); + if(imageptrs->om->map_forward(lonpos1, latpos1, map_x, map_y)) + { + projectionCoordX[nbrLine * 2048 + i * 20 + j + 4] = (int)map_x; + projectionCoordY[nbrLine * 2048 + i * 20 + j + 4] = (int)map_y; + + //if (map_x > 0 && map_x < imageptrs->ptrimageProjection->width() && map_y > 0 && map_y < imageptrs->ptrimageProjection->height()) + { + rgbvalue = row_col[4 + i * 20 + j]; + if (map_x > 0 && map_x < imageptrs->ptrimageProjection->width() && map_y > 0 && map_y < imageptrs->ptrimageProjection->height()) + imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); + projectionCoordValue[nbrLine * 2048 + i * 20 + j + 4] = rgbvalue; + + } + } + else + { + projectionCoordX[nbrLine * 2048 + i * 20 + j + 4] = 65535; + projectionCoordY[nbrLine * 2048 + i * 20 + j + 4] = 65535; + projectionCoordValue[nbrLine * 2048 + i * 20 + j + 4] = qRgb(0,0,0); + } + + } + } + } + +} + void SegmentMetop::ComposeSegmentLCCProjection(int inputchannel, int histogrammethod, bool normalized) { @@ -1476,3 +1501,41 @@ void SegmentMetop::intermediatePoint(double lat1, double lng1, double lat2, doub *lat = atan2(z, sqrt(pow(x, 2) + pow(y, 2))); *lng = atan2(y, x); } + +void SegmentMetop::GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat, int *startindex, int *endindex) +{ + // from pt 5 --> pt 2045 + // = 5 + 20 * 102 total of 103 pts + // to = 5 + 20 * 102 + 3 = 2048 + // central point 5 + 51 * 20 = 1025 + if(earthloc_lon.isNull()) + { + *startlon = 0.0; + *startlat = 0.0; + *endlon = 0.0; + *endlat = 0.0; + return; + } + + for(int i = 0; i < NbrOfLines; i++) + { + *startindex = i; + *startlon = earthloc_lon[i * 103 + 51]; + *startlat = earthloc_lat[i * 103 + 51]; + if(abs(*startlon) < 180.0 && abs(*startlat) < 90.0) + break; + } + + for(int i = NbrOfLines - 1; i >= 0; i--) + { + *endindex = i; + *endlon = earthloc_lon[i * 103 + 51]; + *endlat = earthloc_lat[i * 103 + 51]; + if(abs(*endlon) < 180.0 && abs(*endlat) < 90.0) + break; + } + + qDebug() << "SegmentMetop::GetCentralCoords startindex = " << *startindex << " endindex = " << *endindex << " slon = " << *startlon << + " slat = " << *startlat << " elon = " << *endlon << " elat = " << *endlat; + +} diff --git a/core/segmentmetop.h b/core/segmentmetop.h index 6f5c160..3cb351b 100644 --- a/core/segmentmetop.h +++ b/core/segmentmetop.h @@ -37,9 +37,14 @@ class SegmentMetop : public Segment void ComposeSegmentSGProjection(int inputchannel, int histogrammethod, bool normalized); void RenderSegmentlineInSG( int channel, int nbrLine, int heightintotalimage, bool normalized); + void ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized); + void RenderSegmentlineInOM( int channel, int nbrLine, int heightintotalimage, bool normalized); + + void intermediatePoint(double lat1, double lng1, double lat2, double lng2, double f, double *lat, double *lng, double d); int ReadNbrOfLines(); float getSolarZenith(int navpoint, int intpoint, int nbrLine, int startnavindex, int deltaint, int lengthintindex, int lengthnavindex ); + void GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat, int *startindex, int *endindex); double earth_loc_lon_first[1080], earth_loc_lat_first[1080]; double earth_loc_lon_last[1080], earth_loc_lat_last[1080]; diff --git a/core/segmentnoaa.cpp b/core/segmentnoaa.cpp index 7cf2c55..1c12c8a 100644 --- a/core/segmentnoaa.cpp +++ b/core/segmentnoaa.cpp @@ -801,6 +801,8 @@ void SegmentNoaa::RenderSegmentlineInProjectionAlternative( int channel, int nbr double latpos = geolocation.latitude; ///////////////////////////////////////////// + if(nbrLine == 0) + qDebug() << QString("nbrPoint = %1 lonpos = %2 latpos = %3").arg(nbrPoint).arg(Util::RadiansToDegrees(lonpos)).arg(Util::RadiansToDegrees(latpos)); if(proj == LCC) { @@ -885,12 +887,12 @@ void SegmentNoaa::RenderSegmentlineInProjectionAlternative( int channel, int nbr } } - //qDebug() << QString("lonpos = %1 latpos = %2 Angle = %3 posmag = %4 rangvector = %5 firstterm = %6 secterm = %7 posnorm = %8 scan x = %9 y = %10 z = %11").arg(Util::RadiansToDegrees(lonpos)).arg(Util::RadiansToDegrees(latpos)) - // .arg(Off_Nadir_Angle).arg(posmag).arg(rangevector.Magnitude()).arg(firstterm).arg(secterm).arg(posnorm.Magnitude()).arg(scan.x).arg(scan.y).arg(scan.z); - //double dotprod = pos.Dot(location); - //double phi = acos(dotprod / ( pos.Magnitude()*location.Magnitude())); - //qDebug() << QString("nbrLine = %1 nbrPoint = %2 off_nadir angle = %3 phi = %4 range_disctance = %5").arg(nbrLine).arg(nbrPoint).arg(Util::RadiansToDegrees(Off_Nadir_Angle)).arg(Util::RadiansToDegrees(phi)) - // .arg(range_distance); +// qDebug() << QString("lonpos = %1 latpos = %2 Angle = %3 posmag = %4 rangvector = %5 firstterm = %6 secterm = %7 posnorm = %8 scan x = %9 y = %10 z = %11").arg(Util::RadiansToDegrees(lonpos)).arg(Util::RadiansToDegrees(latpos)) +// .arg(Off_Nadir_Angle).arg(posmag).arg(rangevector.Magnitude()).arg(firstterm).arg(secterm).arg(posnorm.Magnitude()).arg(scan.x).arg(scan.y).arg(scan.z); +// double dotprod = pos.Dot(location); +// double phi = acos(dotprod / ( pos.Magnitude()*location.Magnitude())); +// qDebug() << QString("nbrLine = %1 nbrPoint = %2 off_nadir angle = %3 phi = %4 range_disctance = %5").arg(nbrLine).arg(nbrPoint).arg(Util::RadiansToDegrees(Off_Nadir_Angle)).arg(Util::RadiansToDegrees(phi)) +// .arg(range_distance); } } diff --git a/core/segmentviirsm.cpp b/core/segmentviirsm.cpp index 09e7929..b5a607f 100644 --- a/core/segmentviirsm.cpp +++ b/core/segmentviirsm.cpp @@ -401,6 +401,7 @@ void SegmentVIIRSM::ReadVIIRSM_GEO_All(hid_t h5_file_id) { hid_t tiepoints_lat_id, tiepoints_lon_id; hid_t aligncoef_id, expanscoef_id; + hid_t sc_position_id, sc_velocity_id; herr_t h5_status; tiepoints_lat.reset(new float[96 * 201]); @@ -409,12 +410,16 @@ void SegmentVIIRSM::ReadVIIRSM_GEO_All(hid_t h5_file_id) expanscoef.reset(new float[200]); geolongitude.reset(new float[NbrOfLines * earth_views_per_scanline]); geolatitude.reset(new float[NbrOfLines * earth_views_per_scanline]); + sc_position.reset(new float[48 * 3]); + sc_velocity.reset(new float[48 * 3]); tiepoints_lat_id = H5Dopen2(h5_file_id, "/All_Data/VIIRS-MOD-GEO_All/Latitude", H5P_DEFAULT); tiepoints_lon_id = H5Dopen2(h5_file_id, "/All_Data/VIIRS-MOD-GEO_All/Longitude", H5P_DEFAULT); aligncoef_id = H5Dopen2(h5_file_id, "/All_Data/VIIRS-MOD-GEO_All/AlignmentCoefficient", H5P_DEFAULT); expanscoef_id = H5Dopen2(h5_file_id, "/All_Data/VIIRS-MOD-GEO_All/ExpansionCoefficient", H5P_DEFAULT); + sc_position_id = H5Dopen2(h5_file_id, "/All_Data/VIIRS-MOD-GEO_All/SCPosition", H5P_DEFAULT); + sc_velocity_id = H5Dopen2(h5_file_id, "/All_Data/VIIRS-MOD-GEO_All/SCVelocity", H5P_DEFAULT); if((h5_status = H5Dread (tiepoints_lat_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tiepoints_lat.data())) < 0) @@ -432,10 +437,20 @@ void SegmentVIIRSM::ReadVIIRSM_GEO_All(hid_t h5_file_id) H5P_DEFAULT, expanscoef.data())) < 0) fprintf(stderr, "unable to read ExpansionCoefficient dataset"); + if((h5_status = H5Dread (sc_position_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, sc_position.data())) < 0) + fprintf(stderr, "unable to read SCPosition dataset"); + + if((h5_status = H5Dread (sc_velocity_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, sc_velocity.data())) < 0) + fprintf(stderr, "unable to read SCVelocity dataset"); + h5_status = H5Dclose (tiepoints_lat_id); h5_status = H5Dclose (tiepoints_lon_id); h5_status = H5Dclose (aligncoef_id); h5_status = H5Dclose (expanscoef_id); + h5_status = H5Dclose (sc_position_id); + h5_status = H5Dclose (sc_velocity_id); } @@ -707,7 +722,7 @@ void SegmentVIIRSM::CalcGeoLocations(int itrack, int iscan) // 0 <= itrack < 48 lat_C = tiepoints_lat[iC * 201 + jC]; lat_D = tiepoints_lat[iD * 201 + jD]; -// if(itrack == 0) +// if(itrack == 47) // qDebug() << QString("itrack = %1 iscan = %2 Lat tiepoint A = %3 B = %4 C = %5 D = %6").arg(itrack).arg(iscan).arg(lat_A).arg(lat_B).arg(lat_C).arg(lat_D); lon_A = tiepoints_lon[iA * 201 + jA]; @@ -721,24 +736,37 @@ void SegmentVIIRSM::CalcGeoLocations(int itrack, int iscan) // 0 <= itrack < 48 val_C = ptrbaVIIRS[0][((itrack * 16) + 15) * earth_views_per_scanline + (iscan * 16) + 15]; val_D = ptrbaVIIRS[0][((itrack * 16) + 15) * earth_views_per_scanline + (iscan * 16)]; - if( val_A == 0 || val_A > 65528 || val_B == 0 || val_B > 65528 || val_C == 0 || val_C > 65528 || val_D == 0 || val_D > 65528) + if( val_A == 0 || val_A > 65527 || val_B == 0 || val_B > 65527 || val_C == 0 || val_C > 65527 || val_D == 0 || val_D > 65527) { - quint16 minval = Min(val_A, val_B, val_C, val_D); - for(int relt = 0; relt < 16; relt++) { for(int rels = 0; rels < 16; rels++) { - if(ptrbaVIIRS[0][((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] == 0 || ptrbaVIIRS[0][((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] >= 65528) - { +// if(ptrbaVIIRS[0][((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] == 0 || ptrbaVIIRS[0][((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] >= 65528) +// { geolatitude[((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] = 65535; geolongitude[((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] = 65535; - } +// } } } } -// if(itrack == 0) + if(lon_A > 180.0 || lon_A < -180.0 || lon_B > 180.0 || lon_B < -180.0 || lon_C > 180.0 || lon_C < -180.0 || lon_D > 180.0 || lon_D < -180.0 || + lat_A > 90.0 || lat_A < -90.0 || lat_B > 90.0 || lat_B < -90.0 || lat_C > 90.0 || lat_C < -90.0 || lat_D > 90.0 || lat_D < -90.0) + { + for(int relt = 0; relt < 16; relt++) + { + for(int rels = 0; rels < 16; rels++) + { + geolatitude[((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] = 65535; + geolongitude[((itrack * 16) + relt) * earth_views_per_scanline + (iscan * 16) + rels] = 65535; + } + } + return; + + } + +// if(itrack == 47) // qDebug() << QString("itrack = %1 iscan = %2 Lon tiepoint A = %3 B = %4 C = %5 D = %6").arg(itrack).arg(iscan).arg(lon_A).arg(lon_B).arg(lon_C).arg(lon_D); float themin = Minf(lon_A, lon_B, lon_C, lon_D); @@ -1044,6 +1072,11 @@ void SegmentVIIRSM::ComposeSegmentSGProjection(int inputchannel, int histogramme ComposeProjection(SG, histogrammethod, normalized); } +void SegmentVIIRSM::ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized) +{ + ComposeProjection(OM, histogrammethod, normalized); +} + void SegmentVIIRSM::ComposeProjection(eProjections proj, int histogrammethod, bool normalized) { @@ -1119,6 +1152,13 @@ void SegmentVIIRSM::ComposeProjection(eProjections proj, int histogrammethod, bo MapPixel( i, j, map_x, map_y, color); } } + else if(proj == OM) // Oblique Mercator + { + if(imageptrs->om->map_forward(lonpos1 * PI / 180.0, latpos1 * PI / 180.0, map_x, map_y)) + { + MapPixel( i, j, map_x, map_y, color); + } + } } else { projectionCoordX[i * earth_views_per_scanline + j] = 65535; @@ -1756,59 +1796,133 @@ qint32 SegmentVIIRSM::Max(const qint32 v11, const qint32 v12, const qint32 v21, return Maximum; } -// float m00_A = -sin(lon_A); -// float m01_A = cos(lon_A); -// float m02_A = 0; -// float m10_A = -sin(lat_A)*cos(lon_A); -// float m11_A = -sin(lat_A)*sin(lon_A); -// float m12_A = cos(lat_A); -// float m20_A = cos(lat_A) * cos(lon_A); -// float m21_A = cos(lat_A) * sin(lon_A); -// float m22_A = sin(lat_A); - -// float m00_B = -sin(lon_B); -// float m01_B = cos(lon_B); -// float m02_B = 0; -// float m10_B = -sin(lat_B)*cos(lon_B); -// float m11_B = -sin(lat_B)*sin(lon_B); -// float m12_B = cos(lat_B); -// float m20_B = cos(lat_B) * cos(lon_B); -// float m21_B = cos(lat_B) * sin(lon_B); -// float m22_B = sin(lat_B); - -// float m00_C = -sin(lon_C); -// float m01_C = cos(lon_C); -// float m02_C = 0; -// float m10_C = -sin(lat_C)*cos(lon_C); -// float m11_C = -sin(lat_C)*sin(lon_C); -// float m12_C = cos(lat_C); -// float m20_C = cos(lat_C) * cos(lon_C); -// float m21_C = cos(lat_C) * sin(lon_C); -// float m22_C = sin(lat_C); - -// float m00_D = -sin(lon_D); -// float m01_D = cos(lon_D); -// float m02_D = 0; -// float m10_D = -sin(lat_D)*cos(lon_D); -// float m11_D = -sin(lat_D)*sin(lon_D); -// float m12_D = cos(lat_D); -// float m20_D = cos(lat_D) * cos(lon_D); -// float m21_D = cos(lat_D) * sin(lon_D); -// float m22_D = sin(lat_D); - -//// Pixel centred -// float x_A_pc = m00_A * x_A_ec + m10_A * y_A_ec + m20_A * z_A_ec; -// float y_A_pc = m01_A * x_A_ec + m11_A * y_A_ec + m21_A * z_A_ec; -// float z_A_pc = m02_A * x_A_ec + m12_A * y_A_ec + m22_A * z_A_ec; - -// float x_B_pc = m00_B * x_B_ec + m10_B * y_B_ec + m20_B * z_B_ec; -// float y_B_pc = m01_B * x_B_ec + m11_B * y_B_ec + m21_B * z_B_ec; -// float z_B_pc = m02_B * x_B_ec + m12_B * y_B_ec + m22_B * z_B_ec; - -// float x_C_pc = m00_C * x_C_ec + m10_C * y_C_ec + m20_C * z_C_ec; -// float y_C_pc = m01_C * x_C_ec + m11_C * y_C_ec + m21_C * z_C_ec; -// float z_C_pc = m02_C * x_C_ec + m12_C * y_C_ec + m22_C * z_C_ec; - -// float x_D_pc = m00_D * x_D_ec + m10_D * y_D_ec + m20_D * z_D_ec; -// float y_D_pc = m01_D * x_D_ec + m11_D * y_D_ec + m21_D * z_D_ec; -// float z_D_pc = m02_D * x_D_ec + m12_D * y_D_ec + m22_D * z_D_ec; +void SegmentVIIRSM::GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat, int *startindex, int *endindex) +{ + if(geolatitude.isNull()) + { + *startlon = 0.0; + *startlat = 0.0; + *endlon = 0.0; + *endlat = 0.0; + return; + } + + for(int i = 0; i < this->NbrOfLines; i++) + { + *startindex = i; + *startlon = geolongitude[i * earth_views_per_scanline + (earth_views_per_scanline/2)]; + *startlat = geolatitude[i * earth_views_per_scanline + (earth_views_per_scanline/2)]; + if(abs(*startlon) <= 180.0 && abs(*startlat) <= 90.0) + break; + } + + for(int i = this->NbrOfLines - 1; i >= 0; i--) + { + *endindex = i; + *endlon = geolongitude[i * earth_views_per_scanline + (earth_views_per_scanline/2)]; + *endlat = geolatitude[i * earth_views_per_scanline + (earth_views_per_scanline/2)]; + if(abs(*endlon) <= 180.0 && abs(*endlat) <= 90.0) + break; + } + +// for(int i = 0; i < this->NbrOfLines;i++) +// { +// cout << geolongitude[i * earth_views_per_scanline + (int)(earth_views_per_scanline/2)] << " "; +// } +// cout << endl; + + qDebug() << "SegmentVIIRSM::GetCentralCoords startindex = " << *startindex << " endindex = " << *endindex << " slon = " << *startlon << + " slat = " << *startlat << " elon = " << *endlon << " elat = " << *endlat; + +} + +void SegmentVIIRSM::GetStartCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, + int *Xstartindex1, int *Xstartindex2, int *Ystartindex12) +{ + if(geolatitude.isNull()) + { + *cornerlon1 = 999.0; + *cornerlat1 = 999.0; + *cornerlon2 = 999.0; + *cornerlat2 = 999.0; + *Xstartindex1 = 0; + *Xstartindex2 = 0; + *Ystartindex12 = 0; + return; + } + + for(int i = 0; i < this->NbrOfLines; i++) + { + *Ystartindex12 = i; + + for(int j = 0; j < earth_views_per_scanline; j++) + { + *Xstartindex1 = j; + *cornerlon1 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat1 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon1) <= 180.0 && abs(*cornerlat1) <= 90.0) + break; + } + + for(int j = earth_views_per_scanline - 1; j >= 0; j--) + { + *Xstartindex2 = j; + *cornerlon2 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat2 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon2) <= 180.0 && abs(*cornerlat2) <= 90.0) + break; + } + + if(abs(*cornerlon1) <= 180.0 && abs(*cornerlat1) <= 90.0 && abs(*cornerlon2) <= 180.0 && abs(*cornerlat2) <= 90.0) + break; + } + + qDebug() << "SegmentVIIRSM::GetStartCornerCoords " << " cornerlon1 = " << *cornerlon1 << " cornerlat1 = " << *cornerlat1 << " cornerlon2 = " << *cornerlon2 << " cornerlat2 = " << *cornerlat2 << + " Xstartindex1 = " << *Xstartindex1 << " Xstartindex2 = " << *Xstartindex2 << " Ystartindex12 = " << *Ystartindex12; + +} +void SegmentVIIRSM::GetEndCornerCoords(double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4, + int *Xstartindex3, int *Xstartindex4, int *Ystartindex34) +{ + if(geolatitude.isNull()) + { + *cornerlon3 = 999.0; + *cornerlat3 = 999.0; + *cornerlon4 = 999.0; + *cornerlat4 = 999.0; + *Xstartindex3 = 0; + *Xstartindex4 = 0; + *Ystartindex34 = 0; + return; + } + + for(int i = this->NbrOfLines - 1; i >= 0; i--) + { + *Ystartindex34 = i; + + for(int j = 0; j < earth_views_per_scanline; j++) + { + *Xstartindex3 = j; + *cornerlon3 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat3 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon3) <= 180.0 && abs(*cornerlat3) <= 90.0) + break; + } + + for(int j = earth_views_per_scanline - 1; j >= 0; j--) + { + *Xstartindex4 = j; + *cornerlon4 = geolongitude[i * earth_views_per_scanline + j]; + *cornerlat4 = geolatitude[i * earth_views_per_scanline + j]; + if(abs(*cornerlon4) <= 180.0 && abs(*cornerlat4) <= 90.0) + break; + } + + if(abs(*cornerlon3) <= 180.0 && abs(*cornerlat3) <= 90.0 && abs(*cornerlon4) <= 180.0 && abs(*cornerlat4) <= 90.0) + break; + } + + qDebug() << "SegmentVIIRSM::GetEndCornerCoords " << " cornerlon3 = " << *cornerlon3 << " cornerlat3 = " << *cornerlat3 << " cornerlon4 = " << *cornerlon4 << " cornerlat4 = " << *cornerlat4 << + " Xstartindex3 = " << *Xstartindex3 << " Xstartindex4 = " << *Xstartindex4 << " Ystartindex34 = " << *Ystartindex34; + +} diff --git a/core/segmentviirsm.h b/core/segmentviirsm.h index 29c66a8..eb57632 100644 --- a/core/segmentviirsm.h +++ b/core/segmentviirsm.h @@ -29,6 +29,7 @@ class SegmentVIIRSM : public Segment void ComposeSegmentLCCProjection(int inputchannel, int histogrammethod, bool normalized); void ComposeSegmentGVProjection(int inputchannel, int histogrammethod, bool normalized); void ComposeSegmentSGProjection(int inputchannel, int histogrammethod, bool normalized); + void ComposeSegmentOMProjection(int inputchannel, int histogrammethod, bool normalized); void ComposeProjection(eProjections proj, int histogrammethod, bool normalized); //void ComposeProjectionConcurrent(); void RecalculateProjection(); @@ -41,6 +42,11 @@ class SegmentVIIRSM : public Segment float getBrightnessTemp(int radiance); float getRadiance(int lines, int views); float getRadiance(int radiance); + void GetCentralCoords(double *startlon, double *startlat, double *endlon, double *endlat, int *startindex, int *endindex); + void GetStartCornerCoords(double *cornerlon1, double *cornerlat1, double *cornerlon2, double *cornerlat2, + int *Xstartindex1, int *Xstartindex2, int *Ystartindex12); + void GetEndCornerCoords(double *cornerlon3, double *cornerlat3, double *cornerlon4, double *cornerlat4, + int *Xstartindex3, int *Xstartindex4, int *Ystartindex34); int stat_max_projection[3]; int stat_min_projection[3]; diff --git a/core/stereographic.cpp b/core/stereographic.cpp index 4647401..afccf00 100644 --- a/core/stereographic.cpp +++ b/core/stereographic.cpp @@ -22,6 +22,9 @@ StereoGraphic::StereoGraphic(QObject *parent, AVHRRSatellite *seglist) : scale = opts.mapsgscale; double map_x,map_y; + image_width = 0; + image_height = 0; + map_radius = 0; // Initialize(opts.mapsglon, opts.mapsglat, opts.mapsgscale, opts.mapwidth, opts.mapheight); Initialize(0.0, 0.0, 1.0, opts.mapwidth, opts.mapheight, 0, 0);