OpenLayers OpenLayers

Ticket #1018 (closed task: fixed)

Opened 1 year ago

Last modified 1 year ago

Remove 'drawn' property from tile altogether

Reported by: euzuro Assigned to: euzuro
Priority: minor Milestone: 2.6 Release
Component: Tile Version: 2.5 RC3
Keywords: Cc:
State:

Description

The 'drawn' property as we know it is only used in one case:

the case where you have a gridded layer with buffer set to 0 and where a new grid is initialized (initGriddedTiles) and it just so happens that there is an extra row/col of tiles to the right or bottom of the displayed map. Since the buffer is set to 0 we are instructed to *not* load any tiles which are off the grid, so this extra row/col's tiles do not get loaded.

However! in the case where the user then drags the map just a tiny bit up or left, that extra row of tiles is brought into view. They then need to be drawn, and this is the entire reason for the 'drawn' property and the following code snippet, at the end of the moveGriddedTiles() function:

        if (this.buffer == 0) {
            for (var r=0, rl=this.grid.length; r<rl; r++) {
                var row = this.grid[r];
                for (var c=0, cl=row.length; c<cl; c++) {
                    var tile = row[c];
                    if (!tile.drawn && H
                         tile.bounds.intersectsBounds(bounds, false)) {
                        tile.draw();
                    }
                }
            }
        }

This border case I believe can be avoided by simply changing one line of the tile.draw() function:

    var withinMapExtent = (mapExtent &&
                           this.bounds.intersectsBounds(mapExtent, false));

to

    var withinMapExtent = (mapExtent &&
                           this.bounds.intersectsBounds(mapExtent, true));

which makes the bounds test *inclusive* and therefore yes will draw the last col/row of tiles. OK, the user said NO BUFFER, but we're only buffering one little tiny row/column and the whole point of OpenLayers in the first place is to be slippy and so it doesn't seem unreasonable to expect/hope the user to slip around.

And of course the bonus of this is that by changing that one line, we can eliminate a property that results in confusing code that noone can understand. To me, this seems like a win.

Attachments

drawn.patch (2.1 kB) - added by euzuro on 09/27/07 02:19:28.
depends on #1017
drawn.2.patch (2.7 kB) - added by euzuro on 09/28/07 15:14:44.
update of patch to simply remove the 2nd test case from tile.draw. just draw it all the time. tests pass ie/ff

Change History

09/27/07 02:19:28 changed by euzuro

  • attachment drawn.patch added.

depends on #1017

09/28/07 15:11:40 changed by euzuro

update to this, i think the problem description is not quite right. just changing the inclusivity is not going to fix this problem. In fact, we should just remove the 2nd test case altogether.

09/28/07 15:14:44 changed by euzuro

  • attachment drawn.2.patch added.

update of patch to simply remove the 2nd test case from tile.draw. just draw it all the time. tests pass ie/ff

09/28/07 15:52:43 changed by crschmidt

  • keywords set to commit.

After talking about this with Erik, I agree that this is the right path. Please commit.

09/28/07 16:45:36 changed by euzuro

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

(In [4557]) Remove 'drawn' property from Tiles. (Closes #1018)