OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimRLevelFilter.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Garrett Potts
9 //
10 //*************************************************************************
11 // $Id: ossimRLevelFilter.cpp 21631 2012-09-06 18:10:55Z dburken $
17 #include <ossim/base/ossimTrace.h>
18 
19 static const char* CURRENT_RLEVEL_KW = "current_rlevel";
20 static const char* OVERRIDE_GEOMETRY_KW = "override_geometry";
21 
22 static ossimTrace traceDebug("ossimRLevelFilter:debug");
23 
25 
26 //**************************************************************************************************
29  theCurrentRLevel(0),
30  theOverrideGeometryFlag(false)
31 {
32 }
33 
34 //**************************************************************************************************
36 {
37 }
38 
39 //**************************************************************************************************
41  ossimDpt& result) const
42 {
44  {
45  result.makeNan();
46  }
47 
49  result);
50 }
51 
52 //**************************************************************************************************
54 {
56 }
57 
58 //**************************************************************************************************
60 {
61  theOverrideGeometryFlag = override;
62 }
63 
64 //**************************************************************************************************
66 {
67  theCurrentRLevel = rlevel;
69 }
70 
71 //**************************************************************************************************
73 {
74  return theCurrentRLevel;
75 }
76 
77 //**************************************************************************************************
78 // Returns a pointer reference to the active image geometry at this filter. The input source
79 // geometry is modified, so we need to maintain our own geometry object as a data member.
80 //**************************************************************************************************
82 {
83  // Have we already defined our own geometry? Return it if so:
85 
87 
88  ossim_uint32 rlevel = getCurrentRLevel();
90 
91  // If no scaling is happening, just return the input image geometry:
92  if ((!inputGeom) || (rlevel == 0) || (getEnableFlag() == false))
93  return inputGeom;
94 
95  // Need to create a copy of the input geom and modify it as our own, then pass that:
96  m_ScaledGeometry = new ossimImageGeometry(*inputGeom);
98 
99  // Return our version of the image geometry:
100  return m_ScaledGeometry;
101 }
102 
103 //**************************************************************************************************
106 //**************************************************************************************************
108 {
109  if (m_ScaledGeometry.valid())
110  {
111  // Modify the image geometry's projection with the scale factor before returning geom:
114  if(mapProj)
115  {
116  ossimDpt decimation;
118  decimation.x = 1.0/decimation.x;
119  decimation.y = 1.0/decimation.y;
120 
121  // This will adjust both the scale and the tie point to account for decimation.
122  mapProj->applyScale(decimation, true); // recenter tie point flag
123  }
124  }
125 }
126 
127 //**************************************************************************************************
129 {
130  // Start with fresh values.
131  result.x = 0.0;
132  result.y = 0.0;
133 
134  ossim_uint32 rlevel = getCurrentRLevel();
135 
136  if (rlevel == 0)
137  {
138  return; // no decimation.
139  }
140 
141  // Sum the decimations from rlevel one to the current rlevel.
142  for (ossim_uint32 i = 1; i <= rlevel; ++i)
143  {
144  ossimDpt dpt;
145  getDecimationFactor(i, dpt);
146  if (dpt.hasNans())
147  {
149  << "ossimRLevelFilter::getSummedDecimation WARNING:"
150  << "\nNans returned from getDecimationFactor!"
151  << std::endl;
152  result.makeNan();
153  return;
154  }
155  result.x += dpt.x;
156  result.y += dpt.y;
157  }
158 
159  if (traceDebug())
160  {
162  << "ossimRLevelFilter::getSummedDecimation result: " << result
163  << std::endl;
164  }
165 }
166 
167 //**************************************************************************************************
169 {
170  ossimIrect rect;
171  rect.makeNan();
172  if(!theInputConnection) return rect;
173 
174  if (isSourceEnabled())
175  {
177  }
178  return theInputConnection->getBoundingRect(resLevel);
179 }
180 
181 //**************************************************************************************************
183  const ossimIrect& tileRect,
184  ossim_uint32 resLevel)
185 {
186  if(!theInputConnection)
187  {
188  return 0;
189  }
190 
191  if(!isSourceEnabled())
192  {
193  return theInputConnection->getTile(tileRect, resLevel);
194  }
195 
196  // Ignoring resLevel as we're in charge of it here!
197  return theInputConnection->getTile(tileRect, theCurrentRLevel);
198 }
199 
200 //**************************************************************************************************
202  const char* prefix)
203 {
204  const char* current = kwl.find(prefix, CURRENT_RLEVEL_KW);
205  const char* override = kwl.find(prefix, OVERRIDE_GEOMETRY_KW);
206 
207  if(current)
208  theCurrentRLevel = ossimString(current).toULong();
209 
210  if(override)
212 
213  return ossimImageSourceFilter::loadState(kwl, prefix);
214 
215  // An existing image geometry object here will need to be updated:
216  updateGeometry();
217 }
218 
219 //**************************************************************************************************
221  const char* prefix)const
222 {
223  kwl.add(prefix,
224  CURRENT_RLEVEL_KW,
226  true);
227 
228  kwl.add(prefix,
229  OVERRIDE_GEOMETRY_KW,
231  true);
232 
233  return ossimImageSourceFilter::saveState(kwl, prefix);
234 }
ossimRLevelFilter()
default constructor
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
void getSummedDecimation(ossimDpt &result) const
ossimRefPtr< ossimImageGeometry > m_ScaledGeometry
The input image geometry, altered by the scale.
ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns a pointer reference to the active image geometry at this filter.
virtual void setCurrentRLevel(ossim_uint32 rlevel)
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
double y
Definition: ossimDpt.h:165
virtual bool getOverrideGeometryFlag() const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tileRect, ossim_uint32 resLevel=0)
void updateGeometry()
If this object is maintaining an ossimImageGeometry, this method needs to be called after a scale cha...
virtual void applyScale(const ossimDpt &scale, bool recenterTiePoint)
Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: the...
virtual bool getEnableFlag() const
Definition: ossimSource.cpp:94
ossim_uint32 theCurrentRLevel
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool toBool() const
String to numeric methods.
ossimImageSource * theInputConnection
unsigned int ossim_uint32
virtual ~ossimRLevelFilter()
virtual destructor.
RTTI_DEF1(ossimRLevelFilter, "ossimRLevelFilter", ossimImageSourceFilter)
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
unsigned long toULong() const
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 void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
Will return the decimation factor for the given resolution level.
bool hasNans() const
Definition: ossimDpt.h:67
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual void setOverrideGeometryFlag(bool override)
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void makeNan()
Definition: ossimIrect.h:329
double x
Definition: ossimDpt.h:164
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 ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns the bounding rectangle.
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
Will return the decimation factor for the given resolution level.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
virtual ossim_uint32 getCurrentRLevel() const