From: Peter Sadrozinski Date: Sun, 3 Mar 2013 16:57:38 +0000 (-0500) Subject: Add new api to retreive a list of SGBuckets within a bounding rectangle X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0bc80051000230b81cf60360648b09fe99fc2bae;p=simgear.git Add new api to retreive a list of SGBuckets within a bounding rectangle --- diff --git a/simgear/bucket/newbucket.cxx b/simgear/bucket/newbucket.cxx index bb373fed..93095fd4 100644 --- a/simgear/bucket/newbucket.cxx +++ b/simgear/bucket/newbucket.cxx @@ -345,4 +345,13 @@ void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy ) { #endif } +void sgGetBuckets( const SGGeod& min, const SGGeod& max, std::vector& list ) { + double lon, lat, span; + for (lat = min.getLatitudeDeg(); lat <= max.getLatitudeDeg(); lat += SG_BUCKET_SPAN) { + span = sg_bucket_span( lat ); + for (lon = min.getLongitudeDeg(); lon <= max.getLongitudeDeg(); lon += span) { + list.push_back( SGBucket(lon , lat) ); + } + } +} diff --git a/simgear/bucket/newbucket.hxx b/simgear/bucket/newbucket.hxx index 64aa5f80..09169f86 100644 --- a/simgear/bucket/newbucket.hxx +++ b/simgear/bucket/newbucket.hxx @@ -42,6 +42,7 @@ #include // sprintf() #include #include +#include /** * standard size of a bucket in degrees (1/8 of a degree) @@ -322,6 +323,15 @@ SGBucket sgBucketOffset( double dlon, double dlat, int x, int y ); void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy ); +/** + * \relates SGBucket + * retrieve a list of buckets in the given bounding box + * @param min min lon,lat of bounding box in degrees + * @param max max lon,lat of bounding box in degrees + * @param list standard vector of buckets within the bounding box + */ +void sgGetBuckets( const SGGeod& min, const SGGeod& max, std::vector& list ); + /** * Write the bucket lon, lat, x, and y to the output stream. * @param out output stream