OpenLayers OpenLayers

Ticket #1093 (new bug)

Opened 9 months ago

Last modified 6 months ago

Tile extent always a notch too big

Reported by: pvalsecc Assigned to: euzuro
Priority: minor Milestone: 2.7 Release
Component: Tile Version: SVN
Keywords: Cc:
State: Needs More Work

Description

When I display a raster with a tiled layer, the limits of the tiles can always been seen due to some lines and columns of pixels repeated.

How the code is done now, the right bound of a tile is equal to the left bound of the next tile. Meaning that the colomn that makes the limit between those two tile is always asked twice to the server. It would be OK if it where not displayed twice.

If I apply the following patch the display problem is not visible anymore:

--- lib/OpenLayers/Layer/Grid.js        (revision 4970)
+++ lib/OpenLayers/Layer/Grid.js        (working copy)
@@ -356,8 +356,8 @@
                 var tileBounds =
                     new OpenLayers.Bounds(tileoffsetlon,
                                           tileoffsetlat,
-                                          tileoffsetlon + tilelon,
-                                          tileoffsetlat + tilelat);
+                                          tileoffsetlon + tilelon - resolution,
+                                          tileoffsetlat + tilelat - resolution);

                 var x = tileoffsetx;
                 x -= parseInt(this.map.layerContainerDiv.style.left);

Attachments

badTiling.png (19.1 kB) - added by pvalsecc on 10/16/07 12:59:19.
Example of bad tiling

Change History

10/16/07 12:59:19 changed by pvalsecc

  • attachment badTiling.png added.

Example of bad tiling

10/16/07 15:06:57 changed by crschmidt

For the record, I'm not convinced this is a bug in the client. The tiles are placed such that their tiles line up -- right edge of the image is the right side of the right pixel, left side of the image is the left side of the left pixel.

I've never seen a case where the backend server has a problem like this, despite doing a lot of different setups.

I think that the server is to blame here.

10/17/07 03:36:37 changed by pvalsecc

  • type changed from feature to bug.

10/17/07 09:30:29 changed by pvalsecc

  • version changed from 2.5 to SVN.

See screenshot in attachement of the first post. The map is clearly having a problem. And if I request manually a tile around this zone, there is no problem. So my source data is good.

I did some experimenting with mapserver 5. You can find my stuff here:

http://www2.thus.ch/~patrick/tmp/

The sample.tif image is 22x22 pixels gdalinfo tells me that:

Driver: GTiff/GeoTIFF
Size is 22, 22
Coordinate System is `'
Metadata:
  TIFFTAG_DOCUMENTNAME=/home/pvalsecc/tmp/sample.tif
  TIFFTAG_IMAGEDESCRIPTION=Created with GIMP
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,   22.0)
Upper Right (   22.0,    0.0)
Lower Right (   22.0,   22.0)
Center      (   11.0,   11.0)
Band 1 Block=22x22 Type=Byte, ColorInterp=Red
Band 2 Block=22x22 Type=Byte, ColorInterp=Green
Band 3 Block=22x22 Type=Byte, ColorInterp=Blue

Now, let say I want the image delimited by the blue lines (blue lines included). In mode=map, I need that:

http://www2.thus.ch/cgi-bin/mapserv?map=/home/patrick/public_html/tmp/test.map&mode=map&mapext=1.5+1.5+20.5+20.5&map_size=20+20

But, in mode=wms, here is the URL:

http://www2.thus.ch/cgi-bin/mapserv?map=/home/patrick/public_html/tmp/test.map&mode=wms&request=getMap&bbox=1,1,21,21&version=1.1&layers=test&srs=epsg:4269&format=image/png&width=20&height=20&styles=

You can try to alter both URL, you'll see...

So if you want to be correct, the tile extent you should use depends if you are in Layer.MapServer or in Layer.WMS:

  • MapServer:
    var tileBounds =
        new OpenLayers.Bounds(tileoffsetlon + resolution/2.0,
                              tileoffsetlat + resolution/2.0,
                              tileoffsetlon + tilelon - resolution/2.0,
                              tileoffsetlat + tilelat - resolution/2.0);
    
  • WMS:
    var tileBounds =
        new OpenLayers.Bounds(tileoffsetlon,
                              tileoffsetlat,
                              tileoffsetlon + tilelon,
                              tileoffsetlat + tilelat);
    

What do you think?

10/17/07 09:40:58 changed by crschmidt

This makes more sense to me. Thanks for digging into it.

I'd like to confirm that this is expected behavior with the MapServer developers before we put this in -- it wouldn't be the first time we had broken MapServer -- but in general, I'm supportive of putting a change doing something like this in.

10/17/07 13:26:25 changed by pvalsecc

I have tested that with mapserver 4.10.3 and mapserver 5.0.0. They seem to have the same resolution/2.0 stuff, but 4.10.3 was having incoherent approximations between the two axis (x and y) in mode=map. Try my setup with this extent:

1+1+20+20

You'll see that a red line show up in only one direction.

My home server is in 5.0.0, so you'll have to check with your own install...

12/15/07 16:37:16 changed by crschmidt

  • state set to Needs Discussion.
  • milestone set to 2.6 Release.

01/22/08 17:50:15 changed by crschmidt

  • state changed from Needs Discussion to Needs More Work.

elem is taking this one

02/08/08 19:43:27 changed by crschmidt

  • milestone changed from 2.6 Release to 2.7 Release.

If anyone wants to actually confirm that this is the correct behavior, please put a patch in, and if it's done, we can put it into 2.6.