Package com.geodesk.geom
Class Tile
java.lang.Object
com.geodesk.geom.Tile
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
bottomRight
(Bounds bbox, int zoom) Returns the bottom-right tile occupied by a bounding box.static int
bottomY
(int tile) Returns the bottom (lowest) y-coordinate that lies within the given tile.static Box
bounds
(int tile) static TileBox
childrenOfTileAtZoom
(int tile, int zoom) static int
column
(int tile) static int
columnFromXZ
(int x, int zoom) static int
fromBounds
(Bounds bbox, int zoom) Returns the tile occupied by the given bounding box, or -1 if its extends across multiple tiles.static int
fromColumnRowZoom
(int col, int row, int zoom) Creates a tile number.static int
fromString
(String s) Parses a tile number from a String.static int
fromXYZ
(double x, double y, int zoom) static int
fromXYZ
(int x, int y, int zoom) Determines the tile to which a coordinate belongs; coordinates must be in the projection used by the Mercator class.static Box
intersection
(int tile, Bounds bounds) Calculates a new BoundingBox that represents the area of overlap between the given bounds and the bounding box of a tilestatic Envelope
intersection
(int tile, Envelope env) static boolean
isBlack
(int tile) Checks whether the tile would be black, if we imagine the tile grid being laid out like a checkerboard (with the top left tile being white).static boolean
isValid
(int tile) Checks if the given number represents a valid tile numberstatic int
leftX
(int tile) Returns the leftmost (lowest) x-coordinate that lies within the given tilestatic int
Returns the tile number of an adjacent tile that lies in the specified direction.static Polygon
polygon
(int tile) static int
relative
(int tile, int deltaCol, int deltaRow) static int
rightX
(int tile) Returns the rightmost (highest) x-coordinate that lies within the given tilestatic int
row
(int tile) static int
rowFromYZ
(int y, int zoom) static long
sizeAtZoom
(int zoom) Returns the width/height of a tile at the given zoom levelstatic int
tilesAtZoom
(int zoom) static int
Returns the top-left tile occupied by a bounding box.static int
topY
(int tile) static String
toString
(int tile) static int
zoom
(int tile) static int
zoomedOut
(int tile, int zoom) Returns the tile that contains this tile at the specified (lower) zoom level.static int
zoomFromSize
(long size)
-
Constructor Details
-
Tile
public Tile()
-
-
Method Details
-
row
public static int row(int tile) -
column
public static int column(int tile) -
zoom
public static int zoom(int tile) -
tilesAtZoom
public static int tilesAtZoom(int zoom) -
sizeAtZoom
public static long sizeAtZoom(int zoom) Returns the width/height of a tile at the given zoom level- Parameters:
zoom
- a valid zoom level- Returns:
- width/height in pixels
-
zoomFromSize
public static int zoomFromSize(long size) -
fromColumnRowZoom
public static int fromColumnRowZoom(int col, int row, int zoom) Creates a tile number. This method does not check whether the given column, row, and zoom level are valid.- Parameters:
col
- a valid columnrow
- a valid rowzoom
- a valid zoom level- Returns:
-
fromXYZ
public static int fromXYZ(int x, int y, int zoom) Determines the tile to which a coordinate belongs; coordinates must be in the projection used by the Mercator class.- Parameters:
x
-y
-- Returns:
-
columnFromXZ
public static int columnFromXZ(int x, int zoom) -
rowFromYZ
public static int rowFromYZ(int y, int zoom) -
fromXYZ
public static int fromXYZ(double x, double y, int zoom) -
isValid
public static boolean isValid(int tile) Checks if the given number represents a valid tile number- Parameters:
tile
-- Returns:
-
leftX
public static int leftX(int tile) Returns the leftmost (lowest) x-coordinate that lies within the given tile- Parameters:
tile
-- Returns:
-
rightX
public static int rightX(int tile) Returns the rightmost (highest) x-coordinate that lies within the given tile- Parameters:
tile
-- Returns:
-
bottomY
public static int bottomY(int tile) Returns the bottom (lowest) y-coordinate that lies within the given tile. Remember, going from top to bottom, tile rows *increase*, while y-coordinates *decrease*.- Parameters:
tile
-- Returns:
-
topY
public static int topY(int tile) -
zoomedOut
public static int zoomedOut(int tile, int zoom) Returns the tile that contains this tile at the specified (lower) zoom level. If the zoom level is the same, the tile itself is returned.- Parameters:
tile
- the tilezoom
- zoom level of the parent tile (must be <= the tile's zoom level)- Returns:
- the lower-zoom tile that contains the tile
-
neighbor
Returns the tile number of an adjacent tile that lies in the specified direction.- Parameters:
fromTile
- the current tiledirection
- the direction in which the neighbor tile is located- Returns:
- the tile number of the adjacent tile
-
bounds
-
polygon
-
topLeft
Returns the top-left tile occupied by a bounding box.- Parameters:
bbox
- the boundszoom
- the zoom level for which to return the tile- Returns:
-
bottomRight
Returns the bottom-right tile occupied by a bounding box.- Parameters:
bbox
- the boundszoom
- the zoom level for which to return the tile- Returns:
-
toString
-
fromString
Parses a tile number from a String. Valid formats are: "zoom/column/row" or "column/row" (assumes zoom 12)- Parameters:
s
-- Returns:
- the tile number, or -1 if the String does not represent a valid tile number
-
isBlack
public static boolean isBlack(int tile) Checks whether the tile would be black, if we imagine the tile grid being laid out like a checkerboard (with the top left tile being white). This allows us to implement an optimization strategy that significantly reduces the number of tiles we need to load to obtain the member ways of a large relation: We can check the color of the tiles where a way's start and end nodes are located, and preferably assign a uniform color tile as the home tile.- Parameters:
tile
-- Returns:
-
intersection
-
intersection
Calculates a new BoundingBox that represents the area of overlap between the given bounds and the bounding box of a tile- Parameters:
tile
- the tile to which to constrain the boundsbounds
-- Returns:
-
fromBounds
Returns the tile occupied by the given bounding box, or -1 if its extends across multiple tiles.- Parameters:
bbox
- the bounding boxzoom
- the zoom level of the tile- Returns:
-
childrenOfTileAtZoom
-
relative
public static int relative(int tile, int deltaCol, int deltaRow)
-