Struct MercatorBounds
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
minXdoubleWest edge, normalized mercator.
minYdoubleNorth edge, normalized mercator.
maxXdoubleEast edge, normalized mercator.
maxYdoubleSouth edge, normalized mercator.
Fields
MaxX
East edge, in normalized mercator. May leave [0, 1).
public readonly double MaxX
Field Value
MaxY
South edge, in normalized mercator. Y increases southward.
public readonly double MaxY
Field Value
MinX
West edge, in normalized mercator. May leave [0, 1).
public readonly double MinX
Field Value
MinY
North edge, in normalized mercator. Y increases southward.
public readonly double MinY
Field Value
Properties
Height
Height in normalized mercator.
public double Height { get; }
Property Value
Width
Width in normalized mercator. May exceed 1 when unwrapped.
public double Width { get; }
Property Value
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
otherMercatorBoundsRectangle 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
xdoubleHorizontal position in normalized mercator.
ydoubleVertical 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
dxdoubleHorizontal padding in normalized mercator, added to both west and east.
dydoubleVertical padding in normalized mercator, added to both north and south.
Returns
- MercatorBounds
A larger rectangle; negative padding shrinks it.