Class TileCoordinateConverter
java.lang.Object
org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter
This class handles tile coordinate management and computes their position in the map view.
- Since:
- 10651
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MapViewprivate final TileSourceDisplaySettingsprivate final org.openstreetmap.gui.jmapviewer.interfaces.TileSourceprivate final AffineTransform -
Constructor Summary
ConstructorsConstructorDescriptionTileCoordinateConverter(MapView mapView, org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource, TileSourceDisplaySettings settings) Create a new coordinate converter for the map view. -
Method Summary
Modifier and TypeMethodDescriptiongetPixelForTile(int x, int y, int zoom) Gets the top left position of the tile inside the map view.getPixelForTile(org.openstreetmap.gui.jmapviewer.Tile tile) Gets the top left position of the tile inside the map view.Gets the projecting instance to use to convert between latlon and eastnorth coordinates.getRectangleForTile(org.openstreetmap.gui.jmapviewer.Tile tile) Gets the position of the tile inside the map view.doublegetScaleFactor(int zoom) Returns average number of screen pixels per tile pixel for current mapviewgetScreenAnchorForTile(org.openstreetmap.gui.jmapviewer.Tile tile) GetTileAnchorfor a tile in screen pixel coordinates.org.openstreetmap.gui.jmapviewer.TileXYgetTileforPixel(int sx, int sy, int zoom) Convert screen pixel coordinate to tile position at certain zoom level.getTileShapeScreen(org.openstreetmap.gui.jmapviewer.Tile tile) Returns a shape that approximates the outline of the tile in screen coordinates.private MapViewState.MapViewPointpos(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate ll) private MapViewState.MapViewPointpos(org.openstreetmap.gui.jmapviewer.interfaces.IProjected p) booleanReturn true if tiles need to be reprojected from server projection to display projection.org.openstreetmap.gui.jmapviewer.interfaces.IProjectedApply reverse shift to EastNorth coordinate.
-
Field Details
-
mapView
-
settings
-
tileSource
-
transform
-
-
Constructor Details
-
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:
NullPointerException- if one argument is null
-
-
Method Details
-
pos
-
pos
-
shiftDisplayToServer
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
Gets the projecting instance to use to convert between latlon and eastnorth coordinates.- Returns:
- The
Projectinginstance.
-
getPixelForTile
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
Gets the top left position of the tile inside the map view.- Parameters:
tile- The tile- Returns:
- The position.
-
getTileforPixel
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
Gets the position of the tile inside the map view.- Parameters:
tile- The tile- Returns:
- The position as a rectangle in screen coordinates
-
getTileShapeScreen
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
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
GetTileAnchorfor a tile in screen pixel coordinates.- Parameters:
tile- the tile- Returns:
- position of the tile in screen coordinates
-
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
-