Class TileCoordinateConverter
- java.lang.Object
-
- org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter
-
public class TileCoordinateConverter extends java.lang.Object
This class handles tile coordinate management and computes their position in the map view.- Since:
- 10651
-
-
Field Summary
Fields Modifier and Type Field Description private MapView
mapView
private TileSourceDisplaySettings
settings
private org.openstreetmap.gui.jmapviewer.interfaces.TileSource
tileSource
private java.awt.geom.AffineTransform
transform
-
Constructor Summary
Constructors Constructor Description TileCoordinateConverter(MapView mapView, org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource, TileSourceDisplaySettings settings)
Create a new coordinate converter for the map view.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Point2D
getPixelForTile(int x, int y, int zoom)
Gets the top left position of the tile inside the map view.java.awt.geom.Point2D
getPixelForTile(org.openstreetmap.gui.jmapviewer.Tile tile)
Gets the top left position of the tile inside the map view.Projecting
getProjecting()
Gets the projecting instance to use to convert between latlon and eastnorth coordinates.java.awt.geom.Rectangle2D
getRectangleForTile(org.openstreetmap.gui.jmapviewer.Tile tile)
Gets the position of the tile inside the map view.double
getScaleFactor(int zoom)
Returns average number of screen pixels per tile pixel for current mapviewTileAnchor
getScreenAnchorForTile(org.openstreetmap.gui.jmapviewer.Tile tile)
GetTileAnchor
for a tile in screen pixel coordinates.org.openstreetmap.gui.jmapviewer.TileXY
getTileforPixel(int sx, int sy, int zoom)
Convert screen pixel coordinate to tile position at certain zoom level.java.awt.Shape
getTileShapeScreen(org.openstreetmap.gui.jmapviewer.Tile tile)
Returns a shape that approximates the outline of the tile in screen coordinates.private MapViewState.MapViewPoint
pos(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate ll)
private MapViewState.MapViewPoint
pos(org.openstreetmap.gui.jmapviewer.interfaces.IProjected p)
boolean
requiresReprojection()
Return true if tiles need to be reprojected from server projection to display projection.org.openstreetmap.gui.jmapviewer.interfaces.IProjected
shiftDisplayToServer(EastNorth en)
Apply reverse shift to EastNorth coordinate.
-
-
-
Field Detail
-
settings
private final TileSourceDisplaySettings settings
-
tileSource
private final org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource
-
transform
private final java.awt.geom.AffineTransform transform
-
-
Constructor Detail
-
TileCoordinateConverter
public TileCoordinateConverter(MapView mapView, org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource, TileSourceDisplaySettings settings)
Create a new coordinate converter for the map view.- Parameters:
mapView
- The map view.tileSource
- The tile source to use when converting coordinates.settings
- displacement settings.- Throws:
java.lang.NullPointerException
- if one argument is null
-
-
Method Detail
-
pos
private MapViewState.MapViewPoint pos(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate ll)
-
pos
private MapViewState.MapViewPoint pos(org.openstreetmap.gui.jmapviewer.interfaces.IProjected p)
-
shiftDisplayToServer
public org.openstreetmap.gui.jmapviewer.interfaces.IProjected shiftDisplayToServer(EastNorth en)
Apply reverse shift to EastNorth coordinate.- Parameters:
en
- EastNorth coordinate representing a pixel on screen- Returns:
- IProjected coordinate as it would e.g. be sent to a WMS server
-
getProjecting
public Projecting getProjecting()
Gets the projecting instance to use to convert between latlon and eastnorth coordinates.- Returns:
- The
Projecting
instance.
-
getPixelForTile
public java.awt.geom.Point2D getPixelForTile(int x, int y, int zoom)
Gets the top left position of the tile inside the map view.- Parameters:
x
- x tile indexy
- y tile indexzoom
- zoom level- Returns:
- the position
-
getPixelForTile
public java.awt.geom.Point2D getPixelForTile(org.openstreetmap.gui.jmapviewer.Tile tile)
Gets the top left position of the tile inside the map view.- Parameters:
tile
- The tile- Returns:
- The position.
-
getTileforPixel
public org.openstreetmap.gui.jmapviewer.TileXY getTileforPixel(int sx, int sy, int zoom)
Convert screen pixel coordinate to tile position at certain zoom level.- Parameters:
sx
- x coordinate (screen pixel)sy
- y coordinate (screen pixel)zoom
- zoom level- Returns:
- the tile
-
getRectangleForTile
public java.awt.geom.Rectangle2D getRectangleForTile(org.openstreetmap.gui.jmapviewer.Tile tile)
Gets the position of the tile inside the map view.- Parameters:
tile
- The tile- Returns:
- The position as a rectangle in screen coordinates
-
getTileShapeScreen
public java.awt.Shape getTileShapeScreen(org.openstreetmap.gui.jmapviewer.Tile tile)
Returns a shape that approximates the outline of the tile in screen coordinates. If the tile is rectangular, this will be the exact border of the tile. The tile may be more oddly shaped due to reprojection, then it is an approximation of the tile outline.- Parameters:
tile
- the tile- Returns:
- tile outline in screen coordinates
-
getScaleFactor
public double getScaleFactor(int zoom)
Returns average number of screen pixels per tile pixel for current mapview- Parameters:
zoom
- zoom level- Returns:
- average number of screen pixels per tile pixel
-
getScreenAnchorForTile
public TileAnchor getScreenAnchorForTile(org.openstreetmap.gui.jmapviewer.Tile tile)
GetTileAnchor
for a tile in screen pixel coordinates.- Parameters:
tile
- the tile- Returns:
- position of the tile in screen coordinates
-
requiresReprojection
public boolean requiresReprojection()
Return true if tiles need to be reprojected from server projection to display projection.- Returns:
- true if tiles need to be reprojected from server projection to display projection
-
-