Changeset 388
- Timestamp:
- 09/05/08 02:30:42 (3 months ago)
- Location:
- trunk/geowebcache
- Files:
-
- 8 modified
-
pom.xml (modified) (1 diff)
-
src/main/java/org/geowebcache/demo/Demo.java (modified) (1 diff)
-
src/main/java/org/geowebcache/layer/Grid.java (modified) (4 diffs)
-
src/main/java/org/geowebcache/layer/GridCalculator.java (modified) (5 diffs)
-
src/main/java/org/geowebcache/layer/TileLayerDispatcher.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/service/wms/WMSService.java (modified) (1 diff)
-
src/main/java/org/geowebcache/util/XMLConfiguration.java (modified) (5 diffs)
-
src/test/java/org/geowebcache/layer/GridCalculatorTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/geowebcache/pom.xml
r374 r388 12 12 <properties> 13 13 <!-- gs.version>1.6.4</gs.version --> 14 <gt.version>2.5- RC1</gt.version>14 <gt.version>2.5-SNAPSHOT</gt.version> 15 15 <spring.version>2.5.5</spring.version> 16 16 <restlet.version>1.0.8</restlet.version> -
trunk/geowebcache/src/main/java/org/geowebcache/demo/Demo.java
r375 r388 166 166 BBOX zoomBounds = grid.getBounds(); 167 167 //String res = "resolutions: "+ Arrays.toString(grid.getResolutions()) + ",\n"; 168 String res = "maxResolution: " + Double.toString(grid.getResolutions()[ 0]) +",\n";168 String res = "maxResolution: " + Double.toString(grid.getResolutions()[grid.getZoomStart()]) +",\n"; 169 169 String page = 170 170 "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>\n" -
trunk/geowebcache/src/main/java/org/geowebcache/layer/Grid.java
r386 r388 21 21 import org.geowebcache.GeoWebCacheException; 22 22 import org.geowebcache.util.wms.BBOX; 23 import org.mortbay.log.Log; 23 24 24 25 /** … … 37 38 private volatile transient GridCalculator gridCalculator; 38 39 39 private volatileint zoomStart = 0;40 private int zoomStart = 0; 40 41 41 private volatileint zoomStop = 30;42 private int zoomStop = 30; 42 43 43 44 public Grid(SRS srs, BBOX bounds, BBOX gridBounds, double[] resolutions) { … … 122 123 } 123 124 125 /** 126 * Use double locking to get the calculator to avoid performance hit. 127 * 128 * @return 129 * @throws GeoWebCacheException 130 */ 124 131 public GridCalculator getGridCalculator() throws GeoWebCacheException { 125 132 GridCalculator ret = gridCalculator; … … 136 143 137 144 private GridCalculator initGridCalculator() throws GeoWebCacheException { 145 if(zoomStart < 0 || zoomStop < zoomStart || zoomStop == 0) { 146 Log.debug("Missing values, setting zoomStart,zoomStop to 0,30"); 147 zoomStart = 0; 148 zoomStop = 30; 149 } 138 150 return new GridCalculator(this); 139 151 } -
trunk/geowebcache/src/main/java/org/geowebcache/layer/GridCalculator.java
r387 r388 69 69 public GridCalculator(Grid grid) throws GeoWebCacheException { 70 70 71 //TODO this is messed up, ignoring Grid object72 71 this.grid = grid; 73 this.zoomStart = 0; 74 this.zoomStop = 30; 75 //this.metaWidth = metaWidth; 76 //this.metaHeight = metaHeight; 77 72 78 73 if(grid.resolutions != null) { 79 74 this.resolutions = grid.resolutions; 80 75 this.zoomStop = resolutions.length - 1; 76 } else { 77 this.zoomStart = grid.getZoomStart(); 78 this.zoomStop = grid.getZoomStop(); 81 79 } 82 80 … … 96 94 private void determineGrid() throws GeoWebCacheException { 97 95 if(grid.resolutions == null) { 98 // Figure out the appro riate resolutions96 // Figure out the appropriate resolutions 99 97 100 98 double ratio = gridWidth / gridHeight; … … 152 150 } 153 151 154 this.resolutions = new double[this.zoomStop - this.zoomStart + 1]; 152 // We still need the full array, even though we only care about a part of it 153 this.resolutions = new double[this.zoomStop + 1]; 155 154 for(int i=this.zoomStart; i<= this.zoomStop; i++) { 156 155 this.resolutions[i] = baseResolution; … … 472 471 private int binarySearchForResolution(double reqResolution) 473 472 throws BadTileException { 474 return binarySearchForResolution(this.resolutions, reqResolution );475 } 476 477 protected static int binarySearchForResolution(double[] resolutions, double reqResolution )473 return binarySearchForResolution(this.resolutions, reqResolution, this.zoomStart); 474 } 475 476 protected static int binarySearchForResolution(double[] resolutions, double reqResolution, int zoomStart) 478 477 throws BadTileException { 479 int low = 0;478 int low = zoomStart; 480 479 int high = resolutions.length - 1; 481 480 … … 485 484 486 485 // Deal with the edge cases first 487 if(reqLower > resolutions[ 1]) {486 if(reqLower > resolutions[low]) { 488 487 if(resolutions[0] < reqLower) { 489 488 throw new BadTileException("Resolution "+reqResolution+" is too big for grid," -
trunk/geowebcache/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java
r301 r388 103 103 HashMap<String, TileLayer> layers = new HashMap<String, TileLayer>(); 104 104 105 Iterator configIter = configs.iterator();105 Iterator<Configuration> configIter = configs.iterator(); 106 106 while (configIter.hasNext()) { 107 107 Map<String, TileLayer> configLayers = null; 108 108 109 Configuration config = (Configuration)configIter.next();109 Configuration config = configIter.next(); 110 110 111 111 try { … … 113 113 } catch (GeoWebCacheException gwce) { 114 114 log.error(gwce.getMessage()); 115 log 116 .error("Failed to add layers from " 115 log.error("Failed to add layers from " 117 116 + config.getIdentifier()); 118 117 } -
trunk/geowebcache/src/main/java/org/geowebcache/service/wms/WMSService.java
r379 r388 67 67 throws GeoWebCacheException { 68 68 String[] keys = { "layers", "request" }; 69 String[] values = ServletUtils.selectedStringsFromMap( request70 .getParameterMap(), keys);69 String[] values = ServletUtils.selectedStringsFromMap( 70 request.getParameterMap(), keys); 71 71 72 72 // Look for getCapabilities -
trunk/geowebcache/src/main/java/org/geowebcache/util/XMLConfiguration.java
r384 r388 158 158 xs.alias("transparent", boolean.class); 159 159 xs.alias("SRS", org.geowebcache.layer.SRS.class); 160 161 xs.alias("zoomStart", int.class); 162 xs.alias("zoomStop", int.class); 160 163 //xs.alias("debugheaders", boolean.class); 161 164 … … 312 315 313 316 public void determineConfigDirH() { 317 String baseDir = context.getServletContext().getRealPath(""); 318 314 319 if (absPath != null) { 315 320 configDirH = new File(absPath); … … 317 322 } 318 323 324 319 325 /* Only keep going for relative directory */ 320 326 if (relPath == null) { … … 322 328 //String classpath = System.getProperty("java.class.path"); 323 329 //System.out.println(classpath); 324 relPath = "/WEB-INF/classes"; 330 331 if(new File(baseDir + "/WEB-INF/classes/" + CONFIGURATION_FILE_NAME).exists()) { 332 relPath = "/WEB-INF/classes"; 333 } else if( new File(baseDir + "/../resources/" + CONFIGURATION_FILE_NAME).exists()) { 334 relPath = "/../resources"; 335 } 325 336 } //else { 326 337 // if (File.separator.equals("\\") … … 331 342 //} 332 343 333 String baseDir = context.getServletContext().getRealPath("");334 335 344 configDirH = new File(baseDir + relPath); 336 345 -
trunk/geowebcache/src/test/java/org/geowebcache/layer/GridCalculatorTest.java
r341 r388 238 238 public void test0binarySearch() throws Exception { 239 239 double[] resolutions = {8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0}; 240 int result = GridCalculator.binarySearchForResolution(resolutions, 5.04 );240 int result = GridCalculator.binarySearchForResolution(resolutions, 5.04, 0); 241 241 assertEquals(3, result); 242 242 243 result = GridCalculator.binarySearchForResolution(resolutions, 8.03 );243 result = GridCalculator.binarySearchForResolution(resolutions, 8.03, 0); 244 244 assertEquals(0, result); 245 245 246 result = GridCalculator.binarySearchForResolution(resolutions, 0.98 );246 result = GridCalculator.binarySearchForResolution(resolutions, 0.98, 0); 247 247 assertEquals(7, result); 248 248 249 result = GridCalculator.binarySearchForResolution(resolutions, 1.005 );249 result = GridCalculator.binarySearchForResolution(resolutions, 1.005, 0); 250 250 assertEquals(7, result); 251 251 252 result = GridCalculator.binarySearchForResolution(resolutions, 6.025 );252 result = GridCalculator.binarySearchForResolution(resolutions, 6.025, 0); 253 253 assertEquals(2, result); 254 254 } … … 256 256 public void test1binarySearch() throws Exception { 257 257 double[] resolutions = {12.0, 10.0, 6.0, 5.0, 4.0, 3.0, 1.0}; 258 int result = GridCalculator.binarySearchForResolution(resolutions, 5.04 );258 int result = GridCalculator.binarySearchForResolution(resolutions, 5.04, 0); 259 259 assertEquals(3, result); 260 260 261 result = GridCalculator.binarySearchForResolution(resolutions, 0.98 );261 result = GridCalculator.binarySearchForResolution(resolutions, 0.98, 0); 262 262 assertEquals(6, result); 263 263 264 result = GridCalculator.binarySearchForResolution(resolutions, 12.05 );264 result = GridCalculator.binarySearchForResolution(resolutions, 12.05, 0); 265 265 assertEquals(0, result); 266 266 267 result = GridCalculator.binarySearchForResolution(resolutions, 4.002 );267 result = GridCalculator.binarySearchForResolution(resolutions, 4.002, 0); 268 268 assertEquals(4, result); 269 269
