Package com.geodesk.geom
Class TileQuad
java.lang.Object
com.geodesk.geom.TileQuad
Methods for dealing with numeric values that represent Tile Quads, a
collection of one to four tiles that is at most 2 tiles wide and 2 tiles tall,
at a specific zoom level from 0 to 12.
A "normalized" quad a) has at least one tile and b) does not have tiles in its
eastern/southern quadrants unless it also has tiles in its western/northern
quadrants. Most of the methods of this class expect quads to be in normalized
form, or their results will be undefined.
Tile Quads are represented as int values, which are compatible with Tile
numbers. The 4 most significant bits of a Tile number are always zero.
A Tile Quad uses these 4 bits to indicate which tiles in a quad are in use.
0 -- 1 X- 2 -X 3 XX 4 -- 5 X- 6 -X 7 XX
-- -- -- -- X- X- X- X-
8 -- 9 X- 10 -X 11 XX 12 -- 13 X- 14 -X 15 XX
-X -X -X -X XX XX XX XX
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
addLineSegment
(int quad, double startX, double startY, double endX, double endY, int zoom) static int
addPoint
(int quad, int x, int y, int zoom) static int
addQuad
(int quadA, int quadB) Adds two quads together and returns the resulting quad.static int
addTile
(int quad, int tile) Adds a tile to the given quad and returns the resulting quad.static int
blackTile
(int quad) static boolean
containsTile
(int quadA, int tileB) static boolean
coversQuad
(int quadA, int quadB) static boolean
coversTile
(int quadA, int tileB) static int
dense
(int quad) Returns a dense version of a quad.static void
forEach
(int quad, org.eclipse.collections.api.block.procedure.primitive.IntProcedure consumer) static int
fromDenseParentLocator
(byte loc, int originTile) Reconstitutes a quad from an 8-bit locator, relative to a tile that must be a child tile of the quad.static int
fromSingleTile
(int tile) static int
fromSingleTile
(String tile) static int
fromSparseSiblingLocator
(byte loc, int originTile) Reconstitutes a quad from a 6-bit locator, relative to a tile that must lie within the bounds of the quad (but does not have to be a member of the quad).static int
height
(int quad) static boolean
isNormalized
(int quad) static boolean
isValid
(int quad) static com.geodesk.geom.TileQuad.TileIterator
iterator
(int quad) static int
normalize
(int quad) Returns a tile quad in its "normalized" form.static int
northWestTile
(int quad) static final int
of
(int... tiles) static String
quadChar
(int quad) static int
subtractQuad
(int quadA, int quadB) Subtracts one quad from another.static int
subtractTile
(int quad, int tile) static int
tileCount
(int quad) Returns the number of tiles in the quad.static byte
toDenseParentLocator
(int parentQuad, int childTile) Returns an 8-bit locator, which describes a quad relative to a child tile that is covered by it.static String
toListString
(int quad) static byte
toSparseSiblingLocator
(int quad, int startTile) Returns a 6-bit locator, which describes a quad relative to a tile contained within its bounds.static String
toString
(int quad) static org.eclipse.collections.api.list.primitive.MutableIntList
toTileList
(int quad) static int
width
(int quad) static final int
zoom
(int quad) static int
zoomedOut
(int quad, int zoom)
-
Field Details
-
NW
public static final int NW- See Also:
-
NE
public static final int NE- See Also:
-
SW
public static final int SW- See Also:
-
SE
public static final int SE- See Also:
-
INVALID
public static final int INVALID- See Also:
-
OVERSIZED
public static final int OVERSIZED- See Also:
-
ROOT
public static final int ROOT- See Also:
-
-
Constructor Details
-
TileQuad
public TileQuad()
-
-
Method Details
-
of
public static final int of(int... tiles) -
zoom
public static final int zoom(int quad) -
forEach
public static void forEach(int quad, org.eclipse.collections.api.block.procedure.primitive.IntProcedure consumer) -
fromSingleTile
public static int fromSingleTile(int tile) -
fromSingleTile
-
fromDenseParentLocator
public static int fromDenseParentLocator(byte loc, int originTile) Reconstitutes a quad from an 8-bit locator, relative to a tile that must be a child tile of the quad. The resultant tile is always dense, i.e. its tiles form a rectangular shape, and is guaranteed to be normalized.- Parameters:
loc
- the locatororiginTile
- a valid tile- Returns:
-
fromSparseSiblingLocator
public static int fromSparseSiblingLocator(byte loc, int originTile) Reconstitutes a quad from a 6-bit locator, relative to a tile that must lie within the bounds of the quad (but does not have to be a member of the quad). The resulting quad is sparse and is only guaranteed to be normalized if the locator itself is normalized.- Parameters:
loc
- the locatororiginTile
- a valid tile- Returns:
-
toDenseParentLocator
public static byte toDenseParentLocator(int parentQuad, int childTile) Returns an 8-bit locator, which describes a quad relative to a child tile that is covered by it. The quad and the tile must be valid, the quad must be normalized, and its bounds must include the child tile, or else the result will be undefined.- Parameters:
parentQuad
-childTile
-- Returns:
-
toSparseSiblingLocator
public static byte toSparseSiblingLocator(int quad, int startTile) Returns a 6-bit locator, which describes a quad relative to a tile contained within its bounds. The quad and the tile must be valid, the quad must be normalized, and its bounds must include the tile, or else the result will be undefined.- Parameters:
quad
-startTile
-- Returns:
-
zoomedOut
public static int zoomedOut(int quad, int zoom) -
normalize
public static int normalize(int quad) Returns a tile quad in its "normalized" form. If the quad has tiles in the eastern, but not western quadrants and/or tiles in the southern, but not the northern quadrants, its column and/or row are decreased by one, and the tile bit pattern is adjusted accordingly. Otherwise, the quad is returned unchanged. The quad must be valid and have at least one tile, or the result will be undefined.- Parameters:
quad
-- Returns:
-
isNormalized
public static boolean isNormalized(int quad) -
addQuad
public static int addQuad(int quadA, int quadB) Adds two quads together and returns the resulting quad.- Parameters:
quadA
- a valid, normalized quadquadB
- a valid, normalized quad- Returns:
- a normalized quad that covers both quads
-
addTile
public static int addTile(int quad, int tile) Adds a tile to the given quad and returns the resulting quad. The quad and the tile must be valid, and the quad must be normalized, or the result will be undefined.- Parameters:
quad
- a valid, normalized quadtile
- a valid tile- Returns:
- a normalized quad that covers the original quad and the tile
-
addPoint
public static int addPoint(int quad, int x, int y, int zoom) -
addLineSegment
public static int addLineSegment(int quad, double startX, double startY, double endX, double endY, int zoom) -
dense
public static int dense(int quad) Returns a dense version of a quad. "Dense" means the quad contains a rectangular shape of tiles, or is empty. If the quad is not normalized, the northern/western tile bits will be set if only the southern/eastern tile bits are set.- Parameters:
quad
- a valid, normalized quad- Returns:
-
tileCount
public static int tileCount(int quad) Returns the number of tiles in the quad.- Parameters:
quad
-- Returns:
- the number of tiles (0 to 4)
-
toTileList
public static org.eclipse.collections.api.list.primitive.MutableIntList toTileList(int quad) -
quadChar
-
toString
-
toListString
-
width
public static int width(int quad) -
height
public static int height(int quad) -
northWestTile
public static int northWestTile(int quad) -
subtractQuad
public static int subtractQuad(int quadA, int quadB) Subtracts one quad from another. Both quads must be at the same zoom level. The result will be in normalized form (but may be empty).- Parameters:
quadA
-quadB
-- Returns:
-
subtractTile
public static int subtractTile(int quad, int tile) -
coversQuad
public static boolean coversQuad(int quadA, int quadB) -
coversTile
public static boolean coversTile(int quadA, int tileB) -
containsTile
public static boolean containsTile(int quadA, int tileB) -
isValid
public static boolean isValid(int quad) -
iterator
public static com.geodesk.geom.TileQuad.TileIterator iterator(int quad) -
blackTile
public static int blackTile(int quad)
-