Hi again!

Thinking a bit more about it, the grid could be made consistent if we
would define that 180W and 180E are tile borders instead of enforcing
the Greenwich Meridian to be a tile border at all ranges of latitude.

Find attached my proposed patch.

That would change the arrangement of tiles between 88 and 89 degrees
latitude, fix the inconsistency above 89 degrees latitude, but would
leave the rest of the tile numbers as they are (due to the fact that
tile widths there are divisors of 180) and give us the following benefits:

1) calculation of base longitude would be much easier:
base_lat=(int)((int)((lat+180)/span)*span)-180

with rounding:

base_lat=(int)((int)((lat+SG_EPSILON+180)/span)*span)-180

2) The tiles at 180W/E between 88 and 89 degrees of latitude would not
overlap with their neighbours anymore and have 8 degrees width, as all
the other tiles at that latitude.

3) The calculation above would always lead to 0 as base longitude for
the tiles above latitudes of 89 degrees instead of the flipping of -180
vs 0 depending on the sign of the longitude.

The fact that people seldomly fly north or south of 88 degrees latitude
might be seen as an argument in favour or against this change.

This is a bug that has not created serious problems in FlightGear
itself, but formally, it is a bug and it _has_ created problems in at
least two scenery-related applications, one of them being TerraGear.
Therefore I would vote in favour of such a change.

Any other comments or votes?

Cheers,
Ralf
>From 4462aa3518b65ed76b6fc8a4cabae730fcd160fa Mon Sep 17 00:00:00 2001
From: Ralf Gerlich <[EMAIL PROTECTED]>
Date: Mon, 7 Jan 2008 12:03:44 +0100
Subject: [PATCH] Make the tile grid consistent.

This changes the actual tile numbering only in the range above 88 degrees latitude and fixes inconsistencies in other areas.
---
 simgear/bucket/newbucket.cxx |   46 ++++-------------------------------------
 1 files changed, 5 insertions(+), 41 deletions(-)

diff --git a/simgear/bucket/newbucket.cxx b/simgear/bucket/newbucket.cxx
index 71c0ac2..9135f24 100644
--- a/simgear/bucket/newbucket.cxx
+++ b/simgear/bucket/newbucket.cxx
@@ -88,48 +88,12 @@ void SGBucket::set_bucket( double dlon, double dlat ) {
     // latitude first
     //
     double span = sg_bucket_span( dlat );
-    double diff = dlon - (double)(int)dlon;
-
-    // cout << "diff = " << diff << "  span = " << span << endl;
-
-    if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
-	lon = (int)dlon;
-    } else {
-	lon = (int)dlon - 1;
-    }
-
-    // find subdivision or super lon if needed
-    if ( span < SG_EPSILON ) {
-	// polar cap
-	lon = 0;
-	x = 0;
-    } else if ( span <= 1.0 ) {
-	x = (int)((dlon - lon) / span);
-    } else {
-	if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
-	    lon = (int)( (int)(lon / span) * span);
-	} else {
-	    // cout << " lon = " << lon 
-	    //  << "  tmp = " << (int)((lon-1) / span) << endl;
-	    lon = (int)( (int)((lon + 1) / span) * span - span);
-	    if ( lon < -180 ) {
-		lon = -180;
-	    }
-	}
-	x = 0;
-    }
-
-    //
-    // then latitude
-    //
-    diff = dlat - (double)(int)dlat;
+    
+    lon=(int)((int)((dlon+180+SG_EPSILON)/span)*span)-180;
+    x=(int)((dlon-lon)/span);
 
-    if ( (dlat >= 0) || (fabs(diff) < SG_EPSILON) ) {
-	lat = (int)dlat;
-    } else {
-	lat = (int)dlat - 1;
-    }
-    y = (int)((dlat - lat) * 8);
+    lat=(int)((int)((dlat+90+SG_EPSILON)/SG_BUCKET_SPAN)*SG_BUCKET_SPAN)-90;
+    y=(int)((dlat-lat)/SG_BUCKET_SPAN);
 }
 
 
-- 
1.5.3.4

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to