Commit 041c1600 authored by Janet Barrett's avatar Janet Barrett
Browse files

Added ALLOWOUTSIDE parameter to mappt and changed so it reports when the...

Added ALLOWOUTSIDE parameter to mappt and changed so it reports when the resulting line,sample is off the image. Fixes #1929.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5948 41f8697f-d340-4b68-9986-7bafba869bb8
parent c3b24f3b
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -35,11 +35,20 @@ void IsisMain() {

  // Get the coordinate
  UserInterface &ui = Application::GetUserInterface();
  bool outsideAllowed = ui.GetBoolean("ALLOWOUTSIDE");
  int cubeLineLimit = icube->lineCount() + .5;
  int cubeSampleLimit = icube->sampleCount() + .5;

  // Get the sample/line position if we have an image point
  if(ui.GetString("TYPE") == "IMAGE") {
    double samp = ui.GetDouble("SAMPLE");
    double line = ui.GetDouble("LINE");
    if (!outsideAllowed) {
      if (samp < .5 || line < .5 || samp > cubeSampleLimit || line > cubeLineLimit) {
        QString error = "Requested line,sample is not on the image";
        throw IException(IException::Unknown, error, _FILEINFO_);
      }
    }
    proj->SetWorld(samp, line);
  }

@@ -132,6 +141,18 @@ void IsisMain() {
    proj->SetCoordinate(x, y);
  }

  PvlGroup results("Results");
  if (proj->WorldX() < .5 || proj->WorldY() < .5 || proj->WorldX() > cubeSampleLimit ||
      proj->WorldY() > cubeLineLimit) {
    if (!outsideAllowed) {
      QString error = "Resulting line,sample is not on the image";
      throw IException(IException::Unknown, error, _FILEINFO_);
    }
    else {
      results += PvlKeyword("OutsideOfImage", "Requested point falls outside of image boundaries");
    }
  }

  // Create Brick on samp, line to get the dn value of the pixel
  Brick b(1, 1, 1, icube->pixelType());
  int intSamp = (int)(proj->WorldX() + 0.5);
@@ -141,7 +162,6 @@ void IsisMain() {

  // Log the position
  if(proj->IsGood()) {
    PvlGroup results("Results");
    results += PvlKeyword("Filename",
                          FileName(ui.GetFileName("FROM")).expanded());
    results += PvlKeyword("Sample", toString(proj->WorldX()));
+34 −0
Original line number Diff line number Diff line
@@ -85,6 +85,14 @@
      Changed the order in which the keywords are output to the csv, not the pvl, so it no longer
      depends on the coordinate system of the input cube. Fixes #1614.
    </change>
    <change name="Janet Barrett" date="2014-08-04">
      Added new parameter, ALLOWOUTSIDE, to control the reporting of latitude/longitude 
      and line/sample information that falls outside the boundaries of the image. Also 
      added a message to the output results if the line,sample falls outside the image
      boundaries, regardless of the setting of the ALLOWOUTSIDE parameter. This will
      help the user detect results that fall outside the image even if they are allowing
      for it. Fixes #1929.
    </change>
  </history>

  <groups>
@@ -299,6 +307,32 @@
           will be a projection Y value in meters.
        </description>
      </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>mappt</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>mappt</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>mappt</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="Coordinate System">
+12 −0
Original line number Diff line number Diff line
APPNAME = mappt

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/mola_clon0.cub \
	  to=$(OUTPUT)/mappt.pvl \
	  append=false \
          type=ground \
	  latitude=17 \
          longitude=10 \
          > /dev/null;