Table of Contents

Class WorldWrap

Namespace
LansMap.Core.Geo

Horizontal wrap helpers: longitude is periodic, and mercator X wraps with period 1.

public static class WorldWrap
Inheritance
object
WorldWrap

Remarks

Latitude never wraps (mercator is not periodic in Y), so nothing here touches Y. Use these when a caller would otherwise treat the antimeridian as a wall.

Methods

FloorDiv(int, int)

Integer division that floors toward negative infinity, unlike C# which truncates toward zero.

public static int FloorDiv(int a, int b)

Parameters

a int

Dividend.

b int

Divisor.

Returns

int

Floor of a/b toward negative infinity.

Remarks

Tile sweeps over negative unwrapped indices need floor semantics.

NormalizeLonDeg(double)

Folds any degree longitude into [-180, 180), matching LatLon's spelling of the seam.

public static double NormalizeLonDeg(double lonDeg)

Parameters

lonDeg double

Longitude in degrees WGS84, any magnitude.

Returns

double

Equivalent longitude in [-180, 180). +180 becomes -180.

Remarks

A caller that writes longitude += delta can walk past 180; folding here is what lets that value build a LatLon without throwing.

WrapRelative(double)

Moves an anchor-relative mercator X to the nearest world copy.

public static double WrapRelative(double relX)

Parameters

relX double

X minus the anchor X, in normalized mercator.

Returns

double

Equivalent offset in [-0.5, 0.5].

Remarks

A primitive one pixel across the antimeridian from the anchor stays one pixel away instead of a whole world.

WrapUnit(double)

Folds a mercator X into the canonical world [0, 1).

public static double WrapUnit(double x)

Parameters

x double

Horizontal position in normalized mercator, possibly unwrapped.

Returns

double

Equivalent X in [0, 1).