SimGear - Simulator Construction Tools
SGBucket Class Reference

#include <newbucket.hxx>

Public Member Functions

 SGBucket ()
 
 SGBucket (const double dlon, const double dlat)
 
 SGBucket (const SGGeod &geod)
 
 SGBucket (const long int bindex)
 
std::string gen_base_path () const
 
long int gen_index () const
 
std::string gen_index_str () const
 
SGGeod get_center () const
 
double get_center_lat () const
 
double get_center_lon () const
 
int get_chunk_lat () const
 
int get_chunk_lon () const
 
SGGeod get_corner (unsigned num) const
 
double get_height () const
 
double get_height_m () const
 
double get_highest_lat () const
 
double get_width () const
 
double get_width_m () const
 
int get_x () const
 
int get_y () const
 
bool isValid () const
 
void make_bad ()
 
void set_bucket (const SGGeod &geod)
 
void set_bucket (double dlon, double dlat)
 
SGBucket sibling (int dx, int dy) const
 
unsigned int siblings (int dz, int dy, std::vector< SGBucket > &buckets) const
 

Private Member Functions

void innerSet (double dlon, double dlat)
 

Private Attributes

short lat
 
short lon
 
unsigned char x
 
unsigned char y
 

Friends

std::ostream & operator<< (std::ostream &, const SGBucket &)
 
bool operator== (const SGBucket &, const SGBucket &)
 

Related Functions

(Note that these are not member functions.)

void sgBucketDiff (const SGBucket &b1, const SGBucket &b2, int *dx, int *dy)
 
SGBucket sgBucketOffset (double dlon, double dlat, int x, int y)
 
void sgGetBuckets (const SGGeod &min, const SGGeod &max, std::vector< SGBucket > &list)
 

Detailed Description

A class to manage world scenery tiling. This class encapsulates the world tiling scheme. It provides ways to calculate a unique tile index from a lat/lon, and it can provide information such as the dimensions of a given tile.

Definition at line 98 of file newbucket.hxx.

Constructor & Destructor Documentation

SGBucket::SGBucket ( )

Default constructor, creates an invalid SGBucket

Definition at line 41 of file newbucket.cxx.

Referenced by sibling().

SGBucket::SGBucket ( const double  dlon,
const double  dlat 
)

Construct a bucket given a specific location.

Parameters
dlonlongitude specified in degrees
dlatlatitude specified in degrees

Definition at line 70 of file newbucket.cxx.

SGBucket::SGBucket ( const SGGeod geod)

Construct a bucket given a specific location.

Parameters
geodGeodetic location

Definition at line 75 of file newbucket.cxx.

SGBucket::SGBucket ( const long int  bindex)

Construct a bucket given a unique bucket index number.

Parameters
bindexunique bucket index

Definition at line 81 of file newbucket.cxx.

Member Function Documentation

std::string SGBucket::gen_base_path ( ) const

Build the base path name for this bucket.

Returns
base path in string form

Definition at line 188 of file newbucket.cxx.

Referenced by simgear::ReaderWriterSTG::_ModelBin::load(), simgear::ReaderWriterSTG::readNode(), simgear::SGTerraSync::scheduleTile(), testBasic(), SGBinObject::write_ascii(), and SGBinObject::write_bin().

long int SGBucket::gen_index ( ) const
inline

Generate the unique scenery tile index for this bucket

The index is constructed as follows:

9 bits - to represent 360 degrees of longitude (-180 to 179) 8 bits - to represent 180 degrees of latitude (-90 to 89)

Each 1 degree by 1 degree tile is further broken down into an 8x8 grid. So we also need:

3 bits - to represent x (0 to 7) 3 bits - to represent y (0 to 7)

Returns
tile index

Definition at line 181 of file newbucket.hxx.

Referenced by simgear::createTestTree(), testBasic(), testNearPolar(), and testPolar().

std::string SGBucket::gen_index_str ( ) const

Generate the unique scenery tile index for this bucket in ascii string form.

Returns
tile index in string form

Definition at line 360 of file newbucket.cxx.

Referenced by simgear::ReaderWriterSTG::_ModelBin::checkInsideBucket(), simgear::ReaderWriterSPT::createTree(), simgear::ReaderWriterPGT::createTree(), and simgear::ReaderWriterSTG::_ModelBin::load().

SGGeod SGBucket::get_center ( ) const
inline
Returns
the center of the bucket in geodetic coordinates.

Definition at line 248 of file newbucket.hxx.

Referenced by simgear::ReaderWriterSTG::_ModelBin::DelayLoadReadFileCallback::readNode(), and SGOceanTile().

double SGBucket::get_center_lat ( ) const
inline
Returns
the center lat of a tile.

Definition at line 214 of file newbucket.hxx.

Referenced by get_center(), get_corner(), get_width(), sgBucketDiff(), sgBucketOffset(), sgCalcTexCoords(), SGOceanTile(), sibling(), and siblings().

double SGBucket::get_center_lon ( ) const
inline
Returns
the center lon of a tile.

Definition at line 201 of file newbucket.hxx.

Referenced by get_center(), get_corner(), sgBucketDiff(), SGOceanTile(), sibling(), and siblings().

int SGBucket::get_chunk_lat ( ) const
inline
Returns
the lat of the lower left corner of the 1x1 chunk containing this tile.

Definition at line 274 of file newbucket.hxx.

Referenced by testBasic(), testNearPolar(), testOffset(), testOffsetWrap(), testPolar(), and testPolarOffset().

int SGBucket::get_chunk_lon ( ) const
inline
Returns
the lon of the lower left corner of the 1x1 chunk containing this tile.

Definition at line 268 of file newbucket.hxx.

Referenced by testBasic(), testNearPolar(), testOffset(), testOffsetWrap(), testPolar(), and testPolarOffset().

SGGeod SGBucket::get_corner ( unsigned  num) const
inline
Returns
the center of the bucket in geodetic coordinates.

Definition at line 254 of file newbucket.hxx.

Referenced by testPolar().

double SGBucket::get_height ( ) const
Returns
the height of the tile in degrees.

Definition at line 241 of file newbucket.cxx.

Referenced by get_corner(), and SGOceanTile().

double SGBucket::get_height_m ( ) const
Returns
the height of the tile in meters.

Definition at line 280 of file newbucket.cxx.

double SGBucket::get_highest_lat ( ) const
Returns
the highest (furthest from the equator) latitude of this tile. This is the top edge for tiles north of the equator, and the bottom edge for tiles south

Definition at line 245 of file newbucket.cxx.

Referenced by get_width_m(), and testPolar().

double SGBucket::get_width ( ) const
Returns
the width of the tile in degrees.

Definition at line 235 of file newbucket.cxx.

Referenced by get_center_lon(), get_corner(), get_width_m(), sgBucketDiff(), and SGOceanTile().

double SGBucket::get_width_m ( ) const
Returns
the width of the tile in meters.

Definition at line 261 of file newbucket.cxx.

Referenced by testPolar().

int SGBucket::get_x ( ) const
inline
Returns
the x coord within the 1x1 degree chunk this tile.

Definition at line 279 of file newbucket.hxx.

Referenced by testBasic(), testOffset(), testOffsetWrap(), testPolar(), and testPolarOffset().

int SGBucket::get_y ( ) const
inline
Returns
the y coord within the 1x1 degree chunk this tile.

Definition at line 284 of file newbucket.hxx.

Referenced by testBasic(), testOffset(), testOffsetWrap(), testPolar(), and testPolarOffset().

void SGBucket::innerSet ( double  dlon,
double  dlat 
)
private

Definition at line 124 of file newbucket.cxx.

Referenced by set_bucket(), SGBucket(), sibling(), and siblings().

bool SGBucket::isValid ( ) const

Check if this bucket refers to a valid tile, or not.

Definition at line 49 of file newbucket.cxx.

Referenced by sgGetBuckets(), sibling(), siblings(), and testBasic().

void SGBucket::make_bad ( )

Create an impossible bucket. This is useful if you are comparing cur_bucket to last_bucket and you want to make sure last_bucket starts out as something impossible.

Definition at line 61 of file newbucket.cxx.

void SGBucket::set_bucket ( const SGGeod geod)

Reset a bucket to represent a new location.

Parameters
geodNew geodetic location

Definition at line 116 of file newbucket.cxx.

Referenced by SGBucket(), and sgBucketOffset().

void SGBucket::set_bucket ( double  dlon,
double  dlat 
)

Reset a bucket to represent a new lat and lon

Parameters
dlonlongitude specified in degrees
dlatlatitude specified in degrees

Definition at line 110 of file newbucket.cxx.

SGBucket SGBucket::sibling ( int  dx,
int  dy 
) const
Returns
bucket offset from this by dx,dy

Definition at line 335 of file newbucket.cxx.

Referenced by testOffset(), testOffsetWrap(), and testPolarOffset().

unsigned int SGBucket::siblings ( int  dz,
int  dy,
std::vector< SGBucket > &  buckets 
) const
Returns
multiple buckets offset from this by dx,dy

Definition at line 287 of file newbucket.cxx.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const SGBucket  
)
friend

Write the bucket lon, lat, x, and y to the output stream.

Parameters
outoutput stream
bbucket

Definition at line 471 of file newbucket.cxx.

bool operator== ( const SGBucket b1,
const SGBucket b2 
)
friend

Compare two bucket structures for equality.

Parameters
b1bucket 1
b2bucket 2
Returns
comparison result

Definition at line 356 of file newbucket.hxx.

void sgBucketDiff ( const SGBucket b1,
const SGBucket b2,
int dx,
int dy 
)
related

Calculate the offset between two buckets (in quantity of buckets).

Parameters
b1bucket 1
b2bucket 2
dxoffset distance (lon) in tile units
dyoffset distance (lat) in tile units

Definition at line 399 of file newbucket.cxx.

SGBucket sgBucketOffset ( double  dlon,
double  dlat,
int  x,
int  y 
)
related

Return the bucket which is offset from the specified dlon, dlat by the specified tile units in the X & Y direction.

Parameters
dlonstarting lon in degrees
dlatstarting lat in degrees
xnumber of bucket units to offset in x (lon) direction
ynumber of bucket units to offset in y (lat) direction
Returns
offset bucket

Definition at line 374 of file newbucket.cxx.

Referenced by testOffset(), testOffsetWrap(), and testPolarOffset().

void sgGetBuckets ( const SGGeod min,
const SGGeod max,
std::vector< SGBucket > &  list 
)
related

retrieve a list of buckets in the given bounding box

Parameters
minmin lon,lat of bounding box in degrees
maxmax lon,lat of bounding box in degrees
liststandard vector of buckets within the bounding box

Definition at line 454 of file newbucket.cxx.

Member Data Documentation

short SGBucket::lat
private
short SGBucket::lon
private
unsigned char SGBucket::x
private
unsigned char SGBucket::y
private

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