OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimOverviewBuilderBase.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: David Burken
6 //
7 // Description: Interface class for overview builders.
8 //
9 //----------------------------------------------------------------------------
10 // $Id: ossimOverviewBuilderBase.cpp 21745 2012-09-16 15:21:53Z dburken $
11 
13 #include <ossim/base/ossimIpt.h>
17 
19  "ossimOverviewBuilderBase",
23 
24 static const std::string SCAN_FLOAT_DATA_KW = "overview_builder.scan_for_min_max_null_if_float";
25 
27  : m_overviewStopDimension(0),
28  m_histoMode(OSSIM_HISTO_MODE_UNKNOWN),
29  m_bitMaskSpec(),
30  m_imageHandler(0),
31  m_originalBandList(0),
32  m_maskWriter(0),
33  m_maskFilter(0),
34  m_outputFile(ossimFilename::NIL),
35  m_scanForMinMax(false),
36  m_scanForMinMaxNull(false),
37  m_scanFloatData(false)
38 {
39  initializePreferenceSettings();
40 }
41 
43 {
44  m_imageHandler = 0;
45  m_maskWriter = 0;
46  m_maskFilter = 0;
47 }
48 
50 {
51  return false;
52 }
53 
55 {
56  bool result = false;
57  if ( imageSource )
58  {
59  if ( imageSource->getErrorStatus() == ossimErrorCodes::OSSIM_OK )
60  {
61  m_imageHandler = imageSource;
62 
63  // Check handler to see if it's filtering bands.
65  {
66  // Capture for finalize method.
68 
69  // Set output list to input.
71  }
72 
73  // This will set the flag to scan for min, max, nulls if needed.
75 
76  result = true;
77  }
78  }
79  return result;
80 }
81 
83 {
84  std::vector<ossimString> typeList;
85  getTypeNameList(typeList);
86  std::vector<ossimString>::const_iterator i = typeList.begin();
87  while ( i != typeList.end() )
88  {
89  if ( (*i) == type )
90  {
91  return true;
92  }
93  ++i;
94  }
95  return false;
96 }
97 
99  const ossimImageHandler* ih) const
100 {
101  ossim_uint32 result = 0;
102  if (ih)
103  {
104  // Note we always have one rset
105  result = 1;
106 
107  ossim_uint32 largestImageDimension =
108  ih->getNumberOfSamples(0) >
109  ih->getNumberOfLines(0) ?
110  ih->getNumberOfSamples(0) :
111  ih->getNumberOfLines(0);
112 
113  while(largestImageDimension > m_overviewStopDimension)
114  {
115  largestImageDimension /= 2;
116  ++result;
117  }
118  }
119  return result;
120 }
121 
123 {
125 }
126 
128 {
130 }
131 
133 {
134  return m_histoMode;
135 }
136 
138 {
139  m_histoMode = mode;
140 }
141 
143 {
145  {
147  }
148 }
149 
151 {
152  m_bitMaskSpec = bit_mask_spec;
153 }
154 
156 {
157  m_scanForMinMax = flag;
158 }
159 
161 {
162  return m_scanForMinMax;
163 }
164 
166 {
167  m_scanForMinMaxNull = flag;
168 }
169 
171 {
172  return m_scanForMinMaxNull;
173 }
174 
176 {
177  // Get the stop dimension from ossim preferences.
178  const char* lookup = ossimPreferences::instance()->
180  if (lookup)
181  {
183  }
184 
185  if ( m_overviewStopDimension == 0 )
186  {
187  // Use the smallest default tile size.
188  ossimIpt tileSize;
189  ossim::defaultTileSize(tileSize);
190  m_overviewStopDimension = tileSize.x < tileSize.y ? tileSize.x : tileSize.y;
191  }
192 
193  // Look for overview_builder.scan_for_min_max_null_if_float:
194  lookup = ossimPreferences::instance()->findPreference(SCAN_FLOAT_DATA_KW.c_str());
195  if ( lookup )
196  {
197  m_scanFloatData = ossimString(lookup).toBool();
198  }
199 }
200 
202 {
204  {
206  if ( ( scalar == OSSIM_FLOAT32 ) || ( scalar == OSSIM_FLOAT64 ) )
207  {
208  setScanForMinMaxNull(true);
209  }
210  }
211 }
virtual bool setOutputWriter(ossimImageFileWriter *outputWriter)
Sets an optional file writer to the builder.
ossim_uint32 getRequiredResLevels(const ossimImageHandler *ih) const
Gets the required number of res levels.
ossimHistogramMode
64 bit floating point
ossimOverviewBuilderBase()
default constructor
Represents serializable keyword/value map.
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
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.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
ossim_uint32 toUInt32() const
#define RTTI_DEF3(cls, name, b1, b2, b3)
Definition: ossimRtti.h:501
32 bit floating point
Pure virtual base class for image file writers.
void initializePreferenceSettings()
Initializes preference settings.
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
virtual ossim_uint32 getOverviewStopDimension() const
Get the overview stop dimension.
const char * findPreference(const char *key) const
bool toBool() const
String to numeric methods.
virtual bool hasOverviewType(const ossimString &type) const
Method to check if builder can handle type.
virtual bool setOutputToInputBandList()
If the image handler "isBandSeletor()" then the band selection of the output are set to input or iden...
void initializeScanOptions()
Checks scalar type and turns on scanning for min, max, nulls if needed.
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
unsigned int ossim_uint32
void setScanForMinMaxNull(bool flag)
Turn on/off scan for min, max, null flag.
ossimHistogramMode getHistogramMode() const
Gets the histogram accumulation mode.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const =0
Method to populate class supported types.
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
static ossimPreferences * instance()
ossimScalarType
ossimRefPtr< ossimImageHandler > m_imageHandler
std::vector< ossim_uint32 > m_originalBandList
virtual void finalize()
Finalize method.
ossimRefPtr< ossimMaskFilter > m_maskFilter
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual ~ossimOverviewBuilderBase()
virtual destructor
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossimErrorCode getErrorStatus() const
ossim_int32 y
Definition: ossimIpt.h:142
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
ossim_int32 x
Definition: ossimIpt.h:141
virtual void setOverviewStopDimension(ossim_uint32 dim)
Sets the overview stop dimension.
static const char * OVERVIEW_STOP_DIMENSION_KW
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...
void setScanForMinMax(bool flag)
Turn on/off scan for min max flag.
void setBitMaskSpec(const ossimKeywordlist &bit_mask_spec)
Specifies parameters (in KWL) for generation of an alpha (bit) mask such that any full or partial nul...
void setHistogramMode(ossimHistogramMode mode)
Sets the histogram accumulation mode.