Table of Contents

Class WebMercator

Namespace
EncDotNet.S100.Rendering.Scene
Assembly
EncDotNet.S100.Rendering.Scene.dll

Spherical Web-Mercator (EPSG:3857) forward projection used by the shared vector rendering core. Reimplemented here so the core has no dependency on Mapsui (whose SphericalMercator.FromLonLat this matches).

public static class WebMercator
Inheritance
WebMercator
Inherited Members

Remarks

Uses the WGS-84 semi-major axis as the sphere radius (6378137 m), the standard EPSG:3857 definition. A numeric parity test asserts agreement with Mapsui's projection within a tight metre tolerance, so refactoring the Mapsui path onto this implementation does not shift the visual-regression baselines.

Fields

Circumference

The full EPSG:3857 world width (and height at the projection limits), in metres: one 360° trip around the equator (2·π·EarthRadius ≈ 4.0075×10⁷ m). Used by seam-aware auto-fit to shift longitudes that wrap the ±180° antimeridian into a contiguous world-X window.

public const double Circumference = 40075016.68557849

Field Value

double

EarthRadius

EPSG:3857 sphere radius (WGS-84 semi-major axis), in metres.

public const double EarthRadius = 6378137

Field Value

double

MaxLatitude

The practical EPSG:3857 latitude limit (degrees) where the projection is defined; the Web-Mercator northing diverges towards the poles, so values are clamped to this range (the standard ±85.05112878°).

public const double MaxLatitude = 85.05112878

Field Value

double

Methods

FromLonLat(double, double)

Projects a WGS-84 (longitude, latitude) pair, in degrees, to EPSG:3857 metres (x = easting, y = northing).

public static (double X, double Y) FromLonLat(double longitude, double latitude)

Parameters

longitude double
latitude double

Returns

(double X, double Y)

ToLonLat(double, double)

Inverse of FromLonLat(double, double): converts EPSG:3857 metres (x = easting, y = northing) back to a WGS-84 (longitude, latitude) pair in degrees. Latitude is clamped to ±MaxLatitude.

public static (double Longitude, double Latitude) ToLonLat(double x, double y)

Parameters

x double
y double

Returns

(double X, double Y)

ToLonLat(double, double, bool)

Inverse of FromLonLat(double, double): converts EPSG:3857 metres (x = easting, y = northing) back to a WGS-84 (longitude, latitude) pair in degrees.

public static (double Longitude, double Latitude) ToLonLat(double x, double y, bool clampLatitude)

Parameters

x double

Easting in EPSG:3857 metres.

y double

Northing in EPSG:3857 metres.

clampLatitude bool

true to clamp latitude to ±MaxLatitude (the practical Web-Mercator display limit). Pass false when the result is only used to reconstruct the exact EPSG:3857 bounds via FromLonLat(double, double) — for example when building a render viewport from world-metre bounds. Clamping there is lossy: a viewport edge (or per-tile gutter) whose northing exceeds ±π·EarthRadius would be pulled back to the pole limit, so the round-tripped span no longer matches the true world span and the projected geometry drifts poleward, increasingly so with latitude (seen when a high-latitude dataset such as the US NWS S-411 sea-ice product is zoomed out). Because a normal in-range viewport never reaches the limit, disabling the clamp is a no-op except in that overflow case, where it is the correct behaviour.

Returns

(double X, double Y)