Loading isis/src/base/apps/campt/campt.cpp +133 −31 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ #include "Brick.h" #include "Camera.h" #include "CameraPointInfo.h" #include "CSVReader.h" #include "IException.h" #include "iTime.h" #include "Progress.h" Loading @@ -14,64 +15,159 @@ using namespace std; using namespace Isis; QList< QPair<double, double> > getPoints(const UserInterface &ui, bool usePointList); QList<PvlGroup *> getCameraPointInfo(const UserInterface &ui, QList< QPair<double, double> > points, CameraPointInfo &campt); void writePoints(const UserInterface &ui, QList<PvlGroup*> camPoints); void IsisMain() { UserInterface &ui = Application::GetUserInterface(); bool outsideAllowed = ui.GetBoolean("ALLOWOUTSIDE"); // Set up CameraPointInfo and set file // Setup our input cube CameraPointInfo campt; campt.SetCube(ui.GetFileName("FROM") + "+" + ui.GetInputAttribute("FROM").toString()); Progress prog; prog.SetMaximumSteps(1); // Grab the provided points (coordinates) QList< QPair<double, double> > points = getPoints(ui, ui.WasEntered("COORDLIST")); // Get the camera point info for coordiante QList<PvlGroup*> camPoints = getCameraPointInfo(ui, points, campt); writePoints(ui, camPoints); } // We can grab our coordinates, either from the ui position parameters or the coordlist parameter // This method returns a list of double pairs (i.e. a list of coordinates) QList< QPair<double, double> > getPoints(const UserInterface &ui, bool usePointList) { double point1 = 0.0; double point2 = 0.0; QList< QPair<double, double> > points; QString pointType = ui.GetString("TYPE"); // Check if the provided coordinate list is valid, i.e. a Samp/Line or Lat/Long coordinate per row if (usePointList) { CSVReader reader; reader.read(FileName(ui.GetFileName("COORDLIST")).expanded()); if (!reader.isTableValid(reader.getTable()) || reader.columns() != 2) { QString msg = "Coordinate file formatted incorrectly.\n" "Each row must have two columns: a sample,line or a latitude,longitude pair."; throw IException(IException::User, msg, _FILEINFO_); } for (int row = 0; row < reader.rows(); row++) { point1 = toDouble(reader.getRow(row)[0]); point2 = toDouble(reader.getRow(row)[1]); points.append(QPair<double, double>(point1, point2)); } } // Grab the coordinate from the ui position parameters if no coordinate list is provided else { if (pointType == "IMAGE") { if (ui.WasEntered("SAMPLE")) point1 = ui.GetDouble("SAMPLE"); if (ui.WasEntered("LINE")) point2 = ui.GetDouble("LINE"); } else { point1 = ui.GetDouble("LATITUDE"); point2 = ui.GetDouble("LONGITUDE"); } points.append(QPair<double, double>(point1, point2)); } return points; } // Gets the camera information for each point (coordinate). // Passed in a list of coordinates, passed in by reference a CameraPointInfo object. // Returns a list of PvlGroup pointers - these groups contain the camera info for each coordinate. QList<PvlGroup*> getCameraPointInfo(const UserInterface &ui, QList< QPair<double, double> > points, CameraPointInfo &campt) { // Setup our parameters from ui and variables QList<PvlGroup*> cameraPoints; bool usePointList = ui.WasEntered("COORDLIST"); bool allowOutside = ui.WasEntered("ALLOWOUTSIDE"); QString type; if (ui.WasEntered("COORDLIST")) { type = ui.GetString("COORDTYPE"); } else { type = ui.GetString("TYPE"); } PvlGroup *camPoint = NULL; // Depending on what type is selected, set values accordingly PvlGroup *point = NULL; if (ui.GetString("TYPE") == "IMAGE") { double sample = 0.0; double line = 0.0; for (int i = 0; i < points.size(); i++) { QPair<double, double> pt = points[i]; if (type == "GROUND") { camPoint = campt.SetGround(pt.first, pt.second, allowOutside, usePointList); } else { if (usePointList) { camPoint = campt.SetImage(pt.first, pt.second, allowOutside, usePointList); } else { if (ui.WasEntered("SAMPLE") && ui.WasEntered("LINE")) { sample = ui.GetDouble("SAMPLE"); line = ui.GetDouble("LINE"); point = campt.SetImage(sample, line, outsideAllowed); camPoint = campt.SetImage(pt.first, pt.second, allowOutside); } else { if (ui.WasEntered("SAMPLE")) { sample = ui.GetDouble("SAMPLE"); point = campt.SetSample(sample, outsideAllowed); camPoint = campt.SetSample(pt.first, allowOutside); } else if (ui.WasEntered("LINE")) { line = ui.GetDouble("LINE"); point = campt.SetLine(line, outsideAllowed); camPoint = campt.SetLine(pt.second, allowOutside); } else { point = campt.SetCenter(outsideAllowed); camPoint = campt.SetCenter(allowOutside); } } } else { double lat = ui.GetDouble("LATITUDE"); double lon = ui.GetDouble("LONGITUDE"); point = campt.SetGround(lat, lon, outsideAllowed); } cameraPoints.append(camPoint); } camPoint = NULL; return cameraPoints; } prog.CheckStatus(); // Log it Application::Log((*point)); if (ui.WasEntered("TO")) { // Write our point coordinates to std out in pvl format, or to a pvl or some type of flat file void writePoints(const UserInterface &ui, QList<PvlGroup*> camPoints) { // Progress should increment for each point we process Progress prog; prog.SetMaximumSteps(camPoints.size()); QString outFile; // Get user params from ui QString outFile = FileName(ui.GetFileName("TO")).expanded(); bool exists = FileName(outFile).fileExists(); if (ui.WasEntered("TO")) { outFile = FileName(ui.GetFileName("TO")).expanded(); } bool append = ui.GetBoolean("APPEND"); QString fileFormat = ui.GetString("FORMAT"); PvlGroup *point = NULL; for (int p = 0; p < camPoints.size(); p++) { bool fileExists = FileName(outFile).fileExists(); prog.CheckStatus(); point = camPoints[p]; // write to output file if (ui.WasEntered("TO")) { // Write the pvl group out to the file if (ui.GetString("FORMAT") == "PVL") { if (fileFormat == "PVL") { Pvl temp; temp.setTerminator(""); temp.addGroup((*point)); if (append) { // we don't want to overwrite successive points in outfile if (append || p > 0) { temp.append(outFile); } else { Loading @@ -84,9 +180,9 @@ void IsisMain() { else { ofstream os; bool writeHeader = false; if (append) { if (append || p > 0) { os.open(outFile.toAscii().data(), ios::app); if (!exists) { if (!fileExists) { writeHeader = true; } } Loading Loading @@ -130,13 +226,19 @@ void IsisMain() { os << endl; } } // No output file specified else { // don't log data - if (ui.GetString("FORMAT") == "FLAT") { string msg = "Flat file must have a name."; throw IException(IException::User, msg, _FILEINFO_); } } // we still want to output the results Application::Log((*point)); delete point; point = NULL; } prog.CheckStatus(); } isis/src/base/apps/campt/campt.xml +143 −33 Original line number Diff line number Diff line Loading @@ -8,9 +8,9 @@ <description> <p> Campt computes geometric and photometric information at a given pixel location in the input image <def link="Cube">cube</def>. The program computes spacecraft and instrument related information, and other types of coordinates as described later in this document. The user will have a choice of coordinates location or list of pixel locations in the input image <def link="Cube">cube</def>. The program computes spacecraft and instrument related information, and other types of coordinates as described later in this document. The user will have a choice of coordinates in which to output the information as well as a choice in the output format of the information acquired. </p> Loading @@ -24,12 +24,13 @@ </p> <p> The point of interest in the image can be entered as <def>Latitude</def>/<def>Longitude</def> coordinates or <def>Line</def>/<def>Sample</def> coordinates. Keep in mind coordinates or <def>Sample</def>/<def>Line</def> coordinates. Keep in mind that the input <def>Latitude</def> and <def>Longitude</def> values entered will be interpreted as <def link="Universal Coordinate">Universal Coordinates</def> (ISIS default) regardless of the target body. In the output, all positions are in <def link="Body Fixed Coordinate">Body-Fixed</def> Coordinates. Coordinates. Multiple points of interest may be specified by providing a comma-delimited flatfile of coordinates. </p> <p> The following is a partial list of coordinates computed in the <i>campt</i> application:<br /> Loading Loading @@ -106,8 +107,16 @@ Group = GroundPoint <def>UTC</def> = 1997-10-20T10:58:37.6570806 LocalSolarTime = 17.089704420784 <hour> <def link="Solar Longitude">SolarLongitude</def> = 201.83159041209 Error = NULL End_Group </pre> <p> Note: The "Error" keyword will only appear when using a coordinate list. The value of "Error" will be NULL unless an error occurs during the processing of a coordinate in the <a href="#FilesCOORDLIST">coordinate list</a>. Then, the value of this keyword will be the error message. </p> </description> <category> Loading Loading @@ -184,6 +193,13 @@ End_Group "Related Objects and Documents" section of the documentation. Fixes mantis ticket #1525. </change> <change name="Ian Humphrey" date="2014-11-05"> Added new parameters, USECOORDLIST, COORDLIST, and COORDTYPE for processing a list of points as input. Reorganized campt. Fixes #1449. </change> <change name="Ian Humphrey" date="2015-03-03"> Updated documentation. References #1449. </change> </history> <oldName> Loading Loading @@ -217,6 +233,100 @@ End_Group </filter> </parameter> <parameter name = "USECOORDLIST"> <type>boolean</type> <default><item>FALSE</item></default> <brief> Enable coordinate list parameters in the GUI </brief> <description> Selecting this parameter will enable the 'COORDLIST' and 'COORDTYPE' parameters in the GUI. <p> Note that this parameter is optional when running <i>campt</i> on the command line. </p> </description> <inclusions> <item>COORDLIST</item> <item>COORDTYPE</item> </inclusions> <exclusions> <item>TYPE</item> <item>SAMPLE</item> <item>LINE</item> <item>LATITUDE</item> <item>LONGITUDE</item> </exclusions> </parameter> <parameter name="COORDLIST"> <type>filename</type> <fileMode>input</fileMode> <brief> Input comma-delimited file of image or ground coordinates </brief> <internalDefault>None</internalDefault> <description> An input comma-delimited flatfile of image coordinates or ground coordinates. This allows the program to process multiple coordinates in a single run of <i>campt</i>, and output the results to the specified output file. <p> Expected order for image coordinates: sample, line<br/> Expected order for ground coordinates: latitude, longitude </p> <p> The "Error" keyword will only appear when using a coordinate list. The value of "Error" will then be NULL unless an error occurs during the processing of a coordinate in the coordinate list. Then, the value of this keyword will be the error message. This allows for <i>campt</i> to continue processing the remaining coordinates in the coordinate list. </p> <p> For the input of Latitude and Longitude, campt expects <def>Planetocentric Latitude</def> (within -90 to 90 boundary) and <def>Positive East Longitude</def> (with 0-360 boundary) to find the location in the input camera image. </p> </description> <exclusions> <item>TYPE</item> <item>SAMPLE</item> <item>LINE</item> <item>LATITUDE</item> <item>LONGITUDE</item> </exclusions> </parameter> <parameter name="COORDTYPE"> <type>string</type> <brief>Coordinate type selection (Image or Ground) for 'COORDLIST'</brief> <list> <option value="IMAGE"> <brief>Interprets coordinates in 'COORDLIST' as sample/line</brief> <description> This option interprets the coordinates provided in the input coordinate list file as sample/line and will compute latitude/longitude and Projection x/y. </description> </option> <option value="GROUND"> <brief>Interprets the coordinates in 'COORDLIST' as latitude/longitude</brief> <description> This option interprets the coordinates provided in the input coordinate list file as latitude/longitude and will compute sample/line and Projection x/y. </description> </option> </list> <description> This parameter is used to select the type of coordinates entered in the coordinate list file, which will be used to determine the method to compute the geometric and photometric information. </description> <exclusions> <item>TYPE</item> </exclusions> </parameter> <parameter name="TO"> <type>filename</type> <fileMode>output</fileMode> Loading Loading @@ -273,6 +383,32 @@ End_Group </description> <default><item>TRUE</item></default> </parameter> <parameter name="ALLOWOUTSIDE"> <type>boolean</type> <brief> Allow sample/line values outside the image to be reported </brief> <description> The Allowoutside parameter influences how <i>campt</i> will report resulting latitude/longitude and sample/line coordinates that fall outside the input cube pixel boundaries. <p> The default is set to True, which allows <i>campt</i> to return the values that are outside the cube pixel boundaries. For example, a given latitude/longitude might return a sample location of -1.0 (a single whole pixel coordinate off the left side of the image). This is a feature of the ISIS camera models. </p> <p> When set to False, if a returned coordinate is off the image, <i>campt</i> will fail. This failure can be indicated and ignored within a batch script when only coordinates that fall within the image cube pixel boundaries are desired. </p> </description> <default><item>TRUE</item></default> </parameter> </group> <group name="Position"> Loading Loading @@ -319,7 +455,7 @@ End_Group <internalDefault>Center sample</internalDefault> <description> This is the <def>Sample</def> position used to compute information about the input cube at the pixel. at a given pixel location in the input image cube. </description> </parameter> Loading @@ -332,7 +468,7 @@ End_Group <internalDefault>Center line</internalDefault> <description> This is the <def>Line</def> position used to compute information about the input cube at the pixel. at a given pixel location in the input image cube. </description> </parameter> Loading Loading @@ -368,32 +504,6 @@ End_Group <minimum inclusive="yes">0.0</minimum> <maximum inclusive="yes">360.0</maximum> </parameter> <parameter name="ALLOWOUTSIDE"> <type>boolean</type> <brief> Allow sample/line values outside the image to be reported </brief> <description> The Allowoutside parameter influences how <i>campt</i> will report resulting latitude/longitude and sample/line coordinates that fall outside the input cube pixel boundaries. <p> The default is set to True, which allows <i>campt</i> to return the values that are outside the cube pixel boundaries, For example, a given latitude/longitude might return a sample location of -1.0 (a single whole pixel coordinate off the left side of the image). This is a feature of the ISIS camera models. </p> <p> When set to False, if a returned coordinate is off the image, <i>campt</i> will fail. This failure can be indicated and ignored within a batch script when only coordinates that fall within the image cube pixel boundaries are desired. </p> </description> <default><item>true</item></default> </parameter> </group> </groups> </application> isis/src/base/apps/campt/tsts/errors/Makefile 0 → 100644 +19 −0 Original line number Diff line number Diff line # test for exceptions thrown # the coordinate list is invalid if number of rows and columns don't match # the coordinate list is invalid if there are not 2 columns # no output file is provided when specifying the FORMAT as FLAT APPNAME = campt include $(ISISROOT)/make/isismake.tsts commands: -$(APPNAME) from=$(INPUT)/ab102401.cub \ to=$(OUTPUT)/output.pvl \ coordlist=$(INPUT)/badlist.csv \ coordtype=IMAGE 2> $(OUTPUT)/errorsTruth.txt > /dev/null; -$(APPNAME) from=$(INPUT)/ab102401.cub \ to=$(OUTPUT)/output.pvl \ coordlist=$(INPUT)/badcolumns.csv \ coordtype=IMAGE 2>> $(OUTPUT)/errorsTruth.txt > /dev/null; -$(APPNAME) from=$(INPUT)/ab102401.cub \ format=FLAT 2>> $(OUTPUT)/errorsTruth.txt > /dev/null; isis/src/base/apps/campt/tsts/no_sample_line/Makefile 0 → 100644 +16 −0 Original line number Diff line number Diff line # test for not providing a sample or line value (defaults to center) # also tests for not providing a value to the TO parameter APPNAME = campt include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/ab102401.cub \ > $(OUTPUT)/noSampleLineTruth.txt; cat $(OUTPUT)/noSampleLineTruth.txt | \ $(SED) 's/\([0-9]*\.[0-9]\{5\}\)[0-9]*/\1/g' | \ $(SED) '/Filename.*/ { N; N; N; N; s/-\n[ ]*//g; }' | \ $(SED) 's/\(.*= \).*\(ab102401.cub\)/\1\2/' \ >& $(OUTPUT)/noSampleLineTruthtmp.txt; $(MV) $(OUTPUT)/noSampleLineTruthtmp.txt \ $(OUTPUT)/noSampleLineTruth.txt; isis/src/base/apps/campt/tsts/pointlist_append/Makefile 0 → 100644 +32 −0 Original line number Diff line number Diff line APPNAME = campt include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ to=$(OUTPUT)/pointlistAppendTruth.pvl \ coordtype=IMAGE > /dev/null; $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ to=$(OUTPUT)/pointlistAppendTruth.pvl \ coordtype=IMAGE > /dev/null; cat $(OUTPUT)/pointlistAppendTruth.pvl | \ $(SED) '/Filename.*/ { N; N; N; N; s/-\n[ ]*//g; }' | \ $(SED) 's/\(.*= \).*\(ab102401.cub\)/\1\2/g' \ > $(OUTPUT)/pointlistAppendTruthtmp.pvl; $(MV) $(OUTPUT)/pointlistAppendTruthtmp.pvl \ $(OUTPUT)/pointlistAppendTruth.pvl; $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ format=FLAT coordtype=IMAGE \ to=$(OUTPUT)/pointlistAppendTruth.csv > /dev/null; $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ format=FLAT coordtype=IMAGE \ to=$(OUTPUT)/pointlistAppendTruth.csv > /dev/null; cat $(OUTPUT)/pointlistAppendTruth.csv | \ $(SED) 's/^.*\(ab102401.cub\)\(.*\)/\1\2/g' \ > $(OUTPUT)/pointlistAppendTruthtmp.csv; $(MV) $(OUTPUT)/pointlistAppendTruthtmp.csv \ $(OUTPUT)/pointlistAppendTruth.csv; Loading
isis/src/base/apps/campt/campt.cpp +133 −31 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ #include "Brick.h" #include "Camera.h" #include "CameraPointInfo.h" #include "CSVReader.h" #include "IException.h" #include "iTime.h" #include "Progress.h" Loading @@ -14,64 +15,159 @@ using namespace std; using namespace Isis; QList< QPair<double, double> > getPoints(const UserInterface &ui, bool usePointList); QList<PvlGroup *> getCameraPointInfo(const UserInterface &ui, QList< QPair<double, double> > points, CameraPointInfo &campt); void writePoints(const UserInterface &ui, QList<PvlGroup*> camPoints); void IsisMain() { UserInterface &ui = Application::GetUserInterface(); bool outsideAllowed = ui.GetBoolean("ALLOWOUTSIDE"); // Set up CameraPointInfo and set file // Setup our input cube CameraPointInfo campt; campt.SetCube(ui.GetFileName("FROM") + "+" + ui.GetInputAttribute("FROM").toString()); Progress prog; prog.SetMaximumSteps(1); // Grab the provided points (coordinates) QList< QPair<double, double> > points = getPoints(ui, ui.WasEntered("COORDLIST")); // Get the camera point info for coordiante QList<PvlGroup*> camPoints = getCameraPointInfo(ui, points, campt); writePoints(ui, camPoints); } // We can grab our coordinates, either from the ui position parameters or the coordlist parameter // This method returns a list of double pairs (i.e. a list of coordinates) QList< QPair<double, double> > getPoints(const UserInterface &ui, bool usePointList) { double point1 = 0.0; double point2 = 0.0; QList< QPair<double, double> > points; QString pointType = ui.GetString("TYPE"); // Check if the provided coordinate list is valid, i.e. a Samp/Line or Lat/Long coordinate per row if (usePointList) { CSVReader reader; reader.read(FileName(ui.GetFileName("COORDLIST")).expanded()); if (!reader.isTableValid(reader.getTable()) || reader.columns() != 2) { QString msg = "Coordinate file formatted incorrectly.\n" "Each row must have two columns: a sample,line or a latitude,longitude pair."; throw IException(IException::User, msg, _FILEINFO_); } for (int row = 0; row < reader.rows(); row++) { point1 = toDouble(reader.getRow(row)[0]); point2 = toDouble(reader.getRow(row)[1]); points.append(QPair<double, double>(point1, point2)); } } // Grab the coordinate from the ui position parameters if no coordinate list is provided else { if (pointType == "IMAGE") { if (ui.WasEntered("SAMPLE")) point1 = ui.GetDouble("SAMPLE"); if (ui.WasEntered("LINE")) point2 = ui.GetDouble("LINE"); } else { point1 = ui.GetDouble("LATITUDE"); point2 = ui.GetDouble("LONGITUDE"); } points.append(QPair<double, double>(point1, point2)); } return points; } // Gets the camera information for each point (coordinate). // Passed in a list of coordinates, passed in by reference a CameraPointInfo object. // Returns a list of PvlGroup pointers - these groups contain the camera info for each coordinate. QList<PvlGroup*> getCameraPointInfo(const UserInterface &ui, QList< QPair<double, double> > points, CameraPointInfo &campt) { // Setup our parameters from ui and variables QList<PvlGroup*> cameraPoints; bool usePointList = ui.WasEntered("COORDLIST"); bool allowOutside = ui.WasEntered("ALLOWOUTSIDE"); QString type; if (ui.WasEntered("COORDLIST")) { type = ui.GetString("COORDTYPE"); } else { type = ui.GetString("TYPE"); } PvlGroup *camPoint = NULL; // Depending on what type is selected, set values accordingly PvlGroup *point = NULL; if (ui.GetString("TYPE") == "IMAGE") { double sample = 0.0; double line = 0.0; for (int i = 0; i < points.size(); i++) { QPair<double, double> pt = points[i]; if (type == "GROUND") { camPoint = campt.SetGround(pt.first, pt.second, allowOutside, usePointList); } else { if (usePointList) { camPoint = campt.SetImage(pt.first, pt.second, allowOutside, usePointList); } else { if (ui.WasEntered("SAMPLE") && ui.WasEntered("LINE")) { sample = ui.GetDouble("SAMPLE"); line = ui.GetDouble("LINE"); point = campt.SetImage(sample, line, outsideAllowed); camPoint = campt.SetImage(pt.first, pt.second, allowOutside); } else { if (ui.WasEntered("SAMPLE")) { sample = ui.GetDouble("SAMPLE"); point = campt.SetSample(sample, outsideAllowed); camPoint = campt.SetSample(pt.first, allowOutside); } else if (ui.WasEntered("LINE")) { line = ui.GetDouble("LINE"); point = campt.SetLine(line, outsideAllowed); camPoint = campt.SetLine(pt.second, allowOutside); } else { point = campt.SetCenter(outsideAllowed); camPoint = campt.SetCenter(allowOutside); } } } else { double lat = ui.GetDouble("LATITUDE"); double lon = ui.GetDouble("LONGITUDE"); point = campt.SetGround(lat, lon, outsideAllowed); } cameraPoints.append(camPoint); } camPoint = NULL; return cameraPoints; } prog.CheckStatus(); // Log it Application::Log((*point)); if (ui.WasEntered("TO")) { // Write our point coordinates to std out in pvl format, or to a pvl or some type of flat file void writePoints(const UserInterface &ui, QList<PvlGroup*> camPoints) { // Progress should increment for each point we process Progress prog; prog.SetMaximumSteps(camPoints.size()); QString outFile; // Get user params from ui QString outFile = FileName(ui.GetFileName("TO")).expanded(); bool exists = FileName(outFile).fileExists(); if (ui.WasEntered("TO")) { outFile = FileName(ui.GetFileName("TO")).expanded(); } bool append = ui.GetBoolean("APPEND"); QString fileFormat = ui.GetString("FORMAT"); PvlGroup *point = NULL; for (int p = 0; p < camPoints.size(); p++) { bool fileExists = FileName(outFile).fileExists(); prog.CheckStatus(); point = camPoints[p]; // write to output file if (ui.WasEntered("TO")) { // Write the pvl group out to the file if (ui.GetString("FORMAT") == "PVL") { if (fileFormat == "PVL") { Pvl temp; temp.setTerminator(""); temp.addGroup((*point)); if (append) { // we don't want to overwrite successive points in outfile if (append || p > 0) { temp.append(outFile); } else { Loading @@ -84,9 +180,9 @@ void IsisMain() { else { ofstream os; bool writeHeader = false; if (append) { if (append || p > 0) { os.open(outFile.toAscii().data(), ios::app); if (!exists) { if (!fileExists) { writeHeader = true; } } Loading Loading @@ -130,13 +226,19 @@ void IsisMain() { os << endl; } } // No output file specified else { // don't log data - if (ui.GetString("FORMAT") == "FLAT") { string msg = "Flat file must have a name."; throw IException(IException::User, msg, _FILEINFO_); } } // we still want to output the results Application::Log((*point)); delete point; point = NULL; } prog.CheckStatus(); }
isis/src/base/apps/campt/campt.xml +143 −33 Original line number Diff line number Diff line Loading @@ -8,9 +8,9 @@ <description> <p> Campt computes geometric and photometric information at a given pixel location in the input image <def link="Cube">cube</def>. The program computes spacecraft and instrument related information, and other types of coordinates as described later in this document. The user will have a choice of coordinates location or list of pixel locations in the input image <def link="Cube">cube</def>. The program computes spacecraft and instrument related information, and other types of coordinates as described later in this document. The user will have a choice of coordinates in which to output the information as well as a choice in the output format of the information acquired. </p> Loading @@ -24,12 +24,13 @@ </p> <p> The point of interest in the image can be entered as <def>Latitude</def>/<def>Longitude</def> coordinates or <def>Line</def>/<def>Sample</def> coordinates. Keep in mind coordinates or <def>Sample</def>/<def>Line</def> coordinates. Keep in mind that the input <def>Latitude</def> and <def>Longitude</def> values entered will be interpreted as <def link="Universal Coordinate">Universal Coordinates</def> (ISIS default) regardless of the target body. In the output, all positions are in <def link="Body Fixed Coordinate">Body-Fixed</def> Coordinates. Coordinates. Multiple points of interest may be specified by providing a comma-delimited flatfile of coordinates. </p> <p> The following is a partial list of coordinates computed in the <i>campt</i> application:<br /> Loading Loading @@ -106,8 +107,16 @@ Group = GroundPoint <def>UTC</def> = 1997-10-20T10:58:37.6570806 LocalSolarTime = 17.089704420784 <hour> <def link="Solar Longitude">SolarLongitude</def> = 201.83159041209 Error = NULL End_Group </pre> <p> Note: The "Error" keyword will only appear when using a coordinate list. The value of "Error" will be NULL unless an error occurs during the processing of a coordinate in the <a href="#FilesCOORDLIST">coordinate list</a>. Then, the value of this keyword will be the error message. </p> </description> <category> Loading Loading @@ -184,6 +193,13 @@ End_Group "Related Objects and Documents" section of the documentation. Fixes mantis ticket #1525. </change> <change name="Ian Humphrey" date="2014-11-05"> Added new parameters, USECOORDLIST, COORDLIST, and COORDTYPE for processing a list of points as input. Reorganized campt. Fixes #1449. </change> <change name="Ian Humphrey" date="2015-03-03"> Updated documentation. References #1449. </change> </history> <oldName> Loading Loading @@ -217,6 +233,100 @@ End_Group </filter> </parameter> <parameter name = "USECOORDLIST"> <type>boolean</type> <default><item>FALSE</item></default> <brief> Enable coordinate list parameters in the GUI </brief> <description> Selecting this parameter will enable the 'COORDLIST' and 'COORDTYPE' parameters in the GUI. <p> Note that this parameter is optional when running <i>campt</i> on the command line. </p> </description> <inclusions> <item>COORDLIST</item> <item>COORDTYPE</item> </inclusions> <exclusions> <item>TYPE</item> <item>SAMPLE</item> <item>LINE</item> <item>LATITUDE</item> <item>LONGITUDE</item> </exclusions> </parameter> <parameter name="COORDLIST"> <type>filename</type> <fileMode>input</fileMode> <brief> Input comma-delimited file of image or ground coordinates </brief> <internalDefault>None</internalDefault> <description> An input comma-delimited flatfile of image coordinates or ground coordinates. This allows the program to process multiple coordinates in a single run of <i>campt</i>, and output the results to the specified output file. <p> Expected order for image coordinates: sample, line<br/> Expected order for ground coordinates: latitude, longitude </p> <p> The "Error" keyword will only appear when using a coordinate list. The value of "Error" will then be NULL unless an error occurs during the processing of a coordinate in the coordinate list. Then, the value of this keyword will be the error message. This allows for <i>campt</i> to continue processing the remaining coordinates in the coordinate list. </p> <p> For the input of Latitude and Longitude, campt expects <def>Planetocentric Latitude</def> (within -90 to 90 boundary) and <def>Positive East Longitude</def> (with 0-360 boundary) to find the location in the input camera image. </p> </description> <exclusions> <item>TYPE</item> <item>SAMPLE</item> <item>LINE</item> <item>LATITUDE</item> <item>LONGITUDE</item> </exclusions> </parameter> <parameter name="COORDTYPE"> <type>string</type> <brief>Coordinate type selection (Image or Ground) for 'COORDLIST'</brief> <list> <option value="IMAGE"> <brief>Interprets coordinates in 'COORDLIST' as sample/line</brief> <description> This option interprets the coordinates provided in the input coordinate list file as sample/line and will compute latitude/longitude and Projection x/y. </description> </option> <option value="GROUND"> <brief>Interprets the coordinates in 'COORDLIST' as latitude/longitude</brief> <description> This option interprets the coordinates provided in the input coordinate list file as latitude/longitude and will compute sample/line and Projection x/y. </description> </option> </list> <description> This parameter is used to select the type of coordinates entered in the coordinate list file, which will be used to determine the method to compute the geometric and photometric information. </description> <exclusions> <item>TYPE</item> </exclusions> </parameter> <parameter name="TO"> <type>filename</type> <fileMode>output</fileMode> Loading Loading @@ -273,6 +383,32 @@ End_Group </description> <default><item>TRUE</item></default> </parameter> <parameter name="ALLOWOUTSIDE"> <type>boolean</type> <brief> Allow sample/line values outside the image to be reported </brief> <description> The Allowoutside parameter influences how <i>campt</i> will report resulting latitude/longitude and sample/line coordinates that fall outside the input cube pixel boundaries. <p> The default is set to True, which allows <i>campt</i> to return the values that are outside the cube pixel boundaries. For example, a given latitude/longitude might return a sample location of -1.0 (a single whole pixel coordinate off the left side of the image). This is a feature of the ISIS camera models. </p> <p> When set to False, if a returned coordinate is off the image, <i>campt</i> will fail. This failure can be indicated and ignored within a batch script when only coordinates that fall within the image cube pixel boundaries are desired. </p> </description> <default><item>TRUE</item></default> </parameter> </group> <group name="Position"> Loading Loading @@ -319,7 +455,7 @@ End_Group <internalDefault>Center sample</internalDefault> <description> This is the <def>Sample</def> position used to compute information about the input cube at the pixel. at a given pixel location in the input image cube. </description> </parameter> Loading @@ -332,7 +468,7 @@ End_Group <internalDefault>Center line</internalDefault> <description> This is the <def>Line</def> position used to compute information about the input cube at the pixel. at a given pixel location in the input image cube. </description> </parameter> Loading Loading @@ -368,32 +504,6 @@ End_Group <minimum inclusive="yes">0.0</minimum> <maximum inclusive="yes">360.0</maximum> </parameter> <parameter name="ALLOWOUTSIDE"> <type>boolean</type> <brief> Allow sample/line values outside the image to be reported </brief> <description> The Allowoutside parameter influences how <i>campt</i> will report resulting latitude/longitude and sample/line coordinates that fall outside the input cube pixel boundaries. <p> The default is set to True, which allows <i>campt</i> to return the values that are outside the cube pixel boundaries, For example, a given latitude/longitude might return a sample location of -1.0 (a single whole pixel coordinate off the left side of the image). This is a feature of the ISIS camera models. </p> <p> When set to False, if a returned coordinate is off the image, <i>campt</i> will fail. This failure can be indicated and ignored within a batch script when only coordinates that fall within the image cube pixel boundaries are desired. </p> </description> <default><item>true</item></default> </parameter> </group> </groups> </application>
isis/src/base/apps/campt/tsts/errors/Makefile 0 → 100644 +19 −0 Original line number Diff line number Diff line # test for exceptions thrown # the coordinate list is invalid if number of rows and columns don't match # the coordinate list is invalid if there are not 2 columns # no output file is provided when specifying the FORMAT as FLAT APPNAME = campt include $(ISISROOT)/make/isismake.tsts commands: -$(APPNAME) from=$(INPUT)/ab102401.cub \ to=$(OUTPUT)/output.pvl \ coordlist=$(INPUT)/badlist.csv \ coordtype=IMAGE 2> $(OUTPUT)/errorsTruth.txt > /dev/null; -$(APPNAME) from=$(INPUT)/ab102401.cub \ to=$(OUTPUT)/output.pvl \ coordlist=$(INPUT)/badcolumns.csv \ coordtype=IMAGE 2>> $(OUTPUT)/errorsTruth.txt > /dev/null; -$(APPNAME) from=$(INPUT)/ab102401.cub \ format=FLAT 2>> $(OUTPUT)/errorsTruth.txt > /dev/null;
isis/src/base/apps/campt/tsts/no_sample_line/Makefile 0 → 100644 +16 −0 Original line number Diff line number Diff line # test for not providing a sample or line value (defaults to center) # also tests for not providing a value to the TO parameter APPNAME = campt include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/ab102401.cub \ > $(OUTPUT)/noSampleLineTruth.txt; cat $(OUTPUT)/noSampleLineTruth.txt | \ $(SED) 's/\([0-9]*\.[0-9]\{5\}\)[0-9]*/\1/g' | \ $(SED) '/Filename.*/ { N; N; N; N; s/-\n[ ]*//g; }' | \ $(SED) 's/\(.*= \).*\(ab102401.cub\)/\1\2/' \ >& $(OUTPUT)/noSampleLineTruthtmp.txt; $(MV) $(OUTPUT)/noSampleLineTruthtmp.txt \ $(OUTPUT)/noSampleLineTruth.txt;
isis/src/base/apps/campt/tsts/pointlist_append/Makefile 0 → 100644 +32 −0 Original line number Diff line number Diff line APPNAME = campt include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ to=$(OUTPUT)/pointlistAppendTruth.pvl \ coordtype=IMAGE > /dev/null; $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ to=$(OUTPUT)/pointlistAppendTruth.pvl \ coordtype=IMAGE > /dev/null; cat $(OUTPUT)/pointlistAppendTruth.pvl | \ $(SED) '/Filename.*/ { N; N; N; N; s/-\n[ ]*//g; }' | \ $(SED) 's/\(.*= \).*\(ab102401.cub\)/\1\2/g' \ > $(OUTPUT)/pointlistAppendTruthtmp.pvl; $(MV) $(OUTPUT)/pointlistAppendTruthtmp.pvl \ $(OUTPUT)/pointlistAppendTruth.pvl; $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ format=FLAT coordtype=IMAGE \ to=$(OUTPUT)/pointlistAppendTruth.csv > /dev/null; $(APPNAME) from=$(INPUT)/ab102401.cub \ coordlist=$(INPUT)/image.lis \ format=FLAT coordtype=IMAGE \ to=$(OUTPUT)/pointlistAppendTruth.csv > /dev/null; cat $(OUTPUT)/pointlistAppendTruth.csv | \ $(SED) 's/^.*\(ab102401.cub\)\(.*\)/\1\2/g' \ > $(OUTPUT)/pointlistAppendTruthtmp.csv; $(MV) $(OUTPUT)/pointlistAppendTruthtmp.csv \ $(OUTPUT)/pointlistAppendTruth.csv;