SGBucket Class Reference

A class to manage world scenery tiling. More...

#include <newbucket.hxx>

List of all members.

Public Member Functions

 SGBucket ()
 Default constructor.
 SGBucket (const double dlon, const double dlat)
 Construct a bucket given a specific location.
 SGBucket (const bool is_good)
 Construct a bucket.
 SGBucket (const long int bindex)
 Construct a bucket given a unique bucket index number.
 ~SGBucket ()
 Default destructor.
void set_bucket (double dlon, double dlat)
 Reset a bucket to represent a new lat and lon.
void set_bucket (double *lonlat)
 Reset a bucket to represent a new lat and lon.
void make_bad ()
 Create an impossible bucket.
long int gen_index () const
 Generate the unique scenery tile index for this bucket.
string gen_index_str () const
 Generate the unique scenery tile index for this bucket in ascii string form.
string gen_base_path () const
 Build the base path name for this bucket.
double get_center_lon () const
 
Returns:
the center lon of a tile.

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

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

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

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

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

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

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

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

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


Friends

ostream & operator<< (ostream &, const SGBucket &)
 Write the bucket lon, lat, x, and y to the output stream.
bool operator== (const SGBucket &, const SGBucket &)
 Compare two bucket structures for equality.

Related Functions

(Note that these are not member functions.)

SGBucket sgBucketOffset (double dlon, double dlat, int x, int y)
 Return the bucket which is offset from the specified dlon, dlat by the specified tile units in the X & Y direction.
void sgBucketDiff (const SGBucket &b1, const SGBucket &b2, int *dx, int *dy)
 Calculate the offset between two buckets (in quantity of buckets).


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 113 of file newbucket.hxx.


Constructor & Destructor Documentation

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

Construct a bucket given a specific location.

Parameters:
dlon longitude specified in degrees
dlat latitude specified in degrees

Definition at line 43 of file newbucket.cxx.

References set_bucket().

SGBucket::SGBucket ( const bool  is_good  ) 

Construct a bucket.

Parameters:
is_good if false, create an invalid 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 49 of file newbucket.cxx.

References set_bucket().

SGBucket::SGBucket ( const long int  bindex  ) 

Construct a bucket given a unique bucket index number.

Parameters:
bindex unique bucket index

Definition at line 58 of file newbucket.cxx.


Member Function Documentation

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

Reset a bucket to represent a new lat and lon.

Parameters:
dlon longitude specified in degrees
dlat latitude specified in degrees

Definition at line 88 of file newbucket.cxx.

References SG_EPSILON.

Referenced by make_bad(), set_bucket(), SGBucket(), and sgBucketOffset().

void SGBucket::set_bucket ( double *  lonlat  ) 

Reset a bucket to represent a new lat and lon.

Parameters:
lonlat an array of double[2] holding lon and lat (specified) in degrees

Definition at line 82 of file newbucket.cxx.

References set_bucket().

void SGBucket::make_bad (  )  [inline]

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 174 of file newbucket.hxx.

References set_bucket().

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 194 of file newbucket.hxx.

string SGBucket::gen_index_str (  )  const [inline]

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

Returns:
tile index in string form

Definition at line 203 of file newbucket.hxx.

string SGBucket::gen_base_path (  )  const

Build the base path name for this bucket.

Returns:
base path in string form

Definition at line 139 of file newbucket.cxx.

References SGPath::str().

Referenced by SGBinObject::write_ascii(), and SGBinObject::write_bin().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  out,
const SGBucket b 
) [friend]

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

Parameters:
out output stream
b bucket

Definition at line 317 of file newbucket.hxx.

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

Compare two bucket structures for equality.

Parameters:
b1 bucket 1
b2 bucket 2
Returns:
comparison result

Definition at line 330 of file newbucket.hxx.

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:
dlon starting lon in degrees
dlat starting lat in degrees
x number of bucket units to offset in x (lon) direction
y number of bucket units to offset in y (lat) direction
Returns:
offset bucket

Definition at line 230 of file newbucket.cxx.

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

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

Parameters:
b1 bucket 1
b2 bucket 2
dx offset distance (lon) in tile units
dy offset distance (lat) in tile units

Definition at line 255 of file newbucket.cxx.


The documentation for this class was generated from the following files:
Generated on Mon Dec 17 09:30:57 2007 for SimGear by  doxygen 1.5.1