Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ringsautomos tests added #4155

Merged
merged 5 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 40 additions & 116 deletions isis/src/base/apps/ringsautomos/main.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#define GUIHELPERS

#include "Isis.h"
#include "ProcessMapMosaic.h"

#include "Application.h"
#include "FileList.h"
#include "IException.h"
#include "SpecialPixel.h"
#include "RingPlaneProjection.h"
#include "ProjectionFactory.h"

using namespace std;
#include "ringsautomos.h" // replace with your new header

using namespace Isis;
using namespace std;

void calcRange(double &minRingRad, double &maxRingRad, double &minRingLon, double &maxRingLon);
void helperButtonCalcRange();
void calcRange(double &minRingRad, double &maxRingRad, double &minRingLon, double &maxRingLon);

map <QString, void *> GuiHelpers() {
map <QString, void *> helper;
Expand All @@ -21,104 +23,51 @@ map <QString, void *> GuiHelpers() {
}

void IsisMain() {
FileList list;
UserInterface &ui = Application::GetUserInterface();
Pvl appLog;

// Get the list of cubes to mosaic
list.read(FileName(ui.GetFileName("FROMLIST")));
// Redundant test. Already checked in FileList
// if(list.size() < 1) {
// QString msg = "The list file [" + ui.GetFileName("FROMLIST") +"does not contain any data";
// throw IException(IException::User, msg, _FILEINFO_);
// }

fstream os;
bool olistFlag = false;
if (ui.WasEntered("TOLIST")){
QString olist = ui.GetFileName("TOLIST");
olistFlag = true;
os.open(olist.toLatin1().data(), std::ios::out);
try {
ringsautomos(ui, &appLog);
}

ProcessMapMosaic m;

// Set the create flag-mosaic is always created in ringsautomos
m.SetCreateFlag(true);

// Get the Track Flag
bool bTrack = ui.GetBoolean("TRACK");
m.SetTrackFlag(bTrack);

ProcessMosaic::ImageOverlay overlay = ProcessMosaic::StringToOverlay(
ui.GetString("PRIORITY"));

if (overlay == ProcessMapMosaic::UseBandPlacementCriteria) {
if(ui.GetString("TYPE") == "BANDNUMBER") {
m.SetBandNumber(ui.GetInteger("NUMBER"));
}
else {
// Key name & value
m.SetBandKeyword(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE"));
catch (...) {
for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) {
Application::Log(*grpIt);
}
// Band Criteria
m.SetBandUseMaxValue( (ui.GetString("CRITERIA") == "GREATER") );
throw;
}

// Priority
m.SetImageOverlay(overlay);

CubeAttributeOutput &oAtt = ui.GetOutputAttribute("MOSAIC");
if(ui.GetString("GRANGE") == "USER") {
m.RingsSetOutputCube(list,
ui.GetDouble("MINRINGRAD"), ui.GetDouble("MAXRINGRAD"),
ui.GetDouble("MINRINGLON"), ui.GetDouble("MAXRINGLON"),
oAtt, ui.GetFileName("MOSAIC"));

for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) {
Application::Log(*grpIt);
}
else {
m.RingsSetOutputCube(list, oAtt, ui.GetFileName("MOSAIC"));
}

m.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION"));
m.SetLowSaturationFlag(ui.GetBoolean("LOWSATURATION"));
m.SetNullFlag(ui.GetBoolean("NULL"));

// Loop for each input file and place it in the output mosaic

m.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN"));
}

// Get the MatchDEM Flag
m.SetMatchDEM(ui.GetBoolean("MATCHDEM"));

bool mosaicCreated = false;
for (int i = 0; i < list.size(); i++) {
if (!m.StartProcess(list[i].toString())) {
PvlGroup outsiders("Outside");
outsiders += PvlKeyword("File", list[i].toString());
Application::Log(outsiders);
}
else {
mosaicCreated = true;
if(olistFlag) {
os << list[i].toString() << endl;
}
}
if(mosaicCreated) {
// Mosaic is already created, use the existing mosaic
m.SetCreateFlag(false);
}
}
// Logs the input file location in the mosaic
for (int i = 0; i < m.imagePositions().groups(); i++) {
Application::Log(m.imagePositions().group(i));
}
// Helper function to run calcRange function.
void helperButtonCalcRange() {
UserInterface &ui = Application::GetUserInterface();
acpaquette marked this conversation as resolved.
Show resolved Hide resolved
double minRingRad;
double maxRingRad;
double minRingLon;
double maxRingLon;

if(olistFlag) {
os.close();
}
// Run the function calcRange of calculate range info
calcRange(minRingRad, maxRingRad, minRingLon, maxRingLon);

m.EndProcess();
// Write ranges to the GUI
QString use = "USER";
ui.Clear("GRANGE");
ui.PutAsString("GRANGE", use);
ui.Clear("MINRINGRAD");
ui.PutDouble("MINRINGRAD", minRingRad);
ui.Clear("MAXRINGRAD");
ui.PutDouble("MAXRINGRAD", maxRingRad);
ui.Clear("MINRINGLON");
ui.PutDouble("MINRINGLON", minRingLon);
ui.Clear("MAXRINGLON");
ui.PutDouble("MAXRINGLON", maxRingLon);
}


// Function to calculate the ground range from multiple inputs (list of images)
void calcRange(double &minRingRad, double &maxRingRad, double &minRingLon, double &maxRingLon) {
UserInterface &ui = Application::GetUserInterface();
acpaquette marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -162,29 +111,4 @@ void calcRange(double &minRingRad, double &maxRingRad, double &minRingLon, doubl
if(proj != firstProj)
delete proj;
}
}

// Helper function to run calcRange function.
void helperButtonCalcRange() {
UserInterface &ui = Application::GetUserInterface();
double minRingRad;
double maxRingRad;
double minRingLon;
double maxRingLon;

// Run the function calcRange of calculate range info
calcRange(minRingRad, maxRingRad, minRingLon, maxRingLon);

// Write ranges to the GUI
QString use = "USER";
ui.Clear("GRANGE");
ui.PutAsString("GRANGE", use);
ui.Clear("MINRINGRAD");
ui.PutDouble("MINRINGRAD", minRingRad);
ui.Clear("MAXRINGRAD");
ui.PutDouble("MAXRINGRAD", maxRingRad);
ui.Clear("MINRINGLON");
ui.PutDouble("MINRINGLON", minRingLon);
ui.Clear("MAXRINGLON");
ui.PutDouble("MAXRINGLON", maxRingLon);
}
}
111 changes: 111 additions & 0 deletions isis/src/base/apps/ringsautomos/ringsautomos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "ProcessMapMosaic.h"
#include "FileList.h"
#include "IException.h"
#include "SpecialPixel.h"
#include "RingPlaneProjection.h"
#include "ProjectionFactory.h"

#include "ringsautomos.h"

using namespace std;

namespace Isis {

void ringsautomos(UserInterface &ui, Pvl *log){
FileList list;

// Get the list of cubes to mosaic
list.read(FileName(ui.GetFileName("FROMLIST")));

fstream os;
bool olistFlag = false;
if (ui.WasEntered("TOLIST")){
QString olist = ui.GetFileName("TOLIST");
olistFlag = true;
os.open(olist.toLatin1().data(), std::ios::out);
}

ProcessMapMosaic m;

// Set the create flag-mosaic is always created in ringsautomos
m.SetCreateFlag(true);

// Get the Track Flag
bool bTrack = ui.GetBoolean("TRACK");
m.SetTrackFlag(bTrack);

ProcessMosaic::ImageOverlay overlay = ProcessMosaic::StringToOverlay(
ui.GetString("PRIORITY"));

if (overlay == ProcessMap::UseBandPlacementCriteria) {
if(ui.GetString("TYPE") == "BANDNUMBER") {
m.SetBandNumber(ui.GetInteger("NUMBER"));
}
else {
// Key name & value
m.SetBandKeyword(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE"));
}
// Band Criteria
m.SetBandUseMaxValue( (ui.GetString("CRITERIA") == "GREATER") );
}

// Priority
m.SetImageOverlay(overlay);

CubeAttributeOutput &oAtt = ui.GetOutputAttribute("MOSAIC");
if(ui.GetString("GRANGE") == "USER") {
m.RingsSetOutputCube(list,
ui.GetDouble("MINRINGRAD"), ui.GetDouble("MAXRINGRAD"),
ui.GetDouble("MINRINGLON"), ui.GetDouble("MAXRINGLON"),
oAtt, ui.GetFileName("MOSAIC"));
}
else {
m.RingsSetOutputCube(list, oAtt, ui.GetFileName("MOSAIC"));
}

m.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION"));
m.SetLowSaturationFlag(ui.GetBoolean("LOWSATURATION"));
m.SetNullFlag(ui.GetBoolean("NULL"));

// Loop for each input file and place it in the output mosaic

m.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN"));

// Get the MatchDEM Flag
m.SetMatchDEM(ui.GetBoolean("MATCHDEM"));

bool mosaicCreated = false;
for (int i = 0; i < list.size(); i++) {
if (!m.StartProcess(list[i].toString())) {
PvlGroup outsiders("Outside");
outsiders += PvlKeyword("File", list[i].toString());
if(log) {
log->addGroup(outsiders);
}
}
else {
mosaicCreated = true;
if(olistFlag) {
os << list[i].toString() << endl;
}
}
if(mosaicCreated) {
// Mosaic is already created, use the existing mosaic
m.SetCreateFlag(false);
}
}
// Logs the input file location in the mosaic
for (int i = 0; i < m.imagePositions().groups(); i++) {
if(log) {
log->addGroup(m.imagePositions().group(i));
}
}

if(olistFlag) {
os.close();
}

m.EndProcess();
}
}

10 changes: 10 additions & 0 deletions isis/src/base/apps/ringsautomos/ringsautomos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef ringsautomos_h
#define ringsautomos_h

#include "UserInterface.h"

namespace Isis{
extern void ringsautomos(UserInterface &ui, Pvl *log=nullptr);
}

#endif
4 changes: 0 additions & 4 deletions isis/src/base/apps/ringsautomos/tsts/Makefile

This file was deleted.

33 changes: 0 additions & 33 deletions isis/src/base/apps/ringsautomos/tsts/combination1/Makefile

This file was deleted.

23 changes: 0 additions & 23 deletions isis/src/base/apps/ringsautomos/tsts/combination2/Makefile

This file was deleted.

Loading