From: curt Date: Mon, 4 Dec 2000 04:11:03 +0000 (+0000) Subject: Added methods to return tile dimension in meters. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1da02cca4c07f1de5636eca8651cc1720e7a0585;p=simgear.git Added methods to return tile dimension in meters. --- diff --git a/simgear/bucket/newbucket.cxx b/simgear/bucket/newbucket.cxx index f707d252..74c3ce29 100644 --- a/simgear/bucket/newbucket.cxx +++ b/simgear/bucket/newbucket.cxx @@ -85,6 +85,33 @@ string FGBucket::gen_base_path() const { } +// return width of the tile in meters +double FGBucket::get_width_m() const { + double clat = (int)get_center_lat(); + if ( clat > 0 ) { + clat = (int)clat + 0.5; + } else { + clat = (int)clat - 0.5; + } + double clat_rad = clat * DEG_TO_RAD; + double cos_lat = cos( clat_rad ); + double local_radius = cos_lat * EQUATORIAL_RADIUS_M; + double local_perimeter = 2.0 * local_radius * FG_PI; + double degree_width = local_perimeter / 360.0; + + return bucket_span( get_center_lat() ) * degree_width; +} + + +// return height of the tile in meters +double FGBucket::get_height_m() const { + double perimeter = 2.0 * EQUATORIAL_RADIUS_M * FG_PI; + double degree_height = perimeter / 360.0; + + return FG_BUCKET_SPAN * degree_height; +} + + // find the bucket which is offset by the specified tile units in the // X & Y direction. We need the current lon and lat to resolve // ambiguities when going from a wider tile to a narrower one above or diff --git a/simgear/bucket/newbucket.hxx b/simgear/bucket/newbucket.hxx index 7fabfb6e..775812d3 100644 --- a/simgear/bucket/newbucket.hxx +++ b/simgear/bucket/newbucket.hxx @@ -107,14 +107,18 @@ public: // return the center lon of a tile double get_center_lon() const; - // return width of the tile + // return width of the tile in degrees double get_width() const; + // return width of the tile in meters + double get_width_m() const; + // return height of the tile in degrees + double get_height() const; + // return height of the tile in meters + double get_height_m() const; // return the center lat of a tile double get_center_lat() const; - // return height of the tile - double get_height() const; // Informational methods inline int get_lon() const { return lon; } @@ -300,13 +304,13 @@ inline double FGBucket::get_center_lat() const { } -// return width of the tile +// return width of the tile in degrees inline double FGBucket::get_width() const { return bucket_span( get_center_lat() ); } -// return height of the tile +// return height of the tile in degrees inline double FGBucket::get_height() const { return FG_BUCKET_SPAN; }