ellipsoid

package
v0.0.0-...-01047a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 2 Imported by: 21

Documentation

Index

Constants

View Source
const (

	// Meter is one of the output/input units.
	Meter = 0 //    1.0    meter
	// Foot is one of the output/input units.
	Foot = 1 //    0.3048 meter are a foot
	// Kilometer is one of the output/input units.
	Kilometer = 2 // 1000.0    meter are a kilometer
	// Mile is one of the output/input units.
	Mile = 3 // 1609.344  meter are a mile
	// Nm (nautical mile) is one of the output/input units.
	Nm = 4 // 1852.0    meter are a nautical mile,
	// Degrees is one of the possible angle units for input/output.
	Degrees = iota
	// Radians is one of the possible angle units for input/output.
	Radians = iota
	// LongitudeIsSymmetric determines that the output longitude shall be symmetric.
	LongitudeIsSymmetric = true
	// LongitudeNotSymmetric determines that the output longitude shall not be symmetric.
	LongitudeNotSymmetric = false
	// BearingIsSymmetric determines that the output bearing shall be symmetric.
	BearingIsSymmetric = true
	// BearingNotSymmetric determines that the output bearing shall not be symmetric.
	BearingNotSymmetric = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Ellipsoid

type Ellipsoid struct {
	Ellipse            ellipse
	Units              int
	DistanceUnits      int
	LongitudeSymmetric bool
	BearingSymmetry    bool
	DistanceFactor     float64
}

Ellipsoid is the main object to store information about one ellispoid.

func Init

func Init(name string, units int, distUnits int, longSym bool, bearSym bool) (e Ellipsoid)
Init

The Init constructor must be called with a list of parameters to set the value of the ellipsoid to be used, the value of the units to be used for angles and distances, and whether or not the output range of longitudes and bearing angles should be symmetric around zero or always greater than zero. There is no default constructor, all arguments are required; they may not be abbreviated.

Example:

geo := ellipsoid.Init(
	"WGS84",  // for possible values see below.
	ellipsoid.Degrees, // possible values: Degrees or Radians
	ellipsoid.Meter,   // possible values: Meter, Kilometer,
			   // Foot, Nm, Mile
	ellipsoid.LongitudeIsSymmetric, // possible values
					  // LongitudeIsSymmetric or
					  // LongitudeNotSymmetric
	ellipsoid.BearingIsSymmetric    // possible
					  // values BearingIsSymmetric or
					  // BearingNotSymmetric
)

func (Ellipsoid) At

func (ellipsoid Ellipsoid) At(lat1, lon1, distance, bearing float64) (lat2, lon2 float64)
At returns the list latitude,longitude in degrees or radians that is a

specified range and bearing from a given location.

lat2, lon2  = geo.At( lat1, lon1, range, bearing )

func (Ellipsoid) Displacement

func (ellipsoid Ellipsoid) Displacement(lat1, lon1, lat2, lon2 float64) (x, y float64)
Displacement returns the (x,y) displacement in distance units between the two specified

locations.

x, y  = geo.Displacement( lat1, lon1, lat2, lon2 )

NOTE: The x and y displacements are only approximations and only valid between two locations that are fairly near to each other. Beyond 10 kilometers or more, the concept of X and Y on a curved surface loses its meaning.

func (Ellipsoid) Intermediate

func (ellipsoid Ellipsoid) Intermediate(lat1, lon1, lat2, lon2 float64, steps int) (distance, bearing float64, arr []float64)
Intermediate

Takes two coordinates with longitude and latitude; and a step count and returns range and bearing and an array with the lons and lats of intermediate points on a straight line (whatever that is on an ellipsoid), INCLUDING the start and the endpoint.

So if you put in point1 and point2 with step count 4, the output will be (you make 4 hops, right?)

point1
i1
i2
i3
point2

Each point is two float64 values, lat and lon, thus you have an array with 4*2 + 2 = 5*2 cells.

steps shall not be 0.

I havent tested the upper limit for steps.

func (Ellipsoid) Location

func (ellipsoid Ellipsoid) Location(lat1, lon1, x, y float64) (lat, lon float64)
Location returns the list (latitude,longitude) of a location at a given (x,y)

displacement from a given location.

lat2, lon2 = geo.Location( lat1, lon1, x, y )

The note from Displacement applies.

func (Ellipsoid) To

func (ellipsoid Ellipsoid) To(lat1, lon1, lat2, lon2 float64) (distance, bearing float64)

To returns range, bearing between two specified locations.

dist, theta  = geo.To( lat1, lon1, lat2, lon2 )

func (Ellipsoid) ToECEF

func (ellipsoid Ellipsoid) ToECEF(lat1, lon1, alt1 float64) (x, y, z float64)

ToECEF takes the latitude, longitude, elevation list and

returns three cartesian coordinates x, y, z

func (Ellipsoid) ToLLA

func (ellipsoid Ellipsoid) ToLLA(x, y, z float64) (lat1, lon1, alt1 float64)
ToLLA takes three cartesian coordinates x, y, z and returns

the latitude, longitude, elevation list.

FIXME: This algorithm cannot handle x==0, although this is a valid value. WARNING: I put in an if condition to catch this. Is it still necessary?

type Location

type Location struct {
	Lat float64
	Lon float64
	Ele float64
}

Location is one coordinate in LLA.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL