|
Isis 3.0 Application Source Code Reference |
Home |
00001 #define GUIHELPERS 00002 00003 #include "Isis.h" 00004 00005 #include <map> 00006 #include <cctype> 00007 00008 #include "Camera.h" 00009 #include "Cube.h" 00010 #include "FileList.h" 00011 #include "IException.h" 00012 #include "IString.h" 00013 #include "Projection.h" 00014 #include "ProjectionFactory.h" 00015 #include "PvlGroup.h" 00016 #include "SpecialPixel.h" 00017 #include "Spice.h" 00018 #include "UserInterface.h" 00019 00020 using namespace std; 00021 using namespace Isis; 00022 00023 00024 //functions in the code 00025 void addProject(PvlGroup &mapping); 00026 void addTarget(PvlGroup &mapping); 00027 void addRange(PvlGroup &mapping); 00028 void calcRange(double &minLat, double &maxLat, 00029 double &minLon, double &maxLon); 00030 void addResolution(PvlGroup &mapping); 00031 double calcResolution(); 00032 00033 //helper button functins in the code 00034 void helperButtonLogMap(); 00035 void helperButtonLoadMap(); 00036 void helperButtonLogTargDef(); 00037 void helperButtonLoadTargDef(); 00038 void helperButtonLogRadius(); 00039 void helperButtonCalcRange(); 00040 double helperButtonCalcResolution(); 00041 00042 map <QString, void *> GuiHelpers() { 00043 map <QString, void *> helper; 00044 helper ["helperButtonLogMap"] = (void *) helperButtonLogMap; 00045 helper ["helperButtonLoadMap"] = (void *) helperButtonLoadMap; 00046 helper ["helperButtonLogTargDef"] = (void *) helperButtonLogTargDef; 00047 helper ["helperButtonLoadTargDef"] = (void *) helperButtonLoadTargDef; 00048 helper ["helperButtonLogRadius"] = (void *) helperButtonLogRadius; 00049 helper ["helperButtonCalcRange"] = (void *) helperButtonCalcRange; 00050 helper ["helperButtonCalcResolution"] = (void *) helperButtonCalcResolution; 00051 return helper; 00052 } 00053 00054 void IsisMain() { 00055 // Make the mapping pvl group and add info to it. 00056 PvlGroup mapping("Mapping"); 00057 addProject(mapping); 00058 addTarget(mapping); 00059 addRange(mapping); 00060 addResolution(mapping); 00061 00062 // Get map file name form GUI and write the mapping group pvl 00063 // to the output file, add .map extension if the 00064 // user didnt enter an extension 00065 UserInterface &ui = Application::GetUserInterface(); 00066 FileName out = ui.GetFileName("MAP"); 00067 QString output = ui.GetFileName("MAP"); 00068 if(out.extension() == "") { 00069 output += ".map"; 00070 } 00071 Pvl p; 00072 p.AddGroup(mapping); 00073 p.Write(output); 00074 } 00075 00076 //Helper function to output map file to log. 00077 void helperButtonLogMap() { 00078 UserInterface &ui = Application::GetUserInterface(); 00079 QString mapFile(ui.GetFileName("MAP")); 00080 Pvl p; 00081 p.Read(mapFile); 00082 PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); 00083 QString OQString = "***** Output of [" + mapFile + "] *****"; 00084 Application::GuiLog(OQString); 00085 Application::GuiLog(t); 00086 } 00087 //...........end of helper function LogMap ........ 00088 00089 //Helper 2 function to update GUI with map file values. 00090 void helperButtonLoadMap() { 00091 UserInterface &ui = Application::GetUserInterface(); 00092 QString mapFile(ui.GetFileName("MAP")); 00093 Pvl p; 00094 p.Read(mapFile); 00095 PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); 00096 //Projection Stuff 00097 ui.Clear("CLON"); 00098 ui.Clear("CLAT"); 00099 ui.Clear("SCALEFACTOR"); 00100 ui.Clear("PAR1"); 00101 ui.Clear("PAR2"); 00102 ui.Clear("PLAT"); 00103 ui.Clear("PLON"); 00104 ui.Clear("PROT"); 00105 00106 if(t.HasKeyword("ProjectionName")) { 00107 QString projIn = (QString)t["ProjectionName"]; 00108 projIn = projIn.toUpper(); 00109 ui.Clear("PROJECTION"); 00110 ui.PutAsString("PROJECTION", projIn); 00111 } 00112 if(t.HasKeyword("CenterLongitude")) { 00113 double clonIn = t["CenterLongitude"]; 00114 ui.Clear("CLON"); 00115 ui.PutDouble("CLON", clonIn); 00116 } 00117 if(t.HasKeyword("CenterLatitude")) { 00118 double clatIn = t["CenterLatitude"]; 00119 ui.Clear("CLAT"); 00120 ui.PutDouble("CLAT", clatIn); 00121 } 00122 if(t.HasKeyword("ScaleFactor")) { 00123 double scaleFactorIn = t["ScaleFactor"]; 00124 ui.Clear("SCALEFACTOR"); 00125 ui.PutDouble("SCALEFACTOR", scaleFactorIn); 00126 } 00127 if(t.HasKeyword("FirstStandardParallel")) { 00128 double par1In = t["FirstStandardParallel"]; 00129 ui.Clear("PAR1"); 00130 ui.PutDouble("PAR1", par1In); 00131 } 00132 if(t.HasKeyword("SecondStandardParallel")) { 00133 double par2In = t["SecondStandardParallel"]; 00134 ui.Clear("PAR2"); 00135 ui.PutDouble("PAR2", par2In); 00136 } 00137 if(t.HasKeyword("PoleLatitude")) { 00138 double pLatIn = t["PoleLatitude"]; 00139 ui.Clear("PLAT"); 00140 ui.PutDouble("PLAT", pLatIn); 00141 } 00142 if(t.HasKeyword("PoleLongitude")) { 00143 double pLonIn = t["PoleLongitude"]; 00144 ui.Clear("PLON"); 00145 ui.PutDouble("PLON", pLonIn); 00146 } 00147 if(t.HasKeyword("PoleRotation")) { 00148 double pRotIn = t["PoleRotation"]; 00149 ui.Clear("PROT"); 00150 ui.PutDouble("PROT", pRotIn); 00151 } 00152 00153 //Target Parameters stuff 00154 QString use = "IMAGE"; 00155 ui.Clear("TARGOPT"); 00156 ui.PutAsString("TARGOPT", use); 00157 ui.Clear("TARGDEF"); 00158 ui.Clear("TARGETNAME"); 00159 ui.Clear("LATTYPE"); 00160 ui.Clear("LONDIR"); 00161 ui.Clear("EQRADIUS"); 00162 ui.Clear("POLRADIUS"); 00163 00164 if(t.HasKeyword("TargetName")) { 00165 QString use = "USER"; 00166 ui.Clear("TARGOPT"); 00167 ui.PutAsString("TARGOPT", use); 00168 QString tNameIn = t["TargetName"]; 00169 ui.Clear("TARGETNAME"); 00170 ui.PutAsString("TARGETNAME", tNameIn); 00171 00172 QString LTIn = (QString)t["LatitudeType"]; 00173 LTIn = LTIn.toUpper(); 00174 ui.Clear("LATTYPE"); 00175 ui.PutAsString("LATTYPE", LTIn); 00176 00177 QString LDIn = (QString)t["LongitudeDirection"]; 00178 LDIn = LDIn.toUpper(); 00179 ui.Clear("LONDIR"); 00180 ui.PutAsString("LONDIR", LDIn); 00181 00182 QString LDomIn = t["LongitudeDomain"]; 00183 ui.Clear("LONDOM"); 00184 ui.PutAsString("LONDOM", LDomIn); 00185 00186 QString EQIn = t["EquatorialRadius"]; 00187 ui.Clear("EQRADIUS"); 00188 ui.PutAsString("EQRADIUS", EQIn); 00189 QString PRIn = t["PolarRadius"]; 00190 ui.Clear("POLRADIUS"); 00191 ui.PutAsString("POLRADIUS", PRIn); 00192 } 00193 //Ground Range Parameter stuff 00194 ui.Clear("MINLAT"); 00195 ui.Clear("MAXLAT"); 00196 ui.Clear("MINLON"); 00197 ui.Clear("MAXLON"); 00198 QString useR = "IMAGE"; 00199 ui.Clear("RNGOPT"); 00200 ui.PutAsString("RNGOPT", useR); 00201 00202 if(t.HasKeyword("MinimumLatitude")) { 00203 double minlatIn = t["MinimumLatitude"]; 00204 QString useR = "USER"; 00205 ui.Clear("RNGOPT"); 00206 ui.PutAsString("RNGOPT", useR); 00207 ui.Clear("MINLAT"); 00208 ui.PutDouble("MINLAT", minlatIn); 00209 double maxlatIn = t["MaximumLatitude"]; 00210 ui.Clear("MAXLAT"); 00211 ui.PutDouble("MAXLAT", maxlatIn); 00212 double minlonIn = t["MinimumLongitude"]; 00213 ui.Clear("MINLON"); 00214 ui.PutDouble("MINLON", minlonIn); 00215 double maxlonIn = t["MaximumLongitude"]; 00216 ui.Clear("MAXLON"); 00217 ui.PutDouble("MAXLON", maxlonIn); 00218 } 00219 //Resolution Parameter stuff 00220 if(t.HasKeyword("PixelResolution")) { 00221 QString useM = "MPP"; 00222 ui.Clear("RESOPT"); 00223 ui.PutAsString("RESOPT", useM); 00224 double pixresIn = t["PixelResolution"]; 00225 ui.Clear("RESOLUTION"); 00226 ui.PutDouble("RESOLUTION", pixresIn); 00227 } 00228 if(t.HasKeyword("Scale")) { 00229 QString useM = "PPD"; 00230 ui.Clear("RESOPT"); 00231 ui.PutAsString("RESOPT", useM); 00232 double Mscale = t["Scale"]; 00233 ui.Clear("RESOLUTION"); 00234 ui.PutDouble("RESOLUTION", Mscale); 00235 } 00236 } 00237 //----------End Helper function to load map file into GUI ----------- 00238 00239 //helper function to output targdef to log 00240 void helperButtonLogTargDef() { 00241 UserInterface &ui = Application::GetUserInterface(); 00242 QString targetFile(ui.GetFileName("TARGDEF")); 00243 Pvl p; 00244 p.Read(targetFile); 00245 PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); 00246 QString OQString = "***** Output of [" + targetFile + "] *****"; 00247 Application::GuiLog(OQString); 00248 Application::GuiLog(t); 00249 } 00250 //------------End Helper function to display targdef info to log ----- 00251 00252 //helper function to load target def. to GUI 00253 void helperButtonLoadTargDef() { 00254 UserInterface &ui = Application::GetUserInterface(); 00255 QString targetFile(ui.GetFileName("TARGDEF")); 00256 00257 // test if targdef was entered 00258 Pvl p; 00259 p.Read(targetFile); 00260 PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); 00261 //Load the targdef values into the GUI 00262 QString tOpt = "USER"; 00263 ui.Clear("TARGOPT"); 00264 ui.PutAsString("TARGOPT", tOpt); 00265 if(t.HasKeyword("TargetName")) { 00266 QString tNameIn = t["TargetName"]; 00267 ui.Clear("TARGETNAME"); 00268 ui.PutAsString("TARGETNAME", tNameIn); 00269 } 00270 if(t.HasKeyword("LatitudeType")) { 00271 QString LTIn = (QString)t["LatitudeType"]; 00272 LTIn = LTIn.toUpper(); 00273 ui.Clear("LATTYPE"); 00274 ui.PutAsString("LATTYPE", LTIn); 00275 } 00276 if(t.HasKeyword("LongitudeDirection")) { 00277 QString LDIn = (QString)t["LongitudeDirection"]; 00278 LDIn = LDIn.toUpper(); 00279 ui.Clear("LONDIR"); 00280 ui.PutAsString("LONDIR", LDIn); 00281 } 00282 if(t.HasKeyword("LongitudeDomain")) { 00283 QString LDomIn = t["LongitudeDomain"]; 00284 ui.Clear("LONDOM"); 00285 ui.PutAsString("LONDOM", LDomIn); 00286 } 00287 if(t.HasKeyword("EquatorialRadius")) { 00288 QString EQIn = t["EquatorialRadius"]; 00289 ui.Clear("EQRADIUS"); 00290 ui.PutAsString("EQRADIUS", EQIn); 00291 } 00292 if(t.HasKeyword("PolarRadius")) { 00293 QString PRIn = t["PolarRadius"]; 00294 ui.Clear("POLRADIUS"); 00295 ui.PutAsString("POLRADIUS", PRIn); 00296 } 00297 } 00298 //-----------end Helper Function to Load target def into GUI -------- 00299 00300 //Helper function to show system radius in log. 00301 void helperButtonLogRadius() { 00302 UserInterface &ui = Application::GetUserInterface(); 00303 QString targetName = ui.GetString("TARGETNAME"); 00304 Pvl tMap; 00305 //call function to get system radius 00306 PvlGroup tGrp = Projection::TargetRadii(targetName); 00307 tMap.AddGroup(tGrp); 00308 QString OQString = "***** System radii for " + targetName + "*****"; 00309 //writh to log QString(OQString and mapping group 00310 Application::GuiLog(OQString); 00311 Application::GuiLog(tMap); 00312 } 00313 //-----------end ot log radius helper function--------- 00314 00315 //Helper function to run calcRange function. 00316 void helperButtonCalcRange() { 00317 UserInterface &ui = Application::GetUserInterface(); 00318 double minLat; 00319 double maxLat; 00320 double minLon; 00321 double maxLon; 00322 // Run the function calcRange of calculate range info 00323 calcRange(minLat, maxLat, minLon, maxLon); 00324 // Write ranges to the GUI 00325 QString use = "USER"; 00326 ui.Clear("RNGOPT"); 00327 ui.PutAsString("RNGOPT", use); 00328 ui.Clear("MINLAT"); 00329 ui.PutDouble("MINLAT", minLat); 00330 ui.Clear("MAXLAT"); 00331 ui.PutDouble("MAXLAT", maxLat); 00332 ui.Clear("MINLON"); 00333 ui.PutDouble("MINLON", minLon); 00334 ui.Clear("MAXLON"); 00335 ui.PutDouble("MAXLON", maxLon); 00336 } 00337 //--------------End Helper function to run calcRange ---------------- 00338 00339 //Helper function to run calcResolution function. 00340 double helperButtonCalcResolution() { 00341 UserInterface &ui = Application::GetUserInterface(); 00342 // Call calcResolution which will return a double 00343 double Res = calcResolution(); 00344 //update the GUI with the new resolution 00345 QString resUse = "MPP"; 00346 ui.Clear("RESOPT"); 00347 ui.PutAsString("RESOPT", resUse); 00348 ui.Clear("RESOLUTION"); 00349 ui.PutDouble("RESOLUTION", Res); 00350 return Res; 00351 } 00352 //..............End Helper function to run calcResolution 00353 00354 // Function to Add the projection information to the Mapping PVL 00355 void addProject(PvlGroup &mapping) { 00356 UserInterface &ui = Application::GetUserInterface(); 00357 QString projName = ui.GetString("PROJECTION"); 00358 //setup a look up table for projection names 00359 map <QString, QString> projLUT; 00360 projLUT ["SINUSOIDAL"] = "Sinusoidal"; 00361 projLUT ["MERCATOR"] = "Mercator"; 00362 projLUT ["TRANSVERSEMERCATOR"] = "TransverseMercator"; 00363 projLUT ["ORTHOGRAPHIC"] = "Orthographic"; 00364 projLUT ["POLARSTEREOGRAPHIC"] = "PolarStereographic"; 00365 projLUT ["SIMPLECYLINDRICAL"] = "SimpleCylindrical"; 00366 projLUT ["EQUIRECTANGULAR"] = "Equirectangular"; 00367 projLUT ["LAMBERTCONFORMAL"] = "LambertConformal"; 00368 projLUT ["OBLIQUECYLINDRICAL"] = "ObliqueCylindrical"; 00369 00370 // Add Projection keywords to the mappping PVL 00371 mapping += PvlKeyword("ProjectionName", projLUT[projName]); 00372 if(ui.WasEntered("CLON")) { 00373 double clonOut = ui.GetDouble("CLON"); 00374 mapping += PvlKeyword("CenterLongitude", toString(clonOut)); 00375 } 00376 if(ui.WasEntered("CLAT")) { 00377 double clatOut = ui.GetDouble("CLAT"); 00378 mapping += PvlKeyword("CenterLatitude", toString(clatOut)); 00379 } 00380 if(ui.WasEntered("SCALEFACTOR")) { 00381 double scaleFactorOut = ui.GetDouble("SCALEFACTOR"); 00382 mapping += PvlKeyword("ScaleFactor", toString(scaleFactorOut)); 00383 } 00384 if(ui.WasEntered("PAR1")) { 00385 double par1 = ui.GetDouble("PAR1"); 00386 mapping += PvlKeyword("FirstStandardParallel", toString(par1)); 00387 } 00388 if(ui.WasEntered("PAR2")) { 00389 double par2 = ui.GetDouble("PAR2"); 00390 mapping += PvlKeyword("SecondStandardParallel", toString(par2)); 00391 } 00392 if(ui.WasEntered("PLAT")) { 00393 double plat = ui.GetDouble("PLAT"); 00394 mapping += PvlKeyword("PoleLatitude", toString(plat)); 00395 } 00396 if(ui.WasEntered("PLON")) { 00397 double plon = ui.GetDouble("PLON"); 00398 mapping += PvlKeyword("PoleLongitude", toString(plon)); 00399 } 00400 if(ui.WasEntered("PROT")) { 00401 double prot = ui.GetDouble("PROT"); 00402 mapping += PvlKeyword("PoleRotation", toString(prot)); 00403 } 00404 } 00405 00406 // Function to Add the target information to the Mapping PVL 00407 void addTarget(PvlGroup &mapping) { 00408 UserInterface &ui = Application::GetUserInterface(); 00409 if(ui.GetString("TARGOPT") == "SYSTEM") { 00410 QString targetFile(ui.GetFileName("TARGDEF")); 00411 Pvl p; 00412 p.Read(targetFile); 00413 PvlGroup t = p.FindGroup("mapping"); 00414 if(t.HasKeyword("TargetName")) { 00415 mapping += t["TargetName"]; 00416 } 00417 if(t.HasKeyword("EquatorialRadius")) { 00418 mapping += t["EquatorialRadius"]; 00419 } 00420 if(t.HasKeyword("PolarRadius")) { 00421 mapping += t["PolarRadius"]; 00422 } 00423 if(t.HasKeyword("LatitudeType")) { 00424 mapping += t["LatitudeType"]; 00425 } 00426 if(t.HasKeyword("LongitudeDirection")) { 00427 mapping += t["LongitudeDirection"]; 00428 } 00429 } 00430 // if TARGOPT is user and no radii enter the run TargetRadii to get 00431 // the system radii for target name. 00432 else if(ui.GetString("TARGOPT") == "USER") { 00433 QString targetName = ui.GetString("TARGETNAME"); 00434 PvlGroup grp = Projection::TargetRadii(targetName); 00435 double equatorialRad = grp["EquatorialRadius"]; 00436 double polarRad = grp["PolarRadius"]; 00437 // if radii were entered in GUI then set radii to entered value 00438 if(ui.WasEntered("EQRADIUS")) { 00439 equatorialRad = ui.GetDouble("EQRADIUS"); 00440 } 00441 if(ui.WasEntered("POLRADIUS")) { 00442 polarRad = ui.GetDouble("POLRADIUS"); 00443 } 00444 QString latType = ui.GetString("LATTYPE"); 00445 if(latType == "PLANETOCENTRIC") { 00446 latType = "Planetocentric"; 00447 } 00448 else if(latType == "PLANETOGRAPHIC") { 00449 latType = "Planetographic"; 00450 } 00451 QString lonDir = ui.GetString("LONDIR"); 00452 if(lonDir == "POSITIVEEAST") { 00453 lonDir = "PositiveEast"; 00454 } 00455 else if(lonDir == "POSITIVEWEST") { 00456 lonDir = "PositiveWest"; 00457 } 00458 QString lonDom = ui.GetString("LONDOM"); 00459 //Add targdef values to the mapping pvl 00460 mapping += PvlKeyword("TargetName", targetName); 00461 mapping += PvlKeyword("EquatorialRadius", toString(equatorialRad), "meters"); 00462 mapping += PvlKeyword("PolarRadius", toString(polarRad), "meters"); 00463 mapping += PvlKeyword("LatitudeType", latType); 00464 mapping += PvlKeyword("LongitudeDirection", lonDir); 00465 mapping += PvlKeyword("LongitudeDomain", lonDom); 00466 } 00467 } 00468 00469 // Function to add the range information to the mapping PVL 00470 void addRange(PvlGroup &mapping) { 00471 UserInterface &ui = Application::GetUserInterface(); 00472 //Use the values that have been entered in the GUI 00473 if(ui.GetString("RNGOPT") == "USER") { 00474 double minLat = ui.GetDouble("MINLAT"); 00475 mapping += PvlKeyword("MinimumLatitude", toString(minLat)); 00476 double maxLat = ui.GetDouble("MAXLAT"); 00477 mapping += PvlKeyword("MaximumLatitude", toString(maxLat)); 00478 double minLon = ui.GetDouble("MINLON"); 00479 mapping += PvlKeyword("MinimumLongitude", toString(minLon)); 00480 double maxLon = ui.GetDouble("MAXLON"); 00481 mapping += PvlKeyword("MaximumLongitude", toString(maxLon)); 00482 } 00483 else if(ui.GetString("RNGOPT") == "CALC") { 00484 // calculate range values using function calcRange and fromlist 00485 double minLat; 00486 double maxLat; 00487 double minLon; 00488 double maxLon; 00489 //Call calcRange to calculate min and max ground range values 00490 calcRange(minLat, maxLat, minLon, maxLon); 00491 mapping += PvlKeyword("MinimumLatitude", toString(minLat)); 00492 mapping += PvlKeyword("MaximumLatitude", toString(maxLat)); 00493 mapping += PvlKeyword("MinimumLongitude", toString(minLon)); 00494 mapping += PvlKeyword("MaximumLongitude", toString(maxLon)); 00495 } 00496 } 00497 00498 // Function to add the resolution information to the mapping PVL 00499 void addResolution(PvlGroup &mapping) { 00500 // Use values that have been entered in GUI 00501 UserInterface &ui = Application::GetUserInterface(); 00502 if(ui.GetString("RESOPT") == "PPD") { 00503 double res = ui.GetDouble("RESOLUTION"); 00504 mapping += PvlKeyword("Scale", toString(res), "pixels/degree"); 00505 } 00506 else if(ui.GetString("RESOPT") == "MPP") { 00507 double res = ui.GetDouble("RESOLUTION"); 00508 mapping += PvlKeyword("PixelResolution", toString(res), "meters/pixel"); 00509 } 00510 else if(ui.GetString("RESOPT") == "CALC") { 00511 // run the function to calculate the resolution 00512 double Res = calcResolution(); 00513 mapping += PvlKeyword("PixelResolution", toString(Res), "meters/pixel"); 00514 } 00515 } 00516 00517 // Function to calculate the ground range from multiple inputs (list of images) 00518 void calcRange(double &minLat, double &maxLat, 00519 double &minLon, double &maxLon) { 00520 UserInterface &ui = Application::GetUserInterface(); 00521 FileList flist(FileName(ui.GetFileName("FROMLIST"))); 00522 minLat = DBL_MAX; 00523 maxLat = -DBL_MAX; 00524 minLon = DBL_MAX; 00525 maxLon = -DBL_MAX; 00526 //set up PVL of mapping info from GUI:: need to do this so we use the 00527 // most current info from GUI to calculate the range 00528 Pvl userMap; 00529 PvlGroup userGrp("Mapping"); 00530 if(ui.GetString("TARGOPT") == "SYSTEM") { 00531 userMap.Read(ui.GetFileName("TARGDEF")); 00532 } 00533 else if(ui.GetString("TARGOPT") == "USER") { 00534 userGrp += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); 00535 QString targetName = ui.GetString("TARGETNAME"); 00536 PvlGroup grp = Projection::TargetRadii(targetName); 00537 double equatorialRad = grp["EquatorialRadius"]; 00538 double polarRad = grp["PolarRadius"]; 00539 00540 // if radii were entered in GUI then set radii to entered value 00541 if(ui.WasEntered("EQRADIUS")) { 00542 equatorialRad = ui.GetDouble("EQRADIUS"); 00543 } 00544 if(ui.WasEntered("POLRADIUS")) { 00545 polarRad = ui.GetDouble("POLRADIUS"); 00546 } 00547 if(ui.GetString("LATTYPE") == "PLANETOCENTRIC") { 00548 QString latType = "Planetocentric"; 00549 userGrp += PvlKeyword("LatitudeType", latType); 00550 } 00551 else if(ui.GetString("LATTYPE") == "PLANETOGRAPHIC") { 00552 QString latType = "Planetographic"; 00553 userGrp += PvlKeyword("LatitudeType", latType); 00554 } 00555 if(ui.GetString("LONDIR") == "POSITIVEEAST") { 00556 QString lonD = "PositiveEast"; 00557 userGrp += PvlKeyword("LongitudeDirection", lonD); 00558 } 00559 else if(ui.GetString("LONDIR") == "POSITIVEWEST") { 00560 QString lonD = "PositiveWest"; 00561 userGrp += PvlKeyword("LongitudeDirection", lonD); 00562 } 00563 userGrp += PvlKeyword("LongitudeDomain", ui.GetString("LONDOM")); 00564 userGrp += PvlKeyword("EquatorialRadius", toString(equatorialRad)); 00565 userGrp += PvlKeyword("PolarRadius", toString(polarRad)); 00566 userMap.AddGroup(userGrp); 00567 } 00568 00569 for(int i = 0; i < flist.size(); i++) { 00570 // Get the mapping group from the camera 00571 double camMinLat; 00572 double camMaxLat; 00573 double camMinLon; 00574 double camMaxLon; 00575 Cube c; 00576 c.open(flist[i].toString()); 00577 Camera *cam = c.camera(); 00578 Pvl defaultMap; 00579 cam->BasicMapping(defaultMap); 00580 PvlGroup &defaultGrp = defaultMap.FindGroup("Mapping"); 00581 //Move any defaults that are not in the user map 00582 for(int k = 0; k < defaultGrp.Keywords(); k++) { 00583 if(!userGrp.HasKeyword(defaultGrp[k].Name())) { 00584 userGrp += defaultGrp[k]; 00585 } 00586 } 00587 userMap.AddGroup(userGrp); 00588 //get the camera ground range min and max and solve for range 00589 cam->GroundRange(camMinLat, camMaxLat, camMinLon, camMaxLon, userMap); 00590 if(camMinLat < minLat) { 00591 minLat = camMinLat; 00592 } 00593 if(camMaxLat > maxLat) { 00594 maxLat = camMaxLat; 00595 } 00596 if(camMinLon < minLon) { 00597 minLon = camMinLon; 00598 } 00599 if(camMaxLon > maxLon) { 00600 maxLon = camMaxLon; 00601 } 00602 } 00603 } 00604 00605 // Function to calculate the resolution for images in FROMLIST 00606 // value will be in meters 00607 double calcResolution() { 00608 UserInterface &ui = Application::GetUserInterface(); 00609 FileList flist(FileName(ui.GetFileName("FROMLIST"))); 00610 double sumRes = 0.0; 00611 double highRes = DBL_MAX; 00612 double lowRes = -DBL_MAX; 00613 // Loop through the from list at get high and low camera resolution 00614 for(int i = 0; i < flist.size(); i++) { 00615 Cube c; 00616 c.open(flist[i].toString()); 00617 Camera *cam = c.camera(); 00618 double camLowRes = cam->LowestImageResolution(); 00619 double camHighRes = cam->HighestImageResolution(); 00620 if(camLowRes > lowRes) lowRes = camLowRes; 00621 if(camHighRes < highRes) highRes = camHighRes; 00622 sumRes = sumRes + (camLowRes + camHighRes) / 2.0; 00623 } 00624 //user input (RESCALCOPT) at GUI will determain what is output 00625 // highest, lowest, or avg 00626 if(ui.GetString("RESCALCOPT") == "HIGH") return highRes; 00627 if(ui.GetString("RESCALCOPT") == "LOW") return lowRes; 00628 return(sumRes / flist.size()); 00629 } 00630 00631