Documentation
¶
Overview ¶
Package carto provides cartography functionality for working with and making maps.
This includes:
Various projections between angular coordinates (longitude and latitude) and planar coordinates (x and y).
Earth radius definitions.
Index ¶
Constants ¶
const ( // WGS84EllipsoidEquatorialRadiusM is the radius of the WGS84 ellipsoid at // the equator. WGS84EllipsoidEquatorialRadiusM = 6378137.0 // WGS84EllipsoidPolarRadiusM is the radius of the WGS84 ellipsoid at the poles. WGS84EllipsoidPolarRadiusM = 6356752.314245 // WGS84EllipsoidMeanRadiusM is the mean radius of the WGS84 ellipsoid. WGS84EllipsoidMeanRadiusM = (2*WGS84EllipsoidEquatorialRadiusM + WGS84EllipsoidPolarRadiusM) / 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlbersEqualAreaConic ¶
type AlbersEqualAreaConic struct {
// contains filtered or unexported fields
}
AlbersEqualAreaConic allows projecting (longitude, latitude) coordinates to (x, y) pairs via the Albers equal area conic projection.
The Albers equal area conic projection is a conic projection that is:
- Configured by setting two standard parallels.
- Equal area.
- Not conformal, but preserves shape locally at the standard parallels.
func NewAlbersEqualAreaConic ¶
func NewAlbersEqualAreaConic(earthRadius float64) *AlbersEqualAreaConic
NewAlbersEqualAreaConic returns a new AlbersEqualAreaConic projection with the given earth radius. The standard parallels are set to 30 and 60 degrees north.
func (*AlbersEqualAreaConic) Forward ¶
func (c *AlbersEqualAreaConic) Forward(lonlat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*AlbersEqualAreaConic) Reverse ¶
func (c *AlbersEqualAreaConic) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*AlbersEqualAreaConic) SetOrigin ¶
func (c *AlbersEqualAreaConic) SetOrigin(origin geom.XY)
SetOrigin sets the origin of the projection to the given (longitude, latitude) pair. The origin has projected coordinates (0, 0).
func (*AlbersEqualAreaConic) SetStandardParallels ¶
func (c *AlbersEqualAreaConic) SetStandardParallels(lat1, lat2 float64)
SetStandardParallels sets the standard parallels of the projection to the given latitudes expressed in degrees.
type AzimuthalEquidistant ¶
type AzimuthalEquidistant struct {
// contains filtered or unexported fields
}
AzimuthalEquidistant allows projecting (longitude, latitude) coordinates to (x, y) pairs via the azimuthal equidistant projection.
The azimuthal equidistant projection is a projection that is:
- Configured by setting a center point.
- Equidistant. Distances from the center point are correctly scaled.
- Azimuthal. Directions from the center point are correctly preserved.
- Not conformal, but preserves shape locally at the center point.
- Not equal area, but preserves area locally at the center point.
func NewAzimuthalEquidistant ¶
func NewAzimuthalEquidistant(earthRadius float64) *AzimuthalEquidistant
NewAzimuthalEquidistant returns a new AzimuthalEquidistant projection with the given earth radius.
func (*AzimuthalEquidistant) Forward ¶
func (a *AzimuthalEquidistant) Forward(lonLat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*AzimuthalEquidistant) Reverse ¶
func (a *AzimuthalEquidistant) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*AzimuthalEquidistant) SetCenter ¶
func (a *AzimuthalEquidistant) SetCenter(centerLonLat geom.XY)
SetCenterLonLat sets the center of the projection to the given (longitude, latitude) pair. The center have projected coordinates (0, 0) and be the center of the circular map.
type EquidistantConic ¶
type EquidistantConic struct {
// contains filtered or unexported fields
}
EquidistantConic allows projecting (longitude, latitude) coordinates to (x, y) pairs via the equidistant conic projection.
The equidistant conic projection is a conic projection that is:
- Configured by setting two standard parallels.
- Not equidistant, but has correctly scaled distance along all meridians and the two standard parallels.
- Not conformal, but preserves shape locally at the standard parallels.
- Not equal area, but preserves area locally at the standard parallels.
func NewEquidistantConic ¶
func NewEquidistantConic(earthRadius float64) *EquidistantConic
NewEquidistantConic returns a new EquidistantConic projection with the given earth radius.
func (*EquidistantConic) Forward ¶
func (c *EquidistantConic) Forward(lonlat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*EquidistantConic) Reverse ¶
func (c *EquidistantConic) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*EquidistantConic) SetOrigin ¶
func (c *EquidistantConic) SetOrigin(lonLat geom.XY) *EquidistantConic
SetOrigin sets the origin of the projection to the given (longitude, latitude) pair. The origin have projected coordinates (0, 0).
func (*EquidistantConic) SetStandardParallels ¶
func (c *EquidistantConic) SetStandardParallels(lat1, lat2 float64) *EquidistantConic
SetStandardParallels sets the standard parallels of the projection to the given latitudes expressed in degrees.
type Equirectangular ¶
type Equirectangular struct {
// contains filtered or unexported fields
}
Equirectangular allows projecting (longitude, latitude) coordinates to (x, y) pairs via the equirectangular projection.
The equirectangular projection is a cylindrical projection that is:
- Configured by setting the central meridian and two standard parallels that are symmetric about the equator.
- Not equal area, but preserves area locally at the standard parallels.
- Not conformal, but preserves shape locally at the standard parallels.
- Not equidistant, but preserves distance locally at the standard parallels.
func NewEquirectangular ¶
func NewEquirectangular(earthRadius float64) *Equirectangular
NewEquirectangular returns a new Equirectangular projection with the given earth radius.
func (*Equirectangular) Forward ¶
func (e *Equirectangular) Forward(lonLat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*Equirectangular) Reverse ¶
func (e *Equirectangular) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*Equirectangular) SetCentralMeridian ¶
func (e *Equirectangular) SetCentralMeridian(lon float64)
SetCentralMeridian sets the central meridian of the projection to the given longitude expressed in degrees.
func (*Equirectangular) SetStandardParallels ¶
func (e *Equirectangular) SetStandardParallels(lat float64)
SetStandardParallels sets the standard parallels of the projection to the given latitude and its negative, expressed in degrees. E.g. providing 35 will set the standard parallels to 35 and -35.
type LambertConformalConic ¶
type LambertConformalConic struct {
// contains filtered or unexported fields
}
LambertConformalConic allows projecting (longitude, latitude) coordinates to (x, y) pairs via the Lambert conformal conic projection.
The Lambert conformal conic projection is a conic projection that is:
- Configured by setting two standard parallels.
- Conformal. Shape is preserved locally at all points.
- Not equal area, but preserves area locally at the standard parallels.
- Not equidistant, but preserves distance locally along the standard parallels.
func NewLambertConformalConic ¶
func NewLambertConformalConic(earthRadius float64) *LambertConformalConic
NewLambertConformalConic returns a new LambertConformalConic projection with the given earth radius.
func (*LambertConformalConic) Forward ¶
func (c *LambertConformalConic) Forward(lonlat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*LambertConformalConic) Reverse ¶
func (c *LambertConformalConic) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*LambertConformalConic) SetOrigin ¶
func (c *LambertConformalConic) SetOrigin(origin geom.XY)
SetOrigin sets the origin of the projection to the given (longitude, latitude) pair. The origin have projected coordinates (0, 0).
func (*LambertConformalConic) SetStandardParallels ¶
func (c *LambertConformalConic) SetStandardParallels(lat1, lat2 float64)
SetStandardParallels sets the standard parallels of the projection to the given latitudes expressed in degrees.
type LambertCylindricalEqualArea ¶
type LambertCylindricalEqualArea struct {
// contains filtered or unexported fields
}
LambertCylindricalEqualArea allows projecting (longitude, latitude) coordinates to (x, y) pairs via the Lambert cylindrical equal area projection.
The Lambert cylindrical equal area projection is a cylindrical projection that is:
- Configured by setting the central meridian.
- Equal area.
- Not conformal, but preserves shape locally along the equator.
- Not equidistant, but preserves distance along the equator.
func NewLambertCylindricalEqualArea ¶
func NewLambertCylindricalEqualArea(radius float64) *LambertCylindricalEqualArea
NewLambertCylindricalEqualArea returns a new LambertCylindricalEqualArea projection with the given earth radius.
func (*LambertCylindricalEqualArea) Forward ¶
func (c *LambertCylindricalEqualArea) Forward(lonLat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*LambertCylindricalEqualArea) Reverse ¶
func (c *LambertCylindricalEqualArea) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*LambertCylindricalEqualArea) SetCentralMeridian ¶
func (c *LambertCylindricalEqualArea) SetCentralMeridian(lon float64)
SetCentralMeridian sets the central meridian of the projection to the given longitude expressed in degrees.
type Orthographic ¶
type Orthographic struct {
// contains filtered or unexported fields
}
Orthographic allows projecting (longitude, latitude) coordinates to (x, y) pairs via the orthographic projection.
The orthographic projection projects the sphere onto a tangent plane with a point of perspective that is infinitely far away. It gives a view of the earth as seen from outer space.
It is:
- Configured by setting the center of the projection.
- Not conformal, equal area or equidistant, but preserves shape, area, and distance locally at the center of the projection.
func NewOrthographic ¶
func NewOrthographic(radius float64) *Orthographic
NewOrthographic returns a new Orthographic projection with the given earth radius.
func (*Orthographic) Forward ¶
func (m *Orthographic) Forward(lonLat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*Orthographic) Reverse ¶
func (m *Orthographic) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*Orthographic) SetCenter ¶
func (m *Orthographic) SetCenter(centerLonLat geom.XY)
SetCenter sets the center of the projection to the given (longitude, latitude) pair. The center have projected coordinates (0, 0) and be the center of the circular map.
type Sinusoidal ¶
type Sinusoidal struct {
// contains filtered or unexported fields
}
Sinusoidal allows projecting (longitude, latitude) coordinates to (x, y) pairs via the sinusoidal projection.
The sinusoidal projection is a pseudocylindrical projection that is:
- Configured by setting the central meridian.
- Equal area.
- Not conformal, but preserves shape locally along the central meridian and equator.
- Not equidistant, but preserves distance locally along all parallels and the central meridian.
func NewSinusoidal ¶
func NewSinusoidal(earthRadius float64) *Sinusoidal
NewSinusoidal returns a new Sinusoidal projection with the given earth radius.
func (*Sinusoidal) Forward ¶
func (c *Sinusoidal) Forward(lonLat geom.XY) geom.XY
Forward converts a (longitude, latitude) pair expressed in degrees to a projected (x, y) pair.
func (*Sinusoidal) Reverse ¶
func (c *Sinusoidal) Reverse(xy geom.XY) geom.XY
Reverse converts a projected (x, y) pair to a (longitude, latitude) pair expressed in degrees.
func (*Sinusoidal) SetCentralMeridian ¶
func (c *Sinusoidal) SetCentralMeridian(lon float64)
SetCentralMeridian sets the central meridian of the projection to the given longitude expressed in degrees.
type WebMercator ¶
type WebMercator struct {
// contains filtered or unexported fields
}
WebMercator is a variant of the Web Mercator projection that is used for web maps. The projection maps between (latitude, longitude) pairs expressed in degrees, and (x, y) pairs. The x and y coordinates are in the range 0 to 2^zoom, where zoom is the zoom level of the map.
The x coordinate increases from left to right, and the y coordinate increases from top to bottom.
It is:
- Conformal (shape is preserved locally at all points).
- Not equal area.
- Not equidistant.
func NewWebMercator ¶
func NewWebMercator(zoom int) *WebMercator
NewWebMercator returns a new WebMercator projection with the given zoom.