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) {