26 static const char* MODEL_TYPE =
"ossimPolynomProjection";
27 static const char* LAT_SCALE_KW =
"lat_scale";
28 static const char* LON_SCALE_KW =
"long_scale";
29 static const char* HGT_SCALE_KW =
"height_scale";
30 static const char* LAT_OFFSET_KW =
"lat_off";
31 static const char* LON_OFFSET_KW =
"long_off";
32 static const char* HGT_OFFSET_KW =
"height_off";
33 static const char* POLY_LINE_KW =
"poly_line";
34 static const char* POLY_SAMP_KW =
"poly_samp";
51 thePolyLine(model.thePolySamp),
52 thePolySamp(model.thePolyLine),
54 thePolyLine_DLon(model.thePolyLine_DLon),
55 thePolyLine_DLat(model.thePolyLine_DLat),
56 thePolySamp_DLon(model.thePolySamp_DLon),
57 thePolySamp_DLat(model.thePolySamp_DLat),
59 theLonOffset(model.theLonOffset),
60 theLonScale(model.theLonScale),
61 theLatOffset(model.theLatOffset),
62 theLatScale(model.theLatScale),
63 theHgtOffset(model.theHgtOffset),
64 theHgtScale(model.theHgtScale)
90 vector<double> gpt(3);
136 const double& ellHeight,
142 static const int MAX_NUM_ITERATIONS = 10;
143 static const double CONVERGENCE_EPSILON = 0.1;
151 double U = image_point.
y;
152 double V = image_point.
x;
158 vector<double> ngpt(3);
170 double epsilonU = CONVERGENCE_EPSILON;
171 double epsilonV = CONVERGENCE_EPSILON;
184 double deltaU, deltaV;
185 double dU_dLat, dU_dLon, dV_dLat, dV_dLon, W;
186 double deltaLat, deltaLon;
210 if ((fabs(deltaU) > epsilonU) || (fabs(deltaV) > epsilonV))
220 W = dU_dLon*dV_dLat - dU_dLat*dV_dLon;
225 deltaLat = (dU_dLon*deltaV - dV_dLon*deltaU) / W;
226 deltaLon = (dV_dLat*deltaU - dU_dLat*deltaV) / W;
233 }
while (((fabs(deltaU)>epsilonU) || (fabs(deltaV)>epsilonV))
234 && (iteration < MAX_NUM_ITERATIONS));
239 if (iteration == MAX_NUM_ITERATIONS)
242 <<
"solution. Results are inaccurate." << endl;
295 if(&projection ==
this)
return true;
311 out <<
"\nDump of ossimPolynomProjection object at " << hex <<
this <<
":\n" 332 const char* prefix)
const 350 kwl.
add(prefix, POLY_LINE_KW, polyLineS.str().c_str());
351 kwl.
add(prefix, POLY_SAMP_KW, polySampS.str().c_str());
384 keyword = LAT_SCALE_KW;
385 value = kwl.
find(prefix, keyword);
389 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 395 keyword = LON_SCALE_KW;
396 value = kwl.
find(prefix, keyword);
400 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 406 keyword = HGT_SCALE_KW;
407 value = kwl.
find(prefix, keyword);
411 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 417 keyword = LAT_OFFSET_KW;
418 value = kwl.
find(prefix, keyword);
422 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 428 keyword = LON_OFFSET_KW;
429 value = kwl.
find(prefix, keyword);
433 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 439 keyword = HGT_OFFSET_KW;
440 value = kwl.
find(prefix, keyword);
444 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 451 keyword = POLY_LINE_KW;
452 value = kwl.
find(prefix, keyword);
456 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 461 polyLineIS.str(std::string(value));
464 keyword = POLY_SAMP_KW;
465 value = kwl.
find(prefix, keyword);
469 <<
"<" << keyword <<
">. Check the keywordlist for proper syntax." 474 polySampIS.str(std::string(value));
539 std::vector< ossimString > spm = monoms.
explode(
" \t,;");
540 for (std::vector< ossimString >::const_iterator it = spm.begin(); it!=spm.end() ;++it)
547 "FATAL ossimPolynomProjection::setupDesiredExponents(): bad exponent tuple string: "<<*it<<std::endl;
570 if (tieSet.
size() <=0 )
608 hgtScale = (gmax.
hgt-gmin.
hgt)/2.0;
632 vector< ossimPolynom< ossim_float64 , 3 >::VAR_TUPLE > inputs(tieSet.
size());
633 vector< ossim_float64 > lines(tieSet.
size());
634 vector< ossim_float64 > samps(tieSet.
size());
635 const vector<ossimRefPtr<ossimTieGpt> >& theTPV = tieSet.
getTiePoints();
637 vector< ossimPolynom< ossim_float64 , 3 >::VAR_TUPLE >::iterator pit;
638 vector< ossim_float64 >::iterator sit;
639 vector< ossim_float64 >::iterator lit;
640 vector<ossimRefPtr<ossimTieGpt> >::const_iterator tit;
641 for (tit = theTPV.begin(), pit=inputs.begin(), lit=lines.begin(), sit=samps.begin(); tit!=theTPV.end() ; ++tit,++lit, ++sit,++pit)
656 *sit = (*tit)->tie.x;
657 *lit = (*tit)->tie.y;
681 return samp_rms*samp_rms + line_rms*line_rms;
697 if (ts[static_cast<std::string::size_type>(0)] ==
'1')
699 for(
int i=0;i<3;i++) et.push_back(0);
718 <<
"FATAL ossimPolynomProjection::stringToExp(): symbol appears twice: " 719 <<tkeys[
static_cast<std::string::size_type
>(symb)]
725 for(
int i=0;i<3;i++) et.push_back(ex[i]);
733 for(
unsigned int i=0;i<symbols.
size();++i)
735 if (ts.operator[](0) == symbols.operator[](i))
750 while ( (pos<ts.
size()) && (cts.operator[](pos)<=
'9') && (cts.operator[](pos)>=
'0'))
752 expo = 10*expo + (cts.operator[](pos)-
'0');
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
ossimPolynom< ossim_float64, 3 >::EXPT_SET theExpSet
desired exponents tuples set (for both line and sample polynoms) used for optimization ...
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
unsigned int size() const
static ossimString upcase(const ossimString &aString)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
T eval(const VAR_TUPLE &v) const
evaluation : needs DIM values as input
Represents serializable keyword/value map.
const char * find(const char *key) const
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
ossimString afterPos(std::string::size_type pos) const
void setPolyLine(const ossimPolynom< ossim_float64, 3 > &poly)
void setPolySamp(const ossimPolynom< ossim_float64, 3 > &poly)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimPolynom< ossim_float64, 3 > thePolySamp_DLat
ossim_float64 hgt
Height in meters above the ellipsiod.
ossimPolynom< ossim_float64, 3 > thePolySamp
xyz polynom
ossim_float64 theHgtScale
virtual void lineSampleHeightToWorld(const ossimDpt &image_point, const double &heightEllipsoid, ossimGpt &worldPoint) const
static const char * TYPE_KW
ossim_float64 theLonOffset
normalization parameters
void setupDesiredExponents(int horizonal_ord, int vertical_ord)
bool stringToExp(const ossimString &s, ossimPolynom< ossim_float64, 3 >::EXP_TUPLE &et) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
std::istream & import(std::istream &is)
note that it can only import for the template type T and dimesnion DIM
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual class enabling projection optimization (can be used for outlier rejection - RANSAC) ...
#define OSSIM_DEFAULT_MIN_PIX_DOUBLE
std::string::size_type size() const
ossim_float64 theLonScale
void addExpTupleRight(int newdim, int totalOrder, EXPT_SET &eset) const
concatenate exponents (at the right) to existing tuple set, for a given maximum total order eg: with ...
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossimPolynom< ossim_float64, 3 > thePolyLine_DLon
polynom partial derivatives
const vector< ossimRefPtr< ossimTieGpt > > & getTiePoints() const
void buildDerivatives()
protected methods
std::vector< ossimString > explode(const ossimString &delimeter) const
ossim_float64 theLatOffset
virtual void lineSampleToWorld(const ossimDpt &image_point, ossimGpt &world_point) const
ossimPolynom< ossim_float64, 3 > thePolyLine
ground (3d) to image(2D) polynoms
class for ground to image polynomial projection: (x,y,z)|->(x,y) polynom order is configurable ...
~ossimPolynomProjection()
void getGroundBoundaries(ossimGpt &gBoundInf, ossimGpt &gBoundSup) const
int getExponent(ossimString &ts) const
ossimPolynom< ossim_float64, 3 > thePolySamp_DLon
ossim_float64 theHgtOffset
storage class for a set of geographic tie points, between master and slave images ...
virtual ossimDpt getMetersPerPixel() const
ossim_float64 theLatScale
void buildSampDerivatives()
int getSymbol(ossimString &ts, const ossimString &symbols) const
takes string of xyz monoms, x2z3
bool LMSfit(const EXPT_SET &expset, const std::vector< VAR_TUPLE > obs_input, const std::vector< T > obs_output, T *prms=NULL)
fits the polynom to the observations using Least Mean Squares returns true on success (can fail if no...
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
std::ostream & print(std::ostream &os) const
I/O.
virtual ossimGpt origin() const
void pdiff(int pdim, ossimPolynom &result) const
partial differentiation polynom
virtual ossim_uint32 degreesOfFreedom() const
void buildLineDerivatives()
virtual double optimizeFit(const ossimTieGptSet &tieSet, double *targetVariance=NULL)
std::basic_istringstream< char > istringstream
Class for char input memory streams.
virtual bool operator==(const ossimProjection &projection) const
Basic operations.
ossimPolynomProjection()
Constructors.
virtual bool setupOptimizer(const ossimString &setup)
optimizableProjection implementation
RTTI_DEF2(ossimPolynomProjection, "ossimPolynomProjection", ossimProjection, ossimOptimizableProjection)
ossimPolynom< ossim_float64, 3 > thePolyLine_DLat
virtual void worldToLineSample(const ossimGpt &world_point, ossimDpt &image_point) const
Projection / localization methods.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.