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

#include <ossimTileHash.h>

Inheritance diagram for ossimTileHash:
ossimPointHash

Public Member Functions

 ossimTileHash (const ossimDrect &imageRect, double tileWidth, double tileHeight)
 
virtual ~ossimTileHash ()
 
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 26 of file ossimTileHash.h.

Constructor & Destructor Documentation

◆ ossimTileHash()

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

Definition at line 23 of file ossimTileHash.cpp.

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

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

◆ ~ossimTileHash()

ossimTileHash::~ossimTileHash ( )
virtual

Definition at line 71 of file ossimTileHash.cpp.

72 {
73 }

Member Function Documentation

◆ operator()() [1/2]

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

Implements ossimPointHash.

Definition at line 100 of file ossimTileHash.cpp.

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

101 {
102  if ( (aPoint.x >= theImageRect.ul().x) &&
103  (aPoint.x <= theImageRect.lr().x) &&
104  (aPoint.y <= theImageRect.ul().y) &&
105  (aPoint.y >= theImageRect.lr().y) )
106  {
107  // how far is the point horizontally from the upper left corner
108  double deltaWidth = aPoint.x - theImageRect.ul().x;
109 
110  // how far is the point vertically from the upper left point
111  double deltaHeight = theImageRect.ul().y - aPoint.y;
112 
113  // solve the horizontal and vertical index numbers
114  long indexWidth = static_cast<long>(deltaWidth / theTileWidth);
115  long indexHeight = static_cast<long>(deltaHeight / theTileHeight);
116 
117  // Map to a linear array.
118  // Just like you would index a 2-D array in memory
119  return static_cast<long>(theNumberOfHorizTiles*indexHeight + indexWidth);
120  }
121 
122  return -1;
123 }
long theNumberOfHorizTiles
Definition: ossimTileHash.h:42
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double theTileHeight
Definition: ossimTileHash.h:41
double y
Definition: ossimDpt.h:165
double theTileWidth
Definition: ossimTileHash.h:40
ossimDrect theImageRect
Definition: ossimTileHash.h:39
double x
Definition: ossimDpt.h:164
const ossimDpt & lr() const
Definition: ossimDrect.h:341

◆ operator()() [2/2]

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

Implements ossimPointHash.

Definition at line 75 of file ossimTileHash.cpp.

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

76 {
77  if ( (aPoint.x >= theImageRect.ul().x) &&
78  (aPoint.x <= theImageRect.lr().x) &&
79  (aPoint.y <= theImageRect.ul().y) &&
80  (aPoint.y >= theImageRect.lr().y) )
81  {
82  // how far is the point horizontally from the upper left corner
83  double deltaWidth = aPoint.x - theImageRect.ul().x;
84 
85  // how far is the point vertically from the upper left point
86  double deltaHeight = theImageRect.ul().y - aPoint.y;
87 
88  // solve the horizontal and vertical index numbers
89  long indexWidth = static_cast<long>(deltaWidth / theTileWidth);
90  long indexHeight = static_cast<long>(deltaHeight / theTileHeight);
91 
92  // Map to a linear array.
93  // Just like you would index a 2-D array in memory
94  return static_cast<long>(theNumberOfHorizTiles*indexHeight + indexWidth);
95  }
96 
97  return -1;
98 }
long theNumberOfHorizTiles
Definition: ossimTileHash.h:42
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double theTileHeight
Definition: ossimTileHash.h:41
double y
Definition: ossimDpt.h:165
double theTileWidth
Definition: ossimTileHash.h:40
ossim_float32 x
Definition: ossimFpt.h:70
ossimDrect theImageRect
Definition: ossimTileHash.h:39
double x
Definition: ossimDpt.h:164
ossim_float32 y
Definition: ossimFpt.h:71
const ossimDpt & lr() const
Definition: ossimDrect.h:341

Member Data Documentation

◆ theImageRect

ossimDrect ossimTileHash::theImageRect
private

Definition at line 39 of file ossimTileHash.h.

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

◆ theNumberOfHorizTiles

long ossimTileHash::theNumberOfHorizTiles
private

Definition at line 42 of file ossimTileHash.h.

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

◆ theNumberOfVertTiles

long ossimTileHash::theNumberOfVertTiles
private

Definition at line 43 of file ossimTileHash.h.

Referenced by ossimTileHash().

◆ theTileHeight

double ossimTileHash::theTileHeight
private

Definition at line 41 of file ossimTileHash.h.

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

◆ theTileWidth

double ossimTileHash::theTileWidth
private

Definition at line 40 of file ossimTileHash.h.

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


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