Table of Contents

Struct LatLng

Namespace
H3.NET.Native
Assembly
H3.NET.Native.dll

A geographic coordinate expressed in degrees.

public readonly record struct LatLng : IEquatable<LatLng>
Implements
Inherited Members

Remarks

This is the public, degrees-based coordinate type. The underlying H3 C library operates in radians; conversion happens only at the interop boundary.

Constructors

LatLng(double, double)

A geographic coordinate expressed in degrees.

public LatLng(double LatitudeDegrees, double LongitudeDegrees)

Parameters

LatitudeDegrees double

Latitude in degrees, in the range [-90, 90].

LongitudeDegrees double

Longitude in degrees, in the range [-180, 180].

Remarks

This is the public, degrees-based coordinate type. The underlying H3 C library operates in radians; conversion happens only at the interop boundary.

Properties

LatitudeDegrees

Latitude in degrees, in the range [-90, 90].

public double LatitudeDegrees { get; init; }

Property Value

double

LongitudeDegrees

Longitude in degrees, in the range [-180, 180].

public double LongitudeDegrees { get; init; }

Property Value

double

Methods

DegsToRads(double)

Converts an angle from degrees to radians.

public static double DegsToRads(double degrees)

Parameters

degrees double

The angle to convert, in degrees.

Returns

double

The equivalent angle in radians.

GreatCircleDistanceKm(LatLng, LatLng)

Returns the great-circle (haversine) distance between two coordinates in kilometers.

public static double GreatCircleDistanceKm(LatLng a, LatLng b)

Parameters

a LatLng

The first coordinate, in degrees.

b LatLng

The second coordinate, in degrees.

Returns

double

The great-circle distance in kilometers.

GreatCircleDistanceM(LatLng, LatLng)

Returns the great-circle (haversine) distance between two coordinates in meters.

public static double GreatCircleDistanceM(LatLng a, LatLng b)

Parameters

a LatLng

The first coordinate, in degrees.

b LatLng

The second coordinate, in degrees.

Returns

double

The great-circle distance in meters.

GreatCircleDistanceRads(LatLng, LatLng)

Returns the great-circle (haversine) distance between two coordinates in radians.

public static double GreatCircleDistanceRads(LatLng a, LatLng b)

Parameters

a LatLng

The first coordinate, in degrees.

b LatLng

The second coordinate, in degrees.

Returns

double

The great-circle distance in radians.

RadsToDegs(double)

Converts an angle from radians to degrees.

public static double RadsToDegs(double radians)

Parameters

radians double

The angle to convert, in radians.

Returns

double

The equivalent angle in degrees.

Validate()

Validates that LatitudeDegrees and LongitudeDegrees are finite and within the canonical degree ranges.

public void Validate()

Exceptions

ArgumentOutOfRangeException

Latitude is outside [-90, 90], or longitude is outside [-180, 180], or either component is not a finite number.