Ticket #429 (closed bug: duplicate)

Opened 6 years ago

Last modified 6 years ago

tile.getBoundsFromBaseLayer doesn't return what you'd expect for odd size viewport

Reported by: tschaub Owned by: tschaub
Priority: minor Milestone: 2.5 Release
Component: Tile Version:
Keywords: Cc:
State:

Description

The following example shows a case where tile.getBoundsFromBaseLayer doesn't return the same as tile.bounds despite the overlay having all the same properties as the base layer. Note that if you change the viewport size to something even (like 512, 300) it works well.

This causes problems if you are trying to use something like tilecache - denying tile requests because the bounds aren't within the threshold.

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
        #map {
            width: 511px;
            height: 299px;
            border: 1px solid gray;
        }
    </style>
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        <!--
        var map;
        function init(){
            map = new OpenLayers.Map('map');
            
            var l0 = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); 

            var l1 = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
                {isBaseLayer: false});
                
            map.addLayers([l0, l1]);
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            map.zoomToMaxExtent();
            // When tiles are drawn, overlay tile bounds are re-calculated
            // in tile.getBoundsFromBaseLayer.
            // For odd viewport sizes (odd width or height) - the calculation
            // doesn't return what you'd expect it to.
            alert(l0.grid[0][0].bounds + "\n" + l1.grid[0][0].bounds);
        }
        // -->
    </script>
  </head>
  <body onload="init()">
    <h1>OpenLayers Example</h1>
    <div id="map"></div>
  </body>
</html>

Attachments

odd_size.patch Download (0.7 KB) - added by tschaub 6 years ago.
patch that makes the problem go away
undo_odd_size.patch Download (0.7 KB) - added by tschaub 6 years ago.
undo this mess

Change History

Changed 6 years ago by tschaub

  • type changed from feature to bug

Changed 6 years ago by tschaub

patch that makes the problem go away

Changed 6 years ago by tschaub

  • keywords review added

please review

Changed 6 years ago by tschaub

  • keywords review removed

The problem is bigger than the patch.

Changed 6 years ago by crschmidt

Accepting this patch, even though the problem is bigger than the patch.

Changed 6 years ago by crschmidt

  • owner set to tschaub

Changed 6 years ago by tschaub

  • milestone changed from 2.3 Release to 2.4 Release

This requires some real testing to get to the bottom.

Changed 6 years ago by euzuro

  • milestone changed from 2.4 Release to 2.5 Release

Changed 6 years ago by tschaub

undo this mess

Changed 6 years ago by tschaub

This needs undone. In addition to being a bigger problem than the patch, the patch that was applied causes other problems. (Try panning with an odd sized viewport.)

Changed 6 years ago by crschmidt

  • keywords review added
  • milestone changed from 2.5 Release to 2.3 Release

Changed 6 years ago by crschmidt

  • summary changed from tile.getBoundsFromBaseLayer doesn't return what you'd expect for odd size viewport to fix panning for odd size viewport

Updating title to reflect the need to roll this back out

Changed 6 years ago by sderle

  • keywords review removed

Applied patch #2 (to undo patch #1 applied in r2018) as r2227. Leaving open.

Changed 6 years ago by sderle

  • keywords pullup added

p.s. don't close this ticket after r2227 is pulled up -- the issue is still unresolved

Changed 6 years ago by sderle

  • keywords pullup removed
  • status changed from new to closed
  • resolution set to fixed

Changed 6 years ago by crschmidt

  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 2.3 Release to 2.4 Release

Reopening. This will need a new patch eventually.

Changed 6 years ago by crschmidt

  • summary changed from fix panning for odd size viewport to tile.getBoundsFromBaseLayer doesn't return what you'd expect for odd size viewport

Changed 6 years ago by sderle

  • milestone changed from 2.4 Release to 2.5 Release

Changed 6 years ago by crschmidt

  • component changed from general to Tile

Changed 6 years ago by crschmidt

  • milestone changed from 2.5 Release to 2.6 Release

This code should just go away. See #881. Add deprecation warning and remove it in 3.0.

Changed 6 years ago by crschmidt

  • status changed from reopened to closed
  • resolution set to duplicate

Marking as dupe.

Changed 6 years ago by crschmidt

  • milestone changed from 2.6 Release to 2.5 Release
Note: See TracTickets for help on using tickets.