OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAffineProjection.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // AUTHOR: Oscar Kramer (okramer@imagelinks.com)
6 //
7 // DESCRIPTION:
8 // Contains implementation of class ossimAffineModel. This is an
9 // implementation of a warping interpolation model.
10 //
11 //*****************************************************************************
12 // $Id: ossimAffineProjection.cpp 15766 2009-10-20 12:37:09Z gpotts $
13 
15 RTTI_DEF1(ossimAffineProjection, "ossimAffineProjection", ossimProjection);
16 
20 
21 //***
22 // Define Trace flags for use within this file:
23 //***
24 #include <ossim/base/ossimTrace.h>
25 static ossimTrace traceExec ("ossimAffineProjection:exec");
26 static ossimTrace traceDebug ("ossimAffineProjection:debug");
27 
28 //*****************************************************************************
29 // CONSTRUCTOR: Default
30 //
31 //*****************************************************************************
33  :
35  theClientProjection (NULL),
36  theAffineTransform (NULL)
37 {
38 }
39 
40 
41 //*****************************************************************************
42 // CONSTRUCTOR: Primary constructor accepting pointer to the underlying
43 // client projection
44 //
45 //*****************************************************************************
47  :
49  theClientProjection (client),
50  theAffineTransform (NULL)
51 {
52 }
53 
54 //*****************************************************************************
55 // CONSTRUCTOR: Accepts geom keywordlist
56 //*****************************************************************************
58  const char* prefix)
59  :
61  theClientProjection (NULL),
62  theAffineTransform (NULL)
63 {
65  createProjection(geom_kwl, prefix);
66 
68  bool rtn_stat = theAffineTransform->loadState(geom_kwl, prefix);
69 
70  if (!theClientProjection ||
71  theClientProjection->getErrorStatus() || !rtn_stat)
73 }
74 
75 //*****************************************************************************
76 // DESTRUCTOR
77 //*****************************************************************************
79 {
80 }
81 
82 //*****************************************************************************
83 // METHOD: ossimAffineProjection::worldToLineSample()
84 //*****************************************************************************
85 void
87  ossimDpt& lineSampPt) const
88 {
89  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::worldToLineSample: Entering..." << std::endl;
90 
92  {
93  theClientProjection->worldToLineSample(worldPoint, lineSampPt);
94  theAffineTransform->inverse(lineSampPt);
95  }
96  else
97  lineSampPt.makeNan();
98 
99  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::worldToLineSample: Returning..." << std::endl;
100 }
101 
102 //*****************************************************************************
103 // METHOD: ossimAffineProjection::lineSampleToWorld()
104 //*****************************************************************************
105 void
107  ossimGpt& worldPt) const
108 {
109  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::lineSampleToWorld: Entering..." << std::endl;
110 
112  {
113  ossimDpt adjustedPt;
114  theAffineTransform->forward(lineSampPt, adjustedPt);
115  theClientProjection->lineSampleToWorld(adjustedPt, worldPt);
116  }
117  else
118  {
119  worldPt.makeNan();
120  }
121 
122  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::lineSampleToWorld: Returning..." << std::endl;
123 }
124 
125 //*****************************************************************************
126 // METHOD: ossimAffineProjection::lineSampleToWorld()
127 //*****************************************************************************
128 void
130  const double& hgt,
131  ossimGpt& worldPt) const
132 {
133  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::lineSampleHeightToWorld: Entering..." << std::endl;
134 
136  {
137  ossimDpt adjustedPt;
138  theAffineTransform->forward(lineSampPt, adjustedPt);
139  theClientProjection->lineSampleHeightToWorld(adjustedPt, hgt, worldPt);
140  }
141  else
142  {
143  worldPt.makeNan();
144  }
145 
146  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "dEBUG ossimAffineProjection::lineSampleHeightToWorld: Returning..." << std::endl;
147 }
148 
149 //*****************************************************************************
150 // METHOD: ossimAffineProjection::print()
151 //*****************************************************************************
153 {
154 
156  {
157  out <<
158  "ossimAffineProjection:\n"
159  " Member theClientProjection: ";
161  out << "\n Member theAffineTransform: "
162  << *theAffineTransform << std::endl;
163  }
164  else
165  {
166  out << "ossimAffineProjection -- Not initialized." << std::endl;
167  }
168  return out;
169 }
170 
172 {
173  return m.print(os);
174 }
175 
176 //*****************************************************************************
177 // METHOD: ossimAffineProjection::()
178 //*****************************************************************************
180  const char* prefix) const
181 {
182  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::saveState: entering..." << std::endl;
183 
185  {
186  theClientProjection->saveState(kwl, prefix);
187  theAffineTransform->saveState(kwl, prefix);
188  }
189 
190  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::saveState: returning..." << std::endl;
191  return true;
192 }
193 
194 //*****************************************************************************
195 // METHOD: ossimAffineProjection::()
196 //*****************************************************************************
198  const char* prefix)
199 {
200  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::loadState: entering..." << std::endl;
201 
202  bool good_load;
203  int err_stat;
204 
205  if (!theClientProjection)
206  {
208  createProjection(kwl, prefix);
209  err_stat = theClientProjection->getErrorStatus();
210  if (err_stat != ossimErrorCodes::OSSIM_OK)
211  {
212  return false;
213  }
214  }
215  else
216  {
217  good_load = theClientProjection->loadState(kwl, prefix);
218  if (!good_load)
219  {
220  return false;
221  }
222  }
223 
224  if (!theAffineTransform)
225  {
227  }
228  good_load = theAffineTransform->loadState(kwl, prefix);
229  if (!good_load)
230  {
231  return false;
232  }
233  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimAffineProjection::loadState: returning..." << std::endl;
234 
235  return true;
236 
237 }
238 
239 //*****************************************************************************
240 // METHOD: ossimAffineProjection::()
241 //*****************************************************************************
243 {
244  ossimKeywordlist kwl;
245  saveState(kwl);
246  ossimProjection* duped = new ossimAffineProjection(kwl);
247  return duped;
248 }
249 
250 //*****************************************************************************
251 // METHOD:
252 //*****************************************************************************
254 {
256  return theClientProjection->origin();
257  return ossimGpt(0.0, 0.0, 0.0);
258 }
259 
260 //*****************************************************************************
261 // METHOD:
262 //*****************************************************************************
264 {
267  return ossimDpt(ossim::nan(), ossim::nan());
268 }
269 
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimRefPtr< ossim2dTo2dTransform > theAffineTransform
virtual void forward(const ossimDpt &input, ossimDpt &output) const =0
virtual void lineSampleToWorld(const ossimDpt &lineSampPt, ossimGpt &worldPt) const
virtual ossimGpt origin() const
Represents serializable keyword/value map.
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
std::ostream & operator<<(std::ostream &os, const ossimAffineProjection &m)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
void makeNan()
Definition: ossimGpt.h:130
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
static const ossimErrorCode OSSIM_ERROR
virtual ossimObject * dup() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual void inverse(const ossimDpt &input, ossimDpt &output) const
virtual ossimDpt getMetersPerPixel() const =0
virtual void lineSampleHeightToWorld(const ossimDpt &lineSampPt, const double &heightAboveEllipsoid, ossimGpt &worldPt) const =0
virtual void worldToLineSample(const ossimGpt &worldPoint, ossimDpt &lineSampPt) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
static ossimProjectionFactoryRegistry * instance()
virtual ossimDpt getMetersPerPixel() const
virtual ossimErrorCode getErrorStatus() const
virtual ossimGpt origin() const =0
virtual void lineSampleHeightToWorld(const ossimDpt &lineSampPt, const double &hgtEllipsoid, ossimGpt &worldPt) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual void lineSampleToWorld(const ossimDpt &lineSampPt, ossimGpt &worldPt) const =0
virtual std::ostream & print(std::ostream &out) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
RTTI_DEF1(ossimAffineProjection, "ossimAffineProjection", ossimProjection)
virtual void worldToLineSample(const ossimGpt &worldPoint, ossimDpt &lineSampPt) const =0
ossimRefPtr< ossimProjection > theClientProjection
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23