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

#include <ossimTiffWorld.h>

Public Member Functions

 ossimTiffWorld ()
 
 ossimTiffWorld (const char *source, ossimPixelType ptype=OSSIM_PIXEL_IS_POINT, ossimUnitType unit=OSSIM_METERS)
 
 ~ossimTiffWorld ()
 
bool open (const ossimFilename &file, ossimPixelType ptype, ossimUnitType unit)
 
bool saveToOssimGeom (ossimKeywordlist &kwl, const char *prefix=NULL) const
 
bool loadFromOssimGeom (const ossimKeywordlist &kwl, const char *prefix=NULL)
 
std::ostream & print (std::ostream &out) const
 
void forward (const ossimDpt &imagePoint, ossimDpt &transformedPoint)
 
const ossimDptgetScale () const
 Converts world file parameters into x, y scale (for use in affine transform) More...
 
double getRotation () const
 Converts world file parameters into RH rotation in radians (for use in affine transform) More...
 
const ossimDptgetTranslation () const
 Provides access to the translation (for use in affine transform) More...
 

Protected Attributes

double theXform1
 
double theXform2
 
double theXform3
 
double theXform4
 
ossimDpt theTranslation
 
ossimPixelType thePixelType
 
ossimUnitType theUnit
 
ossimDpt theComputedScale
 
double theComputedRotation
 Radians. More...
 

Friends

OSSIMDLLEXPORT std::ostream & operator<< (std::ostream &out, const ossimTiffWorld &obj)
 

Detailed Description

Definition at line 26 of file ossimTiffWorld.h.

Constructor & Destructor Documentation

◆ ossimTiffWorld() [1/2]

ossimTiffWorld::ossimTiffWorld ( )

Definition at line 30 of file ossimTiffWorld.cpp.

31  :
32  theXform1(1.0),
33  theXform2(0.0),
34  theXform3(0.0),
35  theXform4(-1.0),
36  theTranslation(0.0,0.0),
39  theComputedScale(0.0, 0.0),
41 {}
ossimDpt theComputedScale
double theComputedRotation
Radians.
ossimPixelType thePixelType
ossimDpt theTranslation
ossimUnitType theUnit

◆ ossimTiffWorld() [2/2]

ossimTiffWorld::ossimTiffWorld ( const char *  source,
ossimPixelType  ptype = OSSIM_PIXEL_IS_POINT,
ossimUnitType  unit = OSSIM_METERS 
)

Definition at line 46 of file ossimTiffWorld.cpp.

References open().

49  :
50  theXform1(1.0),
51  theXform2(0.0),
52  theXform3(0.0),
53  theXform4(-1.0),
54  theTranslation(0.0,0.0),
55  thePixelType(ptype),
56  theUnit(scaleUnits),
57  theComputedScale(0.0, 0.0),
59 {
60  open(ossimFilename(file), ptype, scaleUnits);
61 }
bool open(const ossimFilename &file, ossimPixelType ptype, ossimUnitType unit)
ossimDpt theComputedScale
double theComputedRotation
Radians.
ossimPixelType thePixelType
ossimDpt theTranslation
ossimUnitType theUnit

◆ ~ossimTiffWorld()

ossimTiffWorld::~ossimTiffWorld ( )

Definition at line 138 of file ossimTiffWorld.cpp.

139 {
140 }

Member Function Documentation

◆ forward()

void ossimTiffWorld::forward ( const ossimDpt imagePoint,
ossimDpt transformedPoint 
)

transformed.x = imagePoint.x*theX_scale + imagePoint.y*the3rdValue + theTranslateX

transformed.y = imagePoint.x*the2ndValue + imagePoint.y*theY_scale + theTranslateY

Definition at line 142 of file ossimTiffWorld.cpp.

References theTranslation, theXform1, theXform2, theXform3, theXform4, ossimDpt::x, and ossimDpt::y.

144 {
145  transformedPoint.x = ip.x*theXform1 + ip.y*theXform2 + theTranslation.x;
146  transformedPoint.y = ip.x*theXform3 + ip.y*theXform4 + theTranslation.y;
147 }
double y
Definition: ossimDpt.h:165
ossimDpt theTranslation
double x
Definition: ossimDpt.h:164

◆ getRotation()

double ossimTiffWorld::getRotation ( ) const
inline

Converts world file parameters into RH rotation in radians (for use in affine transform)

Definition at line 62 of file ossimTiffWorld.h.

62 { return theComputedRotation; }
double theComputedRotation
Radians.

◆ getScale()

const ossimDpt& ossimTiffWorld::getScale ( ) const
inline

Converts world file parameters into x, y scale (for use in affine transform)

Definition at line 59 of file ossimTiffWorld.h.

59 { return theComputedScale; }
ossimDpt theComputedScale

◆ getTranslation()

const ossimDpt& ossimTiffWorld::getTranslation ( ) const
inline

Provides access to the translation (for use in affine transform)

Definition at line 65 of file ossimTiffWorld.h.

65 { return theTranslation; }
ossimDpt theTranslation

◆ loadFromOssimGeom()

bool ossimTiffWorld::loadFromOssimGeom ( const ossimKeywordlist kwl,
const char *  prefix = NULL 
)

Definition at line 206 of file ossimTiffWorld.cpp.

References ossimKeywordlist::find(), ossimKeywordNames::METERS_PER_PIXEL_X_KW, ossimKeywordNames::METERS_PER_PIXEL_Y_KW, ossimKeywordNames::PIXEL_SCALE_XY_KW, theTranslation, theXform1, theXform2, theXform3, theXform4, ossimKeywordNames::TIE_POINT_EASTING_KW, ossimKeywordNames::TIE_POINT_NORTHING_KW, ossimKeywordNames::TIE_POINT_XY_KW, ossimString::toDouble(), ossimDpt::toPoint(), ossimDpt::x, and ossimDpt::y.

207 {
208  theXform2 = 0.0;
209  theXform3 = 0.0;
210 
211  const char* lookup;
212 
213  // Get the scale...
214  lookup = kwl.find(prefix, ossimKeywordNames::PIXEL_SCALE_XY_KW);
215  if (lookup)
216  {
217  ossimDpt scale;
218  scale.toPoint(std::string(lookup));
219  theXform1 = scale.x;
220  theXform4 = -(scale.y);
221  }
222  else // BACKWARDS COMPATIBILITY LOOKUPS...
223  {
226  theXform1 = xscale.toDouble();
227  theXform4 = -(yscale.toDouble());
228  }
229 
230  // Get the tie...
231  lookup = kwl.find(prefix, ossimKeywordNames::TIE_POINT_XY_KW);
232  if (lookup)
233  {
234  ossimDpt tie;
235  tie.toPoint(std::string(lookup));
236  theTranslation.x = tie.x;
237  theTranslation.y = tie.y;
238  }
239  else // BACKWARDS COMPATIBILITY LOOKUPS...
240  {
241  ossimString easting =
243  ossimString northing =
245  theTranslation.x = easting.toDouble();
246  theTranslation.y = northing.toDouble();
247  }
248 
249  return true;
250 }
const char * find(const char *key) const
double y
Definition: ossimDpt.h:165
static const char * METERS_PER_PIXEL_Y_KW
static const char * PIXEL_SCALE_XY_KW
static const char * TIE_POINT_NORTHING_KW
static const char * TIE_POINT_XY_KW
static const char * TIE_POINT_EASTING_KW
void toPoint(const std::string &s)
Initializes this point from string.
Definition: ossimDpt.cpp:192
double toDouble() const
ossimDpt theTranslation
double x
Definition: ossimDpt.h:164
static const char * METERS_PER_PIXEL_X_KW

◆ open()

bool ossimTiffWorld::open ( const ossimFilename file,
ossimPixelType  ptype,
ossimUnitType  unit 
)

Definition at line 63 of file ossimTiffWorld.cpp.

References ossimString::c_str(), ossimFilename::file(), ossimNotify(), ossimNotifyLevel_WARN, ossimFilename::path(), ossimString::size(), theComputedRotation, theComputedScale, thePixelType, theTranslation, theUnit, theXform1, theXform2, theXform3, theXform4, ossimDpt::x, x, ossimDpt::y, and y.

Referenced by ossimTiffWorld().

64 {
65  bool result = false;
66 
67  ifstream is;
68  is.open(file.c_str());
69 
70  if( !is.is_open() )
71  {
72  // ESH 07/2008, Trac #234: OSSIM is case sensitive
73  // when using worldfile templates during ingest
74  // -- If first you don't succeed with the user-specified
75  // filename, try again with the results of a case insensitive search.
76  ossimFilename fullName(file);
77  ossimDirectory directory(fullName.path());
78  ossimFilename filename(fullName.file());
79 
80  std::vector<ossimFilename> result;
81  bool bSuccess = directory.findCaseInsensitiveEquivalents(
82  filename, result );
83  if ( bSuccess == true )
84  {
85  int numResults = (int)result.size();
86  int i;
87  for ( i=0; i<numResults && !is.is_open(); ++i )
88  {
89  is.open( result[i].c_str() );
90  }
91  }
92  }
93 
94  if ( is.is_open() )
95  {
96  double x,y;
97  is >> theXform1 >> theXform2 >> theXform3 >> theXform4 >> x >> y;
99 
100  // Compute the affine parameters from the transform:
102 
103 /*
104  * Commented out warning.
105  * Used all the time for tie and scale, NOT for affine. We could wrap around trace
106  * if we added trace to class. (drb - 20110115)
107  */
108 #if 0
109  double angle2 = atan2(theXform4,theXform3);
110  if (fabs(theComputedRotation - angle2) > 0.00001)
111  {
113  << "ossimTiffWorld -- Non-affine transform encountered."
114  << " Use of an affine transform to represent this world file geometry will result in errors."
115  << endl;
116  }
117 #endif
118 
119  double cos_rot = cos(theComputedRotation);
120  if (cos_rot != 0.0)
121  {
122  theComputedScale.x = theXform1/cos_rot;
123  theComputedScale.y = theXform4/cos_rot;
124  }
125  else
126  {
129  }
130  thePixelType = ptype;
131  theUnit = unit;
132  is.close();
133  result = true;
134  }
135  return result;
136 }
ossim_uint32 x
ossimDpt theComputedScale
ossim_uint32 y
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
double theComputedRotation
Radians.
double y
Definition: ossimDpt.h:165
std::string::size_type size() const
Definition: ossimString.h:405
ossimPixelType thePixelType
ossimDpt theTranslation
double x
Definition: ossimDpt.h:164
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimUnitType theUnit
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ print()

std::ostream & ossimTiffWorld::print ( std::ostream &  out) const

Definition at line 252 of file ossimTiffWorld.cpp.

References theTranslation, theXform1, theXform2, theXform3, and theXform4.

Referenced by operator<<().

253 {
254  out << setiosflags(ios::fixed) << setprecision(15)
255  << theXform1 << "\n"
256  << theXform2 << "\n"
257  << theXform3 << "\n"
258  << theXform4 << "\n"
259  << theTranslation
260  << endl;
261  return out;
262 }
ossimDpt theTranslation

◆ saveToOssimGeom()

bool ossimTiffWorld::saveToOssimGeom ( ossimKeywordlist kwl,
const char *  prefix = NULL 
) const

Definition at line 149 of file ossimTiffWorld.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), ossimUnitConversionTool::getMeters(), OSSIM_DEGREES, OSSIM_FEET, OSSIM_PIXEL_IS_AREA, OSSIM_US_SURVEY_FEET, ossimKeywordNames::PIXEL_SCALE_UNITS_KW, ossimKeywordNames::PIXEL_SCALE_XY_KW, ossimKeywordNames::PIXEL_TYPE_KW, thePixelType, theTranslation, theUnit, theXform1, theXform4, ossimKeywordNames::TIE_POINT_UNITS_KW, ossimKeywordNames::TIE_POINT_XY_KW, ossimDpt::toString(), ossimDpt::x, and ossimDpt::y.

150 {
151  ossimDpt scale(fabs(theXform1), fabs(theXform4));
153 
154  if ( (theUnit == OSSIM_FEET) || (theUnit == OSSIM_US_SURVEY_FEET) )
155  {
156  // Convert to meters.
157  scale.x = ossimUnitConversionTool(scale.x, theUnit).getMeters();
158  scale.y = ossimUnitConversionTool(scale.y, theUnit).getMeters();
159  tie.x = ossimUnitConversionTool(tie.x, theUnit).getMeters();
160  tie.y = ossimUnitConversionTool(tie.y, theUnit).getMeters();
161  }
162 
163  // Shift the tie point to be relative to the center of the pixel.
165  {
166  tie.x += (scale.x/2.0);
167  tie.y -= (scale.y/2.0);
168 
169  // Adjust the keyword list to reflect pixel is point.
170  kwl.add(prefix,
172  "pixel_is_point",
173  true);
174  }
175 
176  // Units in feet converted to meters up above.
177  ossimString units = "meters";
178  if(theUnit == OSSIM_DEGREES)
179  {
180  units = "degrees";
181  }
182 
183  kwl.add(prefix,
185  tie.toString().c_str(),
186  true);
187 
188  kwl.add(prefix,
190  units.c_str(),
191  true);
192 
193  kwl.add(prefix,
195  scale.toString().c_str(),
196  true);
197 
198  kwl.add(prefix,
200  units.c_str(),
201  true);
202 
203  return true;
204 }
double y
Definition: ossimDpt.h:165
static const char * PIXEL_SCALE_XY_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const char * TIE_POINT_XY_KW
ossimPixelType thePixelType
ossimDpt theTranslation
static const char * PIXEL_TYPE_KW
double x
Definition: ossimDpt.h:164
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimUnitType theUnit
static const char * PIXEL_SCALE_UNITS_KW
static const char * TIE_POINT_UNITS_KW

Friends And Related Function Documentation

◆ operator<<

OSSIMDLLEXPORT std::ostream& operator<< ( std::ostream &  out,
const ossimTiffWorld obj 
)
friend

Definition at line 264 of file ossimTiffWorld.cpp.

265 {
266  return obj.print(out);
267 }
std::ostream & print(std::ostream &out) const

Member Data Documentation

◆ theComputedRotation

double ossimTiffWorld::theComputedRotation
protected

Radians.

Definition at line 77 of file ossimTiffWorld.h.

Referenced by open().

◆ theComputedScale

ossimDpt ossimTiffWorld::theComputedScale
protected

Definition at line 76 of file ossimTiffWorld.h.

Referenced by open().

◆ thePixelType

ossimPixelType ossimTiffWorld::thePixelType
protected

Definition at line 74 of file ossimTiffWorld.h.

Referenced by open(), and saveToOssimGeom().

◆ theTranslation

ossimDpt ossimTiffWorld::theTranslation
protected

Definition at line 72 of file ossimTiffWorld.h.

Referenced by forward(), loadFromOssimGeom(), open(), print(), and saveToOssimGeom().

◆ theUnit

ossimUnitType ossimTiffWorld::theUnit
protected

Definition at line 75 of file ossimTiffWorld.h.

Referenced by open(), and saveToOssimGeom().

◆ theXform1

double ossimTiffWorld::theXform1
protected

Definition at line 68 of file ossimTiffWorld.h.

Referenced by forward(), loadFromOssimGeom(), open(), print(), and saveToOssimGeom().

◆ theXform2

double ossimTiffWorld::theXform2
protected

Definition at line 69 of file ossimTiffWorld.h.

Referenced by forward(), loadFromOssimGeom(), open(), and print().

◆ theXform3

double ossimTiffWorld::theXform3
protected

Definition at line 70 of file ossimTiffWorld.h.

Referenced by forward(), loadFromOssimGeom(), open(), and print().

◆ theXform4

double ossimTiffWorld::theXform4
protected

Definition at line 71 of file ossimTiffWorld.h.

Referenced by forward(), loadFromOssimGeom(), open(), print(), and saveToOssimGeom().


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