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 SGGeod &geod)
 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.
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 set_bucket (const SGGeod &geod)
 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.
std::string gen_index_str () const
 Generate the unique scenery tile index for this bucket in ascii string form.
std::string gen_base_path () const
 Build the base path name for this bucket.
double get_center_lon () const
double get_center_lat () const
double get_width () const
double get_height () const
double get_width_m () const
double get_height_m () const
SGGeod get_center () const
SGGeod get_corner (unsigned num) const
int get_chunk_lon () const
int get_chunk_lat () const
int get_x () const
int get_y () const

Friends

std::ostream & operator<< (std::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)
void sgBucketDiff (const SGBucket &b1, const SGBucket &b2, int *dx, int *dy)


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 95 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.

SGBucket::SGBucket ( const SGGeod geod  ) 

Construct a bucket given a specific location.

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

Definition at line 47 of file newbucket.cxx.

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 52 of file newbucket.cxx.

SGBucket::SGBucket ( const long int  bindex  ) 

Construct a bucket given a unique bucket index number.

Parameters:
bindex unique bucket index

Definition at line 61 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 86 of file newbucket.cxx.

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 80 of file newbucket.cxx.

void SGBucket::set_bucket ( const SGGeod geod  ) 

Reset a bucket to represent a new lat and lon.

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

Definition at line 136 of file newbucket.cxx.

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

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

std::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 194 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 142 of file newbucket.cxx.

double SGBucket::get_center_lon (  )  const [inline]

Returns:
the center lon of a tile.

Definition at line 211 of file newbucket.hxx.

double SGBucket::get_center_lat (  )  const [inline]

Returns:
the center lat of a tile.

Definition at line 224 of file newbucket.hxx.

double SGBucket::get_width (  )  const

Returns:
the width of the tile in degrees.

Definition at line 191 of file newbucket.cxx.

double SGBucket::get_height (  )  const

Returns:
the height of the tile in degrees.

Definition at line 197 of file newbucket.cxx.

double SGBucket::get_width_m (  )  const

Returns:
the width of the tile in meters.

Definition at line 203 of file newbucket.cxx.

double SGBucket::get_height_m (  )  const

Returns:
the height of the tile in meters.

Definition at line 221 of file newbucket.cxx.

SGGeod SGBucket::get_center (  )  const [inline]

Returns:
the center of the bucket in geodetic coordinates.

Definition at line 251 of file newbucket.hxx.

SGGeod SGBucket::get_corner ( unsigned  num  )  const [inline]

Returns:
the center of the bucket in geodetic coordinates.

Definition at line 257 of file newbucket.hxx.

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

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

int SGBucket::get_x (  )  const [inline]

Returns:
the x coord within the 1x1 degree chunk this tile.

Definition at line 282 of file newbucket.hxx.

int SGBucket::get_y (  )  const [inline]

Returns:
the y coord within the 1x1 degree chunk this tile.

Definition at line 287 of file newbucket.hxx.


Friends And Related Function Documentation

std::ostream& operator<< ( std::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 331 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 344 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 233 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 258 of file newbucket.cxx.


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

Generated on Thu Dec 18 15:17:27 2008 for SimGear by  doxygen 1.5.6