Struct TileCoord
An XYZ tile address (the z/x/y of a slippy-map URL), validated at construction.
public readonly struct TileCoord : IEquatable<TileCoord>
- Implements
Remarks
X increases east, Y increases south from the top-left of the world square, using the XYZ tile scheme rather than TMS. Every address packs into a Key long for dictionary use: the frame loop must never build a string tile key.
Constructors
TileCoord(int, int, int)
Creates a tile address, rejecting out-of-range values.
public TileCoord(int z, int x, int y)
Parameters
Exceptions
- ArgumentOutOfRangeException
The zoom is out of range, or x/y fall outside the grid at that zoom.
Properties
Key
The address packed into one long as z<<58 | y<<29 | x, for allocation-free use as a dictionary key.
public long Key { get; }
Property Value
X
Tile column, 0 to 2^Z - 1, increasing east.
public int X { get; }
Property Value
Y
Tile row, 0 to 2^Z - 1, increasing south.
public int Y { get; }
Property Value
Z
Zoom level, 0 to Max.
public int Z { get; }
Property Value
Methods
Equals(TileCoord)
Exact equality on all three components.
public bool Equals(TileCoord other)
Parameters
otherTileCoord
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FromKey(long)
Rebuilds an address from a Key.
public static TileCoord FromKey(long key)
Parameters
Returns
- TileCoord
The address that produced the key.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Parent()
The tile one zoom level out that contains this one. Used to walk the fallback chain while a sharper tile is still loading.
public TileCoord Parent()
Returns
- TileCoord
The containing tile at zoom Z - 1.
Exceptions
- InvalidOperationException
This tile is at zoom 0, which has no parent.
ToString()
Returns "z/x/y".
public override string ToString()