44 ProcessMapMosaic::ProcessMapMosaic() {
45 p_createMosaic =
true;
50 ProcessMapMosaic::~ProcessMapMosaic() { }
58 "ProcessMapMosaic does not support the SetInputCube method",
66 bool ProcessMapMosaic::StartProcess(QString inputFile) {
67 if (InputCubes.size() != 0) {
68 QString msg =
"Input cubes already exist; do not call SetInputCube when using ";
69 msg +=
"ProcessMosaic::StartProcess(QString)";
73 if (OutputCubes.size() == 0) {
74 QString msg =
"An output cube must be set before calling StartProcess";
79 Cube *inCube = ProcessMosaic::SetInputCube(inputFile, inAtt);
81 Cube *mosaicCube = OutputCubes[0];
87 if (*iproj != *oproj) {
88 QString msg =
"Mapping groups do not match between cube [" + inputFile +
"] and mosaic";
92 int outSample, outSampleEnd, outLine, outLineEnd;
108 int ins = InputCubes[0]->sampleCount();
109 int inl = InputCubes[0]->lineCount();
110 outSampleEnd = outSample + ins;
111 outLineEnd = outLine + inl;
118 int worldStart = (int)(oproj->
WorldX() + 0.5);
120 int worldEnd = (int)(oproj->
WorldX() + 0.5);
122 worldSize = abs(worldEnd - worldStart) * 2;
124 wrapPossible = wrapPossible && (worldSize > 0);
130 while (outSampleEnd - worldSize > 1) {
131 outSample -= worldSize;
132 outSampleEnd -= worldSize;
142 ins = ins + outSample - 1;
147 inl = inl + outLine - 1;
151 if ((outSample + ins - 1) > nsMosaic) {
152 ins = nsMosaic - outSample + 1;
156 if ((outLine + inl - 1) > nlMosaic) {
157 inl = nlMosaic - outLine + 1;
160 if (outSampleEnd < 1 || outLineEnd < 1 || outSample > nsMosaic || outLine > nlMosaic || ins < 1 || inl < 1) {
173 ProcessMosaic::StartProcess(outSample, outLine, outBand);
176 outSample += worldSize;
177 outSampleEnd += worldSize;
179 while (wrapPossible && outSample < nsMosaic);
182 QString msg =
"Unable to mosaic cube [" +
FileName(inputFile).name() +
"]";
187 WriteHistory(*mosaicCube);
190 p_propagateHistory =
false;
204 const QString &mosaicFile) {
206 double xmin = DBL_MAX;
207 double xmax = -DBL_MAX;
208 double ymin = DBL_MAX;
209 double ymax = -DBL_MAX;
210 double slat = DBL_MAX;
211 double elat = -DBL_MAX;
212 double slon = DBL_MAX;
213 double elon = -DBL_MAX;
214 bool latlonflag =
true;
218 if (propagationCubes.size() < 1) {
219 QString msg =
"The list does not contain any data";
223 for (
int i = 0; i < propagationCubes.size(); i++) {
233 if ((proj != NULL) && (*proj != *projNew)) {
234 QString msg =
"Mapping groups do not match between cubes [" +
235 propagationCubes[0].toString() +
"] and [" + propagationCubes[i].toString() +
"]";
240 double x = projNew->ToProjectionX(0.5);
241 double y = projNew->ToProjectionY(0.5);
242 if (x < xmin) xmin = x;
243 if (y < ymin) ymin = y;
244 if (x > xmax) xmax = x;
245 if (y > ymax) ymax = y;
247 x = projNew->ToProjectionX(cube.
sampleCount() + 0.5);
248 y = projNew->ToProjectionY(cube.
lineCount() + 0.5);
249 if (x < xmin) xmin = x;
250 if (y < ymin) ymin = y;
251 if (x > xmax) xmax = x;
252 if (y > ymax) ymax = y;
254 if (projNew->MinimumLatitude() == 0.0 && projNew->MaximumLatitude() == 0.0 &&
255 projNew->MinimumLongitude() == 0.0 && projNew->MaximumLongitude() == 0.0) {
259 slat = min(slat, projNew->MinimumLatitude());
260 elat = max(elat, projNew->MaximumLatitude());
261 slon = min(slon, projNew->MinimumLongitude());
262 elon = max(elon, projNew->MaximumLongitude());
266 if (proj)
delete proj;
270 if (proj)
delete proj;
272 return SetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
273 slat, elat, slon, elon, bands, oAtt, mosaicFile, latlonflag);
283 const QString &mosaicFile) {
285 double xmin = DBL_MAX;
286 double xmax = -DBL_MAX;
287 double ymin = DBL_MAX;
288 double ymax = -DBL_MAX;
289 double srad = DBL_MAX;
290 double erad = -DBL_MAX;
291 double saz = DBL_MAX;
292 double eaz = -DBL_MAX;
296 if (propagationCubes.size() < 1) {
297 QString msg =
"The list does not contain any data";
301 for (
int i = 0; i < propagationCubes.size(); i++) {
311 if ((proj != NULL) && (*proj != *projNew)) {
312 QString msg =
"Mapping groups do not match between cubes [" +
313 propagationCubes[0].toString() +
"] and [" + propagationCubes[i].toString() +
"]";
318 double x = projNew->ToProjectionX(0.5);
319 double y = projNew->ToProjectionY(0.5);
320 if (x < xmin) xmin = x;
321 if (y < ymin) ymin = y;
322 if (x > xmax) xmax = x;
323 if (y > ymax) ymax = y;
325 x = projNew->ToProjectionX(cube.
sampleCount() + 0.5);
326 y = projNew->ToProjectionY(cube.
lineCount() + 0.5);
327 if (x < xmin) xmin = x;
328 if (y < ymin) ymin = y;
329 if (x > xmax) xmax = x;
330 if (y > ymax) ymax = y;
332 srad = min(srad, projNew->MinimumRingRadius());
333 erad = max(erad, projNew->MaximumRingRadius());
334 saz = min(saz, projNew->MinimumRingLongitude());
335 eaz = max(eaz, projNew->MaximumRingLongitude());
339 if (proj)
delete proj;
343 if (proj)
delete proj;
345 return RingsSetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
346 srad, erad, saz, eaz, bands, oAtt, mosaicFile);
356 double slat,
double elat,
double slon,
double elon,
358 if (propagationCubes.size() < 1) {
359 QString msg =
"The list does not contain any data";
363 int samples, lines, bands = 0;
375 if (slat < elat && slon < elon) {
394 double xmin, xmax, ymin, ymax;
395 proj->XYRange(xmin, xmax, ymin, ymax);
398 xmin = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerX"];
399 ymax = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerY"];
401 for (
int i = 0; i < propagationCubes.size(); i++) {
413 else if (*proj != *projNew) {
414 QString msg =
"Mapping groups do not match between cube [" + propagationCubes[i].toString() +
415 "] and [" + propagationCubes[0].toString() +
"]";
419 if (proj)
delete proj;
423 if (proj)
delete proj;
425 return SetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
426 slat, elat, slon, elon, bands, oAtt, mosaicFile);
445 double srad,
double erad,
double saz,
double eaz,
447 if (propagationCubes.size() < 1) {
448 QString msg =
"The list does not contain any data";
452 int samples, lines, bands = 0;
473 double xmin, xmax, ymin, ymax;
474 proj->XYRange(xmin, xmax, ymin, ymax);
477 xmin = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerX"];
478 ymax = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerY"];
480 for (
int i = 0; i < propagationCubes.size(); i++) {
491 else if (*proj != *projNew) {
492 QString msg =
"Mapping groups do not match between cube [" + propagationCubes[i].toString() +
493 "] and [" + propagationCubes[0].toString() +
"]";
497 if (proj)
delete proj;
501 if (proj)
delete proj;
503 return RingsSetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
504 srad, erad, saz, eaz, bands, oAtt, mosaicFile);
515 Isis::Cube *ProcessMapMosaic::SetOutputCube(
const QString &inputFile,
516 double xmin,
double xmax,
double ymin,
double ymax,
517 double slat,
double elat,
double slon,
double elon,
int nbands,
519 Pvl fileLab(inputFile);
522 mapping[
"UpperLeftCornerX"] =
toString(xmin);
523 mapping[
"UpperLeftCornerY"] =
toString(ymax);
532 if (latlonflag && slat < elat && slon < elon) {
553 Projection *firstProj = ProjectionFactory::CreateFromCube(fileLab);
554 int samps = (int)(ceil(firstProj->
ToWorldX(xmax) - firstProj->
ToWorldX(xmin)) + 0.5);
555 int lines = (int)(ceil(firstProj->
ToWorldY(ymin) - firstProj->
ToWorldY(ymax)) + 0.5);
558 if (p_createMosaic) {
574 if (GetTrackFlag()) {
578 else if (GetImageOverlay() == AverageImageWithMosaic) {
593 mosaicCube->
open(mosaicFile,
"rw");
596 AddOutputCube(mosaicCube);
621 Isis::Cube *ProcessMapMosaic::RingsSetOutputCube(
const QString &inputFile,
622 double xmin,
double xmax,
double ymin,
double ymax,
623 double srad,
double erad,
double saz,
double eaz,
int nbands,
625 Pvl fileLab(inputFile);
628 mapping[
"UpperLeftCornerX"] =
toString(xmin);
629 mapping[
"UpperLeftCornerY"] =
toString(ymax);
635 Projection *firstProj = ProjectionFactory::RingsCreateFromCube(fileLab);
636 int samps = (int)(ceil(firstProj->
ToWorldX(xmax) - firstProj->
ToWorldX(xmin)) + 0.5);
637 int lines = (int)(ceil(firstProj->
ToWorldY(ymin) - firstProj->
ToWorldY(ymax)) + 0.5);
640 if (p_createMosaic) {
656 if (GetTrackFlag()) {
660 else if (GetImageOverlay() == AverageImageWithMosaic) {
675 mosaicCube->
open(mosaicFile,
"rw");
678 AddOutputCube(mosaicCube);
691 if (OutputCubes.size() != 0) {
692 QString msg =
"You can only specify one output cube and projection";
702 if (p_createMosaic) {
705 int samps, lines, bands;
706 delete ProjectionFactory::CreateForCube(newMap, samps, lines,
false);
715 if (GetTrackFlag()) {
719 else if (GetImageOverlay() == AverageImageWithMosaic) {
737 AddOutputCube(mosaicCube);
738 mosaicCube->
open(mosaicFile,
"rw");
753 if (OutputCubes.size() != 0) {
754 QString msg =
"You can only specify one output cube and projection";
764 if (p_createMosaic) {
767 int samps, lines, bands;
768 delete ProjectionFactory::RingsCreateForCube(newMap, samps, lines,
false);
777 if (GetTrackFlag()) {
781 else if (GetImageOverlay() == AverageImageWithMosaic) {
799 AddOutputCube(mosaicCube);
800 mosaicCube->
open(mosaicFile,
"rw");
812 Cube *ProcessMapMosaic::SetOutputCube(
const QString &mosaicFile) {
813 p_createMosaic =
false;
815 mosaic.
open(mosaicFile);
820 Cube *ocube = SetOutputCube(
"", mapping, oAtt, mosaicFile);
821 p_createMosaic =
true;
832 Cube *ProcessMapMosaic::RingsSetOutputCube(
const QString &mosaicFile) {
833 p_createMosaic =
false;
835 mosaic.
open(mosaicFile);
840 Cube *ocube = RingsSetOutputCube(
"", mapping, oAtt, mosaicFile);
841 p_createMosaic =
true;
851 void ProcessMapMosaic::FillNull(
Buffer &data) {
void PropagateTables(const bool prop)
This method allows the programmer to propagate input tables to the output cube (default is true) ...
Buffer for reading and writing cube data.
double WorldX() const
This returns the world X coordinate provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
const double Null
Value for an Isis Null pixel.
static Isis::Projection * CreateFromCube(Isis::Cube &cube)
This method is a helper method.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
File name manipulation and expansion.
Base class for Map TProjections.
void PropagatePolygons(const bool prop)
This method allows the programmer to propagate input blobs to the output cube (default is true) ...
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
virtual Cube * SetOutputCube(const QString &fname, const CubeAttributeOutput &att)
Create the output file.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Internalizes a list of files.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Projection * projection()
static Isis::Projection * RingsCreateForCube(Isis::Pvl &label, int &samples, int &lines, bool sizeMatch)
This method creates a projection for a cube to a ring plane given a label.
This algorithm is designed for applications that jump around between a couple of spots in the cube wi...
void PropagateOriginalLabel(const bool prop)
This method allows the programmer to propagate original labels to the output cube (default is true) ...
Base class for Map Projections.
Program progress reporter.
void PropagateHistory(const bool prop)
This method allows the programmer to propagate history to the output cube (default is true) ...
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
static Isis::Projection * CreateForCube(Isis::Pvl &label, int &ns, int &nl, bool sizeMatch=true)
This method creates a map projection for a cube given a label.
Manipulate and parse attributes of output cube filenames.
static Isis::Projection * RingsCreateFromCube(Isis::Cube &cube)
This method is a helper method.
A single keyword-value pair.
double ToProjectionY(const double worldY) const
This method converts a world y value to a projection y value.
int bandCount() const
Returns the number of virtual bands for the cube.
void PropagateLabels(const bool prop)
This method allows the programmer to turn on/off the propagation of labels from the 1st input cube to...
void ClearInputCubes()
Close owned input cubes from the list and clear the list.
double ToWorldY(const double projectionY) const
This method converts a projection y value to a world y value.
void close(bool remove=false)
Closes the cube and updates the labels.
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
Container for cube-like labels.
void StartProcess(void funct(Isis::Buffer &inout))
This method invokes the process by line operation over a single input or output cube.
Isis::Progress * Progress()
This method returns a pointer to a Progress object.
Base class for Map Projections of plane shapes.
int size() const
Returns the total number of pixels in the shape buffer.
double ToWorldX(const double projectionX) const
This method converts a projection x value to a world x value.
double ToProjectionX(const double worldX) const
This method converts a world x value to a projection x value.
virtual bool SetUniversalGround(const double coord1, const double coord2)
This method is used to set the lat/lon or radius/azimuth (i.e.
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
virtual bool IsEquatorialCylindrical()
This method returns true if the projection is equatorial cylindrical.
void read(const QString &file)
Loads PVL information from a stream.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
void deleteKeyword(const QString &name)
Remove a specified keyword.
IO Handler for Isis Cubes.