Changeset 320
- Timestamp:
- 08/14/08 19:28:33 (5 months ago)
- Location:
- trunk/geowebcache/src/main
- Files:
-
- 1 added
- 14 modified
-
java/org/geowebcache/GeoWebCacheDispatcher.java (modified) (2 diffs)
-
java/org/geowebcache/layer/BadTileException.java (added)
-
java/org/geowebcache/layer/Grid.java (modified) (2 diffs)
-
java/org/geowebcache/layer/TileLayer.java (modified) (4 diffs)
-
java/org/geowebcache/layer/wms/WMSLayer.java (modified) (13 diffs)
-
java/org/geowebcache/service/kml/KMLDebugGridLayer.java (modified) (3 diffs)
-
java/org/geowebcache/service/kml/KMLService.java (modified) (1 diff)
-
java/org/geowebcache/service/wms/WMSService.java (modified) (2 diffs)
-
java/org/geowebcache/util/GeoServerConfiguration.java (modified) (2 diffs)
-
java/org/geowebcache/util/GetCapabilitiesConfiguration.java (modified) (4 diffs)
-
java/org/geowebcache/util/XMLConfiguration.java (modified) (1 diff)
-
java/org/geowebcache/util/wms/BBOX.java (modified) (1 diff)
-
java/org/geowebcache/util/wms/GridCalculator.java (modified) (8 diffs)
-
resources/log4j.properties (modified) (1 diff)
-
webapp/WEB-INF/geowebcache-servlet.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/geowebcache/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java
r310 r320 30 30 import org.apache.commons.logging.LogFactory; 31 31 import org.geowebcache.demo.Demo; 32 import org.geowebcache.layer.BadTileException; 32 33 import org.geowebcache.layer.TileLayer; 33 34 import org.geowebcache.layer.TileLayerDispatcher; … … 142 143 } catch (Exception e) { 143 144 // e.printStackTrace(); 144 log.error(e.getMessage()+ " " + request.getRequestURL().toString()); 145 if(! (e instanceof BadTileException) || log.isDebugEnabled()) { 146 log.error(e.getMessage()+ " " + request.getRequestURL().toString()); 147 } 148 145 149 writeError(response, 400, e.getMessage()); 146 150 if(! (e instanceof GeoWebCacheException) -
trunk/geowebcache/src/main/java/org/geowebcache/layer/Grid.java
r315 r320 32 32 private SRS projection = null; 33 33 34 public Grid(SRS projection, BBOX bounds, BBOX gridBounds) { 35 this.projection = projection; 36 this.bounds = bounds; 37 this.gridbounds = gridBounds; 38 } 39 34 40 /** 35 41 * method will set the bounds of the layer for this grid from a BBOX … … 44 50 */ 45 51 public void setBounds(String bounds) { 46 47 52 this.bounds = new BBOX(bounds); 48 53 } -
trunk/geowebcache/src/main/java/org/geowebcache/layer/TileLayer.java
r301 r320 39 39 40 40 protected List<Grid> grids; 41 42 // Styles? 43 44 // Metatiling? 41 45 42 46 /** … … 98 102 * location and so forth. 99 103 */ 100 p ublicabstract Boolean initialize();104 protected abstract Boolean initialize(); 101 105 102 106 /** … … 288 292 */ 289 293 public abstract int[] getGridLocForBounds(int srsIdx, BBOX bounds) 290 throws GeoWebCacheException;294 throws BadTileException; 291 295 292 296 /** … … 392 396 public abstract void setExpirationHeader(HttpServletResponse response); 393 397 394 public abstract void lazyLayerInitialization(CacheFactory cf); 398 //public abstract void lazyLayerInitialization(CacheFactory cf); 399 400 public abstract void setCacheFactory(CacheFactory cacheFactory); 395 401 } -
trunk/geowebcache/src/main/java/org/geowebcache/layer/wms/WMSLayer.java
r318 r320 21 21 import java.io.IOException; 22 22 import java.io.OutputStream; 23 import java.util.Arrays; 23 24 import java.util.HashMap; 24 25 import java.util.List; … … 37 38 import org.geowebcache.cache.CacheFactory; 38 39 import org.geowebcache.cache.CacheKey; 40 import org.geowebcache.layer.BadTileException; 39 41 import org.geowebcache.layer.GridLocObj; 40 42 import org.geowebcache.layer.SRS; 41 43 import org.geowebcache.layer.TileLayer; 42 44 import org.geowebcache.layer.Grid; 45 import org.geowebcache.mime.ErrorMime; 43 46 import org.geowebcache.mime.ImageMime; 44 47 import org.geowebcache.mime.MimeException; … … 90 93 private transient int curWmsURL; 91 94 92 private transient String wmsLayers;95 //private transient String wmsLayers; 93 96 94 97 private transient String wmsStyles; 95 98 96 private transient WMSParameters wmsparams;99 //private transient WMSParameters wmsparams; 97 100 98 101 private transient boolean saveExpirationHeaders; … … 128 131 private static transient Log log; 129 132 130 public WMSLayer(String layerName, CacheFactory cacheFactory) 131 throws GeoWebCacheException { 133 //public WMSLayer(String layerName, CacheFactory cacheFactory) 134 // throws GeoWebCacheException { 135 // name = layerName; 136 // initCacheFactory = cacheFactory; 137 // log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 138 //} 139 140 public WMSLayer(String layerName, CacheFactory cacheFactory, 141 String wmsURL, List<String> mimeFormats, 142 List<Grid> grids, int[] metaWidthHeight) { 143 132 144 name = layerName; 133 145 initCacheFactory = cacheFactory; 134 } 135 136 public void lazyLayerInitialization(CacheFactory cf) { 137 zoomStart = 0; 138 zoomStop = 20; 139 request = "GetMap"; 140 curWmsURL = 0; 141 wmsLayers = "topp:states"; 142 saveExpirationHeaders = false; 146 this.WMSurl = wmsURL; 147 super.mimeFormats = mimeFormats; 148 super.grids = grids; 149 this.metaWidthHeight = metaWidthHeight; 143 150 expireClients = GWCVars.CACHE_USE_WMS_BACKEND_VALUE; 144 151 expireCache = GWCVars.CACHE_NEVER_EXPIRE; 145 layerLock = new ReentrantLock(); 146 layerLocked = false; 147 layerLockedCond = layerLock.newCondition(); 148 procQueue = new HashMap<GridLocObj, Boolean>(); 149 cacheLockWait = -1; 150 log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 151 initCacheFactory = cf; 152 153 isInitialized(); 154 155 } 152 } 153 154 public void setCacheFactory(CacheFactory cacheFactory) { 155 initCacheFactory = cacheFactory; 156 //log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 157 } 158 159 // private void lazyLayerInitialization() { 160 // width = 256; 161 // height = 256; 162 // version = "1.1.0"; 163 // transparent = true; 164 // zoomStart = 0; 165 // zoomStop = 20; 166 // request = "GetMap"; 167 // errormime = ErrorMime.vnd_ogc_se_inimage.getMimeType(); 168 // curWmsURL = 0; 169 // wmsLayers = "topp:states"; 170 // saveExpirationHeaders = false; 171 // expireClients = GWCVars.CACHE_USE_WMS_BACKEND_VALUE; 172 // expireCache = GWCVars.CACHE_NEVER_EXPIRE; 173 // layerLock = new ReentrantLock(); 174 // layerLocked = false; 175 // layerLockedCond = layerLock.newCondition(); 176 // procQueue = new HashMap<GridLocObj, Boolean>(); 177 // cacheLockWait = -1; 178 // //initCacheFactory = cf; 179 // } 156 180 157 181 public Boolean isInitialized() { … … 168 192 } 169 193 170 public Boolean initialize() { 194 protected Boolean initialize() { 195 196 //lazyLayerInitialization(); 197 log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 198 curWmsURL = 0; 199 zoomStart = 0; 200 zoomStop = 20; 201 request = "GetMap"; 202 errormime = ErrorMime.vnd_ogc_se_inimage.getMimeType(); 203 width = 256; 204 height = 256; 205 version = "1.1.0"; 206 transparent = true; 207 saveExpirationHeaders = false; 208 layerLock = new ReentrantLock(); 209 layerLockedCond = layerLock.newCondition(); 210 procQueue = new HashMap<GridLocObj, Boolean>(); 211 212 171 213 try { 172 setParametersFromProperties(initCacheFactory);214 initParameters(); 173 215 } catch (GeoWebCacheException gwce) { 174 216 log.error(gwce.getMessage()); … … 419 461 } 420 462 } 463 464 public void setTileIndexHeader(Tile tile) { 465 tile.servletResp.addHeader("geowebcache-tile-index", Arrays.toString(tile.getTileIndex())); 466 } 421 467 422 468 /** … … 446 492 } 447 493 448 Tile tile = new Tile(this, tileProto.getSRS(), gridPos, tileProto449 .getMimeType(), metaTile.getStatus(), out.toByteArray());494 Tile tile = new Tile(this, tileProto.getSRS(), gridPos, 495 tileProto.getMimeType(), metaTile.getStatus(), out.toByteArray()); 450 496 tile.setTileLayer(this); 451 497 cache.set(this.cacheKey, tile, expireCache); … … 508 554 this.setExpirationHeader(tile.servletResp); 509 555 } 556 557 setTileIndexHeader(tile); 558 510 559 return tile; 511 560 } … … 516 565 * @throws CacheException 517 566 */ 518 private void setParametersFromProperties(CacheFactory cacheFactory) 519 throws GeoWebCacheException { 567 private void initParameters() throws GeoWebCacheException { 520 568 // everything that happens in profile construction should happen here 521 569 … … 553 601 maxTileWidth[index] = 20037508.34 * 2; 554 602 maxTileHeight[index] = 20037508.34 * 2; 555 log 556 .error("GeoWebCache only handles EPSG:4326 and EPSG:900913!"); 603 log.error("GeoWebCache only handles EPSG:4326 and EPSG:900913!"); 557 604 throw new GeoWebCacheException( 558 605 "GeoWebCache only handles EPSG:4326 and EPSG:900913!"); … … 571 618 // Cache and CacheKey 572 619 573 cache = cacheFactory.getDefaultCache(); 620 cache = initCacheFactory.getDefaultCache(); 621 574 622 if (cache == null) { 575 623 throw new GeoWebCacheException("Unable to get default cache from cacheFactory in WMSLayer."); 576 624 } 577 625 578 cacheKey = cacheFactory.getCacheKeyFactory().getCacheKey(cache.getDefaultKeyBeanId()); 626 cacheKey = initCacheFactory.getCacheKeyFactory().getCacheKey(cache.getDefaultKeyBeanId()); 627 579 628 String sanitizedName = name.replace(':', '_'); 629 580 630 cachePrefix = cache.getDefaultPrefix(sanitizedName); 631 581 632 log.warn("cachePrefix not defined for layer " + name 582 + ", using default prefi fx and name instead: " + cachePrefix);633 + ", using default prefix and name instead: " + cachePrefix); 583 634 584 635 // Initialize the cache 585 636 cache.setUp(cachePrefix); 586 587 637 } 588 638 … … 640 690 641 691 public WMSParameters getWMSParamTemplate() { 642 wmsparams = new WMSParameters();692 WMSParameters wmsparams = new WMSParameters(); 643 693 wmsparams.setRequest(request); 644 694 wmsparams.setVersion(version); … … 698 748 699 749 public int[] getGridLocForBounds(int srsIdx, BBOX tileBounds) 700 throws ServiceException {750 throws BadTileException { 701 751 return gridCalc[srsIdx].gridLocation(tileBounds); 702 752 } -
trunk/geowebcache/src/main/java/org/geowebcache/service/kml/KMLDebugGridLayer.java
r317 r320 31 31 import org.geowebcache.cache.CacheException; 32 32 import org.geowebcache.cache.CacheKey; 33 import org.geowebcache.layer.BadTileException; 33 34 import org.geowebcache.layer.SRS; 34 35 import org.geowebcache.layer.TileLayer; … … 143 144 144 145 public int[] getGridLocForBounds(int srsIdx, BBOX bounds) 145 throws GeoWebCacheException {146 throws BadTileException { 146 147 // TODO Auto-generated method stub 147 148 //log.warn("getGridLocForBounds(int srsIdx, BBOX bounds)"); … … 466 467 } 467 468 469 470 471 @Override 472 public void setCacheFactory(CacheFactory cacheFactory) { 473 // TODO Auto-generated method stub 474 475 } 476 468 477 } -
trunk/geowebcache/src/main/java/org/geowebcache/service/kml/KMLService.java
r317 r320 169 169 "No layer provided, request parsed to: " + tile.getLayerId()); 170 170 } else if(! layer.isInitialized()){ 171 layer.initialize();171 // ? 172 172 } 173 173 } -
trunk/geowebcache/src/main/java/org/geowebcache/service/wms/WMSService.java
r301 r320 106 106 107 107 int[] tileIndex = tileLayer.getGridLocForBounds(srsIdx, bbox); 108 108 109 109 // String strOrigin = wmsParams.getOrigin(); 110 110 // if (strOrigin != null) { … … 163 163 TileLayer tl = iter.next(); 164 164 if (!tl.isInitialized()) { 165 tl.initialize();165 // ooops ? (Always returns true :) ) 166 166 } 167 167 xml += getTileSets(tl); -
trunk/geowebcache/src/main/java/org/geowebcache/util/GeoServerConfiguration.java
r243 r320 40 40 GeoServerConfiguration.getSystemVar( 41 41 cacheFactory.getWebAppContext(), GEOSERVER_WMS_URL), 42 mimeTypes,43 metaTiling,44 GeoServerConfiguration.getSystemVar(42 mimeTypes, 43 metaTiling, 44 GeoServerConfiguration.getSystemVar( 45 45 cacheFactory.getWebAppContext(), GEOWEBCACHE_VENDOR_PARAMS) 46 46 ); … … 52 52 GeoServerConfiguration.getSystemVar( 53 53 cacheFactory.getWebAppContext(), GEOSERVER_WMS_URL), 54 mimeTypes,55 metaTiling,56 vendorParams54 mimeTypes, 55 metaTiling, 56 vendorParams 57 57 ); 58 58 } -
trunk/geowebcache/src/main/java/org/geowebcache/util/GetCapabilitiesConfiguration.java
r318 r320 20 20 import java.io.IOException; 21 21 import java.net.URL; 22 import java.util.ArrayList; 22 23 import java.util.HashMap; 23 24 import java.util.Iterator; … … 35 36 import org.geowebcache.GeoWebCacheException; 36 37 import org.geowebcache.cache.CacheFactory; 38 import org.geowebcache.layer.Grid; 39 import org.geowebcache.layer.SRS; 37 40 import org.geowebcache.layer.TileLayer; 38 41 import org.geowebcache.layer.wms.WMSLayer; 42 import org.geowebcache.util.wms.BBOX; 39 43 40 44 public class GetCapabilitiesConfiguration implements Configuration { … … 161 165 double maxY = layer.getLatLonBoundingBox().getMaxY(); 162 166 163 String bbox4326Str = Double.toString(minX) + "," 164 + Double.toString(minY) + "," + Double.toString(maxX) 165 + "," + Double.toString(maxY); 166 167 BBOX bounds4326 = new BBOX(minX,minY,maxX,maxX); 167 168 168 169 log.info("Found layer: " + layer.getName() 169 + " with LatLon bbox " + b box4326Str);170 + " with LatLon bbox " + bounds4326.toString()); 170 171 171 String bbox900913Str =172 Double.toString(longToSphericalMercatorX(minX)) + ","173 + Double.toString(latToSphericalMercatorY(minY)) + ","174 + Double.toString(longToSphericalMercatorX(maxX)) + ","175 + Double.toString(latToSphericalMercatorY(maxY));176 172 BBOX bounds900913 = new BBOX( 173 longToSphericalMercatorX(minX), 174 latToSphericalMercatorY(minY), 175 longToSphericalMercatorX(maxX), 176 latToSphericalMercatorY(maxY)); 177 177 178 WMSLayer wmsLayer = null; 178 179 try { 179 wmsLayer = getLayer(name, wmsUrl, b box4326Str,180 b box900913Str, stylesStr);180 wmsLayer = getLayer(name, wmsUrl, bounds4326, 181 bounds900913, stylesStr); 181 182 } catch (GeoWebCacheException gwc) { 182 183 log.error("Error creating " + layer.getName() + ": " … … 194 195 195 196 private WMSLayer getLayer(String name, String wmsurl, 196 String bbox4326Str, String bbox900913Str, String stylesStr)197 BBOX bounds4326, BBOX bounds900913, String stylesStr) 197 198 throws GeoWebCacheException { 198 // Properties props = new Properties(); 199 // props.setProperty(WMSLayer.WMS_URL, wmsurl); 200 // props.setProperty(WMSLayer.WMS_SRS, "EPSG:4326;EPSG:900913"); 201 // props.setProperty(WMSLayer.WMS_BBOX, 202 // bbox4326Str +";"+ bbox900913Str); 203 // props.setProperty(WMSLayer.WMS_STYLES, stylesStr); 204 // props.setProperty(WMSLayer.WMS_TRANSPARENT, "true"); 205 // 206 // if (this.mimeTypes == null || this.mimeTypes.length() == 0) { 207 // props.setProperty(WMSLayer.WMS_MIMETYPES, "image/png,image/jpeg"); 208 // } else { 209 // props.setProperty(WMSLayer.WMS_MIMETYPES, this.mimeTypes); 210 // } 211 // log.debug("Creating new layer " + name + " with properties: " 212 // + props.toString()); 213 // 214 // if (this.metaTiling == null || this.metaTiling.length() == 0) { 215 // props.setProperty(WMSLayer.WMS_METATILING, "3x3"); 216 // } else { 217 // props.setProperty(WMSLayer.WMS_METATILING, metaTiling); 218 // } 219 // 220 // if (this.vendorParameters != null) { 221 // props.setProperty(WMSLayer.WMS_VENDOR_PARAMS, vendorParameters); 222 // } 223 224 //temporary hack 225 226 WMSLayer layer = null; //new WMSLayer(name, props, this.cacheFactory); 227 228 return layer; 199 200 List<Grid> grids = new ArrayList<Grid>(2); 201 grids.add(new Grid(SRS.getEPSG4326(), bounds4326, BBOX.world4326)); 202 grids.add(new Grid(SRS.getEPSG900913(), bounds900913, BBOX.world900913)); 203 204 List<String> mimeFormats = new ArrayList<String>(3); 205 mimeFormats.add("image/png"); 206 mimeFormats.add("image/png8"); 207 mimeFormats.add("image/jpeg"); 208 209 int[] metaWidthHeight = {4,4}; 210 // TODO We're dropping the styles now... 211 return new WMSLayer(name, this.cacheFactory, 212 wmsurl, mimeFormats, grids, metaWidthHeight); 229 213 } 230 214 -
trunk/geowebcache/src/main/java/org/geowebcache/util/XMLConfiguration.java
r317 r320 113 113 result = (WMSLayer) xs.unmarshal(new DomReader( 114 114 (Element) allLayerNodes.item(i))); 115 result. lazyLayerInitialization(this.getCacheFactory());115 result.setCacheFactory(this.cacheFactory); 116 116 layers.put(result.getName(), result); 117 117 } -
trunk/geowebcache/src/main/java/org/geowebcache/util/wms/BBOX.java
r317 r320 32 32 private static double equalityThreshold = 0.03; 33 33 34 public static final BBOX world4326 = 35 new BBOX(-180.0,-90.0,180.0,90.0); 36 37 public static final BBOX world900913 = 38 new BBOX(-20037508.34,-20037508.34,20037508.34,20037508.34); 39 34 40 // minx, miny, maxx, maxy 35 41 public double[] coords = new double[4]; -
trunk/geowebcache/src/main/java/org/geowebcache/util/wms/GridCalculator.java
r221 r320 17 17 package org.geowebcache.util.wms; 18 18 19 import java.util.Arrays; 20 19 21 import org.apache.commons.logging.Log; 20 22 import org.apache.commons.logging.LogFactory; 21 23 import org.geowebcache.GeoWebCacheException; 24 import org.geowebcache.layer.BadTileException; 22 25 import org.geowebcache.service.ServiceException; 23 26 … … 103 106 // " tileWidth: " + tileWidth); 104 107 108 double[] rawNumber = new double[4]; 109 105 110 for (int level = 0; level <= zoomStop; level++) { 106 111 //System.out.println("--- Level "+level+"----"); 112 113 107 114 // Min X 108 gridLevels[level][0] = (int) Math109 .floor((layerBounds.coords[0] - gridBounds.coords[0])110 / tileWidth);115 rawNumber[0] = (layerBounds.coords[0] - gridBounds.coords[0]) / tileWidth; 116 gridLevels[level][0] = (int) Math.floor(rawNumber[0]); 117 111 118 // Min Y 112 gridLevels[level][1] = (int) Math 113 .floor((layerBounds.coords[1] - gridBounds.coords[1]) 114 / tileHeight); 119 rawNumber[1] = (layerBounds.coords[1] - gridBounds.coords[1]) / tileHeight; 120 gridLevels[level][1] = (int) Math.floor(rawNumber[1]); 121 122 // The gridbounds are defined as inclusive, so they actually cover + 1 123 // compared to the bottom left coordinate -> use floor() 124 115 125 // Max X 116 gridLevels[level][2] = (int) Math117 .ceil((layerBounds.coords[2] - gridBounds.coords[0])118 / tileWidth) - 1
