Changeset 338
- Timestamp:
- 08/21/08 15:25:34 (3 months ago)
- Location:
- trunk/geowebcache
- Files:
-
- 21 modified
-
pom.xml (modified) (4 diffs)
-
src/main/java/org/geowebcache/GeoWebCacheDispatcher.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/RESTDispatcher.java (modified) (6 diffs)
-
src/main/java/org/geowebcache/cache/CacheFactory.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/cache/CacheKeyFactory.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/cache/file/FileCache.java (modified) (1 diff)
-
src/main/java/org/geowebcache/layer/GridCalculator.java (modified) (4 diffs)
-
src/main/java/org/geowebcache/layer/TileLayer.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/layer/TileLayerResource.java (modified) (9 diffs)
-
src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java (modified) (4 diffs)
-
src/main/java/org/geowebcache/layer/wms/WMSLayer.java (modified) (8 diffs)
-
src/main/java/org/geowebcache/layer/wms/WMSMetaTile.java (modified) (1 diff)
-
src/main/java/org/geowebcache/seeder/SeedResource.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/service/Service.java (modified) (2 diffs)
-
src/main/java/org/geowebcache/service/kml/KMLService.java (modified) (1 diff)
-
src/main/java/org/geowebcache/tile/Tile.java (modified) (1 diff)
-
src/main/java/org/geowebcache/util/GetCapabilitiesConfiguration.java (modified) (1 diff)
-
src/main/java/org/geowebcache/util/XMLConfiguration.java (modified) (3 diffs)
-
src/main/resources/geowebcache.xml (modified) (1 diff)
-
src/main/webapp/WEB-INF/geowebcache-servlet.xml (modified) (3 diffs)
-
src/test/java/org/geowebcache/layer/wms/MetaTileTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/geowebcache/pom.xml
r328 r338 180 180 <version>${spring.version}</version> 181 181 </dependency> 182 <!-- This is for Acegi --> 183 <dependency> 184 <groupId>org.springframework</groupId> 185 <artifactId>spring-jdbc</artifactId> 186 <version>${spring.version}</version> 187 </dependency> 188 189 190 182 191 183 192 <!-- Jetty starter dependencies --> … … 271 280 <artifactId>acegi-security</artifactId> 272 281 <version>${acegi.version}</version> 273 </dependency> 274 282 <exclusions> 283 <exclusion> 284 <groupId>org.springframework</groupId> 285 <artifactId>spring-remoting</artifactId> 286 </exclusion> 287 <exclusion> 288 <groupId>org.springframework</groupId> 289 <artifactId>spring-jdbc</artifactId> 290 </exclusion> 291 <exclusion> 292 <groupId>org.springframework</groupId> 293 <artifactId>spring-support</artifactId> 294 </exclusion> 295 </exclusions> 296 </dependency> 297 275 298 <dependency> 276 299 <groupId>org.codehaus.jettison</groupId> … … 321 344 </plugin> 322 345 323 324 < !--plugin>346 <!-- 347 <plugin> 325 348 <artifactId>maven-war-plugin</artifactId> 326 349 <executions> … … 332 355 </execution> 333 356 </executions> 334 </plugin -->335 357 </plugin> 358 --> 336 359 <plugin> 337 360 <artifactId>maven-source-plugin</artifactId> -
trunk/geowebcache/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java
r337 r338 203 203 + " given prefix " + servletPrefix); 204 204 } 205 retStrs[0] = new String(splitStr[3]);205 retStrs[0] = splitStr[3]; 206 206 if(splitStr.length > 4) { 207 retStrs[1] = new String(splitStr[4]);207 retStrs[1] = splitStr[4]; 208 208 } 209 209 } else { … … 212 212 } 213 213 if (splitStr.length == 3) { 214 retStrs[0] = new String(splitStr[2]);214 retStrs[0] = splitStr[2]; 215 215 } else { 216 retStrs[0] = new String(splitStr[2]);217 retStrs[1] = new String(splitStr[3]);216 retStrs[0] = splitStr[2]; 217 retStrs[1] = splitStr[3]; 218 218 } 219 219 } -
trunk/geowebcache/src/main/java/org/geowebcache/RESTDispatcher.java
r335 r338 29 29 30 30 import org.geowebcache.layer.TileLayer; 31 import org.geowebcache.layer.TileLayerDispatcher; 31 32 import org.geowebcache.layer.TileLayerResource; 32 33 import org.geowebcache.util.XMLConfiguration; … … 54 55 private static final int THREAD_NUMBER = 10; 55 56 56 private static XMLConfiguration config; 57 private static XMLConfiguration xmlConfig; 58 59 private static TileLayerDispatcher tlDispatcher; 57 60 58 61 private static ThreadPoolExecutor tpe = … … 61 64 private static Map<String, TileLayer> layers = null; 62 65 63 64 66 ServletConverter myConverter; 65 67 66 68 private Router myRouter; 67 69 68 private static Log log = LogFactory 69 .getLog(org.geowebcache.RESTDispatcher.class); 70 private static Log log = LogFactory.getLog(org.geowebcache.RESTDispatcher.class); 70 71 71 72 /** … … 74 75 * @param c - an XMLConfiguration 75 76 */ 76 public RESTDispatcher( XMLConfiguration c) {77 public RESTDispatcher(TileLayerDispatcher tlDispatcher, XMLConfiguration xmlConfig) { 77 78 super(); 78 79 setSupportedMethods(new String[] { 79 80 METHOD_GET, METHOD_POST, METHOD_DELETE }); 80 81 81 RESTDispatcher.config = c; 82 RESTDispatcher.xmlConfig = xmlConfig; 83 RESTDispatcher.tlDispatcher = tlDispatcher; 82 84 83 85 // constructor arguments(in order) int corePoolSize, int maximumPoolSize, … … 111 113 112 114 try { 113 layers = (HashMap<String, TileLayer>) config.getTileLayers(); 115 //layers = (HashMap<String, TileLayer>) xmlConfig.getTileLayers(); 116 layers = (HashMap<String, TileLayer>) tlDispatcher.getLayers(); 114 117 myConverter.service(request, response); 115 } 116 117 catch (GeoWebCacheException gwce) { 118 System.out.println(gwce.getMessage()); 118 //} 119 //catch (GeoWebCacheException gwce) { 120 // System.out.println(gwce.getMessage()); 119 121 } catch (ServletException se) { 120 122 System.out.println(se.getMessage()); … … 155 157 */ 156 158 public static XMLConfiguration getConfig() { 157 return config;159 return xmlConfig; 158 160 } 159 161 -
trunk/geowebcache/src/main/java/org/geowebcache/cache/CacheFactory.java
r204 r338 21 21 import java.util.Iterator; 22 22 import java.util.Map; 23 import java.util.Map.Entry; 23 24 24 25 import org.apache.commons.logging.Log; … … 84 85 */ 85 86 private void loadCaches() { 86 Map cacheBeans = context.getBeansOfType(Cache.class);87 Iterator< String> beanIter = cacheBeans.keySet().iterator();88 87 Map<String,Cache> cacheBeans = context.getBeansOfType(Cache.class); 88 Iterator<Entry<String,Cache>> beanIter = cacheBeans.entrySet().iterator(); 89 89 90 caches = new HashMap<String,Cache>(); 91 90 92 while(beanIter.hasNext()) { 91 String beanId = beanIter.next(); 92 Cache aCache = (Cache) cacheBeans.get(beanId); 93 caches.put(beanId, aCache); 94 log.debug("Added bean for " + beanId); 93 Entry<String,Cache> entry = beanIter.next(); 94 caches.put(entry.getKey(), entry.getValue()); 95 log.debug("Added cache bean for " + entry.getValue().getClass().toString()); 95 96 } 96 97 } -
trunk/geowebcache/src/main/java/org/geowebcache/cache/CacheKeyFactory.java
r203 r338 21 21 import java.util.Iterator; 22 22 import java.util.Map; 23 import java.util.Map.Entry; 23 24 24 25 import org.apache.commons.logging.Log; … … 49 50 50 51 private void loadCacheKeys() { 51 Map cacheBeans = context.getBeansOfType(CacheKey.class);52 Iterator beanIter = cacheBeans.keySet().iterator();52 Map<String,CacheKey> cacheBeans = context.getBeansOfType(CacheKey.class); 53 Iterator<Entry<String,CacheKey>> beanIter = cacheBeans.entrySet().iterator(); 53 54 54 55 cacheKeys = new HashMap<String,CacheKey>(); 56 55 57 while(beanIter.hasNext()) { 56 String beanId = (String)beanIter.next();57 CacheKey aCacheKey = (CacheKey) cacheBeans.get(beanId);58 cacheKeys.put(beanId, aCacheKey);58 Entry<String,CacheKey> entry = beanIter.next(); 59 cacheKeys.put(entry.getKey(), entry.getValue()); 60 log.debug("Added cache key bean for " + entry.getValue().getClass().toString()); 59 61 } 60 62 } -
trunk/geowebcache/src/main/java/org/geowebcache/cache/file/FileCache.java
r317 r338 204 204 for (int j = 0; j < typeStrs.length && defaultCachePrefix == null; j++) { 205 205 String value = null; 206 String varStr = new String(varStrs[i]);206 String varStr = varStrs[i]; 207 207 String typeStr = typeStrs[j]; 208 208 -
trunk/geowebcache/src/main/java/org/geowebcache/layer/GridCalculator.java
r337 r338 26 26 27 27 // We may want to change this later 28 p rivatestatic final int TILEPIXELS = 256;28 public static final int TILEPIXELS = 256; 29 29 30 30 //private BBOX gridBounds = null; 31 31 private Grid grid; 32 32 33 public final static double[] RESOLUTIONS4326 = 33 // The following are created to save memory. 34 // Note that they can be modified by external code -> not 100% safe! 35 protected final static double[] RESOLUTIONS4326 = 34 36 GridCalculator.getResolutionArray(180.0, TILEPIXELS, 26); 35 37 36 p ublicfinal static double[] RESOLUTIONS900913 =38 protected final static double[] RESOLUTIONS900913 = 37 39 GridCalculator.getResolutionArray(20037508.34*2,TILEPIXELS, 26); 38 40 … … 248 250 249 251 // Get the bounds 250 BBOX layerBounds = grid.bounds;252 //BBOX layerBounds = grid.bounds; 251 253 BBOX gridBounds = grid.gridBounds; 252 254 … … 499 501 500 502 while (low <= high) { 501 int mid = (low + high) / 2;503 int mid = (low + high) >>> 1; 502 504 503 505 if(resolutions[mid] > reqUpper) { … … 528 530 } 529 531 532 public static double[] get900913Resolutions() { 533 return GridCalculator.RESOLUTIONS900913; 534 } 535 536 public static double[] get4326Resolutions() { 537 return GridCalculator.RESOLUTIONS4326; 538 } 539 530 540 } -
trunk/geowebcache/src/main/java/org/geowebcache/layer/TileLayer.java
r337 r338 42 42 43 43 // Styles? 44 45 // Metatiling?46 44 47 45 /** … … 203 201 * @return the array of supported projections 204 202 */ 205 public SRS[] getProjections() {206 return (SRS[]) this.grids.keySet().toArray();207 }203 //public SRS[] getProjections() { 204 // return (SRS[]) this.grids.keySet().toArray(); 205 //} 208 206 209 207 -
trunk/geowebcache/src/main/java/org/geowebcache/layer/TileLayerResource.java
r335 r338 23 23 import org.apache.commons.logging.LogFactory; 24 24 25 import com.thoughtworks.xstream.*; 25 //import com.thoughtworks.xstream.*; 26 import com.thoughtworks.xstream.XStream; 26 27 import com.thoughtworks.xstream.io.HierarchicalStreamDriver; 27 28 import com.thoughtworks.xstream.io.HierarchicalStreamReader; … … 35 36 import org.json.JSONException; 36 37 import org.restlet.ext.json.JsonRepresentation; 38 import org.springframework.beans.BeansException; 39 import org.springframework.context.ApplicationContext; 40 import org.springframework.context.ApplicationContextAware; 41 import org.springframework.web.context.WebApplicationContext; 37 42 38 43 import org.geowebcache.layer.wms.WMSLayer; 44 import org.geowebcache.util.XMLConfiguration; 39 45 import org.geowebcache.GeoWebCacheException; 40 46 import org.geowebcache.RESTDispatcher; … … 53 59 public class TileLayerResource extends Resource { 54 60 private TileLayer currentLayer = null; 55 56 private static Log log = LogFactory 57 .getLog(org.geowebcache.layer.TileLayerResource.class); 61 62 private static Log log = LogFactory.getLog(org.geowebcache.layer.TileLayerResource.class); 58 63 59 64 /** … … 126 131 */ 127 132 public DomRepresentation getDomRepresentationAsListOfLayers() { 128 XStream xs = RESTDispatcher.getConfig().getConfiguredXStream(new XStream());133 XStream xs = XMLConfiguration.getConfiguredXStream(new XStream()); 129 134 130 135 StringBuffer buf = new StringBuffer(); … … 179 184 */ 180 185 public DomRepresentation getXMLRepresentation(TileLayer layer) { 181 XStream xs = RESTDispatcher.getConfig().getConfiguredXStream(new XStream());186 XStream xs = XMLConfiguration.getConfiguredXStream(new XStream()); 182 187 String xmlText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + xs.toXML(layer); 183 188 … … 211 216 public JsonRepresentation getJsonRepresentation(TileLayer layer) { 212 217 JsonRepresentation rep = null; 213 try { 214 XStream xs = RESTDispatcher.getConfig().getConfiguredXStream(new XStream(new JsonHierarchicalStreamDriver())); 218 try { 219 XStream xs = XMLConfiguration.getConfiguredXStream( 220 new XStream(new JsonHierarchicalStreamDriver())); 215 221 JSONObject obj = new JSONObject(xs.toXML(layer)); 216 222 rep = new JsonRepresentation(obj); … … 231 237 + getRequest().getHostRef().getHostIdentifier()); 232 238 try{ 233 String xmlText = entity.getText(); 234 XStream xs = RESTDispatcher.getConfig().getConfiguredXStream(new XStream(new DomDriver())); 239 String xmlText = entity.getText(); 240 XStream xs = XMLConfiguration.getConfiguredXStream(new XStream(new DomDriver())); 241 //XStream xs = RESTDispatcher.getConfig().getConfiguredXStream(); 235 242 TileLayer tileLayer = null; 236 243 if(entity.getMediaType().equals(MediaType.APPLICATION_XML)){ … … 239 246 240 247 /** 241 * deserializing a jsonstring is more complicated. XStream does not natively242 * support it. Rather it uses a JettisonMappedXmlDriver to convert to intermediate xml248 * Deserializing a JSON string is more complicated. XStream does not natively 249 * support it. Rather it uses a JettisonMappedXmlDriver to convert to intermediate XML 243 250 * and then deserializes that into the desired object. At this time, there is a known issue 244 * with the Jettison driver involving elements that come after an array in the jsonstring.251 * with the Jettison driver involving elements that come after an array in the JSON string. 245 252 * 246 253 * http://jira.codehaus.org/browse/JETTISON-48 247 254 * 248 * The code below is a hack: it treats the json string as text, then converts it to the intermediate 249 * xml and then deserializes that into the tileLayer object. 250 * 251 * 255 * The code below is a hack: it treats the json string as text, then converts it to the 256 * intermediate XML and then deserializes that into the tileLayer object. 252 257 */ 253 258 else if(entity.getMediaType().equals(MediaType.APPLICATION_JSON)){ … … 294 299 } 295 300 if (trySave) { 296 log.info("Overwrote layer : " + currentLayer.getName() + " with new layer : " + tileLayer.getName()); 301 log.info("Overwrote layer : " + currentLayer.getName() 302 + " with new layer : " + tileLayer.getName()); 297 303 getResponse().setStatus(Status.SUCCESS_OK); 298 304 } else { -
trunk/geowebcache/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java
r337 r338 29 29 import org.geowebcache.GeoWebCacheException; 30 30 import org.geowebcache.layer.Grid; 31 import org.geowebcache.layer.GridCalculator; 31 32 import org.geowebcache.layer.TileResponseReceiver; 32 33 import org.geowebcache.mime.ErrorMime; … … 75 76 wmsparams.setFormat(tile.getMimeType().getFormat()); 76 77 wmsparams.setSrs(tile.getSRS()); 77 wmsparams.setWidth( layer.getWidth());78 wmsparams.setHeight( layer.getHeight());78 wmsparams.setWidth(GridCalculator.TILEPIXELS); 79 wmsparams.setHeight(GridCalculator.TILEPIXELS); 79 80 Grid grid = layer.getGrid(tile.getSRS()); 80 81 … … 183 184 byte[] error = new byte[2048]; 184 185 try { 185 wmsBackendCon.getInputStream().read(error); 186 int readLength = 0; 187 int readAccu = 0; 188 while(readLength > -1 && readAccu < error.length) { 189 int left = error.length - readAccu; 190 readLength = wmsBackendCon.getInputStream().read(error,readAccu, left); 191 readAccu += readLength; 192 } 186 193 } catch (IOException ioe) { 187 194 // Do nothing … … 211 218 int readLength = 0; 212 219 int readAccu = 0; 213 int left = responseLength;214 while(readLength > -1 && left > 0) {220 while(readLength > -1 && readAccu < responseLength) { 221 int left = responseLength - readAccu; 215 222 readLength = wmsBackendCon.getInputStream().read(ret,readAccu,left); 216 223 readAccu += readLength; 217 left -= readLength;218 224 } 219 225 if (readAccu != responseLength) { 220 226 tileRespRecv.setError(); 221 227 throw new GeoWebCacheException( 222 "Responseheader advertised " 223 + responseLength 224 + " bytes, but only received " 225 + readLength + " from " 226 + wmsBackendUrl.toString()); 228 "Responseheader advertised "+ responseLength 229 + " bytes, but only received " + readLength 230 + " from " + wmsBackendUrl.toString()); 227 231 } 228 232 } -
trunk/geowebcache/src/main/java/org/geowebcache/layer/wms/WMSLayer.java
r337 r338 39 39 import org.geowebcache.cache.CacheFactory; 40 40 import org.geowebcache.cache.CacheKey; 41 import org.geowebcache.layer.BadTileException;42 41 import org.geowebcache.layer.GridLocObj; 43 42 import org.geowebcache.layer.SRS; … … 48 47 import org.geowebcache.mime.MimeException; 49 48 import org.geowebcache.mime.MimeType; 50 import org.geowebcache.service.ServiceException;51 49 import org.geowebcache.service.wms.WMSParameters; 52 50 import org.geowebcache.tile.Tile; … … 64 62 private String errormime; 65 63 66 private int width;67 68 private int height;64 //private int width; 65 66 //private int height; 69 67 70 68 private String version; … … 74 72 private boolean transparent; 75 73 76 private boolean debugheaders;74 //private boolean debugheaders; 77 75 78 76 //protected transient GridCalculator[] gridCalc; … … 200 198 log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 201 199 curWmsURL = 0; 200 201 // The following is currently hardcoded in the grid objects 202 202 //zoomStart = 0; 203 203 //zoomStop = 20; 204 //width = 256; 205 //height = 256; 206 204 207 request = "GetMap"; 205 208 errormime = ErrorMime.vnd_ogc_se_inimage.getMimeType(); 206 width = 256;207 height = 256;208 209 version = "1.1.0"; 209 210 transparent = true; … … 338 339 } 339 340 340 metaTile.createTiles( width, height, useJAI);341 metaTile.createTiles(GridCalculator.TILEPIXELS, GridCalculator.TILEPIXELS, useJAI); 341 342 342 343 int[][] gridPositions = metaTile.getTilesGridPositions(); … … 901 902 } 902 903 903 public int getWidth() {904 return this.width;905 }906 907 public int getHeight() {908 return this.height;909 }904 //public int getWidth() { 905 // return this.width; 906 //} 907 908 <
