OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimImageHandler.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description:
10 //
11 // This class defines an abstract image handler which all loaders should
12 // derive from.
13 //
14 //*******************************************************************
15 // $Id: ossimImageHandler.cpp 23013 2014-12-02 19:21:56Z okramer $
16 
19 #include <ossim/base/ossimCommon.h>
28 #include <ossim/base/ossimNotify.h>
32 #include <ossim/base/ossimTrace.h>
42 #include <algorithm>
43 
44 RTTI_DEF1(ossimImageHandler, "ossimImageHandler", ossimImageSource)
45 
46 // Static trace for debugging
47 static ossimTrace traceDebug("ossimImageHandler:debug");
48 
49 // Property keywords.
50 static const char HAS_LUT_KW[] = "has_lut";
51 static const char OPEN_OVERVIEW_FLAG_KW[] = "open_overview_flag";
52 static const char START_RES_LEVEL_KW[] = "start_res_level";
53 static const char SUPPLEMENTARY_DIRECTORY_KW[] = "supplementary_directory";
54 static const char VALID_VERTICES_FILE_KW[] = "valid_vertices_file";
55 
56 #ifdef OSSIM_ID_ENABLED
57 static const char OSSIM_ID[] = "$Id: ossimImageHandler.cpp 23013 2014-12-02 19:21:56Z okramer $";
58 #endif
59 
60 // GARRETT! All of the decimation factors are scattered throughout. We want to fold that into
61 // the image geometry object. The code is ready in ossimImageGeometry for this (more or less), but
62 // the ossimImageGeometry::m_decimationFactors is not being set nor referenced. Can you do this?
63 // I'm a little foggy on how we want to incorporate R-level scaling into the geometry object.
64 
66 :
67 ossimImageSource(0, 0, 0, true, false /* output list is not fixed */ ),
68 theImageFile(ossimFilename::NIL),
69 theOverviewFile(ossimFilename::NIL),
70 theSupplementaryDirectory(ossimFilename::NIL),
71 theOverview(0),
72 theValidImageVertices(0),
73 theMetaData(),
74 theGeometry(),
75 theLut(0),
76 theDecimationFactors(0),
77 theImageID(""),
78 theStartingResLevel(0),
79 theOpenOverviewFlag(true),
80 thePixelType(OSSIM_PIXEL_IS_POINT)
81 {
82  if (traceDebug())
83  {
85  << "ossimImageHandler::ossimImageHandler() DEBUG:" << std::endl;
86 #ifdef OSSIM_ID_ENABLED
88  << "OSSIM_ID: "
89  << OSSIM_ID
90  << std::endl;
91 #endif
92  }
93 
94  // Check for global preference supplementary dir.
96  preferencesKWL().findKey( std::string("ossim_supplementary_directory") );
97 }
98 
100 {
101  theOverview = 0;
102 }
103 
105 {
106 }
107 
108 //*******************************************************************
109 // Public method:
110 //*******************************************************************
112  const char* prefix) const
113 {
114  static const char MODULE[] = "ossimImageHandler::saveState";
115 
116  ossimImageSource::saveState(kwl, prefix);
118  {
120  << MODULE
121  << " ERROR detected in keyword list! State not saved."
122  << std::endl;
123  return false;
124  }
125 
127  kwl.add(prefix, HAS_LUT_KW, (theLut.valid()?"true":"false"), true);
128  kwl.add(prefix, ossimKeywordNames::IMAGE_ID_KW, theImageID, true);
130  kwl.add(prefix, SUPPLEMENTARY_DIRECTORY_KW, theSupplementaryDirectory.c_str(), true);
131  kwl.add(prefix, START_RES_LEVEL_KW, theStartingResLevel, true);
132  kwl.add(prefix, OPEN_OVERVIEW_FLAG_KW, (theOpenOverviewFlag?"1":"0"), true);
134 
135  return true;
136 }
137 
138 //*******************************************************************
139 // Public method:
140 //*******************************************************************
142  const char* prefix)
143 {
144  static const char MODULE[] = "ossimImageHandler::loadState(kwl, prefix)";
145  theDecimationFactors.clear();
146  if(traceDebug())
147  {
149  << MODULE << " DEBUG: entered ..."
150  << std::endl;
151  }
152 
153  ossimImageSource::loadState(kwl, prefix);
154 
156  {
158  << MODULE
159  << "WARNING: error detected in keyword list! State not load."
160  << std::endl;
161 
162  if(traceDebug())
163  {
165  << MODULE << " DEBUG: "
166  << "leaving with error in kwl ..." << std::endl;
167  }
168  return false;
169  }
170 
171  const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
172  if (!lookup)
173  {
174  // Deprecated...
175  lookup = kwl.find(prefix, ossimKeywordNames::IMAGE_FILE_KW);
176  }
177 
178  if (lookup)
179  {
180  theImageFile = lookup;
181  }
182 
183  lookup = kwl.find(prefix, ossimKeywordNames::OVERVIEW_FILE_KW);
184  if(lookup)
185  {
186  theOverviewFile = ossimFilename(lookup);
187  }
188  if(traceDebug())
189  {
191  << MODULE << " DEBUG:\n"
192  << "filename = " << theImageFile << std::endl;
193  }
194 
195  // Check for an external geometry file to initialize our image geometry object:
196  lookup = kwl.find(prefix, ossimKeywordNames::GEOM_FILE_KW);
197  if (lookup)
198  {
199  ossimKeywordlist geomKwl;
200  if (geomKwl.addFile(lookup) == true)
201  {
203  theGeometry->loadState(geomKwl);
204  if(traceDebug())
205  {
207  << MODULE << " DEBUG:"
208  << "Loaded external geometry file: "
209  << lookup
210  << "\n" << geomKwl << std::endl;
211  }
212  }
213  }
214 
215  // Check for an valid image vetices file.
216  lookup = kwl.find(prefix, VALID_VERTICES_FILE_KW);
217  if (lookup)
218  {
219  initVertices(lookup);
220  }
221 
222  // Starting resolution level.
223  lookup = kwl.find(prefix, START_RES_LEVEL_KW);
224  if (lookup)
225  {
227  }
228 
229  // Open overview flag.
230  lookup = kwl.find(prefix, OPEN_OVERVIEW_FLAG_KW);
231  if (lookup)
232  {
233  setOpenOverviewFlag( ossimString(lookup).toBool() );
234  }
235 
236  // The supplementary directory for finding the overview
237  lookup = kwl.find(prefix, SUPPLEMENTARY_DIRECTORY_KW);
238  if (lookup)
239  {
241  }
242 
243  if(getNumberOfInputs())
244  {
245  theInputObjectList.clear();
246  }
248 
249  // Read image id if present:
251 
252  lookup = kwl.find(prefix, ossimKeywordNames::PIXEL_TYPE_KW);
253  if (lookup)
254  {
255  thePixelType = (ossimPixelType) atoi(lookup);
256  }
257 
258  if(traceDebug())
259  {
261  << MODULE << " DEBUG: Leaving Ok ..."
262  << std::endl;
263  }
264  return true;
265 }
266 
267 bool ossimImageHandler::initVertices(const char* file)
268 {
269  static const char MODULE[] = "ossimImageHandler::initVertices";
270  bool loadFromFileFlag = true;
271  std::shared_ptr<ossimKeywordlist> kwl;
272  if(m_state)
273  {
274  bool validVerticesFlag = false;
275  if(m_state->getValidVertices())
276  {
277  loadFromFileFlag = false;
278  kwl = m_state->getValidVertices();
279  if(kwl)
280  {
281  ossimString connectionString = kwl->find("connection_string");
282  if(connectionString != file)
283  {
284  loadFromFileFlag = true;
285  }
286  else if(kwl->getSize()<=0)
287  {
288  return false;
289  }
290  }
291  }
292  else
293  {
294  loadFromFileFlag = true;
295  }
296  }
297  if(!kwl) kwl = std::make_shared<ossimKeywordlist>();
298 
299  if(loadFromFileFlag)
300  {
301  kwl = std::make_shared<ossimKeywordlist>();
302  std::shared_ptr<ossim::istream> instream = ossim::StreamFactoryRegistry::instance()->createIstream(file);
303  kwl->add("connection_string", file, true);
304  if (!instream)
305  {
306  //if(m_state)
307  // m_state->setValidVertices(kwl);
308  return false;
309  }
310 
311  kwl->parseStream(*instream);
312  if(m_state && kwl->getSize())
313  m_state->setValidVertices(kwl);
314  }
315 
316  if (kwl->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
317  {
318  if (traceDebug())
319  {
321  << "ossimImageHandler::initVertices NOTICE:"
322  << "\nError reading valid vertice file: " << file << std::endl;
323  }
324  return false;
325  }
326 
327  // Clean out any old vertices...
328  theValidImageVertices.clear();
329  std::vector<ossimString> indexedPrefixes;
330  kwl->getSortedList(indexedPrefixes, "point");
331  ossim_uint32 number_of_points = indexedPrefixes.size();
332  for (ossim_uint32 i=0; i<number_of_points; i++)
333  {
334  ossimIpt pt;
335  const char* lookup;
336  lookup = kwl->find(indexedPrefixes[i], ".x");
337  if (lookup)
338  {
339  pt.x = atoi(lookup);
340  lookup = kwl->find(indexedPrefixes[i], ".y");
341  if (lookup)
342  pt.y = atoi(lookup);
343  }
344 
345  if (!lookup)
346  {
347  if (traceDebug())
348  CLOG << " ERROR: lookup failed for: " << indexedPrefixes[i] << std::endl;
349  return false;
350  }
351 
352  theValidImageVertices.push_back(pt);
353  }
354 
355 
356  if (traceDebug())
357  {
358  CLOG << " DEBUG:"
359  << "\nVertices file: " << file
360  << "\nValid image vertices:"
361  << std::endl;
362  for (ossim_uint32 i=0; i<theValidImageVertices.size(); ++i)
363  {
365  << "\npoint[" << i << "]: " << theValidImageVertices[i];
366  }
367  ossimNotify(ossimNotifyLevel_DEBUG) << std::endl;
368  }
369 
370  return true;
371 }
372 
374 {
375  ossim_uint32 result = 1; // Add r0
376  if (theOverview.valid())
377  {
379  }
380  return result;
381 }
382 
384 {
386 }
387 
389 {
390  ossimIrect result;
391 
392  if( isOpen() && isValidRLevel(resLevel) )
393  {
394  ossim_int32 lines = getNumberOfLines(resLevel);
395  ossim_int32 samples = getNumberOfSamples(resLevel);
396  if( !lines || !samples )
397  {
398  result.makeNan();
399  }
400  else
401  {
402  result = ossimIrect(0, 0, samples-1, lines-1);
403  }
404  }
405  else
406  {
407  result.makeNan();
408  }
409 
410  return result;
411 }
412 
414 {
415  return getImageRectangle(resLevel);
416 }
417 
418 
420 {
421  if (resLevel < theDecimationFactors.size())
422  result = theDecimationFactors[resLevel];
423  else
424  result.makeNan();
425 }
426 
427 void ossimImageHandler::getDecimationFactors(vector<ossimDpt>& decimations) const
428 {
429  decimations = theDecimationFactors;
430 }
431 
432 //*************************************************************************************************
433 // Method determines the decimation factors at each resolution level. This
434 // base class implementation computes the decimation by considering the ratios in image size
435 // between resolution levels, with fuzzy logic for rounding ratios to the nearest power of 2
436 // if possible. Derived classes need to override this method if the decimations are provided
437 // as part of the image metadata. In some cases (cf. ossimNitfTileSource), the derived class can
438 // set the first R-level (R0) decimation in the case that it is not unity, and then invoke this
439 // base class implementation to compute remaining R-levels, respecting the R0 decimation previously
440 // set by derived class.
441 //*************************************************************************************************
443 {
444  double line_decimation, samp_decimation, decimation, ratio;
445  ossim_uint32 num_lines, num_samps;
446 
447  // The error margin here is effectively the percent error tolerated between ideal number of
448  // pixels for given power-of-2 decimation, and the actual number of pixels found at this
449  // decimation level. Typically, the last level will have fewer pixels than expected, hence the
450  // need for this logic...
451  static const double ERROR_MARGIN = 1.1; // 10% allowance
452 
453  // NOTE -- Until the end of this method, all decimation values are actually inverse quantities,
454  // i.e., a decimation of 0.5 typical for rlevel 1 is represented here as 2. This facilitates the
455  // fuzzy logic for recognizing powers of 2 (as integers)
456 
457  // Default implementation assumes R0 is not decimated. Check for R0 defined by derived class
458  // however, in case this is not the case:
459  ossimDpt decimation_r0 (1.0, 1.0);
460  if (theDecimationFactors.size() > 0)
461  {
462  decimation_r0.x = 1.0/theDecimationFactors[0].x; // note use of inverse decimation
463  decimation_r0.y = 1.0/theDecimationFactors[0].y;
464  }
465  else
466  theDecimationFactors.push_back(decimation_r0);
467 
468  // Variables used in loop below:
469  ossim_uint32 num_lines_r0 = getNumberOfLines(0);
470  ossim_uint32 num_samps_r0 = getNumberOfSamples(0);
471  ossim_uint32 power_of_2_decimation = (ossim_uint32) decimation_r0.x;
472 
473  // Remaining res levels are computed as a ratio of image size at R0 to image size at Rn:
475  for(ossim_uint32 res_level = 1; res_level < nRlevels; ++res_level)
476  {
477  num_lines = getNumberOfLines(res_level);
478  num_samps = getNumberOfSamples(res_level);
479 
480  if ((num_lines < 2) || (num_samps < 2))
481  break;
482 
483  line_decimation = decimation_r0.y * num_lines_r0 / (double)num_lines;
484  samp_decimation = decimation_r0.x * num_samps_r0 / (double)num_samps;
485  decimation = line_decimation<samp_decimation ? line_decimation:samp_decimation;
486 
487  // Check for possible error due to inexact ratios.
488  // Loop until reasonable effort was made to establish the corresponding power-of-2 decimation.
489  // If close match is found, the exact integer value is assigned:
490  do
491  {
492  power_of_2_decimation *= 2;
493  ratio = (double)power_of_2_decimation / decimation;
494  if (ratio < 1.0)
495  ratio = 1.0/ratio;
496  if (ratio < ERROR_MARGIN)
497  decimation = (double) power_of_2_decimation;
498 
499  } while ((double) power_of_2_decimation < decimation);
500 
501  // Convert the computed decimation back to fractional form before saving in the factors list:
502  decimation = 1.0/decimation;
503  theDecimationFactors.push_back(ossimDpt(decimation, decimation));
504  }
505 }
506 
507 bool ossimImageHandler::buildHistogram( int numberOfRLevels,
508  ossimHistogramMode mode )
509 {
510  if(isOpen())
511  {
512  ossimFilename file =
514 
517 
518  if(numberOfRLevels)
519  {
520  histoSource->setMaxNumberOfRLevels(numberOfRLevels);
521  }
522  else
523  {
525  }
526 
527  //---
528  // Note if mode==OSSIM_HISTO_MODE_UNKNOWN the histoSource defaults to
529  // normal mode.
530  //---
531  histoSource->setComputationMode( mode );
532 
533  histoSource->connectMyInputTo(0, this);
534  histoSource->enableSource();
535  writer->connectMyInputTo(0, histoSource.get());
536  writer->setFilename(file);
537  writer->addListener(&theStdOutProgress);
538  writer->execute();
539  histoSource->disconnect();
540  writer->disconnect();
541  histoSource = 0;
542  writer = 0;
543  }
544  else
545  {
546  return false;
547  }
548 
549  return true;
550 }
551 
552 bool ossimImageHandler::buildAllHistograms( int numberOfRLevels,
553  ossimHistogramMode mode )
554 {
555  ossim_uint32 currentEntry = getCurrentEntry();
556  std::vector<ossim_uint32> entryList;
557  getEntryList(entryList);
558  ossim_uint32 idx = 0;
559  for(idx = 0; idx < entryList.size(); ++idx)
560  {
561  setCurrentEntry(entryList[idx]);
562  if(!buildHistogram( numberOfRLevels, mode ))
563  {
564  setCurrentEntry(currentEntry);
565  return false;
566  }
567  }
568 
569  setCurrentEntry(currentEntry);
570  return true;
571 }
572 
574  ossim_uint32 quality,
576  bool includeFullResFlag)
577 {
579 
580  theOverviewFile = file;
581  if(buildOverview(file, compressionType, quality, resampleType, includeFullResFlag))
582  {
583  openOverview();
584  }
585 
586  return true;
587 }
588 
590  ossim_uint32 quality,
592  bool includeFullResFlag)
593 {
594  ossim_uint32 currentEntry = getCurrentEntry();
595  std::vector<ossim_uint32> entryList;
596  getEntryList(entryList);
597  ossim_uint32 idx = 0;
598  for(idx = 0; idx < entryList.size(); ++idx)
599  {
600  setCurrentEntry(entryList[idx]);
601  if(!buildOverview(compressionType, quality, resampleType, includeFullResFlag))
602  {
603  setCurrentEntry(currentEntry);
604  return false;
605  }
606  }
607 
608  setCurrentEntry(currentEntry);
609  return true;
610 }
611 
612 
615  ossim_uint32 quality,
617  bool includeFullResFlag)
618 {
619  closeOverview();
620  if(!isOpen())
621  {
622  return false;
623  }
624 
625  theOverviewFile = filename;
626  ossimTiffOverviewBuilder tiffBuilder;
627  if ( tiffBuilder.setInputSource(this) == false )
628  {
629  return false;
630  }
631 
633  switch(compressionType)
634  {
636  {
637  cType = COMPRESSION_NONE;
638  break;
639  }
641  {
642  cType = COMPRESSION_JPEG;
643  break;
644  }
646  {
647  cType = COMPRESSION_LZW;
648  break;
649  }
651  {
652 
653  cType = COMPRESSION_DEFLATE;
654  break;
655  }
657  {
658  cType = COMPRESSION_PACKBITS;
659  break;
660  }
661  }
662  tiffBuilder.setJpegCompressionQuality(quality);
663  tiffBuilder.setCompressionType(cType);
664  tiffBuilder.setResampleType(resampleType);
665  tiffBuilder.buildOverview(filename, includeFullResFlag);
666 
667  return true;
668 }
669 
671 {
673  if ( isOpen() )
674  {
676  histogram = new ossimMultiResLevelHistogram();
677  if ( histogram->importHistogram(histoFile) == false )
678  {
679  histogram = 0;
680  }
681  }
682  return histogram;
683 }
684 
686 {
687  if ( !theGeometry )
688  {
689  //---
690  // Check factory for external geom:
691  //---
693 
694  if ( !theGeometry )
695  {
696  //---
697  // WARNING:
698  // Must create/set the geometry at this point or the next call to
699  // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop
700  // as it does a recursive call back to ossimImageHandler::getImageGeometry().
701  //---
704 
705  //---
706  // And finally allow factories to extend the internal geometry.
707  // This allows plugins for tagged formats with tags not know in the base
708  // to extend the internal geometry.
709  //
710  // Plugins can do handler->getImageGeometry() then modify/extend.
711  //---
713  {
714  //---
715  // Check for internal, for geotiff, nitf and so on as last resort for getting some
716  // kind of geometry loaded
717  //---
720  }
721  }
722  }
723  return theGeometry;
724 }
725 
727 {
729  // No geometry object has been set up yet. Check for external geometry file.
730  // Try "foo.geom" if image is "foo.tif":
731  ossimFilename filename;
732  getFilenameWithThisExt( ossimString(".geom"), filename );
733 
734  if(!filename.exists())
735  {
736  // Try "foo_e0.tif" if image is "foo.tif" where "e0" is entry index.
737  filename = getFilenameWithThisExtension(ossimString(".geom"), true);
738  }
739 
740 #if 0
741 /* getgetFilenameWithThisExt... methods tack on sup dir if set. drb */
742  if(!filename.exists())
743  {
744  // Try supplementary data directory for remote geometry:
745  filename = getFilenameWithThisExtension(ossimString(".geom"), false);
746  filename = theSupplementaryDirectory.dirCat(filename.file());
747  }
748  if(!filename.exists())
749  {
750  // Try supplementary data directory for remote geometry with entry index:
751  filename = getFilenameWithThisExtension(ossimString(".geom"), true);
752  filename = theSupplementaryDirectory.dirCat(filename.file());
753  }
754 #endif
755 
756  if(filename.exists())
757  {
758  // Open the geom file as a KWL and initialize our geometry object:
759  filename = filename.expand();
760  ossimKeywordlist geomKwl(filename);
761 
762  // Try loadState with no prefix.
763  std::string prefix = "";
764  std::string key = ossimKeywordNames::TYPE_KW;
765  std::string value = geomKwl.findKey(prefix, key);
766 
767  if ( value.empty() || (value != "ossimImageGeometry") )
768  {
769  // Try with "image0." type prefix.
770  prefix += std::string("image") + ossimString::toString(getCurrentEntry()).string() +
771  std::string(".");
772  value = geomKwl.findKey(prefix, key);
773 
774  if ( value.empty() || (value != "ossimImageGeometry") )
775  {
776  // Try with "image0.geometry." prefix.
777  prefix += std::string( "geometry." );
778  value = geomKwl.findKey(prefix, key);
779 
780  if ( value.empty() || (value != "ossimImageGeometry") )
781  {
782  // Try with "geometry." prefix.
783  prefix = std::string( "geometry." );
784  value = geomKwl.findKey(prefix, key);
785  }
786  }
787  }
788 
789  if ( value == "ossimImageGeometry" )
790  {
791  geom = new ossimImageGeometry;
792  if( !geom->loadState(geomKwl, prefix.c_str()) )
793  {
794  geom = 0;
795  }
796  }
797  }
798 
799  return geom;
800 }
801 
803 {
804  // Default, derived classes should override.
806  return geom;
807 }
808 
810 {
811  theGeometry = geom;
812 }
813 
815 {
816  ossimFilename geometryFile = getFilenameWithThisExtension(ossimString(".geom"));
817  saveImageGeometry(geometryFile);
818 }
819 
820 void ossimImageHandler::saveImageGeometry(const ossimFilename& geometry_file) const
821 {
822  if (theGeometry.valid())
823  {
824  ossimKeywordlist kwl;
825  theGeometry->saveState(kwl);
826  kwl.write(geometry_file.chars());
827  }
828 }
829 
831 {
832  theOverview = 0;
833 }
834 
836 {
837  return theOverview.get();
838 }
839 
841 {
842  return (getNumberOfDecimationLevels() > 1);
843 }
844 
846 {
847  bool result = false;
848  if (traceDebug())
849  {
851  << "ossimImageHandler::openOverview(overview_file): ...entered!";
852  }
853  closeOverview();
854 
855  if (overview_file != theImageFile) // Make sure we don't open ourselves.
856  {
857  //---
858  // Get the number of level before the call to opening the overview so
859  // the overview can be told what it's starting res level is.
860  //---
861  ossim_uint32 overviewStartingResLevel = getNumberOfDecimationLevels();
862 
863 
864  // Try to open:
866  if (theOverview.valid())
867  {
868  result = true;
869 
870  //---
871  // Set the owner in case the overview reader needs to get something
872  // from the it like min/max/null.
873  //---
874  theOverview->changeOwner(this);
875 
876  // Set the starting res level of the overview.
877  theOverview->setStartingResLevel(overviewStartingResLevel);
878 
879  // Capture the file name.
880  theOverviewFile = overview_file;
881 
882  //---
883  // Some overview handlers cannot store what the null is. Like dted
884  // null is -32767 not default -32768 so this allows passing this to the
885  // overview reader provided it overrides setMin/Max/NullPixel value
886  // methods. (drb)
887  //---
888  const ossim_uint32 BANDS = getNumberOfOutputBands();
889  for (ossim_uint32 band = 0; band < BANDS; ++band)
890  {
894  }
895  if(m_state)
896  {
897  m_state->setOverviewState(theOverview->getState());
898  }
899  if (traceDebug())
900  {
902  << "overview starting res level: " << overviewStartingResLevel
903  << "\noverview levels: "
905  << "\nlevels: " << getNumberOfDecimationLevels()
906  << endl;
907  }
908 
909  //---
910  // This is not really a container event; however, using for now.
911  //---
912  ossimContainerEvent event(this,
914  event.setObjectList(theOverview.get());
915  fireEvent(event);
916  }
917  }
918  if (traceDebug())
919  {
921  << "ossimImageHandler::openOverview(overview_file): ...leaving!";
922  }
923 
924  return result;
925 }
926 
928 {
929  static const char MODULE[] = "ossimImageHandler::openOverview()";
930  if (traceDebug())
931  {
932  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
933  }
934 
935  bool result = false;
936 
937  closeOverview();
938 
939  if(m_state)
940  {
941  // check if we have an overview state
942  std::shared_ptr<ossim::ImageHandlerState> overviewState = m_state->getOverviewState();
943  if(overviewState)
944  {
945  // check to see if the overvies state was cached
946  // to mark has checked but no overview
947  if(overviewState->getConnectionString().empty())
948  {
949  return false;
950  }
951  ossim_uint32 overviewStartingResLevel = getNumberOfDecimationLevels();
953  if(theOverview)
954  {
955  result = true;
956  //---
957  // Set the owner in case the overview reader needs to get something
958  // from the it like min/max/null.
959  //---
960  theOverview->changeOwner(this);
961 
962  // Set the starting res level of the overview.
963  theOverview->setStartingResLevel(overviewStartingResLevel);
964 
965  // Capture the file name.
966  theOverviewFile = overviewState->getConnectionString();
967 
968  //---
969  // Some overview handlers cannot store what the null is. Like dted
970  // null is -32767 not default -32768 so this allows passing this to the
971  // overview reader provided it overrides setMin/Max/NullPixel value
972  // methods. (drb)
973  //---
974  const ossim_uint32 BANDS = getNumberOfOutputBands();
975  for (ossim_uint32 band = 0; band < BANDS; ++band)
976  {
980  }
981  if (traceDebug())
982  {
984  << "overview starting res level: " << overviewStartingResLevel
985  << "\noverview levels: "
987  << "\nlevels: " << getNumberOfDecimationLevels()
988  << endl;
989  }
990 
991  //---
992  // This is not really a container event; however, using for now.
993  //---
994  ossimContainerEvent event(this,
996  event.setObjectList(theOverview.get());
997  fireEvent(event);
998  return result;
999  }
1000  }
1001  }
1002  // 1) ESH 03/2009 -- Use the overview file set e.g. using a .spec file.
1003  ossimFilename overviewFilename = getOverviewFile();
1004 
1005  // ossimFilename::exists() currently does not work with s3 url's.
1006  if ( overviewFilename.empty() ) // || (overviewFilename.exists() == false) )
1007  {
1008  // 2) Generate the name from image name.
1009  overviewFilename = createDefaultOverviewFilename();
1010  }
1011 
1012  // ossimFilename::exists() currently does not work with s3 url's.
1013  if ( overviewFilename.size() )
1014  {
1015  result = openOverview( overviewFilename );
1016 
1017  if (traceDebug())
1018  {
1020  << (result?"Opened ":"Could not open ") << "overview: " << overviewFilename
1021  << "\n";
1022  }
1023  }
1024  if ( !result )
1025  {
1026  if (overviewFilename.empty() || (overviewFilename.exists() == false) )
1027  {
1028  // 3) For backward compatibility check if single entry and _e0.ovr
1029  overviewFilename = getFilenameWithThisExtension(ossimString(".ovr"), true);
1030 
1031  if (overviewFilename.empty() || (overviewFilename.exists() == false) )
1032  {
1033  //---
1034  // 4) For overviews built with gdal.
1035  // Examples:
1036  // Single entry: foo.tif.ovr
1037  // Multi-entry: foo.tif.x.ovr where "x" == one based entry number.
1038  //
1039  // Note: Take into account a supplementary dir if any.
1040  //---
1042  {
1043  overviewFilename = getFilename();
1044  }
1045  else
1046  {
1047  overviewFilename = theSupplementaryDirectory;
1048  overviewFilename = overviewFilename.dirCat( getFilename().file() );
1049 
1050  }
1051 
1052  if ( getNumberOfEntries() > 1 )
1053  {
1054  overviewFilename += ".";
1055  // Sample multi-entry data "one" based; hence, the + 1.
1056  overviewFilename += ossimString::toString( getCurrentEntry()+1 );
1057  }
1058  overviewFilename += ".ovr";
1059  }
1060  }
1061 
1062  if ( overviewFilename.exists() )
1063  {
1064  result = openOverview( overviewFilename );
1065 
1066  if (traceDebug())
1067  {
1069  << (result?"Opened ":"Could not open ") << "overview: " << overviewFilename
1070  << "\n";
1071  }
1072  }
1073  }
1074 
1075  if (traceDebug())
1076  {
1078  << MODULE << " exit result: " << (result?"true":"false") << "\n";
1079  }
1080 
1081  return result;
1082 }
1083 
1084 
1085 bool ossimImageHandler::writeValidImageVertices(const std::vector<ossimIpt>& vertices, const ossimFilename& file)
1086 {
1087  ossimFilename tempFile = file;
1088  if(tempFile == "")
1089  {
1091  }
1092  ossim_uint32 i = 0;
1093  ossimKeywordlist tempKwl;
1094  ossimPolygon poly(vertices);
1095 
1096  poly.checkOrdering();
1097 
1098  // Capture the vertices.
1099  theValidImageVertices = vertices;
1100 
1102  {
1103  std::reverse(theValidImageVertices.begin(), theValidImageVertices.end());
1104  }
1105 
1106  if(theValidImageVertices.size())
1107  {
1108  for(i = 0; i < theValidImageVertices.size(); ++i)
1109  {
1110  ossimString prefix = ossimString("point") + ossimString::toString(i) + ".";
1111  tempKwl.add(prefix.c_str(),
1112  "x",
1113  theValidImageVertices[i].x,
1114  true);
1115  tempKwl.add(prefix.c_str(),
1116  "y",
1117  theValidImageVertices[i].y,
1118  true);
1119  }
1120 
1121  tempKwl.write(tempFile.c_str());
1122  }
1123 
1124  if ( tempFile.exists() )
1125  {
1126  return true;
1127  }
1128 
1129  return false; // Write of file failed.
1130 }
1131 
1133 {
1134  return initVertices(vertices_file);
1135 }
1136 
1138 {
1139  ossimFilename vertices_file;
1140  vertices_file = theImageFile.path();
1141  vertices_file = vertices_file.dirCat(theImageFile.fileNoExtension());
1142  if(getNumberOfEntries() > 1)
1143  {
1144  vertices_file += ossimString("_vertices") + "_e" + ossimString::toString(getCurrentEntry()) + ".kwl";
1145  }
1146  else
1147  {
1148  vertices_file += "_vertices.kwl";
1149  }
1150 
1151  if (traceDebug())
1152  {
1154  << "Looking for " << vertices_file
1155  << " vertices file..." << std::endl;
1156  }
1157 
1158  return openValidVertices(vertices_file);
1159 }
1160 
1162 {
1163  if(isOpen())
1164  {
1165  close();
1166  }
1167 
1168  setFilename(imageFile);
1169 
1170  return open();
1171 }
1172 
1174  ossim_uint32 entryIndex)
1175 {
1176  if(isOpen())
1177  {
1178  close();
1179  }
1180  setFilename(imageFile);
1181 
1182  bool result = open();
1183 
1184  if(result)
1185  {
1186  return setCurrentEntry(entryIndex);
1187  }
1188 
1189  return result;
1190 }
1191 
1192 bool ossimImageHandler::open(std::shared_ptr<ossim::ImageHandlerState> state)
1193 {
1194  bool result = false;
1195  if(isOpen())
1196  {
1197  close();
1198  }
1199  setFilename(state->getConnectionString());
1200  setState(state);
1201  result = open();
1202 
1203  return result;
1204 }
1205 
1206 
1208 {
1209  bool result = false;
1210 
1211  const ossim_uint32 LEVELS = getNumberOfDecimationLevels();
1212 
1213  if ( !theStartingResLevel) // Not an overview.
1214  {
1215  result = (resLevel < LEVELS);
1216  }
1217  else // Used as overview.
1218  {
1219  if (resLevel >= theStartingResLevel)
1220  {
1221  //---
1222  // Adjust the res level to be zero based for this overview before
1223  // checking.
1224  //---
1225  result = ( (resLevel - theStartingResLevel) < LEVELS);
1226  }
1227  }
1228 
1229  return result;
1230 }
1231 
1232 void ossimImageHandler::getValidImageVertices(vector<ossimIpt>& validVertices,
1233  ossimVertexOrdering ordering,
1234  ossim_uint32 resLevel) const
1235 {
1236  ossimDpt decimation;
1237  getDecimationFactor(resLevel, decimation);
1238  if(decimation.hasNans())
1239  {
1240  return;
1241  }
1242  if (theValidImageVertices.size() != 0)
1243  {
1244  validVertices.clear();
1245  for (ossim_uint32 i=0; i<theValidImageVertices.size(); ++i)
1246  {
1247  ossimIpt pt(ossim::round<int>(theValidImageVertices[i].x*decimation.x),
1248  ossim::round<int>(theValidImageVertices[i].y*decimation.y));
1249  validVertices.push_back(pt);
1250  }
1251 
1252  if(ordering == OSSIM_COUNTERCLOCKWISE_ORDER)
1253  {
1254  std::reverse(validVertices.begin()+1, validVertices.end());
1255  }
1256  }
1257  else
1258  {
1259  // Call the base class method which will set to bounding rectangle.
1260  ossimImageSource::getValidImageVertices(validVertices, ordering, resLevel);
1261  }
1262 }
1263 
1265 {
1266  theOverview = 0;
1267  theGeometry = 0;
1268  theValidImageVertices.clear();
1269  theDecimationFactors.clear();
1270  setState(0);
1271 }
1272 
1274 {
1275  return false;
1276 }
1277 
1278 bool ossimImageHandler::setOutputBandList(const std::vector<ossim_uint32>& /* band_list */)
1279 {
1280  return false;
1281 }
1282 
1283 bool ossimImageHandler::getRgbBandList( std::vector<ossim_uint32>& bandList ) const
1284 {
1285  // Looks for "rgb_bands" key in dot omd file. E.g. "rgb_bands: (2,1,0)"
1286  return theMetaData.getRgbBands( bandList );
1287 }
1288 
1290 {
1291  bool result = false;
1292  if ( isBandSelector() )
1293  {
1294  std::vector<ossim_uint32> bandList;
1296  result = setOutputBandList( bandList );
1297  }
1298  return result;
1299 }
1300 
1301 bool ossimImageHandler::isIdentityBandList( const std::vector<ossim_uint32>& bandList ) const
1302 {
1303  bool result = false;
1304  const ossim_uint32 BANDS = (ossim_uint32)bandList.size();
1305  if ( BANDS )
1306  {
1307  std::vector<ossim_uint32> inputList;
1308  ossimImageSource::getOutputBandList( inputList ); // This populates an identity band list.
1309 
1310  if ( inputList.size() == BANDS )
1311  {
1312  ossim_uint32 band = 0;
1313  while ( band < BANDS )
1314  {
1315  if ( inputList[band] != bandList[band] )
1316  {
1317  break;
1318  }
1319  ++band;
1320  }
1321  if ( band == BANDS )
1322  {
1323  result = true;
1324  }
1325  }
1326  }
1327  return result;
1328 }
1329 
1330 // Protected convenience method:
1331 bool ossimImageHandler::setOutputBandList(const std::vector<ossim_uint32>& inBandList,
1332  std::vector<ossim_uint32>& outBandList)
1333 {
1334  bool result = false;
1335 
1336  const ossim_uint32 INPUT_BANDS = getNumberOfInputBands();
1337  const ossim_uint32 OUTPUT_BANDS = (ossim_uint32)inBandList.size();
1338 
1339  if ( INPUT_BANDS && OUTPUT_BANDS )
1340  {
1341  result = true;
1342  outBandList.resize( OUTPUT_BANDS );
1343  for ( ossim_uint32 band = 0; band < OUTPUT_BANDS; ++band )
1344  {
1345  if ( inBandList[band] < INPUT_BANDS )
1346  {
1347  outBandList[band] = inBandList[band];
1348  }
1349  else // Out of range...
1350  {
1351  result = false;
1352  break;
1353  }
1354  }
1355  if ( result && theOverview.valid() )
1356  {
1357  result = theOverview->setOutputBandList( inBandList );
1358  }
1359  }
1360 
1361  if ( result == false )
1362  {
1363  ossimImageSource::getOutputBandList( outBandList ); // Set to identity.
1364  }
1365 
1366  return result;
1367 }
1368 
1370 {
1371  return (getImageTileWidth() && getImageTileHeight());
1372 }
1373 
1375 {
1376 
1377  if(m_state&&m_state->getMetaData())
1378  {
1379  theMetaData = *m_state->getMetaData();
1380  }
1381  else
1382  {
1383  ossimFilename filename = getFilenameWithThisExtension(ossimString(".omd"), false);
1384  theMetaData.clear();
1385 
1386  std::shared_ptr<ossim::istream> instream = ossim::StreamFactoryRegistry::instance()->createIstream(filename.c_str());
1387 
1388  if(!instream)
1389  {
1390  filename = getFilenameWithThisExtension(ossimString(".omd"), true);
1392  }
1393 
1394  if(instream)
1395  {
1396  ossimKeywordlist kwl;
1397 
1398  kwl.parseStream(*instream);
1399 
1400  theMetaData.loadState(kwl);
1401  }
1402  else
1403  {
1405  }
1406  if(m_state)
1407  {
1408  m_state->setMetaData(std::make_shared<ossimImageMetaData>(theMetaData));
1409  }
1410 
1411  }
1412 
1413 }
1414 
1416 {
1418  {
1419  return theMetaData.getMinPix(band);
1420  }
1422 }
1423 
1425 {
1427  {
1428  return theMetaData.getMaxPix(band);
1429  }
1431 }
1432 
1434 {
1436  {
1437  return theMetaData.getNullPix(band);
1438  }
1439 
1441 }
1442 
1444  const ossim_float64& pix)
1445 {
1446  theMetaData.setMinPix(band, pix);
1447 }
1448 
1450  const ossim_float64& pix)
1451 {
1452  theMetaData.setMaxPix(band, pix);
1453 }
1454 
1456  const ossim_float64& pix)
1457 {
1458  theMetaData.setNullPix(band, pix);
1459 }
1460 
1462 {
1463  return 0;
1464 }
1465 
1467 {
1468  return true;
1469 }
1470 
1472 {
1473  return theOverviewFile;
1474 }
1475 
1476 void ossimImageHandler::getEntryList(std::vector<ossim_uint32>& entryList)const
1477 {
1478  entryList.push_back(0);
1479 }
1480 
1482 {
1483  bool result = false;
1484  if ( isOpen() )
1485  {
1486  std::vector<ossim_uint32> entryList;
1487  getEntryList(entryList);
1488 
1489  if ( entryList.size() )
1490  {
1491  if ( (entryList.size() > 1) || (entryList[0] != 0) ) result = true;
1492  }
1493  }
1494  return result;
1495 }
1496 
1498 {
1499  std::vector<ossim_uint32> tempList;
1500  getEntryList(tempList);
1501 
1502  return (ossim_uint32)tempList.size();
1503 }
1504 
1505 void ossimImageHandler::getEntryNames(std::vector<ossimString>& entryStringList) const
1506 {
1507  entryStringList.clear();
1508 }
1509 
1510 void ossimImageHandler::getEntryName( ossim_uint32 entryIdx, std::string& name ) const
1511 {
1512  name = "";
1513  std::vector<ossimString> entryNames;
1514  getEntryNames(entryNames);
1515  if (entryIdx < entryNames.size())
1516  name = entryNames[entryIdx].string();
1517 }
1518 
1520 {
1521  if(traceDebug())
1522  {
1523  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageHandler::completeOpen(): Entered........" << std::endl;
1524  }
1525  loadMetaData();
1526  if ( theOpenOverviewFlag )
1527  {
1528  openOverview();
1529  }
1531  if(traceDebug())
1532  {
1533  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageHandler::completeOpen(): Leaving......." << std::endl;
1534  }
1536 }
1537 
1539  const ossimConnectableObject* /* object */)const
1540 {
1541  return false;
1542 }
1543 
1545 {
1546  return theMetaData.isValid();
1547 }
1548 
1550 {
1551  theImageFile = filename;
1552 }
1553 
1555 {
1556  return theImageFile;
1557 }
1558 
1560 {
1561  if (dir.isDir())
1563  else
1565  // A change in supplementary directory presents an opportunity to find the OVR that could not be
1566  // opened previously, as well as other support data items:
1567  if (!theOverview.valid())
1568  {
1569  if (theDecimationFactors.size() > 0)
1570  {
1571  theDecimationFactors.clear();
1572  }
1573  completeOpen();
1574  }
1575 }
1576 
1578 {
1580 }
1581 
1583 {
1584  if ( property.valid() )
1585  {
1586  if(property->getName() == ossimKeywordNames::ENTRY_KW)
1587  {
1588  setCurrentEntry(property->valueToString().toUInt32());
1589  }
1590  else if ( property->getName() == OPEN_OVERVIEW_FLAG_KW )
1591  {
1592  setOpenOverviewFlag( property->valueToString().toBool() );
1593  }
1594  else
1595  {
1597  }
1598  }
1599 }
1600 
1602 {
1603 
1604  if(name == ossimKeywordNames::ENTRY_KW)
1605  {
1606  std::vector<ossim_uint32> entryList;
1607  getEntryList(entryList);
1608 
1609  ossimStringProperty* stringProperty = new ossimStringProperty(name,
1611  ossim_uint32 idx = 0;
1612  for(idx = 0; idx < entryList.size(); ++idx)
1613  {
1614  stringProperty->addConstraint(ossimString::toString(entryList[idx]));
1615  }
1616  stringProperty->setFullRefreshBit();
1617  stringProperty->setEditableFlag(false);
1618 
1619  return stringProperty;
1620  }
1621  else if(name == ossimKeywordNames::NUMBER_SAMPLES_KW)
1622  {
1624  prop->setReadOnlyFlag(true);
1625 
1626  return prop;
1627  }
1628  else if(name == ossimKeywordNames::NUMBER_LINES_KW)
1629  {
1631  prop->setReadOnlyFlag(true);
1632 
1633  return prop;
1634  }
1635  else if(name == ossimKeywordNames::NUMBER_BANDS_KW)
1636  {
1638  prop->setReadOnlyFlag(true);
1639 
1640  return prop;
1641  }
1643  {
1645  prop->setReadOnlyFlag(true);
1646 
1647  return prop;
1648  }
1649  else if(name == ossimKeywordNames::SCALAR_TYPE_KW)
1650  {
1652  prop->setReadOnlyFlag(true);
1653 
1654  return prop;
1655  }
1656  else if(name == "histogram_filename")
1657  {
1658  ossimFilenameProperty* filenameProp =
1660 
1662  filenameProp->setCacheRefreshBit();
1663 
1664  return filenameProp;
1665 
1666  }
1667  else if(name == "geometry_filename")
1668  {
1669  ossimFilenameProperty* filenameProp =
1671 
1673  filenameProp->setCacheRefreshBit();
1674 
1675  return filenameProp;
1676 
1677  }
1678  else if(name == "valid_vertices_filename")
1679  {
1680  ossimFilenameProperty* filenameProp =
1682 
1684  filenameProp->setCacheRefreshBit();
1685 
1686  return filenameProp;
1687  }
1688  else if(name == "metadata_filename")
1689  {
1690  ossimFilenameProperty* filenameProp =
1692 
1694  filenameProp->setCacheRefreshBit();
1695 
1696  return filenameProp;
1697  }
1698  else if(name == "overview_filename")
1699  {
1700  ossimFilenameProperty* filenameProp =
1702 
1704  filenameProp->setCacheRefreshBit();
1705 
1706  return filenameProp;
1707  }
1708  else if(name == "filename")
1709  {
1710  ossimFilenameProperty* filenameProp =
1711  new ossimFilenameProperty(name, getFilename());
1712 
1714  filenameProp->setFullRefreshBit();
1715 
1716  return filenameProp;
1717  }
1718  else if ( name == OPEN_OVERVIEW_FLAG_KW)
1719  {
1721  new ossimBooleanProperty(ossimString(OPEN_OVERVIEW_FLAG_KW), theOpenOverviewFlag);
1722  return result;
1723  }
1724 
1725  return ossimImageSource::getProperty(name);
1726 }
1727 
1728 void ossimImageHandler::getPropertyNames(std::vector<ossimString>& propertyNames)const
1729 {
1730  ossimImageSource::getPropertyNames(propertyNames);
1731  propertyNames.push_back(ossimKeywordNames::ENTRY_KW);
1732  propertyNames.push_back(ossimKeywordNames::NUMBER_SAMPLES_KW);
1733  propertyNames.push_back(ossimKeywordNames::NUMBER_LINES_KW);
1734  propertyNames.push_back(ossimKeywordNames::NUMBER_BANDS_KW);
1735  propertyNames.push_back(ossimKeywordNames::NUMBER_REDUCED_RES_SETS_KW);
1736  propertyNames.push_back(ossimKeywordNames::SCALAR_TYPE_KW);
1737  propertyNames.push_back(OPEN_OVERVIEW_FLAG_KW);
1738 }
1739 
1741  const ossimString& ext,
1742  bool set_e0_prefix) const
1743 {
1744  // Get the image file.
1745  ossimFilename f = getFilename();
1746 
1748 
1749  if (set_e0_prefix || (getNumberOfEntries() > 1))
1750  {
1751  f += "_e";
1753  }
1754 
1755  if (ext.size())
1756  {
1757  if (ext.string()[0] != '.')
1758  {
1759  f += ".";
1760  }
1761  f += ext;
1762  }
1763  return f;
1764 }
1765 
1767  ossimFilename& f ) const
1768 {
1769  // Get the image file.
1770  f = getFilename();
1771 
1773 
1774  if (ext.size())
1775  {
1776  if (ext.string()[0] != '.')
1777  {
1778  f += ".";
1779  }
1780  f += ext;
1781  }
1782 }
1783 
1785 {
1786  //---
1787  // If the supplementary directory is set, find the extension at that
1788  // location instead of at the default.
1789  //---
1791  {
1792  ossimString drivePart;
1793  ossimString pathPart;
1794  ossimString filePart;
1795  ossimString extPart;
1796 
1797  f.split(drivePart,
1798  pathPart,
1799  filePart,
1800  extPart);
1801 
1803  ossimFilename newPathPart = theSupplementaryDirectory.after(newDrivePart);
1804 
1805  f.merge( newDrivePart, newPathPart, filePart, extPart );
1806  }
1807 
1808  // Wipe out the extension.
1809  f.setExtension("");
1810 }
1811 
1813  ossimImageData* result)
1814 {
1815  bool status = false;
1816 
1817  if (theOverview.valid())
1818  {
1819  if (theOverview->isValidRLevel(resLevel) && result &&
1820  (result->getNumberOfBands() == getNumberOfOutputBands()) )
1821  {
1822  status = theOverview->getTile(result, resLevel);
1823  }
1824  }
1825 
1826  return status;
1827 }
1828 
1830 {
1831  return theLut;
1832 }
1833 
1835 {
1836  return theLut.valid();
1837 }
1838 
1840 {
1841  return getFilenameWithThisExtension("ovr");
1842 }
1843 
1845 {
1846  return getFilenameWithThisExtension("geom");
1847 }
1848 
1850 {
1851  return getFilenameWithThisExtension("omd");
1852 }
1853 
1855 {
1856  return getFilenameWithThisExtension("his");
1857 }
1858 
1860 {
1861  ossimFilename result;
1862 
1863  result = theImageFile.path();
1864  result = result.dirCat(theImageFile.fileNoExtension());
1865  result += "_vertices";
1866  if(getNumberOfEntries() > 1)
1867  {
1868  result += "_e";
1870  }
1871  result += ".kwl";
1872 
1873  return result;
1874 }
1875 
1877 {
1878  return theStartingResLevel;
1879 }
1880 
1882 {
1883  theStartingResLevel = level;
1884 }
1885 
1887 {
1888  return theOpenOverviewFlag;
1889 }
1890 
1892 {
1893  theOpenOverviewFlag = flag;
1894 
1895  // If false close overview if open??? (drb)
1896 }
1897 
1899 {
1900  if ( geom )
1901  {
1902  // Set decimation levels
1904  if ((num_levels > 0) && (num_levels != geom->getNumberOfDecimations()))
1905  {
1907  }
1908 
1909  // Set image size.
1910  if(geom->getImageSize().hasNans())
1911  {
1912  ossimIrect rect = getBoundingRect();
1913  geom->setImageSize(ossimIpt(rect.width(), rect.height()));
1914  }
1915  }
1916 }
virtual bool open()=0
Pure virtual open.
void setScalarType(ossimScalarType aType)
virtual void valueToString(ossimString &valueResult) const =0
ossim_uint32 x
virtual bool addListener(ossimListener *listener)
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
static const char * OVERVIEW_FILE_KW
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
virtual bool importHistogram(const ossimFilename &inputFile)
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
virtual void getDecimationFactors(vector< ossimDpt > &decimations) const
This returns all decimation for all levels.
virtual void setMaxPixelValue(ossim_uint32 band, const ossim_float64 &pix)
convenience method to set max pixel value.
ossimHistogramMode
void setComputationMode(ossimHistogramMode mode)
virtual ossim_uint32 getNumberOfBands() const
virtual ossimRefPtr< ossimNBandLutDataObject > getLut() const
#define CLOG
Definition: ossimTrace.h:23
ossimFilename theImageFile
const ossimIpt & getImageSize() const
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
virtual bool buildOverview(ossimImageHandlerOverviewCompressionType compressionType=OSSIM_OVERVIEW_COMPRESSION_NONE, ossim_uint32 quality=75, ossimFilterResampler::ossimFilterResamplerType resampleType=ossimFilterResampler::ossimFilterResampler_BOX, bool includeFullResFlag=false)
Will build over file for theImageFile.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
double getMinPix(ossim_uint32 band) const
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).
static const ossimErrorCode OSSIM_OK
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
void setState(std::shared_ptr< ossim::ImageHandlerState > state)
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Attempts to initialize a transform and a projection given the KWL.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
const char * find(const char *key) const
std::vector< ossimDpt > theDecimationFactors
virtual void getEntryNames(std::vector< ossimString > &entryNames) const
ossimFilename expand() const
Method to do file name expansion.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
bool canConnectMyInputTo(ossim_int32 inputIndex, const ossimConnectableObject *object) const
Connection rule.
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
static ossimString toString(bool aValue)
Numeric to string methods.
std::shared_ptr< ossim::ImageHandlerState > m_state
static const char * NUMBER_LINES_KW
virtual const ossimImageHandler * getOverview() const
bool theOpenOverviewFlag
If true opening of overviews will be attempted.
double getMaxPix(ossim_uint32 band) const
void split(ossimString &drivePart, ossimString &pathPart, ossimString &filePart, ossimString &extPart) const
std::shared_ptr< ossim::ImageHandlerState > getState()
virtual void getEntryName(ossim_uint32 entryIdx, std::string &name) const
Get the name of entry as a string.
virtual ossimFilename createDefaultOverviewFilename() const
static const ossimErrorCode OSSIM_ERROR
ossim_uint32 toUInt32() const
static StreamFactoryRegistry * instance()
OSSIM_DLL ossimStdOutProgress theStdOutProgress
virtual void setReadOnlyFlag(bool flag)
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
virtual void closeOverview()
If theOverview is initialized it will be deleted and set to NULL.
void addConstraint(const ossimString &value)
ossimVertexOrdering checkOrdering() const
ossimVertexOrdering getOrdering() const
unsigned short ossim_uint16
virtual void setProperty(ossimRefPtr< ossimProperty > property)
void setImageSize(const ossimIpt &size)
bool isDir() const
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
virtual void fireEvent(ossimEvent &event)
static const char * IMAGE_ID_KW
double getNullPix(ossim_uint32 band) const
static const char * TYPE_KW
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual bool openOverview()
Searches for an overview.
ossim_uint32 getNumberOfBands() const
ossimRefPtr< ossimMultiResLevelHistogram > getImageHistogram() const
Fetches the current entry image&#39;s histogram.
ossimFilename theSupplementaryDirectory
virtual void setImageGeometry(ossimImageGeometry *geom)
Sets the image geometry object.
ossimPixelType thePixelType
void setFullRefreshBit()
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
virtual bool isOpen() const =0
Derived classes must implement this method to be concrete.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
void setMinPix(ossim_uint32 band, double pix)
double ossim_float64
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
void setJpegCompressionQuality(ossim_int32 quality)
Sets the compression quality for use when using a compression type of COMPRESSION_JPEG.
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
Definition: ossimCommon.cpp:73
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
virtual void changeOwner(ossimObject *owner)
Permits changing the object&#39;s owner.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual ossimFilename createDefaultValidVerticesFilename() const
ossimVertexOrdering
bool exists() const
virtual bool setInputSource(ossimImageHandler *imageSource)
Sets the input to the builder.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual const ossimFilename & getFilename() const
Returns the filename.
std::string::size_type size() const
Definition: ossimString.h:405
virtual bool buildAllOverviews(ossimImageHandlerOverviewCompressionType compressionType=OSSIM_OVERVIEW_COMPRESSION_NONE, ossim_uint32 quality=75, ossimFilterResampler::ossimFilterResamplerType resampleType=ossimFilterResampler::ossimFilterResampler_BOX, bool includeFullResFlag=false)
Will build over file for all image entries.
OSSIM_DLL double defaultNull(ossimScalarType scalarType)
virtual void setFilename(const ossimFilename &filename)
Sets the filename.
virtual ossim_uint32 getImageTileHeight() const =0
Returns the tile width of the image or 0 if the image is not tiled.
virtual void getValidImageVertices(std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
ordering specifies how the vertices should be arranged.
virtual bool setOutputToInputBandList()
If the image handler "isBandSeletor()" then the band selection of the output are set to input or iden...
#define OSSIM_EVENT_ADD_OBJECT_ID
Definition: ossimEventIds.h:27
virtual bool isIdentityBandList(const std::vector< ossim_uint32 > &bandList) const
Convenience method to see if band list is identity.
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
virtual bool getRgbBandList(std::vector< ossim_uint32 > &bandList) const
Convenience method to get the zero based rgb output band list.
virtual void setMinPixelValue(ossim_uint32 band, const ossim_float64 &pix)
convenience method to set min pixel value.
vector< ossimIpt > theValidImageVertices
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual ossim_uint32 getCurrentEntry() const
virtual void enableSource()
Definition: ossimSource.cpp:84
static const char * NUMBER_BANDS_KW
static const char * GEOM_FILE_KW
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
void setCompressionType(ossim_uint16 compression_type)
Sets the compression type to use when building overviews.
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual ossim_uint32 getNumberOfEntries() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
bool hasNans() const
Definition: ossimDpt.h:67
virtual bool hasMetaData() const
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
virtual bool openValidVertices()
Creates vertices file name based on image, then tries to open.
virtual void establishDecimationFactors()
Virtual method determines the decimation factors at each resolution level.
static ossimPreferences * instance()
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry() const
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static const char * ENTRY_KW
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
return status
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual ossim_uint32 getImageTileWidth() const =0
Returns the tile width of the image or 0 if the image is not tiled.
void setDiscreteDecimation(const std::vector< ossimDpt > &decimation_list)
Sets the decimation scheme to a discrete list of decimation factors.
virtual void completeOpen()
Will complete the opening process.
ossimPixelType
ConnectableObjectList theInputObjectList
Holds a list of input objects.
virtual bool isImageTiled() const
Indicates whether or not the image is tiled internally.
ossimImageMetaData theMetaData
void setStartingResLevel(ossim_uint32 level)
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
void getFilenameWithThisExt(const ossimString &ext, ossimFilename &f) const
Returns the image file with extension set using supplentary directory for dirname if set...
virtual void initialize()
initialize Does nothing in this class.
ossimRefPtr< ossimImageHandler > theOverview
virtual ossimFilename createDefaultGeometryFilename() const
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual bool buildAllHistograms(int numberOfRLevels=0, ossimHistogramMode mode=OSSIM_HISTO_MODE_NORMAL)
Build a histograms for all image entries.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossimErrorCode getErrorStatus() const
ossim_uint32 getStartingResLevel() const
virtual void loadMetaData()
There is an external file with an omd extension.
virtual void getValidImageVertices(vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
ordering specifies how the vertices should be arranged.
ossim_int32 y
Definition: ossimIpt.h:142
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void setIoType(ossimFilenamePropertyIoType ioType)
void makeNan()
Definition: ossimIrect.h:329
static const char * PIXEL_TYPE_KW
virtual ossim_uint32 getNumberOfInputs() const
Returns the number of input objects.
virtual ossim_uint32 getNumberOfReducedResSets() const
This method is obsolete.
ossimFilename fileNoExtension() const
ossimFilename getOverviewFile() const
void setEditableFlag(bool flag)
virtual bool parseStream(ossim::istream &is, bool ignoreBinaryChars)
deprecated method
double x
Definition: ossimDpt.h:164
ossimFilename dirCat(const ossimFilename &file) const
void merge(const ossimString &drivePart, const ossimString &pathPart, const ossimString &filePart, const ossimString &extPart)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
static const char * SCALAR_TYPE_KW
bool theInputListIsFixedFlag
Indicates whether the theInputObjectList is fixed.
bool empty() const
Definition: ossimString.h:411
virtual void setSupplementaryDirectory(const ossimFilename &dir)
Sets the supplementary directory.
void getFilenameWithNoExtension(ossimFilename &f) const
Get filename with no extension, using supplentary directory for dirname if set.
virtual ossimFilename createDefaultMetadataFilename() const
virtual ossimFilename createDefaultHistogramFilename() const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossimFilename theOverviewFile
bool useEntryIndex() const
Convenience method to determine if entry index should be used for support files, e.g.
ossimFilename file() const
ossimImageHandler()
Constructor (default):
virtual bool hasOverviews() const
virtual void setMaxNumberOfRLevels(ossim_uint32 number)
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the transform (if any) and projection (if any) states to the KWL.
static ossimImageHandlerRegistry * instance()
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
ossim_int32 x
Definition: ossimIpt.h:141
virtual ~ossimImageHandler()
Destructor: Derived classes should implement.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual std::shared_ptr< ossim::istream > createIstream(const std::string &connectionString, const ossimKeywordlist &options=ossimKeywordlist(), std::ios_base::openmode mode=std::ios_base::in|std::ios_base::binary) const
Will try to creates an istream interface to the connectionString passed in.
ossimRefPtr< ossimNBandLutDataObject > theLut
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
static const char * NUMBER_REDUCED_RES_SETS_KW
virtual void setNullPixelValue(ossim_uint32 band, const ossim_float64 &pix)
convenience method to set null pixel value.
bool buildOverview(const ossimFilename &overview_file, bool copy_all=false)
Builds overview file and sets "theOutputFile" to that of the overview_file.
virtual void saveImageGeometry() const
Saves the image geometry to a file that will be made based on the image file name.
bool hasNans() const
Definition: ossimIpt.h:58
virtual ossim_uint32 getNumberOfInputBands() const =0
virtual void setFilename(const ossimFilename &filename)
static const char * IMAGE_FILE_KW
void setResampleType(ossimFilterResampler::ossimFilterResamplerType resampleType)
Supports BOX or NEAREST NEIGHBOR.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
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...
static const char * FILENAME_KW
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...
ossim_uint32 getNumberOfDecimations() const
const std::string & getRgbBands() const
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
virtual const ossimFilename & getSupplementaryDirectory() const
Returns the supplementary directory.
ossimFilename path() const
bool initVertices(const char *file)
Opens file and attempts to initialize the valid image vertices.
ossimFilename drive() const
void setMaxPix(ossim_uint32 band, double pix)
static const char * NUMBER_SAMPLES_KW
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.
Definition: ossimString.h:753
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void setCacheRefreshBit()
virtual bool writeValidImageVertices(const std::vector< ossimIpt > &vertices, const ossimFilename &file=ossimFilename(""))
Outputs vertices to file and updates the internal vertex array variable "theValidImageVertices".
bool getOpenOverviewFlag() const
void setNullPix(ossim_uint32 band, double pix)
const ossimString & getName() const
int ossim_int32
ossim_uint32 theStartingResLevel
theStartingResLevel If set to something other than zero(default) this is indicative that the reader i...
const std::string & string() const
Definition: ossimString.h:414
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
virtual bool buildHistogram(int numberOfRLevels=0, ossimHistogramMode mode=OSSIM_HISTO_MODE_NORMAL)
Build a histogram for image file.
virtual bool hasLut() const