Skip to content

Instantly share code, notes, and snippets.

@jumboly
jumboly / WebMercator.cs
Created June 19, 2021 05:44 — forked from nagasudhirpulla/WebMercator.cs
C# Web Mercator utility class
/// <summary>
/// Conversion routines for Google, TMS, and Microsoft Quadtree tile representations, derived from
/// http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
/// </summary>
public class WebMercator
{
private const int TileSize = 256;
private const int EarthRadius = 6378137;
private const double InitialResolution = 2 * Math.PI * EarthRadius / TileSize;
private const double OriginShift = 2 * Math.PI * EarthRadius / 2;