Пример #1
0
void ossimHillshadeTool::setUsage(ossimArgumentParser& ap)
{
   // Add global usage options.
   ossimInit::instance()->addOptions(ap);
   
   // Set app name.
   ossimString appName = ap.getApplicationName();
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = appName;
   usageString += " hillshade [option]... [input-option]... <input-file(s)> <output-file>\nNote at least one input is required either from one of the input options, e.g. --input-dem <my-dem.hgt> or adding to command line in front of the output file in which case the code will try to ascertain what type of input it is.\n\nAvailable traces:\n-T \"ossimChipperUtil:debug\"   - General debug trace to standard out.\n-T \"ossimChipperUtil:log\"     - Writes a log file to output-file.log.\n-T \"ossimChipperUtil:options\" - Writes the options to output-file-options.kwl.";
   au->setCommandLineUsage(usageString);

   // Add arguments.
   au->addCommandLineOption("--azimuth", "<azimuth>\nLight source azimuth angle for bump shade.\nRange: 0 to 360, Default = 180.0");
   au->addCommandLineOption("--color","<r> <g> <b>\nSet the red, green and blue color values to be used with hillshade.\nRange 0 to 255, Defualt r=255, g=255, b=255");
   au->addCommandLineOption("--color-source","<file>\nSpecifies the image file to use as a color source instead of a fixed RGB value.");
   au->addCommandLineOption("--elevation", "<elevation>\nhillshade option - Light source elevation angle for bumb shade.\nRange: 0 to 90, Default = 45.0");

   // Base class has its own:
   ossimChipProcTool::setUsage(ap);

   ostringstream description;
   description << DESCRIPTION << "\n\nNOTES:\n"
      << "1) Never use same base name in the same directory! Example is you have a Chicago.tif\n"
      << "   and you want a Chicago.jp2, output Chicago.jp2 to its own directory.\n"
      << "\nExample command to Hill shade: Hill shade two DEMs, output to a geotiff.\n"
      << appName << " --color 255 255 255 --azimuth 270 --elevation 45 --exaggeration 2.0 N37W123.hgt N38W123.hgt outputs/hillshade.tif\n"
      << "\n// Above command where all options are in a keyword list:\n"
      << appName << " --options r39-options.kwl\n"
      << std::endl;

   au->setDescription(description.str());

}
Пример #2
0
void ossimImageUtil::addArguments(ossimArgumentParser& ap)
{
   // Set the general usage:
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] <file-or-directory-to-walk>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->addCommandLineOption("-a or --include-fullres", "Copy full res dataset to overview file as well as building reduced res sets. Option only valid with tiff overview builder. Requires -o option.");

   au->addCommandLineOption("--compression-quality", "Compression quality for TIFF JPEG takes values from 0 to 100, where 100 is best.  For J2K plugin, numerically_lossless, visually_lossless, lossy");
   
   au->addCommandLineOption("--compression-type", "Compression type can be: deflate, jpeg, lzw, none or packbits");

   au->addCommandLineOption("--ch or --create-histogram", "Computes full histogram alongside overview.");
   
   au->addCommandLineOption("--chf or --create-histogram-fast", "Computes a histogram in fast mode which samples partial tiles.");

   au->addCommandLineOption("--create-histogram-r0", "Forces create-histogram code to compute a histogram using r0 instead of the starting resolution for the overview builder. Can require a separate pass of R0 layer if the base image has built in overviews.");

   au->addCommandLineOption("-d", "<output_directory> Write overview to output directory specified.");

   au->addCommandLineOption("--dump-filtered-image-list", "Outputs list of filtered images.");
   
   au->addCommandLineOption("-h", "Display this information");

   au->addCommandLineOption("-i or --internal-overviews", "Builds internal overviews. Requires -o option. Option only valid with tiff input image and tiff overview builder. WARNING: Modifies source image and cannot be undone!");
   
   au->addCommandLineOption("--list-entries", "Lists the entries within the image");

   au->addCommandLineOption("-o", "Creates overviews. (default=ossim_tiff_box)");

   au->addCommandLineOption("--of or --output-files", "Output image files we can open, exluding overviews.");
   
   au->addCommandLineOption("--ot", "<overview_type> Overview type. see list at bottom for valid types. (default=ossim_tiff_box)");

   au->addCommandLineOption("--override-filtered-images", "Allows processing of file that is in the filtered image list.");

   au->addCommandLineOption("-r or --rebuild-overviews", "Rebuild overviews even if they are already present.");
   
   au->addCommandLineOption("--rebuild-histogram", "Rebuild histogram even if they are already present.");

   au->addCommandLineOption("--reader-prop", "Adds a property to send to the reader. format is name=value");

   au->addCommandLineOption("-s",  "Stop dimension for overviews.  This controls how \nmany layers will be built. If set to 64 then the builder will stop when height and width for current level are less than or equal to 64.  Note a default can be set in the ossim preferences file by setting the keyword \"overview_stop_dimension\".");

   au->addCommandLineOption("--tile-size", "<size> Defines the tile size for overview builder.  Tiff option only. Must be a multiple of 16. Size will be used in both x and y directions. Note a default can be set in your ossim preferences file by setting the key \"tile_size\".");

   au->addCommandLineOption("--threads", "<threads> The number of threads to use. (default=1) Note a default can be set in your ossim preferences file by setting the key \"ossim_threads\".");

   au->addCommandLineOption("--scanForMinMax", "Turns on min, max scanning when reading tiles. This option assumes the null is known.");

   au->addCommandLineOption("--scanForMinMaxNull", "Turns on min, max, null scanning when reading tiles.  This option tries to find a null value which is useful for float data.");

   au->addCommandLineOption("--writer-prop", "Adds a property to send to the writer. format is name=value");
   
} // void ossimImageUtil::addArguments(ossimArgumentParser& ap)
Пример #3
0
bool ossimHillshadeTool::initialize(ossimArgumentParser& ap)
{
   // Permit base class to pull out common options first.
   if (!ossimChipProcTool::initialize(ap))
      return false;
   if (m_helpRequested)
      return true;

   std::string tempString1;
   ossimArgumentParser::ossimParameter stringParam1(tempString1);
   std::string tempString2;
   ossimArgumentParser::ossimParameter stringParam2(tempString2);
   std::string tempString3;
   ossimArgumentParser::ossimParameter stringParam3(tempString3);
   std::string tempString4;
   ossimArgumentParser::ossimParameter stringParam4(tempString4);
   std::string tempString5;
   ossimArgumentParser::ossimParameter stringParam5(tempString5);
   std::string tempString6;
   ossimArgumentParser::ossimParameter stringParam6(tempString6);
   double tempDouble1;
   ossimArgumentParser::ossimParameter doubleParam1(tempDouble1);
   double tempDouble2;
   ossimArgumentParser::ossimParameter doubleParam2(tempDouble2);
   
   // Extract optional arguments and stuff them in a keyword list.
   if( ap.read("--azimuth", stringParam1) )
   {
      m_kwl.addPair( std::string(ossimKeywordNames::AZIMUTH_ANGLE_KW), tempString1 );
   }

   if( ap.read("--color", stringParam1, stringParam2, stringParam3) )
   {
      m_kwl.addPair( COLOR_RED_KW,   tempString1 );
      m_kwl.addPair( COLOR_GREEN_KW, tempString2 );
      m_kwl.addPair( COLOR_BLUE_KW,  tempString3 );
   }

   int color_source_idx = 0;
   while( ap.read("--color-source", stringParam1) )
   {
      ossimString key = COLOR_SOURCE_KW;
      key += ossimString::toString(color_source_idx++);
      key += ".";
      key += ossimKeywordNames::FILE_KW;
      m_kwl.addPair(key.string(), tempString1 );
   }

   if ( ap.read("--elevation", stringParam1) )
   {
      m_kwl.addPair( std::string(ossimKeywordNames::ELEVATION_ANGLE_KW), tempString1 );
   }

   processRemainingArgs(ap);
   return true;
}
Пример #4
0
void ossimOrthoTool::setUsage(ossimArgumentParser& ap)
{
   // Add options.
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " ortho [options] [<input-image>] <output-image>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->setDescription(DESCRIPTION);

   // Base class has its own:
   ossimChipProcTool::setUsage(ap);
}
Пример #5
0
void ossimPotraceUtil::setUsage(ossimArgumentParser& ap)
{
   // Add global usage options.
   ossimUtility::setUsage(ap);

   // Set the general usage:
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] <output-vector-file>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->addCommandLineOption("--tolerance <float>",
         "tolerance +- deviation from threshold for marginal classifications. Defaults to 0.05.");
}
Пример #6
0
bool ossimShorelineUtil::initialize(ossimArgumentParser& ap)
{
   if (!ossimChipProcUtil::initialize(ap))
      return false;

   string ts1;
   ossimArgumentParser::ossimParameter sp1(ts1);
   string ts2;
   ossimArgumentParser::ossimParameter sp2(ts2);
   string ts3;
   ossimArgumentParser::ossimParameter sp3(ts3);

   if ( ap.read("--algorithm", sp1))
      m_kwl.addPair(ALGORITHM_KW, ts1);

   if (ap.read("--color-coding", sp1, sp2, sp3))
   {
      ostringstream value;
      value<<ts1<<" "<<ts2<<" "<<ts3;
      m_kwl.addPair( COLOR_CODING_KW, value.str() );
   }

   if ( ap.read("--edge"))
      m_kwl.addPair(DO_EDGE_DETECT_KW, string("true"));

   if ( ap.read("--raster"))
      m_kwl.addPair(RASTER_KW, string("true"));

   if ( ap.read("--sensor", sp1))
      m_kwl.addPair(ossimKeywordNames::SENSOR_ID_KW, ts1);

   if ( ap.read("--sigma", sp1))
      m_kwl.addPair(SIGMA_KW, ts1);

   if ( ap.read("--smooth", sp1))
      m_kwl.addPair(SMOOTHING_KW, ts1);

   if ( ap.read("--threshold", sp1))
      m_kwl.addPair(THRESHOLD_KW, ts1);

   if ( ap.read("--tolerance", sp1))
      m_kwl.addPair(TOLERANCE_KW, ts1);

   // Fake the base class into thinking there is a default output filename to avoid it complaining,
   // since this utility will stream vector output to console if no output file name provided:
   m_kwl.add( ossimKeywordNames::OUTPUT_FILE_KW, DUMMY_OUTPUT_FILENAME.c_str());

   processRemainingArgs(ap);
   return true;
}
Пример #7
0
void ossimBandMergeUtil::setUsage(ossimArgumentParser& ap)
{
   // Add options.
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " -r <red_band> -g <green_band> -b <blue_band> <output-rgb-image>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->setDescription(DESCRIPTION);

   // Base class has its own:
   ossimChipProcUtil::setUsage(ap);

   au->addCommandLineOption("--red", "<filename> Filename of red band. ");
   au->addCommandLineOption("--green", "<filename> Filename of green band. ");
   au->addCommandLineOption("--blue", "<filename> Filename of blue band. ");
}
Пример #8
0
void ossimSlopeUtil::setUsage(ossimArgumentParser& ap)
{
   // Add options.
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] <output-image>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->addCommandLineOption(
         "--center <lat> <lon>",
         "The center position of the output product. Required if no input DEM is specified.");
   au->addCommandLineOption(
         "--dem <filename>",
         "Specifies the input DEM filename. If none provided, the elevation database is referenced "
         "as specified in prefs file for the center and ROI specified.");
   au->addCommandLineOption(
         "--remap",
         "The range of slope angle (0.0 to 90.0) is remapped to 0-255 (one byte/pixel)");
   au->addCommandLineOption(
         "--lut <filename>",
         "Specifies the optional lookup table filename for mapping the single-band output "
         "image to an RGB. The LUT provided must be in the ossimIndexToRgbLutFilter format "
         "and should accommodate the output pixel range. This option forces remap to 8-bit, "
         "0-255 where 255 = 90 deg slope");
   au->addCommandLineOption(
         "--roi <meters>",
         "radius of interest surrounding the center point. If absent, the product defaults to "
         "1024 x 1024 pixels, with a radius of 512 * GSD. Alternatively, if a DEM file is "
         "specified, the product ROI defaults to the full DEM coverage.");

   ossimString description =
         "Utility for computing the slope at each elevation post and generating "
         "a corresponding slope image. The output scalar type is a normalized float with 1.0 = 90 "
         "degree angle from the local vertical. Optional 8-bit scalar type is available."
         "Examples:\n\n"
         "    ossim-slope [options] --dem <input-dem> <output-slope-image-file>\n"
         "    ossim-slope [options] --center <lat> <lon> --roi <meters> <output-slope-image-file>\n";
   au->setDescription(description);

   // Base class has its own:
   ossimUtility::setUsage(ap);
}
Пример #9
0
void ossimShorelineUtil::setUsage(ossimArgumentParser& ap)
{
   // Add global usage options.
   ossimChipProcUtil::setUsage(ap);

   // Set the general usage:
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] [<output-vector-filename>]";
   au->setCommandLineUsage(usageString);
   au->setDescription("Computes vector shoreline from raster imagery. The vectors are output "
         "in GeoJSON format. If an output filename is specified, the JSON is written to it. "
         "Otherwise it is written to the console.");

   // Set the command line options:
   au->addCommandLineOption("--algorithm <name>",
         "Specifies detection algorithm to apply. Supported names are \"ndwi\" (requires 2 input "
         "bands: 3 and 5|6) (default), \"awei\" (requires 4 input bands: 3, 6, 5, and 7).");
   au->addCommandLineOption("--color-coding <water> <marginal> <land>",
         "Specifies the pixel values (0-255) for the output product corresponding to water, marginal, "
         "and land zones. Defaults to 0, 128, and 255, respectively.");
   au->addCommandLineOption("--edge",
         "Directs the processing to perform an edge detection instead of outputing a vector product."
         " Defaults to FALSE.");
    au->addCommandLineOption("--raster",
         "Outputs the raster result of indexed image instead of a vector product. For engineering purposes.");
    au->addCommandLineOption("--sensor <string>",
           "Sensor used to compute Modified Normalized Difference Water Index. Currently only "
           "\"ls8\" supported (default).");
    au->addCommandLineOption("--sigma <float>",
           "The multiple of standard deviations below the NDWI water mean to use for threshold. "
           "Defaults to 1.5");
   au->addCommandLineOption("--smooth <sigma>",
         "Applies gaussian filter to index raster file. The filter sigma must be specified (0.2 is good). Sigma=0 "
         "indicates no smoothing.");
   au->addCommandLineOption("--threshold <0.0-1.0>",
         "Normalized threshold for converting the image to bitmap. Defaults to 0.55. Alternatively "
         "can be set to 'X' to skip thresholding operation. If none specified, an optimized threshold"
         " is computed.");
   au->addCommandLineOption("--tolerance <float>",
         "tolerance +- deviation from threshold for marginal classifications. Defaults to 0.01.");
}
Пример #10
0
void ossimHlzUtil::setUsage(ossimArgumentParser& ap)
{
   // Add global usage options.
   ossimChipProcUtil::setUsage(ap);

   // Set the general usage:
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] <output-image>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->addCommandLineOption("--exclude-regions <file1>[, <file2>...]",
         "List of raster image(s) representing mask files that defines regions to be excluded from "
         "HLZ solutions. Any non-zero pixel is excluded Multiple filenames must be comma-separated.");
   au->addCommandLineOption("--hlz-coding <bad> <marginal> <good>",
         "Specifies the pixel values (0-255) for the output product corresponding to bad, marginal, "
         "and good landing zones, respectively. Defaults to bad=255 (null), marginal=128, and "
         "good=64.");
   au->addCommandLineOption("--include-regions <file1>[, <file2>...]",
         "List of raster image(s) representing mask files that defines regions where the HLZs ."
         "identified must overlap. Any non-zero pixel represents an inclusion zone. Multiple "
         "filenames must be comma-separated.");
   au->addCommandLineOption("--output-slope <filename.tif>",
         "Generates a slope byproduct image (floating point degrees) to the specified filename. "
         "Only valid if normal-vector method used (i.e., --ls-fit option NOT specified)");
   au->addCommandLineOption("--point-clouds <file1>[, <file2>...]",
         "Specifies ancillary point-cloud data file(s) for level-2 search for obstructions. "
         "Must be comma-separated file names.");
   au->addCommandLineOption("--min-lz-radius <meters>",
         "Specifies minimum radius of landing zone. Defaults to 25 m. ");
   au->addCommandLineOption("--max-roughness <meters>",
         "Specifies the terrain roughness threshold (meters). This is the maximum deviation from a "
         "flat plane permitted. Defaults to 0.5 m. Valid only with --ls-fit specified.");
   au->addCommandLineOption("--max-slope <degrees>",
         "Threshold for acceptable landing zone terrain slope. Defaults to 7 deg.");
   au->addCommandLineOption("--threads <n>",
         "Number of threads. Defaults to use single core. For engineering/debug purposes.");
   au->addCommandLineOption("--use-slope",
         "Slope is computed from the normal vector using neighboring posts instead of "
         "least-squares fit to a plane (prefered). For engineering/debug purposes.");
}
Пример #11
0
bool ossimBandMergeUtil::initialize(ossimArgumentParser& ap)
{
   if (!ossimChipProcUtil::initialize(ap))
      return false;

   ostringstream xmsg;

   std::string ts1;
   ossimArgumentParser::ossimParameter sp1 (ts1);
   int band_count = 0;

   if ( ap.read("--red", sp1))
   {
      ostringstream key;
      key<<ossimKeywordNames::IMAGE_FILE_KW<<"0";
      m_kwl.addPair( key.str(), ts1 );
      ++band_count;
   }
   if ( ap.read("--green", sp1))
   {
      ostringstream key;
      key<<ossimKeywordNames::IMAGE_FILE_KW<<"1";
      m_kwl.addPair( key.str(), ts1 );
      ++band_count;
   }
   if ( ap.read("--blue", sp1))
   {
      ostringstream key;
      key<<ossimKeywordNames::IMAGE_FILE_KW<<"2";
      m_kwl.addPair( key.str(), ts1 );
      ++band_count;
   }
   if (band_count != 3)
   {
      ossimNotify(ossimNotifyLevel_NOTICE)<<"ossimBandMergeUtil:"<<__LINE__
            <<" Must supply three band filenames."<<endl;
      return false;
   }

   processRemainingArgs(ap);
   return true;
}
Пример #12
0
static void usage(ossimArgumentParser& ap)
{
   // Add global usage options.
   ossimInit::instance()->addOptions(ap);
   
   ossimApplicationUsage* au = ap.getApplicationUsage();
   
   // Set app name.
   au->setApplicationName(ap.getApplicationName());
   
   au->setDescription(ossimString("Returns pixel value at the given sample and line.\nNotes:\nBand, line and sample are zero based.\nUse an \"a\" for <band> if you want to see all bands.\n"));
   
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] <imagefile> <band> <sample> <line>\n";
   au->setCommandLineUsage(usageString);
   
   au->addCommandLineOption("-e","<entry_index> Entry index to get pixel from.  Only significant with multi entry data only.");

   au->addCommandLineOption("--reader-prop","Passes a name=value pair to the reader(s) for setting it's property.  Any number of these can appear on the line.");
   
   // Write usage.
   au->write(ossimNotify(ossimNotifyLevel_INFO));
}
Пример #13
0
void ossimImageUtil::usage(ossimArgumentParser& ap)
{
   // Add global usage options.
   ossimInit::instance()->addOptions(ap);
   
   // Set app name.
   ap.getApplicationUsage()->setApplicationName(ap.getApplicationName());

   // Add options.
   addArguments(ap);
   
   // Write usage.
   ap.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_INFO));

   outputOverviewWriterTypes();
   
   ossimNotify(ossimNotifyLevel_INFO)
      << "\nExample commands:\n"
      << "\n// A single image standard tiff overviews, histogram:\n"
      << "ossim-preproc -o --ch <file>\n"
      << "\n// A single image with j2k overviews(requires kakadu plugin), histogram:\n"
      << "ossim-preproc --ot ossim_kakadu_nitf_j2k --ch <file>\n"
      << "\n// j2k, histogram, 4 threads\n"
      << "\n// standard tiff overviews, full histogram, 4 threads:\n"
      << "ossim-preproc -r -o --ch --threads 4 <directory_to_walk>\n"
      << "\n// j2k, histogram (fast mode), 4 threads\n"
      << "ossim-preproc -r --ot ossim_kakadu_nitf_j2k --chf --threads 4 "
      << "<directory_to_walk>\n"
      << "\n// tiff, jpeg compression, histogram, 4 threads\n"
      << "ossim-preproc -r --ch --compression-quality 75 --compression-type "
      << "jpeg --threads 4 <directory_to_walk>\n"
      << "\nNOTES:\n"
      << "\n  --ch  equals --create-histogram"
      << "\n  --chf equals --create-histogram-fast"
      << std::endl;
}
Пример #14
0
bool ossimPotraceUtil::initialize(ossimArgumentParser& ap)
{
   string ts1;
   ossimArgumentParser::ossimParameter sp1(ts1);
   string ts2;
   ossimArgumentParser::ossimParameter sp2(ts2);
   string ts3;
   ossimArgumentParser::ossimParameter sp3(ts3);

   if ( ap.read("--tolerance", sp1))
      m_kwl.addPair(TOLERANCE_KW, ts1);

   if (!ossimUtility::initialize(ap))
      return false;
   return true;
}
Пример #15
0
bool ossimViewshedUtil::initialize(ossimArgumentParser& ap)
{
   // Base class first:
   if (!ossimUtility::initialize(ap))
      return false;

   std::string ts1;
   ossimArgumentParser::ossimParameter sp1(ts1);
   std::string ts2;
   ossimArgumentParser::ossimParameter sp2(ts2);
   std::string ts3;
   ossimArgumentParser::ossimParameter sp3(ts3);

   if (ap.read("--dem", sp1) || ap.read("--dem-file", sp1))
      m_demFile = ts1;

   if ( ap.read("--fov", sp1, sp2) )
   {
      m_startFov = ossimString(ts1).toDouble();
      m_stopFov = ossimString(ts2).toDouble();
      if (m_startFov < 0)
         m_startFov += 360.0;
   }

   if ( ap.read("--gsd", sp1) )
      m_gsd = ossimString(ts1).toDouble();

   if ( ap.read("--hgt-of-eye", sp1) || ap.read("--height-of-eye", sp1) )
      m_obsHgtAbvTer = ossimString(ts1).toDouble();

   if ( ap.read("--horizon", sp1) || ap.read("--horizon-file", sp1))
      m_horizonFile = ossimString(ts1);

   if ( ap.read("--lut", sp1) || ap.read("--lut-file", sp1))
      m_lutFile = ts1;

   if ( ap.read("--observer", sp1, sp2) )
   {
      m_observerGpt.lat = ossimString(ts1).toDouble();
      m_observerGpt.lon = ossimString(ts2).toDouble();
      m_observerGpt.hgt = 0.0;
   }

   if ( ap.read("--radius", sp1) )
      m_visRadius = ossimString(ts1).toDouble();

   if ( ap.read("--reticle", sp1) )
      m_reticleSize = ossimString(ts1).toInt32();

   if ( ap.read("--tbs") )
      m_threadBySector = true;

   if ( ap.read("--simulation") )
      m_simulation = true;

   if ( ap.read("--summary") )
      m_outputSummary = true;

   if ( ap.read("--size", sp1) )
      m_halfWindow = ossimString(ts1).toUInt32() / 2;

   if ( ap.read("--threads", sp1) )
      m_numThreads = ossimString(ts1).toUInt32();

   if ( ap.read("--values", sp1, sp2, sp3) )
   {
      m_visibleValue = ossimString(ts1).toUInt8();
      m_hiddenValue = ossimString(ts2).toUInt8();
      m_observerValue = ossimString(ts3).toUInt8();
   }

   // There should only be the required command line args left:
   if ( (m_observerGpt.hasNans() && (ap.argc() != 4)) ||
        (!m_observerGpt.hasNans() && (ap.argc() != 2)) )
   {
      setUsage(ap);
      return false;
   }

   // Verify minimum required args were specified:
   if (m_demFile.empty() && (m_visRadius == 0) && (m_halfWindow == 0))
   {
      ossimNotify(ossimNotifyLevel_WARN)
                  << "ossimViewshedUtil::initialize ERR: Command line is underspecified."
                  << std::endl;
      setUsage(ap);
      return false;
   }

   // Parse the required command line params:
   int ap_idx = 1;
   if (m_observerGpt.hasNans())
   {
      m_observerGpt.lat =  ossimString(ap[1]).toDouble();
      m_observerGpt.lon =  ossimString(ap[2]).toDouble();
      m_observerGpt.hgt =  0;
      ap_idx = 3;
   }
   m_filename = ap[ap_idx];

   return initializeChain();
}
Пример #16
0
bool ossimHlzUtil::initialize(ossimArgumentParser& ap)
{
   if (!ossimChipProcUtil::initialize(ap))
      return false;

   string ts1;
   ossimArgumentParser::ossimParameter sp1(ts1);
   string ts2;
   ossimArgumentParser::ossimParameter sp2(ts2);
   string ts3;
   ossimArgumentParser::ossimParameter sp3(ts3);
   ossimString  key ;

   vector<ossimString> maskFnames;
   ap.read("--exclude-regions", maskFnames);
   for(ossim_uint32 idx=0; idx<maskFnames.size(); ++idx)
   {
      key = MASK_EXCLUDE_KW;
      key += ossimString::toString(idx++);
      m_kwl.addPair(key.string(), maskFnames[idx] );
   }

   if (ap.read("--hlz-coding", sp1, sp2, sp3) || ap.read("--values", sp1, sp2, sp3))
   {
      ostringstream value;
      value<<ts1<<" "<<ts2<<" "<<ts3;
      m_kwl.addPair( HLZ_CODING_KW, value.str() );
   }

   maskFnames.clear();
   ap.read("--include-regions", maskFnames);
   for(ossim_uint32 idx=0; idx<maskFnames.size(); ++idx)
   {
      key = MASK_INCLUDE_KW;
      key += ossimString::toString(idx++);
      m_kwl.addPair(key.string(), maskFnames[idx] );
   }

   if ( ap.read("--output-slope", sp1))
      m_kwl.addPair(SLOPE_OUTPUT_FILE_KW, ts1);

   vector<ossimString> pcFnames;
   ap.read("--point-clouds", pcFnames);
   for(ossim_uint32 idx=0; idx<pcFnames.size(); ++idx)
   {
      key = POINT_CLOUD_FILE_KW;
      key += ossimString::toString(idx++);
      m_kwl.addPair(key.string(), pcFnames[idx] );
   }

   if (ap.read("--min-lz-radius", sp1) || ap.read("--rlz", sp1))
      m_kwl.addPair(LZ_MIN_RADIUS_KW, ts1);

   if (ap.read("--max-roughness", sp1) || ap.read("--roughness", sp1))
      m_kwl.addPair(ROUGHNESS_THRESHOLD_KW, ts1);

   if (ap.read("--max-slope", sp1) || ap.read("--slope", sp1))
      m_kwl.addPair(SLOPE_THRESHOLD_KW, ts1);

   if (ap.read("--threads", sp1))
   {
      // Command line mode only
      m_numThreads = ossimString(ts1).toUInt32();
   }

   if (ap.read("--use_slope"))
   {
      // Command line mode only
      m_useLsFitMethod = false;
   }

   processRemainingArgs(ap);
   return true;
}
Пример #17
0
bool ossimImageUtil::initialize(ossimArgumentParser& ap)
{
   static const char M[] = "ossimImageUtil::initialize(ossimArgumentParser&)";
   if ( traceDebug() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   }

   bool result = true;

   if ( (ap.argc() == 1) || ap.read("-h") || ap.read("--help") )
   {
      usage(ap);

      // continue_after_init to false
      result = false;
   }
   else
   {
      //---
      // Start with clean options keyword list.
      //---
      m_kwl->clear();

      while ( 1 ) //  While forever loop...
      {
         // Used throughout below:
         std::string ts1;
         ossimArgumentParser::ossimParameter sp1(ts1);
         std::string ts2;
         ossimArgumentParser::ossimParameter sp2(ts2);

         if( ap.read("-a") || ap.read("--include-fullres") )
         {
            setCopyAllFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--compression-quality", sp1) )
         {
            if ( ts1.size() )
            {
               setCompressionQuality( ts1 );
            }
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--compression-type", sp1) )
         {
            if ( ts1.size() )
            {
               setCompressionType( ts1 );
            }
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("--ch") || ap.read("--create-histogram") )
         {
            setCreateHistogramFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("--chf") || ap.read("--create-histogram-fast") )
         {
            setCreateHistogramFastFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("--create-histogram-r0") )
         {
            setCreateHistogramR0Flag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("-d", sp1) )
         {
            setOutputDirectory( ts1 );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--dump-filtered-image-list") )
         {
            setDumpFilteredImageListFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("-i") || ap.read("--internal-overviews") )
         {
            setInternalOverviewsFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--of") || ap.read("--output-files") )
         {
            setOutputFileNamesFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("-o") )
         {
            setCreateOverviewsFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }        
         
         if( ap.read("--ot", sp1) )
         {
            setOverviewType( ts1 );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--override-filtered-images") )
         {
            setOverrideFilteredImagesFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("-r") || ap.read("--rebuild-overviews") )
         {
            setRebuildOverviewsFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--rebuild-histogram") )
         {
            setRebuildHistogramFlag( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         while(ap.read("--reader-prop", sp1))
         {
            if (ts1.size())
            {
               std::string key = READER_PROP_KW;
               key += ossimString::toString( getNextReaderPropIndex() ).string();
               addOption( key, ts1 );
            }
         }
         if ( ap.argc() < 2 )
         {
            break;
         }
         
         if( ap.read("--scanForMinMax" ) )
         {
            setScanForMinMax( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--scanForMinMaxNull" ) )
         {
            setScanForMinMaxNull( true );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }
         
         if( ap.read("-s", sp1) )
         {
            setOverviewStopDimension( ts1 );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if ( ap.read("-tile-size", sp1))
         {
            setTileSize( ossimString(ts1).toInt32() );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         if( ap.read("--threads", sp1) )
         {
            m_kwl->addPair( THREADS_KW, ts1 );
            if ( ap.argc() < 2 )
            {
               break;
            }
         }

         while(ap.read("--writer-prop", sp1))
         {
            if (ts1.size())
            {
               std::string key = WRITER_PROP_KW;
               key += ossimString::toString( getNextWriterPropIndex() ).string();
               addOption( key, ts1 );
            }
         }
         if ( ap.argc() < 2 )
         {
            break;
         }

         // End of arg parsing.
         ap.reportRemainingOptionsAsUnrecognized();
         if ( ap.errors() )
         {
            ap.writeErrorMessages(ossimNotify(ossimNotifyLevel_NOTICE));
            std::string errMsg = "Unknown option...";
            throw ossimException(errMsg);
         }

         break; // Break from while forever.
         
      } // End while (forever) loop.

      if(ap.argc() > 1)
      {
         for (ossim_int32 i = 0; i < (ap.argc()-1); ++i)
         {
            ossimString kw = "file";
            kw += ossimString::toString(i);
            std::string value = ap[i+1];
            m_kwl->addPair(kw.string(), value, true);
         }
      }
      else
      {
         if ( getDumpFilterImagesFlag() )
         {
            // Caller wants to see filtered image names:
            dumpFilteredImageList();
         }
         else
         {
            usage(ap);
            result = false;
         }
      }

   } // not usage

   if ( traceDebug() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "m_kwl:\n" << *(m_kwl.get()) << "\n"
         << M << " exit result = " << (result?"true":"false")
         << "\n";
   }
   
   return result;
}
Пример #18
0
bool ossimSlopeUtil::initialize(ossimArgumentParser& ap)
{
   // Base class first:
   if (!ossimUtility::initialize(ap))
      return false;

   std::string ts1;
   ossimArgumentParser::ossimParameter sp1(ts1);
   std::string ts2;
   ossimArgumentParser::ossimParameter sp2(ts2);

   if (ap.read("--center", sp1, sp2) || ap.read("--center-lat-lon", sp1, sp2))
   {
      m_centerGpt.lat = ossimString(ts1).toDouble();
      m_centerGpt.lon = ossimString(ts2).toDouble();
      m_centerGpt.hgt = 0.0;
   }

   if (ap.read("--dem", sp1) || ap.read("--dem-file", sp1))
      m_demFile = ts1;

   if ( ap.read("--remap") || ap.read("--remap-to-8bit"))
   {
      m_remapToByte = true;
   }

   if ( ap.read("--lut", sp1) || ap.read("--lut-file", sp1))
      m_lutFile = ts1;

   if (ap.read("--roi", sp1) || ap.read("--roi-radius", sp1))
      m_aoiRadius = ossimString(ts1).toDouble();

   if (m_demFile.empty() && m_centerGpt.hasNans())
   {
      ossimNotify(ossimNotifyLevel_WARN)<<"No DEM file nor center point provided. Cannot "
            <<"compute slope image."<<endl;
      setUsage(ap);
      return false;
   }

   // There should only be the required command line args left:
   if (ap.argc() != 2)
   {
      setUsage(ap);
      return false;
   }

   m_slopeFile = ap[1];

   return initializeChain();
}
Пример #19
0
void ossimViewshedUtil::setUsage(ossimArgumentParser& ap)
{
   // Set the general usage:
   ossimApplicationUsage* au = ap.getApplicationUsage();
   ossimString usageString = ap.getApplicationName();
   usageString += " [options] <obs_lat> <obs_lon> <output-image>";
   au->setCommandLineUsage(usageString);

   // Set the command line options:
   au->addCommandLineOption(
         "--fov <start> <end>",
         "Optional arguments specifying the field-of"
         "-view boundary azimuths (in degrees). By default, a 360 deg FOV is"
         " computed. The arc is taken clockwise from start to end, so for a"
         " FOV of 225 deg from W, through N to SE, start=270 and end=135");
   au->addCommandLineOption(
         "--gsd <meters>",
         "Specifies output GSD in meters. Defaults to the same "
         "resolution as input DEM.");
   au->addCommandLineOption(
         "--hgt-of-eye <meters>",
         "Specifies the observers height-of-eye above the "
         "terrain in meters. Defaults to 1.5 m.");
   au->addCommandLineOption(
         "--horizon <filename>",
         "Experimental. Outputs the max elevation angles "
         "for all azimuths to <filename>, for horizon profiling.");
   au->addCommandLineOption(
         "--dem <filename>",
         "Specifies the input DEM filename. If none "
         "provided, the elevation database is referenced as specified in prefs file");
   au->addCommandLineOption(
         "--lut <filename>",
         "Specifies the optional lookup table filename for "
         "mapping the single-band output image to an RGB. The LUT provided must be "
         "in the ossimIndexToRgbLutFilter format and must handle the three output "
         "viewshed values (see --values option).");
   au->addCommandLineOption(
         "--radius <meters>",
         "Specifies max visibility in meters. Required "
         "unless --size is specified. This option constrains output to a circle, "
         "similar to a radar display");
   au->addCommandLineOption(
         "--request-api",
         "Causes applications API to be output as JSON to stdout."
         " Accepts optional filename to store JSON output.");
   au->addCommandLineOption(
         "--reticle <int>",
         "Specifies the size of the reticle at the observer"
         "location in pixels from the center (i.e., the radius of the reticle). "
         "Defaults to 2. A value of 0 hides the reticle. See --values option for "
         "setting reticle color.");
   au->addCommandLineOption(
         "--simulation",
         "For engineering/debug purposes ");
   au->addCommandLineOption(
         "--size <int>",
         "Instead of a visibility radius, directly specifies "
         "the dimensions of the output product in pixels (output is "
         "square). Required unless --radius is specified.");
   au->addCommandLineOption(
         "--summary",
         "Causes a product summary to be output to the console.");
   au->addCommandLineOption(
         "--tbs",
         "\"Thread By Sector\". For engineering/debug purposes ");
   au->addCommandLineOption(
         "--threads <n>",
         "Number of threads. Defaults to use all available cores. "
         "For engineering/debug purposes ");
   au->addCommandLineOption(
         "--values <int int int>",
         "Specifies the pixel values (0-255) for the visible,"
         " hidden and reticle pixels, respectively. Defaults to visible=null (0), "
         "hidden=128, and observer position reticle is highlighted with 255.");

   ossimString description =
         "\nComputes the viewshed for the given viewpt coordinates. The output is a binary image "
         "with 0 representing hidden points, and 1 representing visible points.\n\n"
         "Examples:\n\n"
         "    ossim-viewshed --radius 50  28.0 -80.5 output-hlz.tif\n"
         "    ossim-viewshed --size 1024  28.0 -80.5 output-hlz.tif\n\n"
         "An alternate command line provides switch for observer lat and lon:\n\n"
         "    ossim-viewshed --rlz 25 --observer 28.0 -80.5  output-hlz.tif \n";
   au->setDescription(description);

   // Base class has its own:
   ossimUtility::setUsage(ap);
}