OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimBilinearProjection Class Reference

#include <ossimBilinearProjection.h>

Inheritance diagram for ossimBilinearProjection:
ossimProjection ossimOptimizableProjection ossimObject ossimErrorStatusInterface ossimReferenced

Public Member Functions

 ossimBilinearProjection ()
 
 ossimBilinearProjection (const ossimBilinearProjection &rhs)
 
 ossimBilinearProjection (const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &lr, const ossimDpt &ll, const ossimGpt &ulg, const ossimGpt &urg, const ossimGpt &lrg, const ossimGpt &llg)
 
virtual ossimObjectdup () const
 
virtual ossimGpt origin () const
 
virtual void worldToLineSample (const ossimGpt &worldPoint, ossimDpt &lineSampPt) const
 
virtual void lineSampleToWorld (const ossimDpt &lineSampPt, ossimGpt &worldPt) const
 
virtual void lineSampleHeightToWorld (const ossimDpt &lineSampPt, const double &heightAboveEllipsoid, ossimGpt &worldPt) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual bool operator== (const ossimProjection &projection) const
 
virtual ossimDpt getMetersPerPixel () const
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
virtual ossim_float64 setTiePoints (const std::vector< ossimDpt > &lsPt, const std::vector< ossimGpt > &geoPt)
 
virtual bool setupOptimizer (const ossimString &setup)
 setupFromString() Derived classes should implement as needed. Initialize parameters needed for optimizeFit and degreesOfFreedom More...
 
virtual bool useForward () const
 
virtual ossim_uint32 degreesOfFreedom () const
 better go from image to ground, also means that errors variance are in squared meters More...
 
virtual double optimizeFit (const ossimTieGptSet &tieSet, double *targetVariance=0)
 
virtual bool isAffectedByElevation () const
 Implementation of pure virtual ossimProjection::isAffectedByElevation method. More...
 
void getTiePoints (std::vector< ossimDpt > &lsPt, std::vector< ossimGpt > &geoPt) const
 Access method for tie point information. More...
 
- Public Member Functions inherited from ossimProjection
 ossimProjection ()
 
virtual ~ossimProjection ()
 
virtual ossimDpt forward (const ossimGpt &wp) const
 
virtual ossimGpt inverse (const ossimDpt &pp) const
 
virtual void getRoundTripError (const ossimDpt &imagePoint, ossimDpt &errorResult) const
 
virtual void getRoundTripError (const ossimGpt &groundPoint, ossimDpt &errorResult) const
 
virtual void getGroundClipPoints (ossimGeoPolygon &gpts) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual bool operator!= (const ossimProjection &projection) const
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
- Public Member Functions inherited from ossimOptimizableProjection
 ossimOptimizableProjection ()
 
 ossimOptimizableProjection (const ossimOptimizableProjection &source)
 
virtual ~ossimOptimizableProjection ()
 
virtual ossimOptimizableProjectionoperator= (const ossimOptimizableProjection &source)
 
virtual bool needsInitialState () const
 needsInitialState() More...
 

Protected Member Functions

virtual ~ossimBilinearProjection ()
 
void initializeBilinear ()
 
bool dPtsHaveNan () const
 Checks theLineSamplePt for nans. More...
 
bool gPtsHaveNan () const
 Checks theGeographicPt for nans. More...
 
ossimDpt midLineSamplePt () const
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

std::vector< ossimDpttheLineSamplePt
 
std::vector< ossimGpttheGeographicPt
 
ossimLeastSquaresBilin theLatFit
 
ossimLeastSquaresBilin theLonFit
 
ossimLeastSquaresBilin theXFit
 
ossimLeastSquaresBilin theYFit
 
bool theInterpolationPointsHaveNanFlag
 
bool theInverseSupportedFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Detailed Description

Definition at line 19 of file ossimBilinearProjection.h.

Constructor & Destructor Documentation

◆ ossimBilinearProjection() [1/3]

ossimBilinearProjection::ossimBilinearProjection ( )

Definition at line 37 of file ossimBilinearProjection.cpp.

Referenced by dup().

38  :
40  theLineSamplePt(0),
41  theGeographicPt(0),
42  theLatFit(),
43  theLonFit()
44 {
45 #ifdef OSSIM_ID_ENABLED
46  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << OSSIM_ID << endl;
47 #endif
48 }
std::vector< ossimGpt > theGeographicPt
ossimLeastSquaresBilin theLatFit
std::vector< ossimDpt > theLineSamplePt
ossimLeastSquaresBilin theLonFit
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ ossimBilinearProjection() [2/3]

ossimBilinearProjection::ossimBilinearProjection ( const ossimBilinearProjection rhs)

Definition at line 50 of file ossimBilinearProjection.cpp.

◆ ossimBilinearProjection() [3/3]

ossimBilinearProjection::ossimBilinearProjection ( const ossimDpt ul,
const ossimDpt ur,
const ossimDpt lr,
const ossimDpt ll,
const ossimGpt ulg,
const ossimGpt urg,
const ossimGpt lrg,
const ossimGpt llg 
)

Definition at line 59 of file ossimBilinearProjection.cpp.

References initializeBilinear(), theGeographicPt, and theLineSamplePt.

67  :
69  theLineSamplePt(4),
70  theGeographicPt(4),
71  theLatFit(),
72  theLonFit()
73 {
74  theLineSamplePt[0] = ul;
75  theLineSamplePt[1] = ur;
76  theLineSamplePt[2] = lr;
77  theLineSamplePt[3] = ll;
78 
79  theGeographicPt[0] = ulg;
80  theGeographicPt[1] = urg;
81  theGeographicPt[2] = lrg;
82  theGeographicPt[3] = llg;
83 
85 }
std::vector< ossimGpt > theGeographicPt
ossimLeastSquaresBilin theLatFit
std::vector< ossimDpt > theLineSamplePt
ossimLeastSquaresBilin theLonFit

◆ ~ossimBilinearProjection()

ossimBilinearProjection::~ossimBilinearProjection ( )
protectedvirtual

Definition at line 87 of file ossimBilinearProjection.cpp.

88 {
89 }

Member Function Documentation

◆ degreesOfFreedom()

ossim_uint32 ossimBilinearProjection::degreesOfFreedom ( ) const
virtual

better go from image to ground, also means that errors variance are in squared meters

Implements ossimOptimizableProjection.

Definition at line 534 of file ossimBilinearProjection.cpp.

535 {
536  return 2*4; //height not used
537 }

◆ dPtsHaveNan()

bool ossimBilinearProjection::dPtsHaveNan ( ) const
protected

Checks theLineSamplePt for nans.

Returns
true if any point has a nan.
Note
If theLineSamplePt size is 0 this returns false.

Definition at line 391 of file ossimBilinearProjection.cpp.

References theLineSamplePt.

Referenced by initializeBilinear(), and midLineSamplePt().

392 {
393  if (theLineSamplePt.size() == 0)
394  {
395  return false;
396  }
397 
398  vector<ossimDpt>::const_iterator i = theLineSamplePt.begin();
399  while (i != theLineSamplePt.end())
400  {
401  if ( (*i).hasNans() )
402  {
403  return true;
404  }
405  ++i;
406  }
407  return false;
408 }
std::vector< ossimDpt > theLineSamplePt

◆ dup()

ossimObject * ossimBilinearProjection::dup ( ) const
virtual

Implements ossimProjection.

Definition at line 91 of file ossimBilinearProjection.cpp.

References ossimBilinearProjection().

92 {
93  return new ossimBilinearProjection(*this);
94 }

◆ getMetersPerPixel()

ossimDpt ossimBilinearProjection::getMetersPerPixel ( ) const
virtual

ACCESS METHODS:

Implements ossimProjection.

Definition at line 313 of file ossimBilinearProjection.cpp.

References lineSampleToWorld(), ossimEcefVector::magnitude(), midLineSamplePt(), and ossimDpt::x.

314 {
315  ossimGpt centerG;
316  ossimGpt rightG;
317  ossimGpt topG;
318 
319  ossimDpt midPoint = midLineSamplePt();
320 
321  lineSampleToWorld(midPoint, centerG);
322  lineSampleToWorld(midPoint+ossimDpt(1,0), rightG);
323  lineSampleToWorld(midPoint+ossimDpt(0,-1), topG);
324 
325  ossimEcefPoint centerP = centerG;
326  ossimEcefPoint rightP = rightG;
327  ossimEcefPoint topP = topG;
328 
329  ossimEcefVector horizontal = rightP-centerP;
330  ossimEcefVector vertical = topP-centerP;
331 
332  ossimDpt result(horizontal.magnitude(),
333  vertical.magnitude());
334 
335  result.x = (result.x + result.y)/2.0;
336  result.y = result.x;
337 
338  return result;
339 }
virtual void lineSampleToWorld(const ossimDpt &lineSampPt, ossimGpt &worldPt) const
double magnitude() const
double x
Definition: ossimDpt.h:164

◆ getTiePoints()

void ossimBilinearProjection::getTiePoints ( std::vector< ossimDpt > &  lsPt,
std::vector< ossimGpt > &  geoPt 
) const

Access method for tie point information.

Definition at line 552 of file ossimBilinearProjection.cpp.

References theGeographicPt, and theLineSamplePt.

554 {
555  lsPt = theLineSamplePt;
556  geoPt = theGeographicPt;
557 }
std::vector< ossimGpt > theGeographicPt
std::vector< ossimDpt > theLineSamplePt

◆ gPtsHaveNan()

bool ossimBilinearProjection::gPtsHaveNan ( ) const
protected

Checks theGeographicPt for nans.

Returns
true if any point has a nan.
Note
If theLineSamplePt size is 0 this returns false.

Definition at line 410 of file ossimBilinearProjection.cpp.

References theGeographicPt.

Referenced by initializeBilinear(), and origin().

411 {
412  //---
413  // NOTE: This method ignores nans in the height field.
414  //---
415 
416  if (theGeographicPt.size() == 0)
417  {
418  return false;
419  }
420 
421  vector<ossimGpt>::const_iterator i = theGeographicPt.begin();
422  while (i != theGeographicPt.end())
423  {
424  if ( (*i).isLatNan() || (*i).isLonNan() )
425  {
426  return true;
427  }
428  ++i;
429  }
430  return false;
431 }
std::vector< ossimGpt > theGeographicPt

◆ initializeBilinear()

void ossimBilinearProjection::initializeBilinear ( )
protected

Definition at line 341 of file ossimBilinearProjection.cpp.

References ossimLeastSquaresBilin::addSample(), ossimLeastSquaresBilin::clear(), dPtsHaveNan(), ossimProjection::getRoundTripError(), gPtsHaveNan(), ossimDpt::length(), ossimLeastSquaresBilin::solveLS(), theGeographicPt, theInterpolationPointsHaveNanFlag, theInverseSupportedFlag, theLatFit, theLineSamplePt, theLonFit, theXFit, theYFit, x, and y.

Referenced by ossimBilinearProjection(), and setTiePoints().

342 {
346  {
347  theLatFit.clear();
348  theLonFit.clear();
349  theXFit.clear();
350  theYFit.clear();
351 
352  const ossim_uint32 SIZE = (ossim_uint32)theLineSamplePt.size();
353  if (SIZE != theGeographicPt.size())
354  {
355  return;
356  }
357 
358  for (ossim_uint32 i = 0; i < SIZE; ++i)
359  {
361  theLineSamplePt[i].y,
362  theGeographicPt[i].latd());
363 
365  theLineSamplePt[i].y,
366  theGeographicPt[i].lond());
367 
369  theGeographicPt[i].latd(),
370  theLineSamplePt[i].x);
372  theGeographicPt[i].latd(),
373  theLineSamplePt[i].y);
374 
375  }
376 
377  theLatFit.solveLS();
378  theLonFit.solveLS();
379  theXFit.solveLS();
380  theYFit.solveLS();
381  ossimDpt errorResult;
383  errorResult);
384  if(errorResult.length() > 1)
385  {
386  theInverseSupportedFlag = false;
387  }
388  }
389 }
ossim_uint32 x
virtual void clear()
Will clear everything and set it up to for another solve.
virtual void addSample(double x, double yy, double zmea)
add a single data sample.
ossimLeastSquaresBilin theXFit
ossim_uint32 y
double length() const
Definition: ossimDpt.h:81
std::vector< ossimGpt > theGeographicPt
ossimLeastSquaresBilin theLatFit
ossimLeastSquaresBilin theYFit
unsigned int ossim_uint32
bool gPtsHaveNan() const
Checks theGeographicPt for nans.
bool solveLS()
compute least squares parameter solution - true if succesfull.
std::vector< ossimDpt > theLineSamplePt
ossimLeastSquaresBilin theLonFit
virtual void getRoundTripError(const ossimDpt &imagePoint, ossimDpt &errorResult) const
bool dPtsHaveNan() const
Checks theLineSamplePt for nans.

◆ isAffectedByElevation()

virtual bool ossimBilinearProjection::isAffectedByElevation ( ) const
inlinevirtual

Implementation of pure virtual ossimProjection::isAffectedByElevation method.

Returns
false.

Implements ossimProjection.

Definition at line 90 of file ossimBilinearProjection.h.

90 { return false; }

◆ lineSampleHeightToWorld()

void ossimBilinearProjection::lineSampleHeightToWorld ( const ossimDpt lineSampPt,
const double &  heightAboveEllipsoid,
ossimGpt worldPt 
) const
virtual

METHOD: lineSampleHeightToWorld This is the pure virtual that projects the image point to the given elevation above ellipsoid, thereby bypassing reference to a DEM. Useful for projections that are sensitive to elevation (such as sensor models).

Implements ossimProjection.

Definition at line 155 of file ossimBilinearProjection.cpp.

References ossimGpt::datum(), ossimGpt::hgt, ossim::isnan(), ossimGpt::lat, ossimGpt::lon, ossimLeastSquaresBilin::lsFitValue(), ossimGpt::makeNan(), theGeographicPt, theInterpolationPointsHaveNanFlag, theLatFit, theLonFit, ossimDpt::x, and ossimDpt::y.

Referenced by lineSampleToWorld().

159 {
160  worldPt.makeNan();
161 
163  {
164  return;
165  }
166 
167 
168  worldPt.lat = theLatFit.lsFitValue(lineSampPt.x, lineSampPt.y);
169  worldPt.lon = theLonFit.lsFitValue(lineSampPt.x, lineSampPt.y);
170  if (ossim::isnan(heightAboveEllipsoid) == false)
171  {
172  worldPt.hgt = heightAboveEllipsoid;
173  }
174  if (theGeographicPt.size())
175  {
176  worldPt.datum(theGeographicPt[0].datum());
177  }
178 }
double y
Definition: ossimDpt.h:165
void makeNan()
Definition: ossimGpt.h:130
ossim_float64 hgt
Height in meters above the ellipsiod.
Definition: ossimGpt.h:274
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
std::vector< ossimGpt > theGeographicPt
ossimLeastSquaresBilin theLatFit
ossim_float64 lon
Definition: ossimGpt.h:266
ossimLeastSquaresBilin theLonFit
double x
Definition: ossimDpt.h:164
virtual double lsFitValue(double xx, double yy) const
interpolate LS-fit value at location (xx,yy) - returns z(xx,yy).
ossim_float64 lat
Definition: ossimGpt.h:265
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ lineSampleToWorld()

void ossimBilinearProjection::lineSampleToWorld ( const ossimDpt lineSampPt,
ossimGpt worldPt 
) const
virtual

METHOD: lineSampleToWorld() Performs the inverse projection from line, sample to ground (world):

Implements ossimProjection.

Definition at line 146 of file ossimBilinearProjection.cpp.

References lineSampleHeightToWorld(), and ossim::nan().

Referenced by getMetersPerPixel().

148 {
149  lineSampleHeightToWorld(lineSampPt,
150  ossim::nan(),
151  worldPt);
152 
153 }
virtual void lineSampleHeightToWorld(const ossimDpt &lineSampPt, const double &heightAboveEllipsoid, ossimGpt &worldPt) const
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135

◆ loadState()

bool ossimBilinearProjection::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of the object from a keyword list. Return true if ok or false on error.

Reimplemented from ossimProjection.

Definition at line 228 of file ossimBilinearProjection.cpp.

References ossimString::empty(), ossimKeywordlist::find(), ossimGpt::height(), ossimGpt::isHgtNan(), ossimProjection::loadState(), ossimKeywordlist::numberOf(), theGeographicPt, theLineSamplePt, ossimDpt::toPoint(), ossimGpt::toPoint(), ossimString::toString(), and ossim::toVector().

230 {
231  // Load the base class.
232  ossimProjection::loadState(kwl, prefix);
233 
234  // Start with clear lists.
235  theLineSamplePt.clear();
236  theGeographicPt.clear();
237 
238  ossimString imagePoints = kwl.find(prefix, "image_points");
239  ossimString groundPoints = kwl.find(prefix, "ground_points");
240 
241  if(!imagePoints.empty()&&!groundPoints.empty())
242  {
243  ossim::toVector(theLineSamplePt, imagePoints);
244  ossim::toVector(theGeographicPt, groundPoints);
245  }
246  else
247  {
248  //---
249  // Get the number of points.
250  // If 0 or gpt size not equal to dpt size get out.
251  //---
252  const ossim_uint32 SIZE = kwl.numberOf(prefix, "gpt");
253  if ( (SIZE == 0) || (SIZE != kwl.numberOf(prefix, "dpt")) )
254  {
255  return false;
256  }
257 
258  for (ossim_uint32 i = 0; i < SIZE; ++i)
259  {
260  const char* lookup;
261  ossimString index_string = ossimString::toString(i);
262 
263  // Get the geographic point.
264  ossimString kw = "gpt";
265  kw += index_string;
266  lookup = kwl.find(prefix, kw);
267  if (lookup)
268  {
269  ossimGpt gp;
270  gp.toPoint(std::string(lookup));
271 
272  //---
273  // Allow for "nan" height values by substituting with 0.0 so the
274  // hasNans() will work. "nan"s will get placed in the point if the
275  // user doesn't have the elevation manager preferences set up
276  // correctly.
277  //---
278  if (gp.isHgtNan())
279  {
280  gp.height(0.0);
281  }
282  theGeographicPt.push_back(gp);
283  }
284 
285  // Get the line sample point.
286  kw = "dpt";
287  kw += index_string;
288  lookup = kwl.find(prefix, kw);
289  if (lookup)
290  {
291  ossimDpt dp;
292  dp.toPoint(std::string(lookup));
293  theLineSamplePt.push_back(dp);
294  }
295  }
296  }
297 
298  if (traceDebug())
299  {
301  }
302 
304 
305  return true;
306 }
ossim_uint32 numberOf(const char *str) const
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
bool isHgtNan() const
Definition: ossimGpt.h:143
std::vector< ossimGpt > theGeographicPt
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
OSSIM_DLL void toVector(std::vector< ossimDpt > &result, const ossimString &stringOfPoints)
Will take a string list separated by spaces and convert to a vector of ossimDpts. ...
void toPoint(const std::string &s)
Initializes this point from string.
Definition: ossimGpt.cpp:116
unsigned int ossim_uint32
void toPoint(const std::string &s)
Initializes this point from string.
Definition: ossimDpt.cpp:192
double height() const
Definition: ossimGpt.h:107
std::vector< ossimDpt > theLineSamplePt
bool empty() const
Definition: ossimString.h:411
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ midLineSamplePt()

ossimDpt ossimBilinearProjection::midLineSamplePt ( ) const
protected
Returns
The mid point of theLineSamplePts.

Definition at line 433 of file ossimBilinearProjection.cpp.

References dPtsHaveNan(), ossimDpt::makeNan(), theLineSamplePt, ossimDpt::x, x, ossimDpt::y, and y.

Referenced by getMetersPerPixel().

434 {
435  ossimDpt result;
436 
437  if ( (theLineSamplePt.size() == 0) || dPtsHaveNan())
438  {
439  result.makeNan();
440  return result;
441  }
442 
443  double x = 0.0;
444  double y = 0.0;
445  vector<ossimDpt>::const_iterator i = theLineSamplePt.begin();
446  while (i != theLineSamplePt.end())
447  {
448  x += (*i).x;
449  y += (*i).y;
450  ++i;
451  }
452  const double SIZE = theLineSamplePt.size();
453  result.x = x / SIZE;
454  result.y = y / SIZE;
455 
456  return result;
457 }
ossim_uint32 x
ossim_uint32 y
double y
Definition: ossimDpt.h:165
std::vector< ossimDpt > theLineSamplePt
double x
Definition: ossimDpt.h:164
bool dPtsHaveNan() const
Checks theLineSamplePt for nans.
void makeNan()
Definition: ossimDpt.h:65

◆ operator==()

bool ossimBilinearProjection::operator== ( const ossimProjection projection) const
virtual

OPERATOR: == Compares this instance with arg projection.

Implements ossimProjection.

Definition at line 308 of file ossimBilinearProjection.cpp.

309 {
310  return false;
311 }

◆ optimizeFit()

double ossimBilinearProjection::optimizeFit ( const ossimTieGptSet tieSet,
double *  targetVariance = 0 
)
virtual

optimizeFit() adjusts projection to GLOBALLY fit best to ALL tie points (no outlier rejection) can select an optional threshold for accuracy

RETURNS : resulting image error variance of fitted model, or negative value for error

IMPORTANT : the unit for *targetVariance and the returned value is : meters^2 when useForward() is true OR pixel^2 if useForward() is false

Implements ossimOptimizableProjection.

Definition at line 540 of file ossimBilinearProjection.cpp.

References ossimTieGptSet::getSlaveMasterPoints(), and setTiePoints().

541 {
542  //NOTE : IGNORE targetVariance
543  std::vector<ossimDpt> imagePoints;
544  std::vector<ossimGpt> groundPoints;
545  tieSet.getSlaveMasterPoints(imagePoints, groundPoints);
546  return setTiePoints(imagePoints, groundPoints); //variance in meters
547 }
void getSlaveMasterPoints(std::vector< ossimDpt > &imv, std::vector< ossimGpt > &gdv) const
virtual ossim_float64 setTiePoints(const std::vector< ossimDpt > &lsPt, const std::vector< ossimGpt > &geoPt)

◆ origin()

ossimGpt ossimBilinearProjection::origin ( ) const
virtual

METHOD: origin() Returns projection's ground point origin. That is the GP corresponding to line=0, sample=0.

Implements ossimProjection.

Definition at line 96 of file ossimBilinearProjection.cpp.

References ossimGpt::datum(), gPtsHaveNan(), ossimGpt::height(), ossimGpt::latd(), ossimGpt::lond(), ossimGpt::makeNan(), and theGeographicPt.

97 {
98  ossimGpt result;
99  result.makeNan();
100  if ( (theGeographicPt.size() == 0) || gPtsHaveNan() )
101  {
102  return result;
103  }
104 
105  double lat = 0.0;
106  double lon = 0.0;
107  const double SIZE = theGeographicPt.size();
108 
109  vector<ossimGpt>::const_iterator i = theGeographicPt.begin();
110  while (i != theGeographicPt.end())
111  {
112  lat += (*i).latd();
113  lon += (*i).lond();
114  ++i;
115  }
116 
117  result.latd(lat/SIZE);
118  result.lond(lon/SIZE);
119  result.height(0.0);
120  result.datum(theGeographicPt[0].datum());
121 
122  return result;
123 }
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
void makeNan()
Definition: ossimGpt.h:130
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
std::vector< ossimGpt > theGeographicPt
double height() const
Definition: ossimGpt.h:107
bool gPtsHaveNan() const
Checks theGeographicPt for nans.

◆ print()

std::ostream & ossimBilinearProjection::print ( std::ostream &  out) const
virtual

Outputs theErrorStatus as an ossimErrorCode and an ossimString.

Returns
std::ostream&
Note
Derived classes should only have to implement a virtual print, not an operator<< funtion as it's implemented here.

Reimplemented from ossimProjection.

Definition at line 459 of file ossimBilinearProjection.cpp.

References ossimNotify(), ossimNotifyLevel_INFO, ossimProjection::print(), theGeographicPt, and theLineSamplePt.

460 {
462  << "ossimBilinearProjection::print\n";
463 
464  ossim_uint32 index = 0;
465  vector<ossimDpt>::const_iterator di = theLineSamplePt.begin();
466  while (di != theLineSamplePt.end())
467  {
469  << "theLineSamplePt[" << index << "]: "
470  << (*di) << endl;
471  ++di;
472  ++index;
473  }
474 
475  index = 0;
476  vector<ossimGpt>::const_iterator gi = theGeographicPt.begin();
477  while (gi != theGeographicPt.end())
478  {
480  << "theGeographicPt[" << index << "]: "
481  << (*gi) << endl;
482  ++gi;
483  ++index;
484  }
485 
486  return ossimProjection::print(out);
487 }
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
std::vector< ossimGpt > theGeographicPt
unsigned int ossim_uint32
std::vector< ossimDpt > theLineSamplePt
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ saveState()

bool ossimBilinearProjection::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

METHODS: saveState, loadState Fulfills ossimObject base-class pure virtuals.

Reimplemented from ossimProjection.

Definition at line 180 of file ossimBilinearProjection.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), os2, ossimProjection::saveState(), theGeographicPt, theLineSamplePt, ossimString::toString(), and ossim::toStringList().

182 {
183  if (theLineSamplePt.size() != theGeographicPt.size())
184  {
185  // Should never happen.
186  return false;
187  }
188 
189  ossimProjection::saveState(kwl, prefix);
190 
191  ossimString imagePoints;
192  ossimString groundPoints;
193  ossim::toStringList(imagePoints, theLineSamplePt);
194  ossim::toStringList(groundPoints, theGeographicPt);
195  kwl.add(prefix,
196  "image_points",
197  imagePoints,
198  true);
199  kwl.add(prefix,
200  "ground_points",
201  groundPoints,
202  true);
203 #if 0
204  const ossim_uint32 SIZE = (ossim_uint32)theLineSamplePt.size();
205 
206  for (ossim_uint32 i = 0; i < SIZE; ++i)
207  {
208  ossimString index_string = ossimString::toString(i);
209 
210  // Add the geographic point.
211  ossimString kw = "gpt";
212  kw += index_string;
213  ostringstream os1;
214  os1 << theGeographicPt[i];
215  kwl.add(prefix, kw, os1.str().c_str());
216 
217  // Add the sample line..
218  kw = "dpt";
219  kw += index_string;
221  os2 << theLineSamplePt[i];
222  kwl.add(prefix, kw, os2.str().c_str());
223  }
224 #endif
225  return true;
226 }
std::ostringstream os2
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
OSSIM_DLL void toStringList(ossimString &resultStringOfPoints, const std::vector< ossimDpt > &pointList, char separator=' ')
Will take a vector of ossimDpt and convert to a string list separated by spaces For example: (45...
static ossimString toString(bool aValue)
Numeric to string methods.
std::vector< ossimGpt > theGeographicPt
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
std::vector< ossimDpt > theLineSamplePt
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const

◆ setTiePoints()

ossim_float64 ossimBilinearProjection::setTiePoints ( const std::vector< ossimDpt > &  lsPt,
const std::vector< ossimGpt > &  geoPt 
)
virtual

METHOD: setTiePoints add any number of tie points and calculate bilinear fit returns the ground error variance (=RMS^2), in meters^2

Definition at line 489 of file ossimBilinearProjection.cpp.

References ossimGpt::hgt, initializeBilinear(), ossimGpt::lat, ossimGpt::lon, ossimLeastSquaresBilin::lsFitValue(), ossimNotify(), ossimNotifyLevel_INFO, theGeographicPt, theLatFit, theLineSamplePt, and theLonFit.

Referenced by ossim_hdf5::getBilinearProjection(), and optimizeFit().

491 {
492  if (lsPt.size() != geoPt.size())
493  {
495  << "mismatch in image and ground point number" << endl;
496  return -1.0;
497  }
498  if (lsPt.size() < 4)
499  {
501  << "not enough tie points - need at least 4" << endl;
502  return -1.0;
503  }
504 
505  theLineSamplePt = lsPt;
506  theGeographicPt = geoPt;
507 
508  //compute fit
510 
511  //compute variance
512  ossim_float64 sumerr2=0.0;
513  vector<ossimDpt>::const_iterator i;
514  vector<ossimGpt>::const_iterator j;
515  ossimGpt gres;
516  for(i=theLineSamplePt.begin() , j=theGeographicPt.begin() ; i != theLineSamplePt.end() ; ++i, ++j )
517  {
518  gres.lat = theLatFit.lsFitValue(i->x, i->y);
519  gres.lon = theLonFit.lsFitValue(i->x, i->y);
520  gres.hgt = j->hgt; //same height as ground point
521 
522  sumerr2 += ( ossimEcefPoint(gres) - ossimEcefPoint(*j) ).norm2(); //add squared error in meters
523  }
524 
525  return sumerr2 / theLineSamplePt.size(); //variance in meter^2
526 }
ossim_float64 hgt
Height in meters above the ellipsiod.
Definition: ossimGpt.h:274
std::vector< ossimGpt > theGeographicPt
double ossim_float64
ossimLeastSquaresBilin theLatFit
ossim_float64 lon
Definition: ossimGpt.h:266
std::vector< ossimDpt > theLineSamplePt
ossimLeastSquaresBilin theLonFit
virtual double lsFitValue(double xx, double yy) const
interpolate LS-fit value at location (xx,yy) - returns z(xx,yy).
ossim_float64 lat
Definition: ossimGpt.h:265
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setupOptimizer()

bool ossimBilinearProjection::setupOptimizer ( const ossimString setup)
virtual

setupFromString() Derived classes should implement as needed. Initialize parameters needed for optimizeFit and degreesOfFreedom

Returns
This implementation does nothing and returns false.

Reimplemented from ossimOptimizableProjection.

Definition at line 528 of file ossimBilinearProjection.cpp.

529 {
530  return false;
531 }

◆ useForward()

virtual bool ossimBilinearProjection::useForward ( ) const
inlinevirtual

useForward() return true when it's better (more accurate / fast) to use forward (from ground to image) than inverse(from image to ground)

Implements ossimOptimizableProjection.

Definition at line 79 of file ossimBilinearProjection.h.

79 {return false;}

◆ worldToLineSample()

void ossimBilinearProjection::worldToLineSample ( const ossimGpt worldPoint,
ossimDpt lineSampPt 
) const
virtual

METHOD: worldToLineSample() Performs the forward projection from ground point to line, sample.

Implements ossimProjection.

Definition at line 125 of file ossimBilinearProjection.cpp.

References ossimGpt::latd(), ossimGpt::lond(), ossimLeastSquaresBilin::lsFitValue(), ossimDpt::makeNan(), theInterpolationPointsHaveNanFlag, theInverseSupportedFlag, theXFit, theYFit, ossimProjection::worldToLineSample(), ossimDpt::x, and ossimDpt::y.

127 {
129  {
130  ossimProjection::worldToLineSample(worldPoint, lineSampPt);
131  }
132  else
133  {
134  lineSampPt.makeNan();
135 
137  {
138  lineSampPt.x = theXFit.lsFitValue(worldPoint.lond(),
139  worldPoint.latd());
140  lineSampPt.y = theYFit.lsFitValue(worldPoint.lond(),
141  worldPoint.latd());
142  }
143  }
144 }
ossimLeastSquaresBilin theXFit
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
double y
Definition: ossimDpt.h:165
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
ossimLeastSquaresBilin theYFit
double x
Definition: ossimDpt.h:164
virtual double lsFitValue(double xx, double yy) const
interpolate LS-fit value at location (xx,yy) - returns z(xx,yy).
virtual void worldToLineSample(const ossimGpt &worldPoint, ossimDpt &lineSampPt) const =0
void makeNan()
Definition: ossimDpt.h:65

Member Data Documentation

◆ theGeographicPt

std::vector<ossimGpt> ossimBilinearProjection::theGeographicPt
protected

◆ theInterpolationPointsHaveNanFlag

bool ossimBilinearProjection::theInterpolationPointsHaveNanFlag
protected

◆ theInverseSupportedFlag

bool ossimBilinearProjection::theInverseSupportedFlag
protected

Definition at line 126 of file ossimBilinearProjection.h.

Referenced by initializeBilinear(), and worldToLineSample().

◆ theLatFit

ossimLeastSquaresBilin ossimBilinearProjection::theLatFit
protected

◆ theLineSamplePt

std::vector<ossimDpt> ossimBilinearProjection::theLineSamplePt
protected

◆ theLonFit

ossimLeastSquaresBilin ossimBilinearProjection::theLonFit
protected

◆ theXFit

ossimLeastSquaresBilin ossimBilinearProjection::theXFit
protected

Definition at line 122 of file ossimBilinearProjection.h.

Referenced by initializeBilinear(), and worldToLineSample().

◆ theYFit

ossimLeastSquaresBilin ossimBilinearProjection::theYFit
protected

Definition at line 123 of file ossimBilinearProjection.h.

Referenced by initializeBilinear(), and worldToLineSample().


The documentation for this class was generated from the following files: