Changeset 407

Show
Ignore:
Timestamp:
11/07/08 12:40:35 (2 months ago)
Author:
arneke
Message:

#53 code for detecting offset requests rarely worked, new attempt

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/layer/GridCalculator.java

    r403 r407  
    235235        double xLoc = xdiff / tileWidth; 
    236236        retVals[0] = (int) Math.round(xLoc); 
    237         double absdiff = Math.abs(retVals[0] - xLoc); 
    238         if(absdiff/xLoc > 0.05 && absdiff > 0.05) { 
     237        double absdiff = Math.abs(retVals[0]*tileWidth - xdiff); 
     238         
     239        // This doesn't work too great 
     240        // http://localhost:8080/geowebcache/service/wms?LAYERS=topp%3Aopen_space&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A900913&BBOX=-8238077.159316406,4955673.447285157,-8218509.280078124,4965241.326523438&WIDTH=256&HEIGHT=256 
     241        if(absdiff > 0.00005 && (absdiff / tileWidth)  > 0.05) { 
    239242            throw new BadTileException("Your bounds in the x direction are offset" 
    240                     + " by more than 5% compared to the underlying grid."); 
     243                    + " by more than 5% compared to the underlying grid.\n" 
     244                    + " Given " + tileBounds.coords[0] + " the closest match is index " + retVals[0] 
     245                    + ", which corresponds to " + (retVals[0]*tileWidth + gridBounds.coords[0]) 
     246                    ); 
    241247        } 
    242248         
     
    245251        double yLoc = ydiff / tileWidth; 
    246252        retVals[1] = (int) Math.round(yLoc); 
    247         absdiff = Math.abs(retVals[1] - yLoc); 
    248         if(absdiff/yLoc > 0.05 && absdiff > 0.05) { 
     253        absdiff = Math.abs(retVals[1]*tileWidth - ydiff); 
     254        if(absdiff > 0.00005 && (absdiff / tileWidth)  > 0.05 ) { 
    249255            throw new BadTileException("Your bounds in the y direction are offset" 
    250                     + " by more than 5% compared to the underlying grid."); 
     256                    + " by more than 5% compared to the underlying grid.\n" 
     257                    + " Given " + tileBounds.coords[1] + " the closest match is index " + retVals[1] 
     258                    + ", which corresponds to " + (retVals[1]*tileWidth + gridBounds.coords[1]) 
     259            ); 
    251260        } 
    252261