OpenLayers OpenLayers

Ticket #429 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: tschaub Assigned to: 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 (0.7 kB) - added by tschaub on 11/30/06 20:21:07.
patch that makes the problem go away
undo_odd_size.patch (0.7 kB) - added by tschaub on 01/28/07 23:38:30.
undo this mess

Change History

11/30/06 20:10:55 changed by tschaub

  • type changed from feature to bug.

11/30/06 20:21:07 changed by tschaub

  • attachment odd_size.patch added.

patch that makes the problem go away

11/30/06 20:21:35 changed by tschaub

  • keywords set to review.

please review

12/01/06 16:25:52 changed by tschaub

  • keywords deleted.

The problem is bigger than the patch.

12/06/06 16:30:11 changed by crschmidt

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

12/06/06 16:41:26 changed by crschmidt

  • owner set to tschaub.

12/22/06 15:58:08 changed by tschaub

  • milestone changed from 2.3 Release to 2.4 Release.

This requires some real testing to get to the bottom.

12/28/06 20:04:23 changed by euzuro

  • milestone changed from 2.4 Release to 2.5 Release.

01/28/07 23:38:30 changed by tschaub

  • attachment undo_odd_size.patch added.

undo this mess

01/28/07 23:40:28 changed 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.)

02/16/07 11:34:16 changed by crschmidt

  • keywords set to review.
  • milestone changed from 2.5 Release to 2.3 Release.

02/16/07 11:35:32 changed 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

02/16/07 11:43:05 changed by sderle

  • keywords deleted.

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

02/16/07 11:43:38 changed by sderle

  • keywords set to pullup.

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

02/16/07 14:27:08 changed by sderle

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

02/16/07 16:40:07 changed by crschmidt

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

Reopening. This will need a new patch eventually.

02/18/07 11:16:57 changed 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.

03/08/07 13:23:46 changed by sderle

  • milestone changed from 2.4 Release to 2.5 Release.

07/15/07 10:54:57 changed by crschmidt

  • component changed from general to Tile.

08/03/07 11:17:00 changed 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.

08/31/07 17:19:01 changed by crschmidt

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

Marking as dupe.

09/15/07 10:47:41 changed by crschmidt

  • milestone changed from 2.6 Release to 2.5 Release.