*
* Written by Curtis L. Olson, started February 1999.
*
- * Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
+ * Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt/
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#ifdef HAVE_CONFIG_H
-# include <config.h>
+# include <simgear_config.h>
#endif
-
#include <math.h>
-#include <simgear/misc/fgpath.hxx>
+#include <simgear/misc/sg_path.hxx>
#include "newbucket.hxx"
hem, top_lon, pole, top_lat,
hem, main_lon, pole, main_lat);
- FGPath path( raw_path );
+ SGPath path( raw_path );
return path.str();
}
} else {
clat = (int)clat - 0.5;
}
- double clat_rad = clat * DEG_TO_RAD;
+ double clat_rad = clat * SGD_DEGREES_TO_RADIANS;
double cos_lat = cos( clat_rad );
- double local_radius = cos_lat * EQUATORIAL_RADIUS_M;
+ double local_radius = cos_lat * SG_EQUATORIAL_RADIUS_M;
double local_perimeter = 2.0 * local_radius * SGD_PI;
double degree_width = local_perimeter / 360.0;
// return height of the tile in meters
double SGBucket::get_height_m() const {
- double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SGD_PI;
+ double perimeter = 2.0 * SG_EQUATORIAL_RADIUS_M * SGD_PI;
double degree_height = perimeter / 360.0;
return SG_BUCKET_SPAN * degree_height;
#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 ( sg_bucket_span(c1_lat) <= sg_bucket_span(c2_lat) ) {
+ double diff_lon=0.0;
+ double span=0.0;
+
+ SGBucket tmp_bucket;
+ // To handle crossing the bucket size boundary
+ // we need to account for different size buckets.
+
+ if ( sg_bucket_span(c1_lat) <= sg_bucket_span(c2_lat) )
+ {
span = sg_bucket_span(c1_lat);
} else {
span = sg_bucket_span(c2_lat);
}
+ diff_lon = b2.get_center_lon() - b1.get_center_lon();
+
+ if (diff_lon <0.0)
+ {
+ diff_lon -= b1.get_width()*0.5 + b2.get_width()*0.5 - span;
+ }
+ else
+ {
+ diff_lon += b1.get_width()*0.5 + b2.get_width()*0.5 - span;
+ }
+
+
#ifdef HAVE_RINT
*dx = (int)rint( diff_lon / span );
#else