Changeset 424

Show
Ignore:
Timestamp:
11/13/08 05:45:17 (8 weeks ago)
Author:
arneke
Message:

Fixed code for truncation

Location:
trunk/geowebcache/src/main/java/org/geowebcache
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/cache/Cache.java

    r418 r424  
    7070    throws CacheException, GeoWebCacheException; 
    7171 
    72     public void truncate(TileLayer tl, SRS srs, int zoomStart, int zoomStop,  
     72    public int truncate(TileLayer tl, SRS srs, int zoomStart, int zoomStop,  
    7373            int[][] bounds, MimeType mimeType) throws CacheException; 
    7474     
  • trunk/geowebcache/src/main/java/org/geowebcache/cache/file/FileCache.java

    r420 r424  
    293293    } 
    294294 
    295     public void truncate(TileLayer tl, SRS srs, int zoomStart, int zoomStop, 
     295    public int truncate(TileLayer tl, SRS srs, int zoomStart, int zoomStop, 
    296296            int[][] bounds, MimeType mimeType) throws CacheException { 
    297297 
     298        int count = 0; 
     299         
    298300        String prefix = tl.getCachePrefix(); 
    299301 
     
    314316                    for (File tile : tiles) { 
    315317                        tile.delete(); 
     318                        count++; 
    316319                    } 
    317320 
     
    319322                    if (chk == null || chk.length == 0) { 
    320323                        imd.delete(); 
     324                        count++; 
    321325                    } 
    322326                } 
     
    325329                if (chk == null || chk.length == 0) { 
    326330                    srsZoom.delete(); 
    327                 } 
    328  
    329             } 
    330  
     331                    count++; 
     332                } 
     333 
     334            } 
     335             
     336            return count; 
     337             
    331338        } else { 
    332339            throw new CacheException(prefix 
  • trunk/geowebcache/src/main/java/org/geowebcache/cache/file/FilePathKey2Filter.java

    r422 r424  
    7878        } else { 
    7979            int tmp = findZoomLevel(name); 
    80             if(tmp <= zoomStart || tmp >= zoomStop) { 
     80            if(tmp < zoomStart || tmp > zoomStop) { 
    8181                return false; 
    8282            } 
     
    118118            int[] box = bounds[zoomLevel]; 
    119119 
    120             // [2, 5, 5, 6] , why that when we've got 00_05 ? 
     120             
    121121            if (x < box[0] || x > box[2]) { 
    122122                return false; 
     
    128128        } 
    129129         
    130         System.out.println(dir.getAbsolutePath() + " " + name); 
     130        //System.out.println(dir.getAbsolutePath() + " " + name); 
    131131         
    132132        return true; 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/TruncateTask.java

    r422 r424  
    1717package org.geowebcache.rest; 
    1818 
     19import java.util.Arrays; 
     20 
    1921import org.apache.commons.logging.Log; 
    2022import org.apache.commons.logging.LogFactory; 
     
    3335    private final TileLayer tl; 
    3436     
     37    private final static double[] nullBbox = {0.0,0.0,0.0,0.0}; 
     38     
    3539    public TruncateTask(SeedRequest req, TileLayer tl) { 
    3640        this.req = req; 
     
    4347         
    4448        Cache cache = tl.getCache(); 
    45          
    46         BBOX bbox = req.getBounds(); 
     49 
    4750        int[][] bounds = null; 
    4851         
    49         if(bbox != null) { 
    50             bounds = tl.getCoveredGridLevels(req.getSRS(), bbox); 
     52        if(! Arrays.equals(req.getBounds().coords, nullBbox)) { 
     53            bounds = tl.getCoveredGridLevels(req.getSRS(), req.getBounds()); 
    5154        } 
    5255         
     
    5457        // we may have to throw a wider net 
    5558        MimeType mimeType = null; 
    56         if(req.getMimeFormat() != null && req.getMimeFormat().length() > 0) { 
     59        if (req.getMimeFormat() != null && req.getMimeFormat().length() > 0) { 
    5760            mimeType = MimeType.createFromFormat(req.getMimeFormat()); 
    58              
    59             int[] metaFactors = tl.getMetaTilingFactors(); 
    60              
    61             int gridBounds[][] = tl.getGrid(req.getSRS()).getGridCalculator().getGridBounds(); 
    62              
    63             if(metaFactors[0] > 1 || metaFactors[1] > 1 
    64                     && mimeType.supportsTiling()) { 
    65                 bounds = GridCalculator.expandBoundsToMetaTiles(gridBounds, bounds, metaFactors); 
     61 
     62            if (bounds != null) { 
     63                int[] metaFactors = tl.getMetaTilingFactors(); 
     64 
     65                int gridBounds[][] = tl.getGrid(req.getSRS()) 
     66                        .getGridCalculator().getGridBounds(); 
     67 
     68                if (metaFactors[0] > 1 || metaFactors[1] > 1 
     69                        && mimeType.supportsTiling()) { 
     70                    bounds = GridCalculator.expandBoundsToMetaTiles(gridBounds, 
     71                            bounds, metaFactors); 
     72                } 
    6673            } 
    6774        } 
    6875         
    69         cache.truncate(tl, req.getSRS(),  
     76        int count = cache.truncate(tl, req.getSRS(),  
    7077                req.getZoomStart(), req.getZoomStop(),  
    7178                bounds, mimeType); 
     79        log.info("Completed truncating " + count + " tiles"); 
    7280    } 
    7381 
  • trunk/geowebcache/src/main/java/org/geowebcache/service/kml/KMLDebugGridLayer.java

    r418 r424  
    387387 
    388388 
    389     public void truncate(TileLayer tl, SRS srs, int zoomStart, int zoomStop, 
     389    public int truncate(TileLayer tl, SRS srs, int zoomStart, int zoomStop, 
    390390            int[][] bounds, MimeType mimeType) throws CacheException { 
    391391        // TODO Auto-generated method stub 
    392          
     392        return 0; 
    393393    } 
    394394