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);
178 ProcessMosaic::SetCreateFlag(
false);
181 outSample += worldSize;
182 outSampleEnd += worldSize;
184 while (wrapPossible && outSample < nsMosaic);
187 QString msg =
"Unable to mosaic cube [" +
FileName(inputFile).
name() +
"]";
192 WriteHistory(*mosaicCube);
195 p_propagateHistory =
false;
209 const QString &mosaicFile) {
211 double xmin = DBL_MAX;
212 double xmax = -DBL_MAX;
213 double ymin = DBL_MAX;
214 double ymax = -DBL_MAX;
215 double slat = DBL_MAX;
216 double elat = -DBL_MAX;
217 double slon = DBL_MAX;
218 double elon = -DBL_MAX;
219 bool latlonflag =
true;
223 if (propagationCubes.size() < 1) {
224 QString msg =
"The list does not contain any data";
228 for (
int i = 0; i < propagationCubes.size(); i++) {
238 if ((proj != NULL) && (*proj != *projNew)) {
239 QString msg =
"Mapping groups do not match between cubes [" +
240 propagationCubes[0].toString() +
"] and [" + propagationCubes[i].toString() +
"]";
245 double x = projNew->ToProjectionX(0.5);
246 double y = projNew->ToProjectionY(0.5);
247 if (x < xmin) xmin = x;
248 if (y < ymin) ymin = y;
249 if (x > xmax) xmax = x;
250 if (y > ymax) ymax = y;
252 x = projNew->ToProjectionX(cube.
sampleCount() + 0.5);
253 y = projNew->ToProjectionY(cube.
lineCount() + 0.5);
254 if (x < xmin) xmin = x;
255 if (y < ymin) ymin = y;
256 if (x > xmax) xmax = x;
257 if (y > ymax) ymax = y;
259 if (projNew->MinimumLatitude() == 0.0 && projNew->MaximumLatitude() == 0.0 &&
260 projNew->MinimumLongitude() == 0.0 && projNew->MaximumLongitude() == 0.0) {
264 slat = min(slat, projNew->MinimumLatitude());
265 elat = max(elat, projNew->MaximumLatitude());
266 slon = min(slon, projNew->MinimumLongitude());
267 elon = max(elon, projNew->MaximumLongitude());
271 if (proj)
delete proj;
275 if (proj)
delete proj;
277 return SetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
278 slat, elat, slon, elon, bands, oAtt, mosaicFile, latlonflag);
288 const QString &mosaicFile) {
290 double xmin = DBL_MAX;
291 double xmax = -DBL_MAX;
292 double ymin = DBL_MAX;
293 double ymax = -DBL_MAX;
294 double srad = DBL_MAX;
295 double erad = -DBL_MAX;
296 double saz = DBL_MAX;
297 double eaz = -DBL_MAX;
301 if (propagationCubes.size() < 1) {
302 QString msg =
"The list does not contain any data";
306 for (
int i = 0; i < propagationCubes.size(); i++) {
316 if ((proj != NULL) && (*proj != *projNew)) {
317 QString msg =
"Mapping groups do not match between cubes [" +
318 propagationCubes[0].toString() +
"] and [" + propagationCubes[i].toString() +
"]";
323 double x = projNew->ToProjectionX(0.5);
324 double y = projNew->ToProjectionY(0.5);
325 if (x < xmin) xmin = x;
326 if (y < ymin) ymin = y;
327 if (x > xmax) xmax = x;
328 if (y > ymax) ymax = y;
330 x = projNew->ToProjectionX(cube.
sampleCount() + 0.5);
331 y = projNew->ToProjectionY(cube.
lineCount() + 0.5);
332 if (x < xmin) xmin = x;
333 if (y < ymin) ymin = y;
334 if (x > xmax) xmax = x;
335 if (y > ymax) ymax = y;
337 srad = min(srad, projNew->MinimumRingRadius());
338 erad = max(erad, projNew->MaximumRingRadius());
339 saz = min(saz, projNew->MinimumRingLongitude());
340 eaz = max(eaz, projNew->MaximumRingLongitude());
344 if (proj)
delete proj;
348 if (proj)
delete proj;
350 return RingsSetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
351 srad, erad, saz, eaz, bands, oAtt, mosaicFile);
361 double slat,
double elat,
double slon,
double elon,
363 if (propagationCubes.size() < 1) {
364 QString msg =
"The list does not contain any data";
368 int samples, lines, bands = 0;
380 if (slat < elat && slon < elon) {
399 double xmin, xmax, ymin, ymax;
400 proj->XYRange(xmin, xmax, ymin, ymax);
403 xmin = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerX"];
404 ymax = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerY"];
406 for (
int i = 0; i < propagationCubes.size(); i++) {
418 else if (*proj != *projNew) {
419 QString msg =
"Mapping groups do not match between cube [" + propagationCubes[i].toString() +
420 "] and [" + propagationCubes[0].toString() +
"]";
424 if (proj)
delete proj;
428 if (proj)
delete proj;
430 return SetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
431 slat, elat, slon, elon, bands, oAtt, mosaicFile);
450 double srad,
double erad,
double saz,
double eaz,
452 if (propagationCubes.size() < 1) {
453 QString msg =
"The list does not contain any data";
457 int samples, lines, bands = 0;
478 double xmin, xmax, ymin, ymax;
479 proj->XYRange(xmin, xmax, ymin, ymax);
482 xmin = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerX"];
483 ymax = mapPvl.
findGroup(
"Mapping")[
"UpperLeftCornerY"];
485 for (
int i = 0; i < propagationCubes.size(); i++) {
496 else if (*proj != *projNew) {
497 QString msg =
"Mapping groups do not match between cube [" + propagationCubes[i].toString() +
498 "] and [" + propagationCubes[0].toString() +
"]";
502 if (proj)
delete proj;
506 if (proj)
delete proj;
508 return RingsSetOutputCube(propagationCubes[0].
toString(), xmin, xmax, ymin, ymax,
509 srad, erad, saz, eaz, bands, oAtt, mosaicFile);
520 Isis::Cube *ProcessMapMosaic::SetOutputCube(
const QString &inputFile,
521 double xmin,
double xmax,
double ymin,
double ymax,
522 double slat,
double elat,
double slon,
double elon,
int nbands,
524 Pvl fileLab(inputFile);
527 mapping[
"UpperLeftCornerX"] =
toString(xmin);
528 mapping[
"UpperLeftCornerY"] =
toString(ymax);
537 if (latlonflag && slat < elat && slon < elon) {
558 Projection *firstProj = ProjectionFactory::CreateFromCube(fileLab);
559 int samps = (int)(ceil(firstProj->
ToWorldX(xmax) - firstProj->
ToWorldX(xmin)) + 0.5);
560 int lines = (int)(ceil(firstProj->
ToWorldY(ymin) - firstProj->
ToWorldY(ymax)) + 0.5);
563 if (p_createMosaic) {
579 if (GetImageOverlay() == AverageImageWithMosaic) {
594 mosaicCube->
open(mosaicFile,
"rw");
597 AddOutputCube(mosaicCube);
622 Isis::Cube *ProcessMapMosaic::RingsSetOutputCube(
const QString &inputFile,
623 double xmin,
double xmax,
double ymin,
double ymax,
624 double srad,
double erad,
double saz,
double eaz,
int nbands,
626 Pvl fileLab(inputFile);
629 mapping[
"UpperLeftCornerX"] =
toString(xmin);
630 mapping[
"UpperLeftCornerY"] =
toString(ymax);
636 Projection *firstProj = ProjectionFactory::RingsCreateFromCube(fileLab);
637 int samps = (int)(ceil(firstProj->
ToWorldX(xmax) - firstProj->
ToWorldX(xmin)) + 0.5);
638 int lines = (int)(ceil(firstProj->
ToWorldY(ymin) - firstProj->
ToWorldY(ymax)) + 0.5);
641 if (p_createMosaic) {
657 if (GetImageOverlay() == AverageImageWithMosaic) {
672 mosaicCube->
open(mosaicFile,
"rw");
675 AddOutputCube(mosaicCube);
688 if (OutputCubes.size() != 0) {
689 QString msg =
"You can only specify one output cube and projection";
699 if (p_createMosaic) {
702 int samps, lines, bands;
703 delete ProjectionFactory::CreateForCube(newMap, samps, lines,
false);
712 if (GetImageOverlay() == AverageImageWithMosaic) {
730 AddOutputCube(mosaicCube);
731 mosaicCube->
open(mosaicFile,
"rw");
746 if (OutputCubes.size() != 0) {
747 QString msg =
"You can only specify one output cube and projection";
757 if (p_createMosaic) {
760 int samps, lines, bands;
761 delete ProjectionFactory::RingsCreateForCube(newMap, samps, lines,
false);
770 if (GetImageOverlay() == AverageImageWithMosaic) {
788 AddOutputCube(mosaicCube);
789 mosaicCube->
open(mosaicFile,
"rw");
801 Cube *ProcessMapMosaic::SetOutputCube(
const QString &mosaicFile) {
802 p_createMosaic =
false;
804 mosaic.
open(mosaicFile);
809 Cube *ocube = SetOutputCube(
"", mapping, oAtt, mosaicFile);
810 p_createMosaic =
true;
821 Cube *ProcessMapMosaic::RingsSetOutputCube(
const QString &mosaicFile) {
822 p_createMosaic =
false;
824 mosaic.
open(mosaicFile);
829 Cube *ocube = RingsSetOutputCube(
"", mapping, oAtt, mosaicFile);
830 p_createMosaic =
true;
840 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.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
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) ...
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.
double ToProjectionX(const double worldX) const
This method converts a world x value to a projection x value.
Namespace for the standard library.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
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) ...
int size() const
Returns the total number of pixels in the shape buffer.
double WorldX() const
This returns the world X coordinate provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
double ToWorldX(const double projectionX) const
This method converts a projection x value to a world x value.
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.
double ToProjectionY(const double worldY) const
This method converts a world y value to a projection y value.
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.
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.
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.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
virtual bool SetUniversalGround(const double coord1, const double coord2)
This method is used to set the lat/lon or radius/azimuth (i.e.
Namespace for ISIS/Bullet specific routines.
virtual int bandCount() const
Returns the number of virtual bands for the cube.
double ToWorldY(const double projectionY) const
This method converts a projection y value to a world y value.
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.
void deleteKeyword(const QString &name)
Remove a specified keyword.
IO Handler for Isis Cubes.