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

#include <ossimTiledImageHash.h>

Inheritance diagram for ossimTiledImageHash:
ossimPointHash

Public Member Functions

 ossimTiledImageHash (const ossimDrect &imageRect, double tileWidth, double tileHeight)
 
virtual ~ossimTiledImageHash ()
 
virtual long operator() (const ossimDpt &aPoint)
 
virtual long operator() (const ossimFpt &aPoint)
 
- Public Member Functions inherited from ossimPointHash
virtual ~ossimPointHash ()
 

Private Attributes

ossimDrect theImageRect
 
double theTileWidth
 
double theTileHeight
 
long theNumberOfHorizTiles
 
long theNumberOfVertTiles
 

Detailed Description

Definition at line 20 of file ossimTiledImageHash.h.

Constructor & Destructor Documentation

◆ ossimTiledImageHash()

ossimTiledImageHash::ossimTiledImageHash ( const ossimDrect imageRect,
double  tileWidth,
double  tileHeight 
)

Definition at line 21 of file ossimTiledImageHash.cpp.

References FLT_EPSILON, ossimDrect::height(), theImageRect, theNumberOfHorizTiles, theNumberOfVertTiles, theTileHeight, theTileWidth, and ossimDrect::width().

24  :ossimPointHash(),
25  theImageRect(imageRect)
26 {
27  // make sure that the width of the tile is not larger than
28  // the width of the image rectangle.
29  if(theImageRect.width() < tileWidth)
30  {
33  }
34  else
35  {
36  theTileWidth = tileWidth;
37  double tempDiv = theImageRect.width()/theTileWidth;
38  double overFlow = tempDiv - static_cast<long>(tempDiv);
39  theNumberOfHorizTiles = static_cast<long>(tempDiv);
40 
41  if(fabs(overFlow) >= FLT_EPSILON) // if the extent went beyond a tile
42  {
43  theNumberOfHorizTiles ++; // we must say it has another tile
44  }
45  }
46 
47  // make sure the height of the tile is not larger than the
48  // height of the image rectangle.
49  if(theImageRect.height() < tileHeight)
50  {
53  }
54  else
55  {
56  theTileHeight = tileHeight;
57  double tempDiv = theImageRect.height()/theTileHeight;
58  double overFlow = tempDiv - static_cast<long>(tempDiv);
59  theNumberOfVertTiles = static_cast<long>(tempDiv);
60 
61  if(fabs(overFlow) >= FLT_EPSILON) // if the extent went beyond a tile
62  {
63  theNumberOfVertTiles ++; // we must say it has another tile
64  }
65  }
66 
67 }
ossim_float64 width() const
Definition: ossimDrect.h:522
#define FLT_EPSILON
ossim_float64 height() const
Definition: ossimDrect.h:517

◆ ~ossimTiledImageHash()

ossimTiledImageHash::~ossimTiledImageHash ( )
virtual

Definition at line 69 of file ossimTiledImageHash.cpp.

70 {
71 }

Member Function Documentation

◆ operator()() [1/2]

long ossimTiledImageHash::operator() ( const ossimDpt aPoint)
virtual

Implements ossimPointHash.

Definition at line 73 of file ossimTiledImageHash.cpp.

References theImageRect, theNumberOfHorizTiles, theNumberOfVertTiles, theTileHeight, theTileWidth, ossimDrect::ul(), ossimDpt::x, and ossimDpt::y.

74 {
75  if(aPoint.x >= theImageRect.ul().x && aPoint.y >= theImageRect.ul().y)
76  {
77  // how far is the point horizontally from the upper left corner
78  double deltaWidth = aPoint.x - theImageRect.ul().x;
79 
80  // how far is the point vertically from the upper left point
81  double deltaHeight = aPoint.y - theImageRect.ul().y;
82 
83  // if deltas are negative then we are outside the
84  // bounds
85  if((deltaWidth < 0) || (deltaHeight < 0))
86  {
87  return -1;
88  }
89 
90  // check if outside the rectangle
91  if( (deltaWidth > theNumberOfHorizTiles*theTileWidth)||
92  (deltaHeight > theNumberOfVertTiles*theTileHeight))
93  {
94  return -1;
95  }
96  // solve the horizontal and vertical index numbers
97  long indexWidth = static_cast<long>(deltaWidth / theTileWidth);
98  long indexHeight = static_cast<long>(deltaHeight / theTileHeight);
99 
100  // map to a linear array. Just like you would index a 2-D array in memory
101  return static_cast<long>(theNumberOfHorizTiles*indexHeight + indexWidth);
102  }
103 
104  return -1;
105 }
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164

◆ operator()() [2/2]

long ossimTiledImageHash::operator() ( const ossimFpt aPoint)
virtual

Implements ossimPointHash.

Definition at line 107 of file ossimTiledImageHash.cpp.

References theImageRect, theNumberOfHorizTiles, theNumberOfVertTiles, theTileHeight, theTileWidth, ossimDrect::ul(), ossimFpt::x, ossimDpt::x, ossimFpt::y, and ossimDpt::y.

108 {
109  if(aPoint.x >= theImageRect.ul().x && aPoint.y >= theImageRect.ul().y)
110  {
111  // how far is the point horizontally from the upper left corner
112  double deltaWidth = aPoint.x - theImageRect.ul().x;
113 
114  // how far is the point vertically from the upper left point
115  double deltaHeight = aPoint.y - theImageRect.ul().y;
116 
117  // if deltas are negative then we are outside the
118  // bounds
119  if((deltaWidth < 0) || (deltaHeight < 0))
120  {
121  return -1;
122  }
123 
124  // check if outside the rectangle
125  if( (deltaWidth > theNumberOfHorizTiles*theTileWidth)||
126  (deltaHeight > theNumberOfVertTiles*theTileHeight))
127  {
128  return -1;
129  }
130  // solve the horizontal and vertical index numbers
131  long indexWidth = static_cast<long>(deltaWidth / theTileWidth);
132  long indexHeight = static_cast<long>(deltaHeight / theTileHeight);
133 
134  // map to a linear array. Just like you would index a 2-D array in memory
135  return static_cast<long>(theNumberOfHorizTiles*indexHeight + indexWidth);
136  }
137 
138  return -1;
139 }
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
ossim_float32 x
Definition: ossimFpt.h:70
double x
Definition: ossimDpt.h:164
ossim_float32 y
Definition: ossimFpt.h:71

Member Data Documentation

◆ theImageRect

ossimDrect ossimTiledImageHash::theImageRect
private

Definition at line 33 of file ossimTiledImageHash.h.

Referenced by operator()(), and ossimTiledImageHash().

◆ theNumberOfHorizTiles

long ossimTiledImageHash::theNumberOfHorizTiles
private

Definition at line 36 of file ossimTiledImageHash.h.

Referenced by operator()(), and ossimTiledImageHash().

◆ theNumberOfVertTiles

long ossimTiledImageHash::theNumberOfVertTiles
private

Definition at line 37 of file ossimTiledImageHash.h.

Referenced by operator()(), and ossimTiledImageHash().

◆ theTileHeight

double ossimTiledImageHash::theTileHeight
private

Definition at line 35 of file ossimTiledImageHash.h.

Referenced by operator()(), and ossimTiledImageHash().

◆ theTileWidth

double ossimTiledImageHash::theTileWidth
private

Definition at line 34 of file ossimTiledImageHash.h.

Referenced by operator()(), and ossimTiledImageHash().


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