Ticket #7872: wmsTileSize-0.patch
File wmsTileSize-0.patch, 4.9 KB (added by , 13 years ago) |
---|
-
src/org/openstreetmap/josm/gui/layer/WMSLayer.java
105 105 public static final BooleanProperty PROP_OVERLAP = new BooleanProperty("imagery.wms.overlap", false); 106 106 public static final IntegerProperty PROP_OVERLAP_EAST = new IntegerProperty("imagery.wms.overlapEast", 14); 107 107 public static final IntegerProperty PROP_OVERLAP_NORTH = new IntegerProperty("imagery.wms.overlapNorth", 4); 108 public static final IntegerProperty PROP_IMAGE_SIZE = new IntegerProperty("imagery.wms.imageSize", 500); 108 109 109 110 public int messageNum = 5; //limit for messages per layer 110 111 protected String resolution; … … 168 169 } 169 170 } 170 171 if (cache == null) { 171 cache = new WmsCache(info.getUrl(), imageSize);172 cache = new WmsCache(info.getUrl(), PROP_IMAGE_SIZE.get()); 172 173 cache.loadIndex(); 173 174 } 174 175 } … … 343 344 } 344 345 345 346 public int getImageXIndex(double coord) { 346 return (int)Math.floor( ((coord - dx) * info.getPixelPerDegree()) / imageSize);347 return (int)Math.floor( ((coord - dx) * info.getPixelPerDegree()) / PROP_IMAGE_SIZE.get()); 347 348 } 348 349 349 350 public int getImageYIndex(double coord) { 350 return (int)Math.floor( ((coord - dy) * info.getPixelPerDegree()) / imageSize);351 return (int)Math.floor( ((coord - dy) * info.getPixelPerDegree()) / PROP_IMAGE_SIZE.get()); 351 352 } 352 353 353 354 public int getImageX(int imageIndex) { 354 return (int)(imageIndex * imageSize* (getPPD() / info.getPixelPerDegree()) + dx * getPPD());355 return (int)(imageIndex * PROP_IMAGE_SIZE.get() * (getPPD() / info.getPixelPerDegree()) + dx * getPPD()); 355 356 } 356 357 357 358 public int getImageY(int imageIndex) { 358 return (int)(imageIndex * imageSize* (getPPD() / info.getPixelPerDegree()) + dy * getPPD());359 return (int)(imageIndex * PROP_IMAGE_SIZE.get() * (getPPD() / info.getPixelPerDegree()) + dy * getPPD()); 359 360 } 360 361 361 362 public int getImageWidth(int xIndex) { … … 371 372 * @return Size of image in original zoom 372 373 */ 373 374 public int getBaseImageWidth() { 374 int overlap = PROP_OVERLAP.get() ? (PROP_OVERLAP_EAST.get() * imageSize/ 100) : 0;375 return imageSize+ overlap;375 int overlap = PROP_OVERLAP.get() ? (PROP_OVERLAP_EAST.get() * PROP_IMAGE_SIZE.get() / 100) : 0; 376 return PROP_IMAGE_SIZE.get() + overlap; 376 377 } 377 378 378 379 /** … … 380 381 * @return Size of image in original zoom 381 382 */ 382 383 public int getBaseImageHeight() { 383 int overlap = PROP_OVERLAP.get() ? (PROP_OVERLAP_NORTH.get() * imageSize/ 100) : 0;384 return imageSize+ overlap;384 int overlap = PROP_OVERLAP.get() ? (PROP_OVERLAP_NORTH.get() * PROP_IMAGE_SIZE.get() / 100) : 0; 385 return PROP_IMAGE_SIZE.get() + overlap; 385 386 } 386 387 387 388 public int getImageSize() { 388 return imageSize;389 return PROP_IMAGE_SIZE.get(); 389 390 } 390 391 391 392 public boolean isOverlapEnabled() { … … 399 400 public BufferedImage normalizeImage(BufferedImage img) { 400 401 if (isOverlapEnabled()) { 401 402 BufferedImage copy = img; 402 img = new BufferedImage( imageSize, imageSize, copy.getType());403 img.createGraphics().drawImage(copy, 0, 0, imageSize, imageSize,404 0, copy.getHeight() - imageSize, imageSize, copy.getHeight(), null);403 img = new BufferedImage(PROP_IMAGE_SIZE.get(), PROP_IMAGE_SIZE.get(), copy.getType()); 404 img.createGraphics().drawImage(copy, 0, 0, PROP_IMAGE_SIZE.get(), PROP_IMAGE_SIZE.get(), 405 0, copy.getHeight() - PROP_IMAGE_SIZE.get(), PROP_IMAGE_SIZE.get(), copy.getHeight(), null); 405 406 } 406 407 return img; 407 408 } … … 413 414 * @return Real EastNorth of given tile. dx/dy is not counted in 414 415 */ 415 416 public EastNorth getEastNorth(int xIndex, int yIndex) { 416 return new EastNorth((xIndex * imageSize) / info.getPixelPerDegree(), (yIndex * imageSize) / info.getPixelPerDegree());417 return new EastNorth((xIndex * PROP_IMAGE_SIZE.get()) / info.getPixelPerDegree(), (yIndex * PROP_IMAGE_SIZE.get()) / info.getPixelPerDegree()); 417 418 } 418 419 419 420 protected void downloadAndPaintVisible(Graphics g, final MapView mv, boolean real){ … … 986 987 } else if ( 987 988 event.getKey().equals(PROP_OVERLAP.getKey()) 988 989 || event.getKey().equals(PROP_OVERLAP_EAST.getKey()) 989 || event.getKey().equals(PROP_OVERLAP_NORTH.getKey())) { 990 || event.getKey().equals(PROP_OVERLAP_NORTH.getKey()) 991 || event.getKey().equals(PROP_IMAGE_SIZE.getKey())) { 990 992 for (int i=0; i<images.length; i++) { 991 993 for (int k=0; k<images[i].length; k++) { 992 994 images[i][k] = new GeorefImage(this);