Table of Contents

Struct MercatorBounds

Namespace
LansMap.Core.Geo

An axis-aligned rectangle in normalized mercator that can stay unwrapped across the antimeridian.

public readonly struct MercatorBounds
Inherited Members

Remarks

X may leave [0, 1) so a viewport straddling the antimeridian stays one interval instead of splitting in two. ContainsPoint(double, double) tests the given X and its two neighbouring world copies, which is how a marker stored in the canonical world matches an unwrapped rect. Y is not periodic in mercator and is tested as given.

Constructors

MercatorBounds(double, double, double, double)

Creates an unwrapped mercator rectangle from its edges.

public MercatorBounds(double minX, double minY, double maxX, double maxY)

Parameters

minX double

West edge, normalized mercator.

minY double

North edge, normalized mercator.

maxX double

East edge, normalized mercator.

maxY double

South edge, normalized mercator.

Fields

MaxX

East edge, in normalized mercator. May leave [0, 1).

public readonly double MaxX

Field Value

double

MaxY

South edge, in normalized mercator. Y increases southward.

public readonly double MaxY

Field Value

double

MinX

West edge, in normalized mercator. May leave [0, 1).

public readonly double MinX

Field Value

double

MinY

North edge, in normalized mercator. Y increases southward.

public readonly double MinY

Field Value

double

Properties

Height

Height in normalized mercator.

public double Height { get; }

Property Value

double

Width

Width in normalized mercator. May exceed 1 when unwrapped.

public double Width { get; }

Property Value

double

Methods

ContainsBounds(in MercatorBounds)

Plain interval containment, no wrap: both rects must come from the same unwrapped frame (successive viewports of one view seam). A containment that fails because the center wrapped is a conservative miss, never a false hit.

public bool ContainsBounds(in MercatorBounds other)

Parameters

other MercatorBounds

Rectangle in the same unwrapped frame.

Returns

bool

True when other lies entirely inside this rectangle, without wrap.

ContainsPoint(double, double)

True when (x, y) or one of x's two neighbouring world copies lies inside the rect. A rect one world or wider contains every X.

public bool ContainsPoint(double x, double y)

Parameters

x double

Horizontal position in normalized mercator.

y double

Vertical position in normalized mercator.

Returns

bool

True when the point, or a neighbouring world copy of it, lies inside.

Expanded(double, double)

Grows the rectangle by the given padding on every side.

public MercatorBounds Expanded(double dx, double dy)

Parameters

dx double

Horizontal padding in normalized mercator, added to both west and east.

dy double

Vertical padding in normalized mercator, added to both north and south.

Returns

MercatorBounds

A larger rectangle; negative padding shrinks it.