**************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+
#include "newbucket.hxx"
}
+// 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$
+// 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
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile
string gen_base_path();
// return the center lon of a tile
- double get_center_lon();
+ double get_center_lon() const;
// return the center lat of a tile
- double get_center_lat();
+ double get_center_lat() const;
// friends
friend ostream& operator<< ( ostream&, const FGBucket& );
+ friend bool operator== ( const FGBucket&, const FGBucket& );
};
// 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 );
if ( span >= 1.0 ) {
// 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;
}
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
void fgBucketGenIdxArray(fgBUCKET *p1, fgBUCKET *tiles, int width, int height);
+*/
+inline ostream&
+operator<< ( ostream& out, const FGBucket& b )
+{
+ return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
+}
+
inline bool
-operator== ( const fgBUCKET& b1, const fgBUCKET& b2 )
+operator== ( const FGBucket& b1, const FGBucket& b2 )
{
return ( b1.lon == b2.lon &&
b1.lat == b2.lat &&
b1.y == b2.y );
}
+/*
inline string
fgBucketGenIndex( const fgBUCKET& 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&
-operator<< ( ostream& out, const FGBucket& b )
-{
- return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
-}
#endif // _NEWBUCKET_HXX
// $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
// Added a new "newbucket.[ch]xx" FGBucket class to replace the old
// fgBUCKET struct and C routines. This FGBucket class adjusts the tile