Added a routine to calculate the offset in bucket units between two buckets.
This commit is contained in:
parent
236a1f2a2d
commit
505de4703b
2 changed files with 84 additions and 32 deletions
|
@ -24,6 +24,11 @@
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "newbucket.hxx"
|
#include "newbucket.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +104,51 @@ FGBucket fgBucketOffset( double dlon, double dlat, int dx, int dy ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// calculate the offset between two buckets
|
||||||
|
void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy ) {
|
||||||
|
|
||||||
|
// Latitude difference
|
||||||
|
double c1_lat = b1.get_center_lat();
|
||||||
|
double c2_lat = b2.get_center_lat();
|
||||||
|
double diff_lat = c2_lat - c1_lat;
|
||||||
|
|
||||||
|
#ifdef HAVE_RINT
|
||||||
|
*dy = (int)rint( diff_lat / FG_BUCKET_SPAN );
|
||||||
|
#else
|
||||||
|
if ( diff_lat > 0 ) {
|
||||||
|
*dy = (int)( diff_lat / FG_BUCKET_SPAN + 0.5 );
|
||||||
|
} else {
|
||||||
|
*dy = (int)( diff_lat / FG_BUCKET_SPAN - 0.5 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// longitude difference
|
||||||
|
double c1_lon = b1.get_center_lon();
|
||||||
|
double c2_lon = b2.get_center_lon();
|
||||||
|
double diff_lon = c2_lon - c1_lon;
|
||||||
|
double span;
|
||||||
|
if ( bucket_span(c1_lat) <= bucket_span(c2_lat) ) {
|
||||||
|
span = bucket_span(c1_lat);
|
||||||
|
} else {
|
||||||
|
span = bucket_span(c2_lat);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_RINT
|
||||||
|
*dx = (int)rint( diff_lon / span );
|
||||||
|
#else
|
||||||
|
if ( diff_lon > 0 ) {
|
||||||
|
*dx = (int)( diff_lon / span + 0.5 );
|
||||||
|
} else {
|
||||||
|
*dx = (int)( diff_lon / span - 0.5 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.2 1999/02/11 01:09:33 curt
|
||||||
|
// Added a routine to calculate the offset in bucket units between two buckets.
|
||||||
|
//
|
||||||
// Revision 1.1 1999/02/08 23:52:16 curt
|
// Revision 1.1 1999/02/08 23:52:16 curt
|
||||||
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
||||||
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
||||||
|
|
|
@ -75,13 +75,14 @@ public:
|
||||||
string gen_base_path();
|
string gen_base_path();
|
||||||
|
|
||||||
// return the center lon of a tile
|
// return the center lon of a tile
|
||||||
double get_center_lon();
|
double get_center_lon() const;
|
||||||
|
|
||||||
// return the center lat of a tile
|
// return the center lat of a tile
|
||||||
double get_center_lat();
|
double get_center_lat() const;
|
||||||
|
|
||||||
// friends
|
// friends
|
||||||
friend ostream& operator<< ( ostream&, const FGBucket& );
|
friend ostream& operator<< ( ostream&, const FGBucket& );
|
||||||
|
friend bool operator== ( const FGBucket&, const FGBucket& );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,7 +225,7 @@ inline long int FGBucket::gen_index() {
|
||||||
|
|
||||||
|
|
||||||
// return the center lon of a tile
|
// return the center lon of a tile
|
||||||
inline double FGBucket::get_center_lon() {
|
inline double FGBucket::get_center_lon() const {
|
||||||
double span = bucket_span( lat + y / 8.0 + FG_HALF_BUCKET_SPAN );
|
double span = bucket_span( lat + y / 8.0 + FG_HALF_BUCKET_SPAN );
|
||||||
|
|
||||||
if ( span >= 1.0 ) {
|
if ( span >= 1.0 ) {
|
||||||
|
@ -236,7 +237,7 @@ inline double FGBucket::get_center_lon() {
|
||||||
|
|
||||||
|
|
||||||
// return the center lat of a tile
|
// return the center lat of a tile
|
||||||
inline double FGBucket::get_center_lat() {
|
inline double FGBucket::get_center_lat() const {
|
||||||
return lat + y / 8.0 + FG_HALF_BUCKET_SPAN;
|
return lat + y / 8.0 + FG_HALF_BUCKET_SPAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,39 +247,16 @@ inline double FGBucket::get_center_lat() {
|
||||||
FGBucket fgBucketOffset( double dlon, double dlat, int x, int y );
|
FGBucket fgBucketOffset( double dlon, double dlat, int x, int y );
|
||||||
|
|
||||||
|
|
||||||
|
// calculate the offset between two buckets
|
||||||
|
void fgBucketDiff( const FGBucket& b1, const FGBucket& b2, int *dx, int *dy );
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Given a lat/lon, fill in the local tile index array
|
// Given a lat/lon, fill in the local tile index array
|
||||||
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
|
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
operator== ( const fgBUCKET& b1, const fgBUCKET& b2 )
|
|
||||||
{
|
|
||||||
return ( b1.lon == b2.lon &&
|
|
||||||
b1.lat == b2.lat &&
|
|
||||||
b1.x == b2.x &&
|
|
||||||
b1.y == b2.y );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline string
|
|
||||||
fgBucketGenIndex( const fgBUCKET& p )
|
|
||||||
{
|
|
||||||
char index_str[256];
|
|
||||||
sprintf( index_str, "%ld", fgBucketGenIndex( &p ) );
|
|
||||||
return string( index_str );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline string
|
|
||||||
fgBucketGenBasePath( const fgBUCKET& p )
|
|
||||||
{
|
|
||||||
char base_path[256];
|
|
||||||
fgBucketGenBasePath( &p, base_path );
|
|
||||||
return string( base_path );
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
inline ostream&
|
inline ostream&
|
||||||
operator<< ( ostream& out, const FGBucket& b )
|
operator<< ( ostream& out, const FGBucket& b )
|
||||||
{
|
{
|
||||||
|
@ -286,10 +264,35 @@ operator<< ( ostream& out, const FGBucket& b )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator== ( const FGBucket& b1, const FGBucket& b2 )
|
||||||
|
{
|
||||||
|
return ( b1.lon == b2.lon &&
|
||||||
|
b1.lat == b2.lat &&
|
||||||
|
b1.x == b2.x &&
|
||||||
|
b1.y == b2.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
inline string
|
||||||
|
fgBucketGenIndex( const fgBUCKET& p )
|
||||||
|
{
|
||||||
|
char index_str[256];
|
||||||
|
sprintf( index_str, "%ld", fgBucketGenIndex( &p ) );
|
||||||
|
return string( index_str );
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _NEWBUCKET_HXX
|
#endif // _NEWBUCKET_HXX
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.2 1999/02/11 01:09:34 curt
|
||||||
|
// Added a routine to calculate the offset in bucket units between two buckets.
|
||||||
|
//
|
||||||
// Revision 1.1 1999/02/08 23:52:16 curt
|
// Revision 1.1 1999/02/08 23:52:16 curt
|
||||||
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
|
||||||
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
|
||||||
|
|
Loading…
Add table
Reference in a new issue