public Envelope CoordToEnvelope(Coord coord)
{
int z = coord.Z;
int x = coord.X;
int y = coord.Y;
if (coord.TopOrigin)
{
y = this.GridHeight(z) - y - 1;
}
if (!(z >= 0 && z < this._resolutions.Count))
throw new TileOutOfRangeException(string.Format("Zoom level {0} is out of range (min: {1} max: {2})", coord.Z, 0, this._resolutions.Count - 1));
int xMax = GridWidth(z);
if (!(x >=0 && x < xMax))
throw new TileOutOfRangeException(string.Format("Column {0} is out of range (min: {1} max: {2})", coord.X, 0, xMax - 1));
int yMax = GridHeight(z);
if (!(y >=0 && y < yMax))
throw new TileOutOfRangeException(string.Format("Row {0} is out of range (min: {1} max: {2})", coord.Y, 0, yMax - 1));
double res = this._resolutions[z];
double minx = x * this._tileWidth * res + this._envelope.Minx;
double maxx = (x + 1) * this._tileWidth * res + this._envelope.Minx;
double miny = y * this._tileHeight * res + this._envelope.Miny;
double maxy = (y + 1) * this._tileHeight * res + this._envelope.Miny;
return new Envelope(minx, miny, maxx, maxy);
}