Class ReprojectionTile
- java.lang.Object
-
- org.openstreetmap.gui.jmapviewer.Tile
-
- org.openstreetmap.josm.gui.layer.imagery.ReprojectionTile
-
public class ReprojectionTile extends org.openstreetmap.gui.jmapviewer.Tile
Tile class that stores a reprojected version of the original tile.- Since:
- 11858
-
-
Field Summary
Fields Modifier and Type Field Description protected TileAnchor
anchor
protected boolean
maxZoomReached
private double
nativeScale
private org.openstreetmap.gui.jmapviewer.Tile
tile
-
Constructor Summary
Constructors Constructor Description ReprojectionTile(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source, int xtile, int ytile, int zoom)
Constructs a newReprojectionTile
.ReprojectionTile(org.openstreetmap.gui.jmapviewer.Tile tile)
Create a reprojection tile for a specific tile
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TileAnchor
getAnchor()
Get the position of the tile inside the image.private static Dimension
getDimension(ProjectionBounds bounds, double scale)
double
getNativeScale()
Get the scale that was used for reprojecting the tile.void
invalidate()
Invalidate tile - mark it as not loaded.protected Integer
limitScale(double lenOrig, double lenNow)
Make sure, the image is not scaled up too much.void
loadImage(InputStream inputStream)
boolean
needsUpdate(double currentScale)
Check if it is necessary to refresh the cache to match the current mapview scale and get optimized image quality.private static ProjectionBounds
pbMarginAndAlign(ProjectionBounds box, double scale, double margin)
private void
reset()
void
setImage(BufferedImage image)
private EastNorth
tileToEastNorth(int x, int y, int z)
protected void
transform(BufferedImage imageIn)
Transforms the given image.-
Methods inherited from class org.openstreetmap.gui.jmapviewer.Tile
equals, finishLoading, getErrorMessage, getImage, getKey, getMetadata, getSource, getStatus, getTileKey, getTileSource, getTileXY, getUrl, getValue, getXtile, getYtile, getZoom, hasError, hashCode, initLoading, isLoaded, isLoading, loadingCanceled, loadPlaceholderFromCache, paint, paint, putValue, setError, setError, setLoaded, toString
-
-
-
-
Field Detail
-
tile
private final org.openstreetmap.gui.jmapviewer.Tile tile
-
anchor
protected TileAnchor anchor
-
nativeScale
private double nativeScale
-
maxZoomReached
protected boolean maxZoomReached
-
-
Constructor Detail
-
ReprojectionTile
public ReprojectionTile(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source, int xtile, int ytile, int zoom)
Constructs a newReprojectionTile
.- Parameters:
source
- source tilextile
- X coordinateytile
- Y coordinatezoom
- zoom level
-
ReprojectionTile
public ReprojectionTile(org.openstreetmap.gui.jmapviewer.Tile tile)
Create a reprojection tile for a specific tile- Parameters:
tile
- The tile to use
-
-
Method Detail
-
getAnchor
public TileAnchor getAnchor()
Get the position of the tile inside the image.- Returns:
- the position of the tile inside the image
- See Also:
Tile.getImage()
-
getNativeScale
public double getNativeScale()
Get the scale that was used for reprojecting the tile. This is not necessarily the mapview scale, but may be adjusted to avoid excessively large cache image.- Returns:
- the scale that was used for reprojecting the tile
-
needsUpdate
public boolean needsUpdate(double currentScale)
Check if it is necessary to refresh the cache to match the current mapview scale and get optimized image quality. When the maximum zoom is exceeded, this method will generally return false.- Parameters:
currentScale
- the current mapview scale- Returns:
- true if the tile should be reprojected again from the source image.
-
loadImage
public void loadImage(InputStream inputStream) throws IOException
- Overrides:
loadImage
in classorg.openstreetmap.gui.jmapviewer.Tile
- Throws:
IOException
-
setImage
public void setImage(BufferedImage image)
- Overrides:
setImage
in classorg.openstreetmap.gui.jmapviewer.Tile
-
invalidate
public void invalidate()
Invalidate tile - mark it as not loaded.
-
reset
private void reset()
-
tileToEastNorth
private EastNorth tileToEastNorth(int x, int y, int z)
-
transform
protected void transform(BufferedImage imageIn)
Transforms the given image.- Parameters:
imageIn
- tile image to reproject
-
pbMarginAndAlign
private static ProjectionBounds pbMarginAndAlign(ProjectionBounds box, double scale, double margin)
-
getDimension
private static Dimension getDimension(ProjectionBounds bounds, double scale)
-
limitScale
protected Integer limitScale(double lenOrig, double lenNow)
Make sure, the image is not scaled up too much. This would not give any significant improvement in image quality and may exceed the user's memory. The correction factor is a power of 2.- Parameters:
lenOrig
- tile size of original imagelenNow
- (averaged) tile size of warped image- Returns:
- factor to shrink if limit is exceeded; 1 if it is already at the limit, but no change needed; null if it is well below the limit and can still be scaled up by at least a factor of 2.
-
-