Package com.geodesk.geom
Class Tile
java.lang.Object
com.geodesk.geom.Tile
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intbottomRight(Bounds bbox, int zoom) Returns the bottom-right tile occupied by a bounding box.static intbottomY(int tile) Returns the bottom (lowest) y-coordinate that lies within the given tile.static Boxbounds(int tile) static TileBoxchildrenOfTileAtZoom(int tile, int zoom) static intcolumn(int tile) static intcolumnFromXZ(int x, int zoom) static intfromBounds(Bounds bbox, int zoom) Returns the tile occupied by the given bounding box, or -1 if its extends across multiple tiles.static intfromColumnRowZoom(int col, int row, int zoom) Creates a tile number.static intfromString(String s) Parses a tile number from a String.static intfromXYZ(double x, double y, int zoom) static intfromXYZ(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 Boxintersection(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 Envelopeintersection(int tile, Envelope env) static booleanisBlack(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 booleanisValid(int tile) Checks if the given number represents a valid tile numberstatic intleftX(int tile) Returns the leftmost (lowest) x-coordinate that lies within the given tilestatic intReturns the tile number of an adjacent tile that lies in the specified direction.static Polygonpolygon(int tile) static intrelative(int tile, int deltaCol, int deltaRow) static intrightX(int tile) Returns the rightmost (highest) x-coordinate that lies within the given tilestatic introw(int tile) static introwFromYZ(int y, int zoom) static longsizeAtZoom(int zoom) Returns the width/height of a tile at the given zoom levelstatic inttilesAtZoom(int zoom) static intReturns the top-left tile occupied by a bounding box.static inttopY(int tile) static StringtoString(int tile) static intzoom(int tile) static intzoomedOut(int tile, int zoom) Returns the tile that contains this tile at the specified (lower) zoom level.static intzoomFromSize(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)
-