GeoProjection Class

A map projection: converts longitudes and latitudes to points of a plane, in radii of the Earth, with y increasing to the north. Scale and translate the result to draw a map.

public abstract class GeoProjection

Remarks

The formulas are ports of d3-geo and d3-geo-projection (ISC license, Copyright Mike Bostock).

Constructors

NameDescription
GeoProjection()Initializes a new instance of the GeoProjection class.

GeoProjection()

GeoProjection.cs

Initializes a new instance of the GeoProjection class.

protected GeoProjection()

Properties

NameDescription
CenterLongitudeGets the longitude at the center of the map, in degrees. The default is 0.
HasStraightMeridiansGets a value that indicates whether the meridians are straight lines, so a line along a meridian needs no intermediate points. The default is true.
HasStraightParallelsGets a value that indicates whether the parallels are straight lines. The default is true.
MaxLatitudeGets the largest latitude the projection draws, in degrees: GeoProjection.Project moves the latitudes past it to it. The default is 90.

CenterLongitude

GeoProjection.cs

Gets the longitude at the center of the map, in degrees. The default is 0.

public virtual double CenterLongitude { get; }

Property value

double

HasStraightMeridians

GeoProjection.cs

Gets a value that indicates whether the meridians are straight lines, so a line along a meridian needs no intermediate points. The default is true.

public virtual bool HasStraightMeridians { get; }

Property value

bool

HasStraightParallels

GeoProjection.cs

Gets a value that indicates whether the parallels are straight lines. The default is true.

public virtual bool HasStraightParallels { get; }

Property value

bool

MaxLatitude

GeoProjection.cs

Gets the largest latitude the projection draws, in degrees: GeoProjection.Project moves the latitudes past it to it. The default is 90.

public virtual double MaxLatitude { get; }

Property value

double

Methods

NameDescription
Invert(double, double)Converts a point of the plane back to a position: the inverse of GeoProjection.Project.
InvertRadians(double, double)Converts a point of the plane back to a position, in radians.
Project(GeoPosition)Projects a position to a point of the plane.
Project(double, double)Projects a position to a point of the plane.
ProjectRadians(double, double)Projects a position, in radians.

Invert(double, double)

GeoProjection.cs

Converts a point of the plane back to a position: the inverse of GeoProjection.Project.

public GeoPosition? Invert(double x, double y)

Parameters

x double
The x coordinate, in radii of the Earth.
y double
The y coordinate, in radii of the Earth, increasing to the north.

Returns

GeoPosition? The position, with a longitude from -180 to 180, or null when the point is outside of the map or the projection has no inverse.

InvertRadians(double, double)

GeoProjection.cs

Converts a point of the plane back to a position, in radians.

protected virtual (double Lambda, double Phi)? InvertRadians(double x, double y)

Parameters

x double
The x coordinate, in radii of the Earth.
y double
The y coordinate, in radii of the Earth.

Returns

(double Lambda, double Phi)? The longitude and the latitude, in radians, or null when the point is outside of the map or the projection has no inverse. The default returns null.

Project overloads

Project(GeoPosition)

GeoProjection.cs

Projects a position to a point of the plane.

public (double X, double Y) Project(GeoPosition position)
Parameters
position GeoPosition
The position. The altitude is ignored.
Returns

(double X, double Y) The point, in radii of the Earth, with y increasing to the north.

Project(double, double)

GeoProjection.cs

Projects a position to a point of the plane.

public (double X, double Y) Project(double longitude, double latitude)
Parameters
longitude double
The longitude, in degrees.
latitude double
The latitude, in degrees.
Returns

(double X, double Y) The point, in radii of the Earth, with y increasing to the north.

ProjectRadians(double, double)

Projects a position, in radians.

protected abstract (double X, double Y) ProjectRadians(double lambda, double phi)

Parameters

lambda double
The longitude, in radians.
phi double
The latitude, in radians, already limited to GeoProjection.MaxLatitude.

Returns

(double X, double Y) The point, in radii of the Earth, with y increasing to the north.