71 static std::string CMM_MAX_KW =
"cmm_max";
72 static std::string CMM_MIN_KW =
"cmm_min";
73 static std::string CMM_NULL_KW =
"cmm_null";
74 static std::string COPY_ALL_FLAG_KW =
"copy_all_flag";
75 static std::string CREATE_HISTOGRAM_KW =
"create_histogram";
76 static std::string CREATE_HISTOGRAM_FAST_KW =
"create_histogram_fast";
77 static std::string CREATE_HISTOGRAM_R0_KW =
"create_histogram_r0";
78 static std::string CREATE_OVERVIEWS_KW =
"create_overviews";
79 static std::string CREATE_THUMBNAILS_KW =
"create_thumbnails";
80 static std::string DUMP_FILTERED_IMAGES_KW =
"dump_filter_image";
81 static std::string FALSE_KW =
"false";
82 static std::string FILE_KW =
"file";
83 static std::string INTERNAL_OVERVIEWS_FLAG_KW =
"internal_overviews_flag";
84 static std::string OUTPUT_DIRECTORY_KW =
"output_directory";
85 static std::string OUTPUT_FILENAMES_KW =
"output_filenames";
86 static std::string OVERRIDE_FILTERED_IMAGES_KW =
"override_filtered_images";
87 static std::string OVERVIEW_STOP_DIM_KW =
"overview_stop_dimension";
88 static std::string OVERVIEW_TYPE_KW =
"overview_type";
89 static std::string READER_PROP_KW =
"reader_prop";
90 static std::string REBUILD_HISTOGRAM_KW =
"rebuild_histogram";
91 static std::string REBUILD_OVERVIEWS_KW =
"rebuild_overviews";
92 static std::string SCAN_MIN_MAX_KW =
"scan_for_min_max";
93 static std::string SCAN_MIN_MAX_NULL_KW =
"scan_for_min_max_null";
94 static std::string THREADS_KW =
"threads";
95 static std::string THUMBNAIL_SIZE_KW =
"thumbnail_size";
96 static std::string THUMBNAIL_STRETCH_TYPE_KW =
"thumbnail_stretch_type";
97 static std::string THUMBNAIL_TYPE_KW =
"thumbnail_type";
98 static std::string TILE_SIZE_KW =
"tile_size";
99 static std::string TRUE_KW =
"true";
100 static std::string WRITER_PROP_KW =
"writer_prop";
129 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.");
131 au->
addCommandLineOption(
"--ch or --create-histogram",
"Computes full histogram alongside overview.");
133 au->
addCommandLineOption(
"--chf or --create-histogram-fast",
"Computes a histogram in fast mode which samples partial tiles.");
136 au->
addCommandLineOption(
"--tst or --thumbnail-stretch-type",
"Can be of values none,auto-minmax,auto-percentile,std-stretch-1,std-stretch-2,std-stretch-3");
138 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");
140 au->
addCommandLineOption(
"--compute-min-max",
"Turns on min, max scanning when reading tiles and writes a dot omd file. This option assumes the null is known.");
142 au->
addCommandLineOption(
"--compute-min-max-null",
"Turns on min, max, null scanning when reading tiles and write a dot omd file. This option tries to find a null value which is useful for float data.");
144 au->
addCommandLineOption(
"--compression-type",
"Compression type can be: deflate, jpeg, lzw, none or packbits");
146 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.");
148 au->
addCommandLineOption(
"-d",
"<output_directory> Write overview to output directory specified.");
150 au->
addCommandLineOption(
"--dump-filtered-image-list",
"Outputs list of filtered images and extensions.");
154 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!");
162 au->
addCommandLineOption(
"--null",
"<null_value> Overrides null value for compute-min-max option. e.g. -9999.0 for float data");
166 au->
addCommandLineOption(
"--of or --output-files",
"Output image files we can open, exluding overviews.");
168 au->
addCommandLineOption(
"--options",
"<options.kwl> This can be all or part of the application options. Also used for custom prep, per file and post system commands. To get a template you can turn on trace to the ossimImageUtil class by adding \"-T ossimImageUtil\" to your command.");
170 au->
addCommandLineOption(
"--ot",
"<overview_type> Overview type. see list at bottom for valid types. (default=ossim_tiff_box)");
172 au->
addCommandLineOption(
"--override-filtered-images",
"Allows processing of file that is in the filtered image list.");
174 au->
addCommandLineOption(
"-r or --rebuild-overviews",
"Rebuild overviews even if they are already present.");
176 au->
addCommandLineOption(
"--rebuild-histogram",
"Rebuild histogram even if they are already present.");
178 au->
addCommandLineOption(
"--reader-prop",
"Adds a property to send to the reader. format is name=value");
180 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\".");
182 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\".");
184 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\".");
186 au->
addCommandLineOption(
"--writer-prop",
"Adds a property to send to the writer. format is name=value");
194 usageString +=
" [options] <file-or-directory-to-walk>";
203 static const char M[] =
"ossimImageUtil::initialize(ossimArgumentParser&)";
211 if ( (ap.
argc() == 1) || ap.
read(
"-h") || ap.
read(
"--help") )
231 if( ap.
read(
"-a") || ap.
read(
"--include-fullres") )
240 if( ap.
read(
"--compression-quality", sp1) )
252 if( ap.
read(
"--compression-type", sp1) )
264 if( ap.
read(
"--ch") || ap.
read(
"--create-histogram") )
273 if( ap.
read(
"--chf") || ap.
read(
"--create-histogram-fast") )
282 if( ap.
read(
"--compute-min-max") )
291 if( ap.
read(
"--compute-min-max-null") )
300 if( ap.
read(
"--create-histogram-r0") )
309 if( ap.
read(
"-d", sp1) )
318 if( ap.
read(
"--dump-filtered-image-list") )
327 if( ap.
read(
"-i") || ap.
read(
"--internal-overviews") )
336 if( ap.
read(
"--max", sp1) )
345 if( ap.
read(
"--min", sp1) )
354 if( ap.
read(
"--null", sp1) )
363 if( ap.
read(
"--options", sp1) )
366 if ( optionsKwl.
exists() )
370 std::string errMsg =
"ERROR could not open options keyword list file: ";
371 errMsg += optionsKwl.
string();
377 std::string errMsg =
"ERROR options keyword list file does not exists: ";
378 errMsg += optionsKwl.
string();
383 if( ap.
read(
"--of") || ap.
read(
"--output-files") )
408 if (ap.
read(
"--tt", sp1) || ap.
read(
"--thumbnail-type", sp1))
416 if (ap.
read(
"--tst", sp1) || ap.
read(
"--thumbnail-stretch-type", sp1))
425 if (ap.
read(
"--ot", sp1))
434 if( ap.
read(
"--override-filtered-images") )
443 if( ap.
read(
"-r") || ap.
read(
"--rebuild-overviews") )
452 if( ap.
read(
"--rebuild-histogram") )
461 while(ap.
read(
"--reader-prop", sp1))
465 std::string key = READER_PROP_KW;
475 if( ap.
read(
"-s", sp1) )
484 if ( ap.
read(
"--tile-size", sp1))
493 if( ap.
read(
"--threads", sp1) )
502 while(ap.
read(
"--writer-prop", sp1))
506 std::string key = WRITER_PROP_KW;
521 std::string errMsg =
"Unknown option...";
535 std::string value = ap[i+1];
576 <<
"m_kwl:\n" << *(
m_kwl.
get()) <<
"\n" 577 << M <<
" exit result = " << (result?
"true":
"false")
586 static const char M[] =
"ossimImageUtil::execute()";
618 std::vector<ossimFilename> files;
621 while ( processedFiles < fileCount )
633 if ( i > (fileCount + 100) )
break;
642 ( (files.size() > 1) || (files[0].isDir() ==
true) ) )
660 <<
"Caught exception: " << e.
what() << endl;
685 static const char M[] =
"ossimImageUtil::processFile";
689 << M <<
" entered...\n" <<
"file: " << file <<
"\n";
692 bool processFileFlag =
true;
698 if ( processFileFlag )
733 bool consumedHistogramOptions =
false;
734 bool consumedCmmOptions =
false;
786 <<
"Filtered file, not processing: " << file << std::endl;
798 bool& consumedHistogramOptions,
799 bool& consumedCmmOptions )
801 static const char M[] =
"ossimImageUtil::createOverview #1";
810 std::vector<ossim_uint32> entryList;
813 bool useEntryIndex =
false;
814 if ( entryList.size() )
816 if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex =
true;
831 if ( stopDimension ) ob->setOverviewStopDimension(stopDimension);
844 consumedCmmOptions =
true;
847 for(
ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
849 createOverview(ih, ob, entryList[idx], useEntryIndex, consumedHistogramOptions);
855 <<
"ERROR:\nCould not create builder for: "<< overviewType << std::endl;
871 bool& consumedHistogramOptions)
873 static const char M[] =
"ossimImageUtil::createOverview #2";
894 if ( outputFile.
exists() )
915 <<
"Internal overviews not supported for reader type: " 917 <<
"\nIgnoring option..." 955 consumedHistogramOptions =
true;
959 <<
"Creating overviews with histogram for file: " << ih->
getFilename() << std::endl;
965 consumedHistogramOptions =
false;
967 <<
"Creating overviews for file: " << ih->
getFilename() << std::endl;
975 std::vector< ossimRefPtr<ossimProperty> > propertyList(0);
992 <<
"Error returned creating overviews for file: " << ih->
getFilename() << std::endl;
997 consumedHistogramOptions =
false;
999 <<
"Image has required reduced resolution data sets." << std::endl;
1011 bandsKeywordList.
add(
"type",
"ossimBandSelector");
1034 cutRect = bounds * scale;
1042 trans->
scale(scale, scale);
1049 if ((bandCount == 2) || (bandCount > 3))
1075 writerKwl.
add(
"type",
"image/" + ext);
1076 writerKwl.
add(
"filename", thumbnailFilename.
c_str());
1077 writerKwl.
add(
"create_external_geometry",
"false");
1080 writerKwl.
add(
"add_alpha_channel",
"true");
1108 bool result =
false;
1130 while(largestImageDimension > overviewStopDimension)
1132 largestImageDimension /= 2;
1136 if ( startingResLevel >= required )
1147 static const char M[] =
"ossimImageUtil::createHistogram #1";
1156 std::vector<ossim_uint32> entryList;
1159 bool useEntryIndex =
false;
1160 if ( entryList.size() )
1162 if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex =
true;
1165 for(
ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
1182 static const char M[] =
"ossimImageUtil::createHistogram #2";
1204 <<
"Computing histogram for file: " << ih->
getFilename() << std::endl;
1207 std::vector<ossim_uint32> originalBandList(0);
1280 static const char M[] =
"ossimImageUtil::computeMinMax #1";
1289 std::vector<ossim_uint32> entryList;
1292 bool useEntryIndex =
false;
1293 if ( entryList.size() )
1295 if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex =
true;
1298 for(
ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
1313 bool useEntryIndex )
1315 static const char M[] =
"ossimImageUtil::computeMinMax #2";
1340 bool hasNull =
false;
1365 omd_file = outputDir.
dirCat( omd_file.
file() );
1369 if ( useEntryIndex )
1396 if (!tileWidthHeight.x)
1404 if(!tileWidthHeight.y)
1412 <<
"Sequencer tile size: " << tileWidthHeight << endl;
1431 vector<double> tmin(BANDS);
1432 vector<double> tmax(BANDS);
1433 vector<double> tnull(BANDS);
1434 for (i = 0; i < BANDS; ++i)
1436 tmin[i] = DEFAULT_MAX;
1437 tmax[i] = DEFAULT_MIN;
1442 tnull[i] = nullValue;
1452 double tile_count = 0.0;
1454 << setiosflags(ios::fixed) << setprecision(0);
1466 id->computeMinMaxPix(tmin, tmax);
1471 << (tile_count / TOTAL_TILES * 100.0) <<
"%" 1478 std::fill(tmin.begin(), tmin.end(), minValue);
1482 std::fill(tmax.begin(), tmax.end(), maxValue);
1485 <<
"\r100%\nFinished..." << endl;
1489 for(i = 0; i < BANDS; ++i)
1495 if (tmin[i] == DEFAULT_MAX)
1497 tmin[i] = DEFAULT_MIN;
1499 <<
"cmm scan for min failed! Using default min." 1502 if (tmax[i] == DEFAULT_MIN)
1504 tmax[i] = DEFAULT_MAX;
1506 <<
"cmm scan for max failed! Using default max." 1513 if (tmin[i] == DEFAULT_MAX)
1515 tmin[i] = DEFAULT_MIN;
1519 okwl.
add(band +
"min_value", tmin[i],
true);
1520 okwl.
add(band +
"max_value", tmax[i],
true);
1521 okwl.
add(band +
"null_value", tnull[i],
true);
1526 << setiosflags(ios::fixed) << setprecision(16)
1532 << tnull[i] << endl;
1539 okwl.
add(
"number_bands", BANDS,
true);
1543 okwl.
write(omd_file);
1545 <<
"wrote file: " << omd_file << endl;
1575 <<
"\nExample commands:\n" 1577 <<
"\n// A single image standard tiff overviews, histogram:\n" 1578 <<
"ossim-preproc -o --ch <file>\n" 1580 <<
"\n// A single image with j2k overviews(requires kakadu plugin), histogram:\n" 1581 <<
"ossim-preproc --ot ossim_kakadu_nitf_j2k --ch <file>\n" 1582 <<
"\n// j2k, histogram, 4 threads\n" 1584 <<
"\n// standard tiff overviews, full histogram, 4 threads:\n" 1585 <<
"ossim-preproc -r -o --ch --threads 4 <directory_to_walk>\n" 1587 <<
"\n// j2k, histogram (fast mode), 4 threads\n" 1588 <<
"ossim-preproc -r --ot ossim_kakadu_nitf_j2k --chf --threads 4 " 1589 <<
"<directory_to_walk>\n" 1591 <<
"\n// tiff, jpeg compression, histogram, 4 threads\n" 1592 <<
"ossim-preproc -r --ch --compression-quality 75 --compression-type " 1593 <<
"jpeg --threads 4 <directory_to_walk>\n" 1594 <<
"ossim-preproc -r --ch --compression-quality 75 --compression-type " 1595 <<
"jpeg --threads 4 <directory_to_walk>\n" 1597 <<
"\n// Process all the tiffs in a directory feeding \"prep\", \"file\", \"post\" system commands via the --options option which includes indexing file into the omar database via omar-data-mgr app:\n" 1598 <<
"ossim-preproc --options preproc-options.kwl -r -o --ch *.tif\n" 1599 <<
"\n// Contents of preproc-options.kwl used in above command:\n" 1600 <<
"prep.command0: echo start_time: %{date}\n" 1601 <<
"prep.command0.strf_time_format: %Y%m%d%H%M%S\n" 1602 <<
"prep.command1: mkdir -p %{date}\n" 1603 <<
"file.command0: mv %{file_no_ext}.* %{date}/.\n" 1604 <<
"file.command1: omar-data-mgr -u http://localhost:8080/omar add %{date}/%{basename}\n" 1605 <<
"post.command0: echo end_time: %{date}\n" 1606 <<
"post.command0.strf_time_format: %Y%m%d%H%M%S\n" 1609 <<
"\n --ch equals --create-histogram" 1610 <<
"\n --chf equals --create-histogram-fast" 1612 <<
"\n\nExpanded command option variables:\n\n" 1613 <<
"%{basename} = filename without path\n" 1614 <<
"%{basename_no_ext} = filename without path and without extension\n" 1615 <<
"%{date} = Expanded to current zulu time. Default format=yyyymmdd\n" 1616 <<
" output format controlled by command0.strf_time_format key.\n" 1617 <<
"%{dirname} = path of filename\n" 1618 <<
"%{file} = filename being processed\n" 1619 <<
"%{file_no_ext} = filename with no extension\n" 1628 <<
"\nValid overview types: " << std::endl;
1630 std::vector<ossimString> outputType;
1633 std::copy(outputType.begin(),
1641 bool result =
false;
1646 if ( (imageHandlerName ==
"ossimAdrgTileSource") ||
1647 (imageHandlerName ==
"ossimCibCadrgTileSource") )
1657 addOption( CREATE_OVERVIEWS_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1662 return keyIsTrue( CREATE_OVERVIEWS_KW );
1666 addOption(CREATE_THUMBNAILS_KW, (flag ? TRUE_KW : FALSE_KW));
1676 addOption( REBUILD_OVERVIEWS_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1685 return keyIsTrue( REBUILD_OVERVIEWS_KW );
1690 addOption( REBUILD_HISTOGRAM_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1699 return keyIsTrue( REBUILD_HISTOGRAM_KW );
1704 addOption( SCAN_MIN_MAX_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1714 addOption( SCAN_MIN_MAX_NULL_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1719 return keyIsTrue( SCAN_MIN_MAX_NULL_KW );
1724 if ( quality.size() )
1726 std::string key = WRITER_PROP_KW;
1739 std::string key = WRITER_PROP_KW;
1751 std::string key = COPY_ALL_FLAG_KW;
1752 std::string value = ( flag ? TRUE_KW : FALSE_KW );
1756 key = WRITER_PROP_KW;
1758 value = COPY_ALL_FLAG_KW;
1760 value += ( flag ? TRUE_KW : FALSE_KW );
1771 std::string key = DUMP_FILTERED_IMAGES_KW;
1772 std::string value = ( flag ? TRUE_KW : FALSE_KW );
1778 return keyIsTrue( DUMP_FILTERED_IMAGES_KW );
1784 std::string key = INTERNAL_OVERVIEWS_FLAG_KW;
1785 std::string value = ( flag ? TRUE_KW : FALSE_KW );
1789 key = WRITER_PROP_KW;
1791 value = INTERNAL_OVERVIEWS_FLAG_KW;
1793 value += ( flag ? TRUE_KW : FALSE_KW );
1799 return keyIsTrue( INTERNAL_OVERVIEWS_FLAG_KW );
1804 std::string key = OUTPUT_FILENAMES_KW;
1805 std::string value = ( flag ? TRUE_KW : FALSE_KW );
1811 return keyIsTrue( OUTPUT_FILENAMES_KW );
1816 std::string key = OVERRIDE_FILTERED_IMAGES_KW;
1817 std::string value = ( flag ? TRUE_KW : FALSE_KW );
1823 return keyIsTrue( OVERRIDE_FILTERED_IMAGES_KW );
1828 std::string key = OUTPUT_DIRECTORY_KW;
1834 std::string key = OVERVIEW_TYPE_KW;
1842 if ( lookup.size() )
1848 type =
"ossim_tiff_box";
1857 if ( dynamic_cast<ossimImageHandler*>(pi) )
1859 baseKey = READER_PROP_KW;
1863 baseKey = WRITER_PROP_KW;
1873 while ( (foundProps < propCount) && (index < (propCount+100) ) )
1878 if ( lookup.size() )
1881 std::vector<ossimString> v = value.
split(
"=");
1900 addOption( OVERVIEW_STOP_DIM_KW, dimension );
1905 addOption( OVERVIEW_STOP_DIM_KW, dimension );
1910 if ((tileSize % 16) == 0)
1917 <<
"ossimImageUtil::setTileSize NOTICE:" 1918 <<
"\nTile width must be a multiple of 16!" 1925 bool result =
false;
1927 if ( lookup.size() )
1930 if ( (i % 16) == 0 )
1943 std::string lookup =
m_kwl->
findKey( OVERVIEW_STOP_DIM_KW );
1944 if ( lookup.size() )
1953 addOption( CREATE_HISTOGRAM_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1958 return keyIsTrue( CREATE_HISTOGRAM_KW );
1963 addOption( CREATE_HISTOGRAM_FAST_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1968 return keyIsTrue( CREATE_HISTOGRAM_FAST_KW );
1973 addOption( CREATE_HISTOGRAM_R0_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1978 return keyIsTrue( CREATE_HISTOGRAM_R0_KW );
2019 if ( lookup.size() )
2042 while ( (foundProps < result) && (index < (result+100) ) )
2047 if ( lookup.size() )
2070 while ( (foundProps < result) && (index < (result+100) ) )
2075 if ( lookup.size() )
2088 std::string lookup =
m_kwl->
findKey(THUMBNAIL_SIZE_KW);
2101 addOption(THUMBNAIL_STRETCH_TYPE_KW, value);
2110 if (typeString.
empty())
2112 typeString =
"auto-minmax";
2115 typeString = typeString.
downcase();
2117 if ((typeString ==
"auto-minmax"))
2119 result = ossimHistogramRemapper::StretchMode::LINEAR_AUTO_MIN_MAX;
2121 else if ((typeString ==
"auto-percentile"))
2123 result = ossimHistogramRemapper::StretchMode::LINEAR_AUTO_PERCENTILE;
2125 else if ((typeString ==
"std-stretch-1") || (typeString ==
"std-stretch 1"))
2127 result = ossimHistogramRemapper::StretchMode::LINEAR_1STD_FROM_MEAN;
2129 else if ((typeString ==
"std-stretch-2") || (typeString ==
"std-stretch 2"))
2131 result = ossimHistogramRemapper::StretchMode::LINEAR_2STD_FROM_MEAN;
2133 else if ((typeString ==
"std-stretch-3") || (typeString ==
"std-stretch 3"))
2135 result = ossimHistogramRemapper::StretchMode::LINEAR_3STD_FROM_MEAN;
2137 else if (typeString ==
"auto-minmax")
2139 result = ossimHistogramRemapper::StretchMode::STRETCH_UNKNOWN;
2152 std::string result =
"jpeg";
2154 typeString = typeString.
downcase();
2156 if(typeString !=
"png" && typeString !=
"jpeg")
2158 typeString =
"jpeg";
2161 result = typeString.
string();
2170 if (thumbnailType ==
"png")
2172 thumbnailFilename =
ossimFilename(thumbnailFilename +
"thumb.png");
2176 thumbnailFilename =
ossimFilename(thumbnailFilename +
"thumb.jpg");
2179 return thumbnailFilename.
string();
2192 if ( key.size() && value.size() )
2209 bool result =
false;
2214 if ( baseName.size() )
2219 if ( baseName == (*i) )
2232 <<
"ossimFileWalker::isFiltered file " << (result?
"filtered: ":
"not filtered: ")
2242 bool result =
false;
2290 std::string prefix =
"prep.";
2297 std::string prefix =
"file.";
2303 std::string prefix =
"post.";
2309 const std::string& prefix,
const ossimFilename& file )
const 2311 const std::string BASE_KEY =
"command";
2314 const std::string REG_EXP_STR = prefix + BASE_KEY + std::string(
"[0-9]+");
2321 std::string commandKey;
2324 while ( processedIndexes < MAX_INDEX )
2329 if ( command.
size() )
2334 <<
"executing_command: " << command << std::endl;
2340 <<
"return_status: " <<
status << std::endl;
2344 if ( processedIndexes == NUM_COMMANDS )
2355 const std::string& prefix,
2356 const std::string& commandKey,
2364 if ( prefix ==
"file." )
2373 const std::string BASENAME_VARIABLE =
"%{basename}";
2376 const std::string BASENAME_NO_EXT_VARIABLE =
"%{basename_no_ext}";
2379 const std::string DIRNAME_VARIABLE =
"%{dirname}";
2382 const std::string FILE_VARIABLE =
"%{file}";
2385 const std::string FILE_NO_EXT_VARIABLE =
"%{file_no_ext}";
2393 const std::string DATE_VARIABLE =
"%{date}";
2394 if ( command.
find( DATE_VARIABLE ) )
2396 std::string key =
".strf_time_format";
2397 std::string strfTimeFormat =
m_kwl->
findKey( commandKey, key );
2398 if ( strfTimeFormat.empty() )
2401 strfTimeFormat =
"%Y%m%d";
2414 command.
gsub( DATE_VARIABLE, date,
true );
bool keyIsTrue(const std::string &key) const
void setRectangle(const ossimIrect &rect)
ossimString toString() const
void dumpFilteredExtensionList() const
Dumps filtered image extenstions to std out.
void write(std::ostream &output, const UsageMap &um, unsigned int widthOfOutput=80)
virtual bool addListener(ossimListener *listener)
std::string getApplicationName() const
return the application name, as specified by argv[0]
bool createHistogramR0() const
bool createOverviews() const
void addCommandLineOption(const ossimString &option, const ossimString &explanation)
void setCreateHistogramFastFlag(bool flag)
Sets create histogram flag keyword CREATE_HISTOGRAM_FAST_KW used by processFile method.
bool createHistogramFast() const
ossimFilename noExtension() const
static bool remove(const ossimFilename &pathname)
Removes pathname from filesystem if supported by platform.
ossim_uint32 getOverviewStopDimension() const
void setProperties(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
ossim_uint32 numberOf(const char *str) const
void setComputationMode(ossimHistogramMode mode)
ossim_uint32 getNumberOfSubstringKeys(const ossimString ®ularExpression) const
ossim_float64 width() const
void setFileProcessor(ossimFileProcessorInterface *fpi)
Sets ossimFileProcessorInterfacecallback method to process files.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
void setRecurseFlag(bool flag)
Sets recurse flag.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
void setNumberOfBinsOverride(ossim_int32 numberOfBinsOverride)
void executePrepCommands() const
run prep system commands.
Represents serializable keyword/value map.
bool addFile(const char *file)
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
void setState(std::shared_ptr< ossim::ImageHandlerState > state)
static const char * OUTPUT_TILE_SIZE_KW
std::vector< std::string > m_filteredImages
Hold images we never want to process.
bool hasHistogramOption() const
void addOptions(ossimArgumentParser &parser)
ossimFilename expand() const
Method to do file name expansion.
std::string getThumbnailFilename(ossimImageHandler *ih) const
ossimReferenced allows for shared object ref counting if the reference count ever gets to 0 or less i...
bool read(const std::string &str)
search for an occurance of a string in the argument list, on sucess remove that occurance from the li...
virtual bool setInputSource(ossimImageHandler *imageSource)
Sets the input to the builder.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
double nan()
Method to return ieee floating point double precision NAN.
bool getInternalOverviewsFlag() const
ossim_int64 getNumberOfTiles() const
bool getOutputFileNamesFlag() const
void setCreateHistogramFlag(bool flag)
Sets create histogram flag keyword CREATE_HISTOGRAM_KW used by processFile method.
bool hasKey(const std::string &key) const
Checks for key in map.
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
bool scanForMinMax() const
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
static ossimImageWriterFactoryRegistry * instance()
static ossimString toString(bool aValue)
Numeric to string methods.
void setCopyAllFlag(bool flag)
Sets the overview builder copy all flag.
void getOverviewType(std::string &type) const
Initializes type from OVERVIEW_TYPE_KW or sets to default ossim_tiff_box if not found.
std::string getThumbnailType() const
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
void substituteCommandString(const ossimFilename &file, const std::string &prefix, const std::string &commandKey, ossimString &command) const
Expands variables in a command string.
void setOutputDirectory(const std::string &directory)
Sets the output directory.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
const std::vector< std::string > & getFilteredExtensions() const
static const ossimErrorCode OSSIM_ERROR
virtual ossimString getClassName() const
bool rebuildOverviews() const
ossim_uint32 toUInt32() const
void setCommandLineUsage(const ossimString &explanation)
ossimFileWalker * m_fileWalker
void setThumbnailType(const std::string &value)
void setErrorStatus(ossim_int32 status)
Sets the m_errorStatus for return on execute.
OSSIM_DLL ossimStdOutProgress theStdOutProgress
bool hasRequiredOverview(ossimRefPtr< ossimImageHandler > &ih, ossimRefPtr< ossimOverviewBuilderBase > &ob)
virtual void closeOverview()
If theOverview is initialized it will be deleted and set to NULL.
void addArguments(ossimArgumentParser &ap)
Adds application arguments to the argument parser.
void setCreateHistogramR0Flag(bool flag)
Sets create histogram "R0" flag keyword CREATE_HISTOGRAM_R0_KW used by processFile method...
void usage(ossimArgumentParser &ap)
Initializes arg parser and outputs usage.
ossimApplicationUsage * getApplicationUsage()
Utility class to walk through directories and get a list of files to process.
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
bool getTileSize(ossimIpt &tileSize) const
Gets the tile size.
virtual void processFile(const ossimFilename &file)
ProcessFile method.
virtual bool openOverview()
Searches for an overview.
void setImageViewTransform(ossimImageViewTransform *transform)
OSSIM_DLL ossim_uint32 getNumberOfThreads()
Get the number threads to use from ossimPreferences or ossim::Thread.
void substituteFileStrings(const ossimFilename &file, ossimString &command) const
Expands file level variables in a command string.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
ossim_int32 toInt32() const
void setOverrideFilteredImagesFlag(bool flag)
Sets the override filtered images flag.
void reportRemainingOptionsAsUnrecognized(ossimErrorSeverity severity=OSSIM_BENIGN)
for each remaining option report it as an unrecongnized.
bool createHistogram() const
void setStretchMode(StretchMode mode, bool rebuildTableFlag=false)
Sets remap mode to mode.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool scanForMinMaxNull() const
bool isFiltered(const ossimFilename &f) const
Convenience method to check file to see is if file should be processed.
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual void setNullPix(ossim_float64 null_pix)
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
ossimImageUtil()
default constructor
void setCompressionType(const std::string &type)
Sets the compression type to use when building overviews.
ossimString expandEnvironmentVariable() const
If the variable "$(env_var_name)" is found in the string, where "env_var_name" is any system environm...
virtual ossim_uint32 getOverviewStopDimension() const
Get the overview stop dimension.
void executeFileCommands(const ossimFilename &file) const
run per file system commands.
bool errors(ossimErrorSeverity severity=OSSIM_BENIGN) const
virtual const ossimFilename & getFilename() const
Returns the filename.
OSSIM_DLL void getFormattedTime(const std::string &format, bool gmtFlag, std::string &result)
Gets the current time.
virtual const char * what() const
Returns the error message.
void dumpFilteredImageList() const
Dumps filtered image list to std out.
std::string::size_type size() const
void createOverview(ossimRefPtr< ossimImageHandler > &ih, bool &consumedHistogramOptions, bool &consumedCmmOptions)
void setTileSize(ossim_uint32 tileSize)
Sets the tile size.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
Method to populate a list of supported types of all factories registered to this registry.
bool toBool() const
String to numeric methods.
static const char * COMPRESSION_TYPE_KW
virtual bool execute()=0
Builds the overviews.
virtual void setFlushStreamFlag(bool flag)
virtual ossim_uint32 getImageTileHeight() const =0
Returns the tile width of the image or 0 if the image is not tiled.
virtual bool setOutputToInputBandList()
If the image handler "isBandSeletor()" then the band selection of the output are set to input or iden...
unsigned int ossim_uint32
void setNumberOfThreads(ossim_uint32 nThreads)
Sets the max number of threads(jobs) to run at one time.
bool getDumpFilterImagesFlag() const
void setProps(ossimPropertyInterface *pi) const
set reader or writer properties based on cast of pi.
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
void setApplicationName(const ossimString &name)
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
int getThumbnailStretchType() const
void computeMinMax(ossimRefPtr< ossimImageHandler > &ih)
virtual ossim_uint32 getCurrentEntry() const
virtual void enableSource()
virtual void setOutputFile(const ossimFilename &file)=0
Sets the output file name.
static ossimString downcase(const ossimString &aString)
ossim_int32 m_errorStatus
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
ossim_uint32 getNextWriterPropIndex() const
ossim_uint32 getThumbnailSize() const
bool rebuildHistogram() const
void setScanForMinMaxNull(bool flag)
Sets scan for min/max/null flag keyword SCAN_MIN_MAX_KW used by processFile method.
virtual ossim_uint32 getNumberOfEntries() const
ossim_uint32 width() const
static const char * BANDS_KW
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
ossim_float64 height() const
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
void addOptions(ossimApplicationUsage *au)
void setOutputFileNamesFlag(bool flag)
Sets the output file name flag OUTPUT_FILENAMES_KW.
void setScanForMinMax(bool flag)
Sets scan for min/max flag keyword SCAN_MIN_MAX_KW used by processFile method.
void setMaxValueOverride(ossim_float32 maxValueOverride)
ossim_uint32 getNextReaderPropIndex() const
bool createThumbnails() const
bool getOverrideFilteredImagesFlag() const
void executeCommands(const std::string &prefix, const ossimFilename &file) const
system commands.
virtual ossim_uint32 getImageTileWidth() const =0
Returns the tile width of the image or 0 if the image is not tiled.
virtual ~ossimImageUtil()
virtual destructor
static ossimOverviewBuilderFactoryRegistry * instance()
instance method for access to theInstance pointer.
void executePostCommands() const
run post system commands.
virtual ossimImageSource * createImageSource(const ossimString &name) const
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimHistogramMode getHistogramMode() const
This class defines an abstract Handler which all image handlers(loaders) should derive from...
const std::vector< std::string > & getFilteredImages() const
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
virtual void loadMetaData()
There is an external file with an omd extension.
void setNumberOfThreads(ossim_uint32 threads)
Set number of threads to use.
virtual void setProperty(const ossimString &name, const ossimString &value)
void setDumpFilteredImageListFlag(bool flag)
Sets the dump filteredImageList flag.
virtual void setThreeBandRgb()
Will set to three bands (rgb) out.
static const char * COMPRESSION_QUALITY_KW
ossimFilename dirCat(const ossimFilename &file) const
void setCreateOverviewsFlag(bool flag)
Sets create overviews flag keyword CREATE_OVERVIEWS_KW used by processFile method.
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual void setSupplementaryDirectory(const ossimFilename &dir)
Sets the supplementary directory.
virtual ossimFilename createDefaultHistogramFilename() const
void outputOverviewWriterTypes() const
static ossimInit * instance()
void createThumbnail(ossimRefPtr< ossimImageHandler > &ih)
bool initialize(ossimArgumentParser &ap)
Initial method.
void setCompressionQuality(const std::string &quality)
Sets the writer property for compression quality.
ossimFilename file() const
void setRebuildOverviewsFlag(bool flag)
Sets the rebuild overview flag keyword REBUILD_OVERVIEWS_KW used by processFile method.
virtual void setMaxNumberOfRLevels(ossim_uint32 number)
ossimImageFileWriter * createWriter(const ossimFilename &filename) const
bool isDirectoryBasedImage(const ossimImageHandler *ih) const
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
static ossimImageHandlerRegistry * instance()
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
void setCreateThumbnailsFlag(bool flag)
Sets create thumbnails flag keyword CREATE_THUMBNAILS_KW used by processFile method.
void setOverviewType(const std::string &type)
Sets key OVERVIEW_TYPE_KW.
virtual void initialize()=0
ossimString & gsub(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
Substitutes searchKey string with replacementValue and returns a reference to *this.
void setThumbnailStretchType(const std::string &value)
void setWaitOnDirFlag(bool flag)
Sets waitOnDir flag.
void setOverviewStopDimension(ossim_uint32 dimension)
sets the overview stop dimension.
void gsubDate(const std::string &commandPrefix, ossimString &command) const
Expands date variables in a command string.
virtual ossim_uint32 getNumberOfInputBands() const =0
virtual void setFilename(const ossimFilename &filename)
void setMinValueOverride(ossim_float32 minValueOverride)
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual void setTileSize(const ossimIpt &tileSize)
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
ossimOverviewBuilderBase * createBuilder(const ossimString &typeName) const
Creates a builder from a string.
virtual bool setOutputBandList(const std::vector< ossim_uint32 > &band_list)
If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled...
bool hasCmmOption() const
void setRebuildHistogramFlag(bool flag)
Sets the rebuild histogram flag keyword REBUILD_HISTOGRAM_KW used by processFile method.
ossimFilename getFilenameWithThisExtension(const ossimString &ext, bool set_e0_prefix=false) const
Returns the image file with extension set using supplentary directory for dirname if set...
int & argc()
return the argument count.
ossim_int32 execute()
Execute method.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
ossimFilename path() const
bool getCopyAllFlag() const
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
static ossimImageSourceFactoryRegistry * instance()
void walk(const std::vector< ossimFilename > &files)
Takes an array of files.
void setInternalOverviewsFlag(bool flag)
Sets the overview builder internal overviews flag.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool openHistogram(const ossimFilename &histogram_file)
Open the histogram file.
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()
ossim_uint32 getNumberOfThreads() const
void writeErrorMessages(std::ostream &output, ossimErrorSeverity sevrity=OSSIM_BENIGN)
write out error messages at an above specified .
const std::string & string() const
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
void setHistogramMode(ossimHistogramMode mode)
Sets the histogram accumulation mode.