Ticket #1261 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

floor => round in TileCache.js

Reported by: brentp Owned by: tschaub
Priority: minor Milestone: 2.6 Release
Component: Layer.TileCache Version: 2.5
Keywords: Cc:
State: Complete

Description

the error visible here is because of the different handling of rounding in tilecache's Layer.py and openlyers' TileCache.js this patch fixes that:

svn diff TileCache.js
Index: TileCache.js
===================================================================
--- TileCache.js        (revision 5710)
+++ TileCache.js        (working copy)
@@ -103,8 +103,8 @@
        var res = this.map.getResolution();
        var bbox = this.maxExtent;
        var size = this.tileSize;
-        var tileX = Math.floor((bounds.left - bbox.left) / (res * size.w));
-        var tileY = Math.floor((bounds.bottom - bbox.bottom) / (res * size.h));
+        var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
+        var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h));
        var tileZ = this.map.zoom;
        /**
         * Zero-pad a positive integer.

Attachments

tc.patch Download (0.7 KB) - added by brentp 5 years ago.

Change History

Changed 5 years ago by brentp

Changed 5 years ago by euzuro

  • state set to Needs More Work
  • milestone set to 2.6 Release

needs tests....

Changed 5 years ago by crschmidt

  • state changed from Needs More Work to Commit

Although in general, I agree with you, I'm in favor of just going ahead with it in this case.

  • It's causing problems
  • It's a clear bug, and matching the behavior of TC is the right thing to do here.

With that in mind, I'm going to commit it, despite a lack of tests.

Changed 5 years ago by crschmidt

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [5745]) TileCache.js uses math.floor instead of math.round like TC does. Thanks Brent. (Closes #1261)

Note: See TracTickets for help on using tickets.