Class GeographicBoundingBox
Represents a WGS84 geographic bounding box defined by longitude and latitude extents expressed in decimal degrees.
public sealed record GeographicBoundingBox : IEquatable<GeographicBoundingBox>
- Inheritance
-
GeographicBoundingBox
- Implements
- Inherited Members
Remarks
This type is intentionally CRS-free; coordinates are always interpreted as EPSG:4326 (WGS84) longitude/latitude. For a CRS-aware bounding box that supports arbitrary spatial references, use FeatureBoundingBox.
Constructors
GeographicBoundingBox(double, double, double, double)
Initializes a new instance of the GeographicBoundingBox record, validating that all coordinates are finite and within the WGS84 ranges, and that the southern boundary is strictly less than the northern boundary.
public GeographicBoundingBox(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
Parameters
minLongitudedoubleWestern boundary in decimal degrees, within [-180, 180].
minLatitudedoubleSouthern boundary in decimal degrees, within [-90, 90].
maxLongitudedoubleEastern boundary in decimal degrees, within [-180, 180].
maxLatitudedoubleNorthern boundary in decimal degrees, within [-90, 90].
Remarks
A box whose minLongitude is greater than its maxLongitude
is interpreted as an extent that crosses the antimeridian (±180°), spanning eastward from
the western edge across 180° to the eastern edge. See CrossesAntimeridian.
Exceptions
- ArgumentException
Thrown when any coordinate is not finite, when a longitude falls outside [-180, 180], when a latitude falls outside [-90, 90], or when
minLatitudeis not strictly less thanmaxLatitude.
Fields
Wgs84CrsIdentifier
The canonical WGS84 CRS identifier used when converting to FeatureBoundingBox.
public const string Wgs84CrsIdentifier = "EPSG:4326"
Field Value
Properties
CrossesAntimeridian
Gets a value indicating whether this bounding box crosses the antimeridian (±180°), which is the case when MinLongitude is greater than MaxLongitude. When true, the longitudinal extent wraps eastward from MinLongitude across 180° to MaxLongitude.
public bool CrossesAntimeridian { get; }
Property Value
LongitudeSpan
Gets the longitudinal span of this bounding box in decimal degrees, accounting for
antimeridian wrapping. For a non-crossing box this is MaxLongitude - MinLongitude;
for an antimeridian-crossing box it is (180 - MinLongitude) + (MaxLongitude - (-180)).
public double LongitudeSpan { get; }
Property Value
MaxLatitude
Gets the northern boundary in decimal degrees.
public double MaxLatitude { get; }
Property Value
MaxLongitude
Gets the eastern boundary in decimal degrees.
public double MaxLongitude { get; }
Property Value
MinLatitude
Gets the southern boundary in decimal degrees.
public double MinLatitude { get; }
Property Value
MinLongitude
Gets the western boundary in decimal degrees.
public double MinLongitude { get; }
Property Value
Methods
Contains(double, double)
Determines whether the supplied WGS84 coordinate lies on or within this bounding box, accounting for antimeridian wrapping.
public bool Contains(double longitude, double latitude)
Parameters
Returns
FromFeatureBoundingBox(FeatureBoundingBox)
Creates a GeographicBoundingBox from a CRS-aware FeatureBoundingBox, ensuring the source CRS is WGS84.
public static GeographicBoundingBox FromFeatureBoundingBox(FeatureBoundingBox bbox)
Parameters
bboxFeatureBoundingBoxThe CRS-aware bounding box to convert.
Returns
- GeographicBoundingBox
An equivalent WGS84 GeographicBoundingBox.
Exceptions
- ArgumentNullException
Thrown when
bboxis null.- ArgumentException
Thrown when
bboxdeclares a non-WGS84 CRS, or when its coordinate extents are invalid.
Intersects(GeographicBoundingBox)
Determines whether this bounding box intersects another WGS84 bounding box. Boxes that share only an edge are considered to intersect.
public bool Intersects(GeographicBoundingBox other)
Parameters
otherGeographicBoundingBoxThe other bounding box to test against.
Returns
Exceptions
- ArgumentNullException
Thrown when
otheris null.
ToFeatureBoundingBox()
Creates a CRS-aware FeatureBoundingBox representation of this geographic bounding box, tagged with the canonical WGS84 CRS identifier.
public FeatureBoundingBox ToFeatureBoundingBox()
Returns
- FeatureBoundingBox
A FeatureBoundingBox with
Crs = "EPSG:4326".