Changeset 371
- Timestamp:
- 09/03/08 14:02:44 (4 months ago)
- Location:
- trunk/geowebcache/src/main/java/org/geowebcache/service/kml
- Files:
-
- 2 modified
-
KMLDebugGridLayer.java (modified) (16 diffs)
-
KMLService.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/geowebcache/src/main/java/org/geowebcache/service/kml/KMLDebugGridLayer.java
r370 r371 18 18 19 19 import java.io.IOException; 20 import java.util.Hashtable; 20 21 import java.util.List; 21 22 import java.util.Properties; 22 import java.util.Vector;23 23 24 24 import javax.servlet.http.HttpServletResponse; 25 25 26 import org.apache.commons.logging.Log;27 import org.apache.commons.logging.LogFactory;28 26 import org.geowebcache.GeoWebCacheException; 29 27 import org.geowebcache.cache.Cache; … … 32 30 import org.geowebcache.cache.CacheKey; 33 31 import org.geowebcache.layer.BadTileException; 32 import org.geowebcache.layer.Grid; 34 33 import org.geowebcache.layer.SRS; 35 34 import org.geowebcache.layer.TileLayer; 36 35 import org.geowebcache.mime.MimeType; 37 import org.geowebcache.mime.XMLMime;38 36 import org.geowebcache.tile.Tile; 39 37 import org.geowebcache.util.wms.BBOX; … … 52 50 public static final int IS_KMZ = 100; 53 51 54 private static Log log = LogFactory.getLog(org.geowebcache.service.kml.KMLDebugGridLayer.class);52 //private static Log log = LogFactory.getLog(org.geowebcache.service.kml.KMLDebugGridLayer.class); 55 53 56 54 private static KMLDebugGridLayer instance; … … 61 59 public void lazyLayerInitialization(CacheFactory c){ 62 60 //blah 61 63 62 } 64 63 … … 66 65 67 66 private KMLDebugGridLayer() { 68 67 super.grids = new Hashtable<SRS,Grid>(); 68 grids.put(SRS.getEPSG4326(), new Grid(SRS.getEPSG4326(),BBOX.WORLD4326, BBOX.WORLD4326, null)); 69 69 } 70 70 … … 77 77 78 78 public void acquireLayerLock() { 79 // TODO Auto-generated method stub80 //log.warn("acquireLayerLock()");81 79 } 82 80 83 81 public void destroy() { 84 // TODO Auto-generated method stub85 //log.warn("destroy()");86 82 } 87 83 88 84 public Tile doNonMetatilingRequest(Tile tile) throws GeoWebCacheException { 89 // TODO Auto-generated method stub 90 //log.warn("doNonMetatilingRequest(int[] gridLoc, int idx,String formatStr)"); 91 return null; 92 } 93 94 public BBOX getBboxForGridLoc(int srsIdx, int[] gridLoc) { 95 // TODO Auto-generated method stub 96 //log.warn("done - getBboxForGridLoc(int srsIdx, int[] gridLoc)"); 97 98 double tileWidth = 180.0 / Math.pow(2, gridLoc[2]); 99 100 BBOX bbox = new BBOX( 101 -180.0 + tileWidth * gridLoc[0], 102 -90.0 + tileWidth * gridLoc[1], 103 -180.0 + tileWidth * (gridLoc[0] + 1), 104 -90.0 + tileWidth * (gridLoc[1] + 1)); 105 106 return bbox; 107 } 108 109 public BBOX getBounds(int srsIdx) { 110 // TODO Auto-generated method stub 111 //log.warn("done - getBounds"); 85 return null; 86 } 87 88 public BBOX getBounds(SRS srs) { 112 89 return new BBOX(-180.0, -90.0, 180.0, 90.0); 113 90 } 114 91 115 92 public Cache getCache() { 116 // TODO Auto-generated method stub117 //log.warn("getCache");118 93 return null; 119 94 } 120 95 121 96 public CacheKey getCacheKey() { 122 // TODO Auto-generated method stub123 //log.warn("done - getCacheKey");124 97 return this; 125 98 } 126 99 127 100 public String getCachePrefix() { 128 // TODO Auto-generated method stub129 //log.warn("done - getCachePrefix");130 return null;131 }132 133 public int[][] getCoveredGridLevels(int srsIdx, BBOX bounds) {134 // TODO Auto-generated method stub135 //log.warn("getCoveredGridLevels(int srsIdx, BBOX bounds)");136 101 return null; 137 102 } 138 103 139 104 public MimeType getDefaultMimeType() { 140 // TODO Auto-generated method stub141 //log.warn("getDefaultMimeType()");142 return null;143 }144 145 public int[] getGridLocForBounds(int srsIdx, BBOX bounds)146 throws BadTileException {147 // TODO Auto-generated method stub148 //log.warn("getGridLocForBounds(int srsIdx, BBOX bounds)");149 105 return null; 150 106 } 151 107 152 108 public int[] getMetaTilingFactors() { 153 // TODO Auto-generated method stub154 //log.warn("getMetaTilingFactors()");155 109 return null; 156 110 } 157 111 158 112 public List <MimeType> getMimeTypes() { 159 // TODO Auto-generated method stub160 //log.warn("getMimeTypes()");161 113 return null; 162 114 } 163 115 164 116 public String getName() { 165 // TODO Auto-generated method stub166 //log.warn("done - getName()");167 117 return "Debug grid"; 168 118 } 169 119 170 120 public SRS[] getProjections() { 171 // TODO Auto-generated method stub172 //log.warn("done - getProjections()");173 174 121 SRS[] srsList = { SRS.getEPSG4326() }; 175 122 return srsList; … … 177 124 178 125 public double[] getResolutions(int srsIdx) { 179 // TODO Auto-generated method stub180 //log.warn("getResolutions()");181 126 return null; 182 127 } 183 128 184 129 public Tile getTile(Tile tile) 185 throws GeoWebCacheException, IOException { 186 // TODO Auto-generated method stub 187 //log.warn("getResponse(TileRequest tileRequest,ServiceRequest servReq, HttpServletResponse response)"); 188 130 throws GeoWebCacheException, IOException { 189 131 int[] gridLoc = tile.getTileIndex(); 190 132 191 BBOX bbox = this.getBboxForGridLoc( 0, gridLoc);133 BBOX bbox = this.getBboxForGridLoc(SRS.getEPSG4326(), gridLoc); 192 134 193 135 String data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" … … 226 168 } 227 169 228 public int getSRSIndex(SRS reqSRS) {229 // TODO Auto-generated method stub230 //log.warn("done - getSRSIndex");231 return 0;232 }233 234 170 public String getStyles() { 235 // TODO Auto-generated method stub 236 //log.warn("getStyles()"); 237 return null; 238 } 239 240 public int[][] getZoomInGridLoc(int srsIdx, int[] gridLoc) { 171 return null; 172 } 173 174 public int[][] getZoomInGridLoc(SRS srs, int[] gridLoc) { 241 175 //log.warn("done - getZoomInGridLoc(srsIdx, gridLoc)"); 242 176 … … 265 199 266 200 public int getZoomStart() { 267 // TODO Auto-generated method stub268 //log.warn("getZoomStart()");269 201 return 0; 270 202 } 271 203 272 204 public int getZoomStop() { 273 // TODO Auto-generated method stub274 //log.warn("getZoomStop()");275 205 return 25; 276 206 } 277 207 278 public int[] getZoomedOutGridLoc(int srsIdx) {279 // TODO Auto-generated method stub280 //log.warn("done - getZoomedOutGridLoc");281 int[] zoomedOutGridLoc = new int[3];282 zoomedOutGridLoc[0] = -1;283 zoomedOutGridLoc[1] = -1;284 zoomedOutGridLoc[2] = -1;285 286 return zoomedOutGridLoc;287 }288 289 208 public Boolean initialize() { 290 // TODO Auto-generated method stub291 //log.warn("initialize()");292 209 return true; 293 210 } 294 211 295 212 public Boolean isInitialized() { 296 // TODO Auto-generated method stub297 //log.warn("isInitialized()");298 213 return true; 299 214 } … … 301 216 public void putTile(Tile tile, Object ck, int[] gridLoc) 302 217 throws CacheException { 303 // TODO Auto-generated method stub304 //log.warn("putTile");305 218 } 306 219 307 220 public void releaseLayerLock() { 308 // TODO Auto-generated method stub309 //log.warn("releaseLayerLock()");310 221 } 311 222 312 223 public void setExpirationHeader(HttpServletResponse response) { 313 // TODO Auto-generated method stub314 //log.warn("setExpirationHeader");315 224 } 316 225 317 226 public String supportsBbox(SRS srs, BBOX bounds) 318 227 throws GeoWebCacheException { 319 // TODO Auto-generated method stub320 //log.warn("supportsBbox");321 228 return null; 322 229 } 323 230 324 231 public boolean supportsFormat(String formatStr) throws GeoWebCacheException { 325 // TODO Auto-generated method stub326 //log.warn("supportsFormat");327 232 return false; 328 233 } 329 234 330 235 public boolean supportsSRS(SRS srs) throws GeoWebCacheException { 331 // TODO Auto-generated method stub 332 //log.warn("supportsProjection"); 333 return false; 334 } 335 336 // Returns the KML for the tile, but not a cached KMZ overlay 337 // public boolean tryCacheFetch(Tile tile) { 338 // // TODO Auto-generated method stub 339 // //log.warn("done - tryCacheFetch"); 340 // 341 // Vector<Integer> lst = (Vector<Integer>) tile; 342 // 343 // int kmz = lst.get(0); 344 // 345 // if(kmz != KMLDebugGridLayer.IS_KMZ) { 346 // return true; 347 // } else { 348 // System.out.println("OOPS"); 349 // } 350 // 351 // return false; 352 // } 236 return false; 237 } 353 238 354 239 public boolean get(Tile tile, long ttl) throws CacheException { 355 // TODO Auto-generated method stub 240 356 241 return true; 357 242 } 358 243 359 244 public String getDefaultKeyBeanId() { 360 // TODO Auto-generated method stub 245 361 246 return null; 362 247 } 363 248 364 249 public String getDefaultPrefix(String param) throws CacheException { 365 // TODO Auto-generated method stub 250 366 251 return null; 367 252 } … … 369 254 370 255 public void init(Properties props) throws CacheException { 371 // TODO Auto-generated method stub 256 372 257 373 258 } 374 259 375 260 public boolean remove(Tile tile) throws CacheException { 376 // TODO Auto-generated method stub 261 377 262 return false; 378 263 } 379 264 380 265 public void removeAll() throws CacheException { 381 // TODO Auto-generated method stub 266 382 267 383 268 } … … 385 270 /** Cache interface **/ 386 271 public void set(Object key, Object obj, long ttl) throws CacheException { 387 // TODO Auto-generated method stub 272 388 273 389 274 } 390 275 391 276 public void setDefaultKeyBeanId(String defaultKeyBeanId) { 392 // TODO Auto-generated method stub 277 393 278 394 279 } 395 280 396 281 public void setUp(String cachePrefix) throws CacheException { 397 // TODO Auto-generated method stub 282 398 283 399 284 } … … 401 286 public void setApplicationContext(ApplicationContext arg0) 402 287 throws BeansException { 403 // TODO Auto-generated method stub 288 404 289 405 290 } … … 421 306 422 307 public int getType() { 423 // TODO Auto-generated method stub 308 424 309 return 0; 425 310 } 426 311 427 312 public void init() { 428 // TODO Auto-generated method stub 313 429 314 430 315 } 431 316 432 317 public void putTile(Tile tile) throws CacheException { 433 // TODO Auto-generated method stub 318 434 319 435 320 } 436 321 437 322 public void set(Tile tile, long ttl) throws CacheException { 438 // TODO Auto-generated method stub 323 439 324 440 325 } 441 326 442 327 public boolean tryCacheFetch(Tile tile) { 443 // TODO Auto-generated method stub 328 444 329 return false; 445 330 } … … 447 332 public boolean get(CacheKey keyProto, Tile tile, long ttl) 448 333 throws CacheException, GeoWebCacheException { 449 // TODO Auto-generated method stub 334 450 335 return false; 451 336 } 452 337 453 338 public boolean remove(CacheKey keyProto, Tile tile) throws CacheException { 454 // TODO Auto-generated method stub455 339 return false; 456 340 } … … 458 342 public void set(CacheKey keyProto, Tile tile, long ttl) 459 343 throws CacheException, GeoWebCacheException { 460 // TODO Auto-generated method stub461 462 344 } 463 345 464 346 public Object createKey(Tile tile) { 465 // TODO Auto-generated method stub 466 return null; 467 } 468 469 470 471 @Override 347 return null; 348 } 349 472 350 public void setCacheFactory(CacheFactory cacheFactory) { 473 // TODO Auto-generated method stub 474 475 } 476 477 478 479 @Override 351 } 352 480 353 public BBOX getBboxForGridLoc(SRS srs, int[] gridLoc) { 481 // TODO Auto-generated method stub 482 return null; 483 } 484 485 486 487 @Override 354 double tileWidth = 180.0 / Math.pow(2, gridLoc[2]); 355 356 BBOX bbox = new BBOX( 357 -180.0 + tileWidth * gridLoc[0], 358 -90.0 + tileWidth * gridLoc[1], 359 -180.0 + tileWidth * (gridLoc[0] + 1), 360 -90.0 + tileWidth * (gridLoc[1] + 1)); 361 362 return bbox; 363 } 364 488 365 public int[][] getCoveredGridLevels(SRS srs, BBOX bounds) { 489 // TODO Auto-generated method stub 490 return null; 491 } 492 493 494 495 @Override 366 return null; 367 } 368 496 369 public int[] getGridLocForBounds(SRS srs, BBOX bounds) 497 370 throws BadTileException { 498 // TODO Auto-generated method stub 499 return null; 500 } 501 502 503 504 @Override 505 public int[][] getZoomInGridLoc(SRS srs, int[] gridLoc) { 506 // TODO Auto-generated method stub 507 return null; 508 } 509 510 511 512 @Override 371 return null; 372 } 373 513 374 public int[] getZoomedOutGridLoc(SRS srs) { 514 // TODO Auto-generated method stub 515 return null; 516 } 517 518 @Override 375 // log.warn("done - getZoomedOutGridLoc"); 376 int[] zoomedOutGridLoc = new int[3]; 377 zoomedOutGridLoc[0] = -1; 378 zoomedOutGridLoc[1] = -1; 379 zoomedOutGridLoc[2] = -1; 380 381 return zoomedOutGridLoc; 382 383 } 384 519 385 public void seedTile(Tile tile, boolean tryCache) 520 386 throws GeoWebCacheException, IOException { 521 // TODO Auto-generated method stub522 387 523 388 } -
trunk/geowebcache/src/main/java/org/geowebcache/service/kml/KMLService.java
r370 r371 19 19 import java.io.IOException; 20 20 import java.io.OutputStream; 21 import java.util.Arrays; 21 22 22 23 import javax.servlet.http.HttpServletRequest; … … 147 148 if(tile.getLayerId().equalsIgnoreCase(KMLDebugGridLayer.LAYERNAME)) { 148 149 tile.setHint(HINT_DEBUGGRID); 149 } 150 150 tile.setRequestHandler(Tile.RequestHandler.SERVICE); 151 } 152 153 //System.out.println(Arrays.toString(tile.getTileIndex()) + " " + tile.servletReq.getHeader("referer")); 151 154 return tile; 152 155 } … … 171 174 } 172 175 tile.setTileLayer(layer); 173 174 176 175 177 //TODO this needs to be done more nicely … … 406 408 tile.getMimeType() instanceof ImageMime)); 407 409 410 buf.append("\n<!-- Network links to subtiles -->\n"); 408 411 // 2) Network links, only to tiles within bounds 409 412 int[][] linkGridLocs = tileLayer.getZoomInGridLoc(srs, gridLoc); … … 421 424 linkGridLocs[i]); 422 425 423 // Always use absolute URLs for these424 String gridLocUrl = tile.getUrlPrefix() + gridLocString(linkGridLocs[i])425 +"." +tile.getMimeType().getFileExtension()+ "." + tile.getWrapperMimeType().getFileExtension();426 427 426 String gridLocStr = gridLocString(linkGridLocs[i]); 428 427 429 buf.append(createNetworkLinkElement(tileLayer, linkBbox, gridLocUrl, gridLocStr)); 428 // Always use absolute URLs for these 429 String gridLocUrl = tile.getUrlPrefix() 430 + gridLocStr +"." +tile.getMimeType().getFileExtension() 431 + "." + tile.getWrapperMimeType().getFileExtension(); 432 433 buf.append(createNetworkLinkElement(tileLayer, linkBbox, gridLocUrl, gridLocStr,-1)); 430 434 //moreData++; 431 435 } 432 436 } 433 434 // 3) Overlay, should be relative 437 438 // The following was a nice try, unfortunately Google Earth appears to go to 100% CPU etc... 439 // and the pane on the left hand side with the tile tree doesn't really know what to do 440 // with new parents.... 441 // 442 // buf.append("\n<!-- Network link to parent or sibling tile -->\n"); 443 // // 4) Add link to parent or sibling tile 444 // // Just in case someone comes in via a search result 445 // // Sibling = other hemisphere, when at zoom level 0 446 // if(gridLoc[2] >= 0) { 447 // int z = gridLoc[2] - 1; 448 // int x = Math.min((int) Math.round((gridLoc[0] -0.01) / 2.0), 2*(1 << z) - 1); 449 // int y = Math.min((int) Math.round((gridLoc[1] -0.01) / 2.0), (1 << z) - 1); 450 // 451 // 452 // // Override if we're linking to the sibling top tile 453 // if(gridLoc[2] == 0 && tile.getLayer().getZoomedOutGridLoc(srs)[2] == -1) { 454 // if(gridLoc[0] == 0) { 455 // x = 1; 456 // } else { 457 // x = 0; 458 // } 459 // y = 0; 460 // z = 0; 461 // } 462 // 463 // int[] parentGridLoc = {x,y,z}; 464 // 465 // BBOX linkBbox = tileLayer.getBboxForGridLoc(srs,parentGridLoc); 466 // 467 // // Absolute URLs for these 468 // String gridLocStr = gridLocString(parentGridLoc); 469 // 470 // String gridLocUrl = tile.getUrlPrefix() 471 // + gridLocStr +"." +tile.getMimeType().getFileExtension() 472 // + "." + tile.getWrapperMimeType().getFileExtension(); 473 // 474 // buf.append(createNetworkLinkElement(tileLayer, linkBbox, gridLocUrl, gridLocStr, 385)); 475 // } 476 477 buf.append("\n<!-- Network link to actual content -->\n"); 478 // 5) Overlay, should be relative 435 479 if (tile.getMimeType() instanceof ImageMime) { 436 480 buf.append( … … 442 486 String gridLocStr = gridLocString(gridLoc); 443 487 String gridLocUrl = gridLocStr + "." + tile.getMimeType().getFileExtension(); 488 444 489 if(isPackaged) { 445 490 gridLocUrl = "data_" + gridLocUrl; 446 491 } 447 buf.append(createNetworkLinkElement(tileLayer, bbox, gridLocUrl, gridLocStr)); 492 493 int maxLodPixels = -1; 494 if(tile.getLayer() instanceof KMLDebugGridLayer) { 495 maxLodPixels = 385; 496 } 497 498 buf.append(createNetworkLinkElement(tileLayer, bbox, gridLocUrl, gridLocStr, maxLodPixels)); 448 499 } 449 500 … … 489 540 */ 490 541 private static String createNetworkLinkElement( 491 TileLayer layer, BBOX bbox, String gridLocUrl, String tileIdx) { 492 493 int maxLodPixels = -1; 494 495 496 // Hack 497 if(layer instanceof KMLDebugGridLayer && gridLocUrl.startsWith("data_")) { 498 maxLodPixels = 385; 499 } 542 TileLayer layer, BBOX bbox, String gridLocUrl, String tileIdx, int maxLodPixels) { 500 543 501 544 String xml = "\n<NetworkLink>"
