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

#include <ossimUnitConversionTool.h>

Public Member Functions

 ossimUnitConversionTool (double value=1.0, ossimUnitType unitType=OSSIM_METERS)
 
 ossimUnitConversionTool (const ossimGpt &origin, double value, ossimUnitType unitType=OSSIM_METERS)
 
void setOrigin (const ossimGpt &gpt)
 
ossimGpt getOrigin () const
 
void getOrigin (ossimGpt &result) const
 
void setValue (double value, ossimUnitType unitType=OSSIM_METERS)
 
double getValue (ossimUnitType unitType=OSSIM_METERS) const
 
void setMeters (double value)
 
void setRadians (double value)
 
void setDegrees (double value)
 
void setMinutes (double value)
 
void setSeconds (double value)
 
void setUsSurveyFeet (double value)
 
void setFeet (double value)
 
void setNauticalMiles (double value)
 
void setMiles (double value)
 
void setMillimeters (double value)
 
void setMicrons (double value)
 
void setCentimeters (double value)
 
void setYards (double value)
 
void setInches (double value)
 
void setKilometers (double value)
 
double getMeters () const
 
double getRadians () const
 
double getDegrees () const
 
double getMinutes () const
 
double getSeconds () const
 
double getUsSurveyFeet () const
 
double getFeet () const
 
double getNauticalMiles () const
 
double getMiles () const
 
double getMillimeters () const
 
double getMicrons () const
 
double getCentimeters () const
 
double getYards () const
 
double getInches () const
 
double getKilometers () const
 

Protected Member Functions

double computeMeters () const
 

Protected Attributes

double theValue
 
ossimUnitType theUnitType
 
ossimGpt theOrigin
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimUnitConversionTool &data)
 

Detailed Description

Definition at line 18 of file ossimUnitConversionTool.h.

Constructor & Destructor Documentation

◆ ossimUnitConversionTool() [1/2]

ossimUnitConversionTool::ossimUnitConversionTool ( double  value = 1.0,
ossimUnitType  unitType = OSSIM_METERS 
)

Definition at line 33 of file ossimUnitConversionTool.cpp.

35  : theValue(value),
36  theUnitType(unitType),
37  theOrigin()
38 {
39 }

◆ ossimUnitConversionTool() [2/2]

ossimUnitConversionTool::ossimUnitConversionTool ( const ossimGpt origin,
double  value,
ossimUnitType  unitType = OSSIM_METERS 
)

Definition at line 41 of file ossimUnitConversionTool.cpp.

44  : theValue(value),
45  theUnitType(unitType),
46  theOrigin(origin)
47 {
48 }

Member Function Documentation

◆ computeMeters()

double ossimUnitConversionTool::computeMeters ( ) const
protected

Definition at line 377 of file ossimUnitConversionTool.cpp.

References DEG_PER_RAD, FT_PER_MILE, ossimGpt::metersPerDegree(), MTRS_PER_FT, ossim::nan(), OSSIM_DEGREES, OSSIM_FEET, OSSIM_METERS, OSSIM_MICRONS, OSSIM_MILES, OSSIM_MILLIMETERS, OSSIM_MINUTES, OSSIM_NAUTICAL_MILES, OSSIM_RADIANS, OSSIM_SECONDS, OSSIM_US_SURVEY_FEET, theOrigin, theUnitType, theValue, US_METERS_PER_FT, ossimDpt::x, and ossimDpt::y.

Referenced by getCentimeters(), getDegrees(), getFeet(), getKilometers(), getMeters(), getMicrons(), getMiles(), getMillimeters(), getNauticalMiles(), getUsSurveyFeet(), and getYards().

378 {
379  switch(theUnitType)
380  {
381  case OSSIM_METERS:
382  {
383  return theValue;
384  break;
385  }
386  case OSSIM_RADIANS:
387  {
389  return (theValue*DEG_PER_RAD)*((pt.x+pt.y)*.5);
390  }
391  case OSSIM_DEGREES:
392  {
394  return theValue*((pt.x+pt.y)*.5);
395  }
397  {
398  return US_METERS_PER_FT*theValue;
399  }
400  case OSSIM_FEET:
401  {
402  return MTRS_PER_FT*theValue;
403  }
404  case OSSIM_SECONDS:
405  {
407  return (theValue/3600.0)*((pt.x+pt.y)*.5);
408  }
409  case OSSIM_MINUTES:
410  {
412  return (theValue/60.0)*((pt.x+pt.y)*.5);
413  }
415  {
416  return (theOrigin.metersPerDegree().y/60.0)*theValue;
417  }
418  case OSSIM_MILES:
419  {
421  }
422  case OSSIM_MILLIMETERS:
423  {
424  return (theValue/(1e3));
425  }
426  case OSSIM_MICRONS:
427  {
428  return (theValue/(1e6));
429  }
430  default:
431  break;
432  }
433 
434  return ossim::nan();
435 }
#define DEG_PER_RAD
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double y
Definition: ossimDpt.h:165
#define US_METERS_PER_FT
#define FT_PER_MILE
#define MTRS_PER_FT
double x
Definition: ossimDpt.h:164
ossimDpt metersPerDegree() const
Definition: ossimGpt.cpp:498

◆ getCentimeters()

double ossimUnitConversionTool::getCentimeters ( ) const

Definition at line 338 of file ossimUnitConversionTool.cpp.

References computeMeters(), OSSIM_KILOMETERS, theUnitType, and theValue.

Referenced by getValue().

339 {
341  {
342  return theValue;
343  }
344 
345  return ((computeMeters()*1e2));
346 }

◆ getDegrees()

double ossimUnitConversionTool::getDegrees ( ) const

Definition at line 237 of file ossimUnitConversionTool.cpp.

References computeMeters(), DEG_PER_RAD, ossimGpt::metersPerDegree(), OSSIM_DEGREES, OSSIM_MINUTES, OSSIM_RADIANS, OSSIM_SECONDS, theOrigin, theUnitType, theValue, ossimDpt::x, and ossimDpt::y.

Referenced by getMinutes(), getRadians(), getSeconds(), getValue(), operator<<(), and ossimMapProjection::snapTiePointTo().

238 {
239  switch (theUnitType)
240  {
241  case OSSIM_DEGREES:
242  {
243  return theValue;
244  }
245  case OSSIM_MINUTES:
246  {
247  return (theValue / 60.0);
248  }
249  case OSSIM_SECONDS:
250  {
251  return (theValue / 3600.0);
252  }
253  case OSSIM_RADIANS:
254  {
255  return (theValue * DEG_PER_RAD);
256  }
257  default:
258  break;
259  }
260 
262  return (computeMeters() /((pt.x+pt.y)*.5));
263 }
#define DEG_PER_RAD
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164
ossimDpt metersPerDegree() const
Definition: ossimGpt.cpp:498

◆ getFeet()

double ossimUnitConversionTool::getFeet ( ) const

Definition at line 292 of file ossimUnitConversionTool.cpp.

References computeMeters(), FT_PER_MTRS, OSSIM_FEET, theUnitType, and theValue.

Referenced by getInches(), getValue(), and operator<<().

293 {
294  if(theUnitType == OSSIM_FEET)
295  {
296  return theValue;
297  }
298  return (computeMeters()*FT_PER_MTRS);
299 }
#define FT_PER_MTRS

◆ getInches()

double ossimUnitConversionTool::getInches ( ) const

Definition at line 358 of file ossimUnitConversionTool.cpp.

References getFeet(), OSSIM_INCHES, theUnitType, and theValue.

Referenced by getValue().

359 {
361  {
362  return theValue;
363  }
364 
365  return ((getFeet()*12.0));
366 }

◆ getKilometers()

double ossimUnitConversionTool::getKilometers ( ) const

Definition at line 368 of file ossimUnitConversionTool.cpp.

References computeMeters(), OSSIM_KILOMETERS, theUnitType, and theValue.

Referenced by getValue().

369 {
371  {
372  return theValue;
373  }
374  return ((computeMeters()*1e-3));
375 }

◆ getMeters()

double ossimUnitConversionTool::getMeters ( ) const

◆ getMicrons()

double ossimUnitConversionTool::getMicrons ( ) const

Definition at line 329 of file ossimUnitConversionTool.cpp.

References computeMeters(), OSSIM_MICRONS, theUnitType, and theValue.

Referenced by getValue().

330 {
332  {
333  return theValue;
334  }
335  return ((computeMeters()*1e6));
336 }

◆ getMiles()

double ossimUnitConversionTool::getMiles ( ) const

Definition at line 311 of file ossimUnitConversionTool.cpp.

References computeMeters(), FT_PER_MILE, FT_PER_MTRS, OSSIM_MILES, theUnitType, and theValue.

Referenced by getValue().

312 {
313  if(theUnitType == OSSIM_MILES)
314  {
315  return theValue;
316  }
318 }
#define FT_PER_MTRS
#define FT_PER_MILE

◆ getMillimeters()

double ossimUnitConversionTool::getMillimeters ( ) const

Definition at line 320 of file ossimUnitConversionTool.cpp.

References computeMeters(), OSSIM_MILLIMETERS, theUnitType, and theValue.

Referenced by getValue().

321 {
323  {
324  return theValue;
325  }
326  return ((computeMeters()*1e3));
327 }

◆ getMinutes()

double ossimUnitConversionTool::getMinutes ( ) const

Definition at line 265 of file ossimUnitConversionTool.cpp.

References getDegrees(), OSSIM_MINUTES, theUnitType, and theValue.

Referenced by getValue(), and operator<<().

266 {
268  {
269  return theValue;
270  }
271  return (getDegrees()*60.0);
272 }

◆ getNauticalMiles()

double ossimUnitConversionTool::getNauticalMiles ( ) const

Definition at line 301 of file ossimUnitConversionTool.cpp.

References computeMeters(), ossimGpt::metersPerDegree(), OSSIM_NAUTICAL_MILES, theOrigin, theUnitType, theValue, and ossimDpt::y.

Referenced by getValue(), and operator<<().

302 {
304  {
305  return theValue;
306  }
307 
308  return (computeMeters()/(theOrigin.metersPerDegree().y/60.0));
309 }
double y
Definition: ossimDpt.h:165
ossimDpt metersPerDegree() const
Definition: ossimGpt.cpp:498

◆ getOrigin() [1/2]

ossimGpt ossimUnitConversionTool::getOrigin ( ) const

Definition at line 55 of file ossimUnitConversionTool.cpp.

References theOrigin.

56 {
57  return theOrigin;
58 }

◆ getOrigin() [2/2]

void ossimUnitConversionTool::getOrigin ( ossimGpt result) const

Definition at line 60 of file ossimUnitConversionTool.cpp.

References theOrigin.

61 {
62  result = theOrigin;
63 }

◆ getRadians()

double ossimUnitConversionTool::getRadians ( ) const

Definition at line 228 of file ossimUnitConversionTool.cpp.

References getDegrees(), OSSIM_RADIANS, RAD_PER_DEG, theUnitType, and theValue.

Referenced by getValue().

229 {
231  {
232  return theValue;
233  }
234  return getDegrees()*RAD_PER_DEG;
235 }
#define RAD_PER_DEG

◆ getSeconds()

double ossimUnitConversionTool::getSeconds ( ) const

Definition at line 274 of file ossimUnitConversionTool.cpp.

References getDegrees(), OSSIM_SECONDS, theUnitType, and theValue.

Referenced by getValue(), and operator<<().

275 {
277  {
278  return theValue;
279  }
280  return (getDegrees()*3600.0);
281 }

◆ getUsSurveyFeet()

double ossimUnitConversionTool::getUsSurveyFeet ( ) const

Definition at line 283 of file ossimUnitConversionTool.cpp.

References computeMeters(), OSSIM_US_SURVEY_FEET, theUnitType, theValue, and US_METERS_PER_FT.

Referenced by getValue(), and operator<<().

284 {
286  {
287  return theValue;
288  }
289  return (computeMeters()/US_METERS_PER_FT);
290 }
#define US_METERS_PER_FT

◆ getValue()

double ossimUnitConversionTool::getValue ( ossimUnitType  unitType = OSSIM_METERS) const

Definition at line 72 of file ossimUnitConversionTool.cpp.

References getCentimeters(), getDegrees(), getFeet(), getInches(), getKilometers(), getMeters(), getMicrons(), getMiles(), getMillimeters(), getMinutes(), getNauticalMiles(), getRadians(), getSeconds(), getUsSurveyFeet(), getYards(), ossim::nan(), OSSIM_CENTIMETERS, OSSIM_DEGREES, OSSIM_FEET, OSSIM_INCHES, OSSIM_KILOMETERS, OSSIM_METERS, OSSIM_MICRONS, OSSIM_MILES, OSSIM_MILLIMETERS, OSSIM_MINUTES, OSSIM_NAUTICAL_MILES, OSSIM_RADIANS, OSSIM_SECONDS, OSSIM_US_SURVEY_FEET, and OSSIM_YARDS.

Referenced by ossimOgcWktTranslator::fromOssimKwl(), ossimTilingRect::getPaddingSize(), ossimGeoAnnotationEllipseObject::getWidthHeightInPixels(), ossimMapProjection::lineSampleHeightToWorld(), ossimGdalOgrVectorAnnotation::loadOmdFile(), ossimGdalOgrVectorAnnotation::loadState(), ossimMapProjection::loadState(), ossimEsriShapeFileFilter::loadState(), ossimMapProjection::updateFromTransform(), and ossimMapProjection::worldToLineSample().

73 {
74  switch(unitType)
75  {
76  case OSSIM_METERS:
77  {
78  return getMeters();
79  }
80  case OSSIM_RADIANS:
81  {
82  return getRadians();
83  }
84  case OSSIM_DEGREES:
85  {
86  return getDegrees();
87  }
89  {
90  return getUsSurveyFeet();
91  }
92  case OSSIM_FEET:
93  {
94  return getFeet();
95  }
96  case OSSIM_SECONDS:
97  {
98  return getSeconds();
99  }
100  case OSSIM_MINUTES:
101  {
102  return getMinutes();
103  }
105  {
106  return getNauticalMiles();
107  }
108  case OSSIM_MILES:
109  {
110  return getMiles();
111  }
112  case OSSIM_MICRONS:
113  {
114  return getMicrons();
115  }
116  case OSSIM_CENTIMETERS:
117  {
118  return getCentimeters();
119  }
120  case OSSIM_MILLIMETERS:
121  {
122  return getMillimeters();
123  }
124  case OSSIM_YARDS:
125  {
126  return getYards();
127  }
128  case OSSIM_INCHES:
129  {
130  return getInches();
131  }
132  case OSSIM_KILOMETERS:
133  {
134  return getKilometers();
135  }
136  default:
137  break;
138  }
139 
140  return ossim::nan();
141 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135

◆ getYards()

double ossimUnitConversionTool::getYards ( ) const

Definition at line 348 of file ossimUnitConversionTool.cpp.

References computeMeters(), OSSIM_INCHES, theUnitType, and theValue.

Referenced by getValue().

349 {
351  {
352  return theValue;
353  }
354 
355  return ((computeMeters()/0.914));
356 }

◆ setCentimeters()

void ossimUnitConversionTool::setCentimeters ( double  value)

Definition at line 198 of file ossimUnitConversionTool.cpp.

References OSSIM_CENTIMETERS, and setValue().

199 {
200  setValue(value, OSSIM_CENTIMETERS);
201 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setDegrees()

void ossimUnitConversionTool::setDegrees ( double  value)

Definition at line 153 of file ossimUnitConversionTool.cpp.

References OSSIM_DEGREES, and setValue().

154 {
155  setValue(value, OSSIM_DEGREES);
156 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setFeet()

void ossimUnitConversionTool::setFeet ( double  value)

Definition at line 173 of file ossimUnitConversionTool.cpp.

References OSSIM_FEET, and setValue().

174 {
175  setValue(value, OSSIM_FEET);
176 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setInches()

void ossimUnitConversionTool::setInches ( double  value)

Definition at line 208 of file ossimUnitConversionTool.cpp.

References OSSIM_INCHES, and setValue().

209 {
210  setValue(value, OSSIM_INCHES);
211 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setKilometers()

void ossimUnitConversionTool::setKilometers ( double  value)

Definition at line 213 of file ossimUnitConversionTool.cpp.

References OSSIM_KILOMETERS, and setValue().

214 {
215  setValue(value, OSSIM_KILOMETERS);
216 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setMeters()

void ossimUnitConversionTool::setMeters ( double  value)

Definition at line 143 of file ossimUnitConversionTool.cpp.

References OSSIM_METERS, and setValue().

144 {
145  setValue(value, OSSIM_METERS);
146 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setMicrons()

void ossimUnitConversionTool::setMicrons ( double  value)

Definition at line 193 of file ossimUnitConversionTool.cpp.

References OSSIM_MICRONS, and setValue().

194 {
195  setValue(value, OSSIM_MICRONS);
196 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setMiles()

void ossimUnitConversionTool::setMiles ( double  value)

Definition at line 183 of file ossimUnitConversionTool.cpp.

References OSSIM_MILES, and setValue().

184 {
185  setValue(value, OSSIM_MILES);
186 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setMillimeters()

void ossimUnitConversionTool::setMillimeters ( double  value)

Definition at line 188 of file ossimUnitConversionTool.cpp.

References OSSIM_MILLIMETERS, and setValue().

189 {
190  setValue(value, OSSIM_MILLIMETERS);
191 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setMinutes()

void ossimUnitConversionTool::setMinutes ( double  value)

Definition at line 158 of file ossimUnitConversionTool.cpp.

References OSSIM_MINUTES, and setValue().

159 {
160  setValue(value, OSSIM_MINUTES);
161 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setNauticalMiles()

void ossimUnitConversionTool::setNauticalMiles ( double  value)

Definition at line 178 of file ossimUnitConversionTool.cpp.

References OSSIM_NAUTICAL_MILES, and setValue().

179 {
181 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setOrigin()

void ossimUnitConversionTool::setOrigin ( const ossimGpt gpt)

Definition at line 50 of file ossimUnitConversionTool.cpp.

References theOrigin.

Referenced by ossimMapProjection::snapTiePointTo().

51 {
52  theOrigin = gpt;
53 }

◆ setRadians()

void ossimUnitConversionTool::setRadians ( double  value)

Definition at line 148 of file ossimUnitConversionTool.cpp.

References OSSIM_RADIANS, and setValue().

149 {
150  setValue(value, OSSIM_RADIANS);
151 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setSeconds()

void ossimUnitConversionTool::setSeconds ( double  value)

Definition at line 163 of file ossimUnitConversionTool.cpp.

References OSSIM_SECONDS, and setValue().

164 {
165  setValue(value, OSSIM_SECONDS);
166 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setUsSurveyFeet()

void ossimUnitConversionTool::setUsSurveyFeet ( double  value)

Definition at line 168 of file ossimUnitConversionTool.cpp.

References OSSIM_US_SURVEY_FEET, and setValue().

169 {
171 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

◆ setValue()

void ossimUnitConversionTool::setValue ( double  value,
ossimUnitType  unitType = OSSIM_METERS 
)

◆ setYards()

void ossimUnitConversionTool::setYards ( double  value)

Definition at line 203 of file ossimUnitConversionTool.cpp.

References OSSIM_YARDS, and setValue().

204 {
205  setValue(value, OSSIM_YARDS);
206 }
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimUnitConversionTool data 
)
friend

Definition at line 18 of file ossimUnitConversionTool.cpp.

20 {
21  out << std::setprecision(15) << std::setiosflags(std::ios::fixed)
22  << "Meters: " << data.getMeters()
23  << "\nFeet: " << data.getFeet()
24  << "\nU.S. Survey Feet: " << data.getUsSurveyFeet()
25  << "\nNautical miles: " << data.getNauticalMiles()
26  << "\nDegrees: " << data.getDegrees()
27  << "\nMinutes: " << data.getMinutes()
28  << "\nSeconds: " << data.getSeconds() << std::endl;
29 
30  return out;
31 }

Member Data Documentation

◆ theOrigin

ossimGpt ossimUnitConversionTool::theOrigin
protected

◆ theUnitType

ossimUnitType ossimUnitConversionTool::theUnitType
protected

◆ theValue

double ossimUnitConversionTool::theValue
protected

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