Skip to main content

struct LatLng

(Niantic.Lightship.Maps.Core.Coordinates.LatLng)

Overview

Latitude and Longitude, location on a globe

struct LatLng {
// fields

static const double MIN_LONGITUDE_DEGREES = -180.0d;
static const double MAX_LONGITUDE_DEGREES = 180.0d;
static const double MIN_LATITUDE_DEGREES = -90.0d;
static const double MAX_LATITUDE_DEGREES = 90.0d;
readonly double Latitude;
readonly double Longitude;
bool IsValid =>
MathEx.IsBetween(Latitude, MIN_LATITUDE_DEGREES, MAX_LATITUDE_DEGREES)&&
MathEx.IsBetween(Longitude, MIN_LONGITUDE_DEGREES, MAX_LONGITUDE_DEGREES);

// methods

bool Equals(in LatLng other);
override bool Equals(object obj);
override int GetHashCode();
LatLng(double latitude, double longitude);
WebMercator12 ToWebMercator12(double elevation = 0.0f);
override string ToString();
static bool operator == (in LatLng left, in LatLng right);
static bool operator != (in LatLng left, in LatLng right);
static double WrapLongitude(double longitude);
static double ClampLatitude(double latitude);
};

Detailed Documentation

Latitude and Longitude, location on a globe

Fields

MIN_LONGITUDE_DEGREES

static const double MIN_LONGITUDE_DEGREES = -180.0d

The minimum longitude, in degrees

MAX_LONGITUDE_DEGREES

static const double MAX_LONGITUDE_DEGREES = 180.0d

The maximum longitude, in degrees

MIN_LATITUDE_DEGREES

static const double MIN_LATITUDE_DEGREES = -90.0d

The minimum latitude, in degrees

MAX_LATITUDE_DEGREES

static const double MAX_LATITUDE_DEGREES = 90.0d

The maximum latitude, in degrees

Latitude

readonly double Latitude

Latitude, in degrees, from -90 to 90

Longitude

readonly double Longitude

Longitude, in degrees, from -180 to 180

IsValid

bool IsValid =>
MathEx.IsBetween(Latitude, MIN_LATITUDE_DEGREES, MAX_LATITUDE_DEGREES)&&
MathEx.IsBetween(Longitude, MIN_LONGITUDE_DEGREES, MAX_LONGITUDE_DEGREES)

Returns true if the latitude and longitude are a valid geographic location and the map.

Methods

LatLng

LatLng(double latitude, double longitude)

Constructor

    Parameters:

    latitude - Latitude, in degrees

    longitude - Longitude, in degrees

ToWebMercator12

WebMercator12 ToWebMercator12(double elevation = 0.0f)

Converts a location in LatLng coordinates to WebMercator12

    Parameters:

    elevation - Optional elevation parameter

    Returns:

    The location in WebMercator12 coordinates

WrapLongitude

static double WrapLongitude(double longitude)

Wraps a longitude (in degrees) if it's outside of the range defined by MIN_LONGITUDE_DEGREES and MAX_LONGITUDE_DEGREES.

    Parameters:

    longitude - The longitude to wrap

    Returns:

    A longitude wrapped around the globe such that it fits within the valid range of longitudes.

ClampLatitude

static double ClampLatitude(double latitude)

Clamps a latitude (in degrees) to MIN_LATITUDE_DEGREES if it's less than the minimum value, or to MAX_LATITUDE_DEGREES if it's greater than the maximum value.

    Parameters:

    latitude - The latitude to clamp

    Returns:

    A latitude clamped to within the min and max