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

#include <ossimNadconGridFile.h>

Public Member Functions

 ossimNadconGridFile ()
 
 ~ossimNadconGridFile ()
 
bool open (const ossimFilename &file)
 
void close ()
 
double getShiftAtLatLon (double lat, double lon) const
 
bool pointWithin (double lat, double lon) const
 
const ossimDrect getBoundingRect () const
 
const ossimFilenamegetFilename () const
 
bool getFileOkFlag () const
 
ossimDpt getSpacing () const
 

Protected Attributes

std::ifstream theInputFile
 
bool theFileOkFlag
 
ossimFilename theFilename
 
ossimNadconGridHeader theHeader
 
ossimDrect theBoundingRect
 
ossimDpt theLatLonOrigin
 

Detailed Description

Definition at line 14 of file ossimNadconGridFile.h.

Constructor & Destructor Documentation

◆ ossimNadconGridFile()

ossimNadconGridFile::ossimNadconGridFile ( )
inline

Definition at line 17 of file ossimNadconGridFile.h.

17 : theFileOkFlag(false) {}

◆ ~ossimNadconGridFile()

ossimNadconGridFile::~ossimNadconGridFile ( )

Definition at line 6 of file ossimNadconGridFile.cpp.

7 {
8  close();
9 }

Member Function Documentation

◆ close()

void ossimNadconGridFile::close ( )

Definition at line 32 of file ossimNadconGridFile.cpp.

33 {
34  theInputFile.close();
35 }
std::ifstream theInputFile

◆ getBoundingRect()

const ossimDrect ossimNadconGridFile::getBoundingRect ( ) const
inline

Definition at line 26 of file ossimNadconGridFile.h.

27  {
28  return theBoundingRect;
29  }

◆ getFilename()

const ossimFilename& ossimNadconGridFile::getFilename ( ) const
inline

Definition at line 31 of file ossimNadconGridFile.h.

32  {
33  return theFilename;
34  }

◆ getFileOkFlag()

bool ossimNadconGridFile::getFileOkFlag ( ) const
inline

Definition at line 35 of file ossimNadconGridFile.h.

Referenced by ossimNadconNarDatum::shift(), and ossimNadconNasDatum::shift().

36  {
37  return theFileOkFlag;
38  }

◆ getShiftAtLatLon()

double ossimNadconGridFile::getShiftAtLatLon ( double  lat,
double  lon 
) const

Definition at line 37 of file ossimNadconGridFile.cpp.

References ossimEndian::getSystemEndianType(), ossim::nan(), OSSIM_LITTLE_ENDIAN, ossimEndian::swap(), x, and y.

Referenced by ossimNadconNarDatum::shift(), and ossimNadconNasDatum::shift().

38 {
39  double result = ossim::nan();
40  if(pointWithin(lat, lon))
41  {
42  double x = (lon - theLatLonOrigin.lon)/(double)theHeader.getDeltaX();
43  double y = (lat - theLatLonOrigin.lat)/(double)theHeader.getDeltaY();
44 
45  int lat0 = (int)y;
46  int lat1 = lat0 + 1;
47  int lon0 = (int)x;
48  int lon1 = lon0 + 1;
49 
50  int rows = theHeader.getNumberOfRows();
51  int cols = theHeader.getNumberOfCols();
52 
53  if(lat1 >= rows) lat1 = lat0;
54  if(lon1 >= cols) lon1 = lon0;
55 
56  double tLat = y - lat0;
57  double tLon = x - lon0;
58 
59  int offset00 = lat0*theHeader.getBytesPerRow() + lon0*4 + theHeader.getStartOffset();
60  int offset01 = lat0*theHeader.getBytesPerRow() + lon1*4 + theHeader.getStartOffset();
61  int offset11 = lat1*theHeader.getBytesPerRow() + lon1*4 + theHeader.getStartOffset();
62  int offset10 = lat1*theHeader.getBytesPerRow() + lon0*4 + theHeader.getStartOffset();
63 
64 
65  double v00 = 0.0;
66  double v01 = 0.0;
67  double v11 = 0.0;
68  double v10 = 0.0;
69 
70  theInputFile.seekg((std::streampos)offset00);
71  theInputFile.read((char*)&v00, 4);
72  theInputFile.seekg((std::streampos)offset01);
73  theInputFile.read((char*)&v01, 4);
74  theInputFile.seekg((std::streampos)offset11);
75  theInputFile.read((char*)&v11, 4);
76  theInputFile.seekg((std::streampos)offset10);
77  theInputFile.read((char*)&v10, 4);
78  ossimEndian anEndian;
79 
81  {
82  anEndian.swap(v00);
83  anEndian.swap(v01);
84  anEndian.swap(v11);
85  anEndian.swap(v10);
86  }
87 
88  double top = (double)v00 + ((double)v01 - (double)v00)*tLon;
89  double bottom = (double)v10 + ((double)v11 - (double)v10)*tLon;
90 
91  result = top + (bottom-top)*tLat;
92  }
93 
94  return result;
95 }
ossim_uint32 x
ossim_uint32 y
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double lat
Definition: ossimDpt.h:165
ossimNadconGridHeader theHeader
double lon
Definition: ossimDpt.h:164
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
std::ifstream theInputFile
bool pointWithin(double lat, double lon) const
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26

◆ getSpacing()

ossimDpt ossimNadconGridFile::getSpacing ( ) const
inline

Definition at line 39 of file ossimNadconGridFile.h.

40  {
41  return theHeader.getSpacing();
42  }
ossimNadconGridHeader theHeader

◆ open()

bool ossimNadconGridFile::open ( const ossimFilename file)

Definition at line 11 of file ossimNadconGridFile.cpp.

References ossimString::c_str().

Referenced by ossimNadconGridDatum::checkGrid().

12 {
13  if(theHeader.readHeader(file))
14  {
15  theInputFile.close();
16  theInputFile.clear();
17  theInputFile.open(file.c_str(), ios::in|ios::binary);
18 
22  theFilename = file;
23  theFileOkFlag = true;
24  return theInputFile.good();
25  }
26  theFileOkFlag = false;
27  theFilename = "";
28 
29  return false;
30 }
bool readHeader(const ossimFilename &file)
double lat
Definition: ossimDpt.h:165
ossimNadconGridHeader theHeader
ossimDrect getBoundingRect() const
double lon
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
std::ifstream theInputFile

◆ pointWithin()

bool ossimNadconGridFile::pointWithin ( double  lat,
double  lon 
) const

Definition at line 97 of file ossimNadconGridFile.cpp.

98 {
99  return theBoundingRect.pointWithin(ossimDpt(lon, lat));
100 }
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781

Member Data Documentation

◆ theBoundingRect

ossimDrect ossimNadconGridFile::theBoundingRect
protected

Definition at line 49 of file ossimNadconGridFile.h.

◆ theFilename

ossimFilename ossimNadconGridFile::theFilename
protected

Definition at line 47 of file ossimNadconGridFile.h.

◆ theFileOkFlag

bool ossimNadconGridFile::theFileOkFlag
mutableprotected

Definition at line 46 of file ossimNadconGridFile.h.

◆ theHeader

ossimNadconGridHeader ossimNadconGridFile::theHeader
protected

Definition at line 48 of file ossimNadconGridFile.h.

◆ theInputFile

std::ifstream ossimNadconGridFile::theInputFile
mutableprotected

Definition at line 45 of file ossimNadconGridFile.h.

◆ theLatLonOrigin

ossimDpt ossimNadconGridFile::theLatLonOrigin
protected

Definition at line 50 of file ossimNadconGridFile.h.


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