Documentation
¶
Overview ¶
Package offers two main functionalities: solving the "direct" and the "inverse" problems.
Direct:
Place a second point, given the first point, an azimuth, and a distance.
Arguments ¶
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
Returns ¶
There are a variety of outputs associated with this calculation. We save computation by only calculating the outputs you need. You can get any and all of the following
- lat2 latitude of point 2 [degrees].
- lon2 longitude of point 2 [degrees].
- azi2 (forward) azimuth at point 2 [degrees].
- m12 reduced length of geodesic (meters).
- M12 geodesic scale of point 2 relative to point 1 [dimensionless].
- M21 geodesic scale of point 1 relative to point 2 [dimensionless].
- S12 area under the geodesic [meters^2]
- a12 arc length of between point 1 and point 2 [degrees].
Call the appropriate function to get the output you need. The following functions are available for solving the Direct problem. Each describes what it returns
- DirectCalcLatLon -> calculate latitude and longitude
- DirectCalcLatLonAzi -> calculate latitude, longitude, and azimuth
- DirectCalcLatLonAziReducedLength -> calculate latitude, longitude, azimuth, and reduced length of the geodesic
- DirectCalcLatLonAziGeodesicScales -> calculate latitude, longitude, azimuth, and the geodesic scales
- DirectCalcLatLonAziReducedLengthGeodesicScales -> calculate latitude, longitude, azimuth, reduced length, and the geodesic scales
- DirectCalcAll -> calculates all of the above plus Area under the geodesic and the arc length between point 1 and point 2
===================================================================================== ===================================================================================== ===================================================================================== Indirect:
Measure the distance (and other values) between two points.
# Arguments - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
Returns ¶
There are a variety of outputs associated with this calculation. We save computation by only calculating the outputs you need. You can get any and all of the following
- s12 distance between point 1 and point 2 (meters). - azi1 azimuth at point 1 [degrees]. - azi2 (forward) azimuth at point 2 [degrees]. - m12 reduced length of geodesic (meters). - M12 geodesic scale of point 2 relative to point 1 [dimensionless]. - M21 geodesic scale of point 1 relative to point 2 [dimensionless]. - S12 area under the geodesic [meters^2] - a12 arc length of between point 1 and point 2 [degrees].
Call the appropriate function to get the output you need. The following functions are available for solving the Direct problem. Each describes what it returns
`lat1` and `lat2` should be in the range [−90°, 90°]. The values of `azi1` and `azi2` returned are in the range [−180°, 180°].
If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing `lat` = ±(90° − ε), and taking the limit ε → 0+.
The solution to the inverse problem is found using Newton's method. If this fails to converge (this is very unlikely in geodetic applications but does occur for very eccentric ellipsoids), then the bisection method is used to refine the solution.
Example ¶
package main
import (
"fmt"
geodesic "github.com/natemcintosh/geographiclib-go"
)
func main() {
// Create a struct representing the Earth
earth := geodesic.Wgs84()
// If I start in the middle of Times Square in New York City, and head due West for
// 1000km, where will I end up?
NY_lat := 40.757954
NY_lon := -73.985548
ended_up_at := earth.DirectCalcLatLon(NY_lat, NY_lon, -90, 1000e3)
fmt.Println("Ended up at", ended_up_at)
// Looking on a map, we have ended up in Lafayette Township, a little ways outside
// Indianapolis
// Now let's do the inverse calculation. What is the distance from New York City to
// Chicago?
CHI_lat := 41.882609
CHI_lon := -87.621978
NYC_to_CHI_dist := earth.InverseCalcDistance(NY_lat, NY_lon, CHI_lat, CHI_lon)
fmt.Printf("Distance from NYC to CHI is %0.1f m\n", NYC_to_CHI_dist)
// Wyoming is a fairly rectangular state. Taking its four corners as its boundaries,
// what is its area?
WY_corners_lat_lon := [][2]float64{
{40.997958, -111.046710},
{45.001311, -111.055200},
{44.997380, -104.057699},
{41.001432, -104.053249},
}
polygon := geodesic.NewPolygonArea(earth, false)
for _, corner := range WY_corners_lat_lon {
polygon.AddPoint(corner[0], corner[1])
}
polygon_result := polygon.Compute(true, false)
fmt.Printf("Wyoming area is approximatley %0.0f m^2\n", polygon_result.Area)
// What is the approximate perimeter of Wyoming?
fmt.Printf("Wyoming perimeter is approximately %0.0f m\n", polygon_result.Perimeter)
// But we don't only have to do calculations on Earth. Let's try some on Mars!
mars_equatorial_radius_m := 3396.2e3
mars_flattening_factor := 5.0304e-3
mars := geodesic.NewGeodesic(mars_equatorial_radius_m, mars_flattening_factor)
// What is the distance from Olympus Mons (18.65, -133.8) to the Curiosity Rover's
// landing site (-4.47, 137.42)?
mars_distance := mars.InverseCalcDistance(18.65, -133.8, -4.47, 137.42)
fmt.Printf("Olympus Mons to Curiosity landing site is %0.0f m", mars_distance)
}
Output: Ended up at {40.15431701948773 -85.75720579845405} Distance from NYC to CHI is 1147311.9 m Wyoming area is approximatley 253282066939 m^2 Wyoming perimeter is approximately 2028472 m Olympus Mons to Curiosity landing site is 5348380 m
Index ¶
- Constants
- type Accumulator
- type AllDirectResults
- type AllInverseResults
- type AzimuthsArcLength
- type DistanceArcLength
- type DistanceAzimuths
- type DistanceAzimuthsArcLength
- type DistanceAzimuthsArcLengthReducedLength
- type DistanceAzimuthsArcLengthReducedLengthScales
- type Geodesic
- func (g *Geodesic) DirectCalcAll(lat1_deg, lon1_deg, azi1_deg, s12_m float64) AllDirectResults
- func (g *Geodesic) DirectCalcLatLon(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLon
- func (g *Geodesic) DirectCalcLatLonAzi(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAzi
- func (g *Geodesic) DirectCalcLatLonAziGeodesicScales(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAziGeodesicScales
- func (g *Geodesic) DirectCalcLatLonAziReducedLength(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAziReducedLength
- func (g *Geodesic) DirectCalcLatLonAziReducedLengthGeodesicScales(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAziReducedLengthGeodesicScales
- func (g *Geodesic) DirectCalcWithCapabilities(lat1_deg, lon1_deg, azi1_deg, s12_m float64, capabilities uint64) AllDirectResults
- func (g *Geodesic) DirectLineWithCapabilities(lat1_deg, lon1_deg, azi1_deg, s12_m float64, capabilities uint64) GeodesicLine
- func (g *Geodesic) EqualtorialRadius() float64
- func (g *Geodesic) Flattening() float64
- func (g *Geodesic) InverseCalcAll(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) AllInverseResults
- func (g *Geodesic) InverseCalcAzimuthsArcLength(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) AzimuthsArcLength
- func (g *Geodesic) InverseCalcDistance(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) float64
- func (g *Geodesic) InverseCalcDistanceArcLength(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceArcLength
- func (g *Geodesic) InverseCalcDistanceAzimuths(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceAzimuths
- func (g *Geodesic) InverseCalcDistanceAzimuthsArcLength(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceAzimuthsArcLength
- func (g *Geodesic) InverseCalcDistanceAzimuthsArcLengthReducedLength(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceAzimuthsArcLengthReducedLength
- func (g *Geodesic) InverseCalcDistanceAzimuthsArcLengthReducedLengthScales(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceAzimuthsArcLengthReducedLengthScales
- func (g *Geodesic) InverseCalcWithCapabilities(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, capabilities uint64) AllInverseResults
- func (g *Geodesic) InverseLineWithCapabilities(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, capabilities uint64) GeodesicLine
- func (g *Geodesic) LineWithCapabilities(lat1_deg, lon1_deg, azi1_deg float64, capabilities uint64) GeodesicLine
- type GeodesicLine
- type LatLon
- type LatLonAzi
- type LatLonAziGeodesicScales
- type LatLonAziReducedLength
- type LatLonAziReducedLengthGeodesicScales
- type PolygonArea
- func (p *PolygonArea) AddEdge(azi_deg, s_m float64)
- func (p *PolygonArea) AddPoint(lat_deg, lon_deg float64)
- func (p *PolygonArea) Clear()
- func (p *PolygonArea) Compute(reverse, sign bool) PolygonResult
- func (p *PolygonArea) TestEdge(azi_deg float64, s_m float64, reverse bool, sign bool) PolygonResult
- func (p *PolygonArea) TestPoint(lat_deg float64, lon_deg float64, reverse bool, sign bool) PolygonResult
- type PolygonResult
- type PositionResult
- type PositionResultStandard
Examples ¶
Constants ¶
const ( // Includes LONG_UNROLL OUT_MASK uint64 = 0xFF80 EMPTY uint64 = 0 LATITUDE uint64 = 1<<7 | _CAP_NONE LONGITUDE uint64 = 1<<8 | _CAP_C3 AZIMUTH uint64 = 1<<9 | _CAP_NONE DISTANCE uint64 = 1<<10 | _CAP_C1 STANDARD uint64 = LATITUDE | LONGITUDE | AZIMUTH | DISTANCE DISTANCE_IN uint64 = 1<<11 | _CAP_C1 | _CAP_C1p REDUCEDLENGTH uint64 = 1<<12 | _CAP_C1 | _CAP_C2 GEODESICSCALE uint64 = 1<<13 | _CAP_C1 | _CAP_C2 AREA uint64 = 1<<14 | _CAP_C4 LONG_UNROLL uint64 = 1 << 15 // Does not include LONG_UNROLL ALL uint64 = _OUT_ALL | _CAP_ALL )
const DEG2RAD float64 = math.Pi / 180.0
const RAD2DEG float64 = 180.0 / math.Pi
const WGS84_A float64 = 6378137.0
const WGS84_F float64 = 1.0 / ((298257223563.0) / 1000000000.0)
Evaluating this as 1000000000.0 / (298257223563f_64) reduces the round-off error by about 10%. However, expressing the flattening as 1/298.257223563 is well ingrained.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
type Accumulator struct {
// contains filtered or unexported fields
}
Accumulator allows a running sum of float64s
func NewAccumulatorFromS ¶
func NewAccumulatorFromS(s float64) Accumulator
func NewAccumulatorFromST ¶
func NewAccumulatorFromST(s, t float64) Accumulator
func (*Accumulator) Remainder ¶
func (p *Accumulator) Remainder(y float64)
Remainder on division by y
func (*Accumulator) SetS ¶
func (p *Accumulator) SetS(s float64)
SetS sets s to the argument, and t to 0
type AllDirectResults ¶
type AllDirectResults struct {
LatDeg float64 // Latitude [degrees]
LonDeg float64 // Longitude [degrees]
AziDeg float64 // Azimuth [degrees]
ReducedLengthM float64 // Reduced length of the geodesic [meters]
M12 float64 // Geodesic scale of point 2 relative to point 1 [dimensionless]
M21 float64 // Geodesic scale of point 1 relative to point 2 [dimensionless]
S12M2 float64 // Area under the geodesic [meters^2]
A12Deg float64 // Arc length between point 1 and point 2 [degrees]
}
AllDirectResults contains all information that can be computed from the direct method latitude, longitude, azimuth, reduced length, geodesic scales, area under the geodesic, and arc length between point 1 and point 2
type AllInverseResults ¶
type AllInverseResults struct {
DistanceM float64 // distance between point 1 and point 2 [meters]
Azimuth1Deg float64 // azimuth at point 1 [degrees]
Azimuth2Deg float64 // (forward) azimuth at point 2 [degrees]
ArcLengthDeg float64 // arc length between point 1 and point 2 [degrees]
ReducedLengthM float64 // reduced length of geodesic [meters]
M12 float64 // geodesic scale of point 2 relative to point 1 [dimensionless]
M21 float64 // geodesic scale of point 1 relative to point 2 [dimensionless]
S12M2 float64 // area under the geodesic [meters^2]
}
type AzimuthsArcLength ¶
type DistanceArcLength ¶
type DistanceAzimuths ¶
type DistanceAzimuthsArcLengthReducedLength ¶
type DistanceAzimuthsArcLengthReducedLength struct {
DistanceM float64 // distance between point 1 and point 2 [meters]
Azimuth1Deg float64 // azimuth at point 1 [degrees]
Azimuth2Deg float64 // (forward) azimuth at point 2 [degrees]
ArcLengthDeg float64 // arc length between point 1 and point 2 [degrees]
ReducedLengthM float64 // reduced length of geodesic [meters]
}
type DistanceAzimuthsArcLengthReducedLengthScales ¶
type DistanceAzimuthsArcLengthReducedLengthScales struct {
DistanceM float64 // distance between point 1 and point 2 [meters]
Azimuth1Deg float64 // azimuth at point 1 [degrees]
Azimuth2Deg float64 // (forward) azimuth at point 2 [degrees]
ArcLengthDeg float64 // arc length between point 1 and point 2 [degrees]
ReducedLengthM float64 // reduced length of geodesic [meters]
M12 float64 // geodesic scale of point 2 relative to point 1 [dimensionless]
M21 float64 // geodesic scale of point 1 relative to point 2 [dimensionless]
}
type Geodesic ¶
type Geodesic struct {
GEODESIC_ORDER int64
// contains filtered or unexported fields
}
func NewGeodesic ¶
func (*Geodesic) DirectCalcAll ¶
func (g *Geodesic) DirectCalcAll(lat1_deg, lon1_deg, azi1_deg, s12_m float64) AllDirectResults
DirectCalcAll calculates everything possible for the direct method. Takes inputs
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
func (*Geodesic) DirectCalcLatLon ¶
DirectCalcLatLon gets the lat and lon of the second point, based on input
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
func (*Geodesic) DirectCalcLatLonAzi ¶
DirectCalcLatLonAzi gets the lat, lon, and azimuth of the second point, based on input
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
func (*Geodesic) DirectCalcLatLonAziGeodesicScales ¶
func (g *Geodesic) DirectCalcLatLonAziGeodesicScales(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAziGeodesicScales
DirectCalcLatLonAziGeodesicScales gets the lat, lon, azimuth, and geodesic scales, based on input
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
func (*Geodesic) DirectCalcLatLonAziReducedLength ¶
func (g *Geodesic) DirectCalcLatLonAziReducedLength(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAziReducedLength
DirectCalcLatLonAziReducedLength gets the lat, lon, azimuth, and reduced length of geodesic of the second point, based on input
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
func (*Geodesic) DirectCalcLatLonAziReducedLengthGeodesicScales ¶
func (g *Geodesic) DirectCalcLatLonAziReducedLengthGeodesicScales( lat1_deg, lon1_deg, azi1_deg, s12_m float64, ) LatLonAziReducedLengthGeodesicScales
DirectCalcLatLonAziReducedLengthGeodesicScales gets the lat, lon, azimuth, reduced length, and geodesic scales based on input
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- s12_m - Distance from 1st to 2nd point [meters] Value may be negative
func (*Geodesic) DirectCalcWithCapabilities ¶
func (g *Geodesic) DirectCalcWithCapabilities( lat1_deg, lon1_deg, azi1_deg, s12_m float64, capabilities uint64, ) AllDirectResults
DirectCalcWithCapabilities allows the user to specify which capabilites they wish to use. This function is useful if you want some other subset of capabilities than those offered by the other DirectCalc...() methods. Takes inputs
- lat1_deg - Latitude of 1st point [degrees] [-90.,90.]
- lon1_deg - Longitude of 1st point [degrees] [-180., 180.]
- azi1_deg - Azimuth at 1st point [degrees] [-180., 180.]
- capabilities - One or more of the capabilities constant as defined in the file geodesiccapability.go. Usually, they are OR'd together, e.g. LATITUDE | LONGITUDE
func (*Geodesic) DirectLineWithCapabilities ¶
func (g *Geodesic) DirectLineWithCapabilities( lat1_deg, lon1_deg, azi1_deg, s12_m float64, capabilities uint64, ) GeodesicLine
DirectLineWithCapabilities defines a GeodesicLine struct in terms of the the direct geodesic problem specified in terms of spherical arc length. This function sets point 3 of the GeodesicLine to correspond to point 2 of the direct geodesic problem
func (*Geodesic) EqualtorialRadius ¶
func (*Geodesic) Flattening ¶
func (*Geodesic) InverseCalcAll ¶
func (g *Geodesic) InverseCalcAll( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, ) AllInverseResults
InverseCalcAll returns everything described in the `AllInverseResults` results type. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcAzimuthsArcLength ¶
func (g *Geodesic) InverseCalcAzimuthsArcLength( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, ) AzimuthsArcLength
InverseCalcAzimuthsArcLength returns the azimuth at point 1, the azimuth at point 2, and the arc length between the points. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcDistance ¶
InverseCalcDistance returns the distance from point 1 to point 2 in meters. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcDistanceArcLength ¶
func (g *Geodesic) InverseCalcDistanceArcLength(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceArcLength
InverseCalcDistanceArcLength returns the distance from one point to the next, and the arc length between the points. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcDistanceAzimuths ¶
func (g *Geodesic) InverseCalcDistanceAzimuths(lat1_deg, lon1_deg, lat2_deg, lon2_deg float64) DistanceAzimuths
InverseCalcDistanceAzimuths returns the distance from one point to the next, and the azimuths. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcDistanceAzimuthsArcLength ¶
func (g *Geodesic) InverseCalcDistanceAzimuthsArcLength( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, ) DistanceAzimuthsArcLength
InverseCalcDistanceAzimuthsArcLength returns the distance from one point to the next, the azimuth at point 1, the azimuth at point 2, and the arc length between the points. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcDistanceAzimuthsArcLengthReducedLength ¶
func (g *Geodesic) InverseCalcDistanceAzimuthsArcLengthReducedLength( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, ) DistanceAzimuthsArcLengthReducedLength
InverseCalcDistanceAzimuthsArcLengthReducedLength returns the distance from one point to the next, the azimuth at point 1, the azimuth at point 2, the arc length between the points, and the reduceed length of the geodesic. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcDistanceAzimuthsArcLengthReducedLengthScales ¶
func (g *Geodesic) InverseCalcDistanceAzimuthsArcLengthReducedLengthScales( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, ) DistanceAzimuthsArcLengthReducedLengthScales
InverseCalcDistanceAzimuthsArcLengthReducedLengthScales returns everything described by the `DistanceAzimuthsArcLengthReducedLengthScales` type. Takes inputs - lat1_deg latitude of point 1 [degrees]. - lon1_deg longitude of point 1 [degrees]. - lat2_deg latitude of point 2 [degrees]. - lon2_deg longitude of point 2 [degrees].
func (*Geodesic) InverseCalcWithCapabilities ¶
func (g *Geodesic) InverseCalcWithCapabilities( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, capabilities uint64, ) AllInverseResults
InverseCalcWithCapabilities allows the user to specify which capabilites they wish to use. This function is useful if you want some other subset of capabilities than those offered by the other InverseCalc...() methods. Takes inputs
- lat1_deg latitude of point 1 [degrees].
- lon1_deg longitude of point 1 [degrees].
- lat2_deg latitude of point 2 [degrees].
- lon2_deg longitude of point 2 [degrees].
- capabilities - One or more of the capabilities constant as defined in the file geodesiccapability.go. Usually, they are OR'd together, e.g. LATITUDE | LONGITUDE
func (*Geodesic) InverseLineWithCapabilities ¶
func (g *Geodesic) InverseLineWithCapabilities( lat1_deg, lon1_deg, lat2_deg, lon2_deg float64, capabilities uint64, ) GeodesicLine
InverseLineWithCapabilities: define a GeodesicLine struct in terms of the inverse geodesic problem. This function sets point 3 of the GeodesicLine to correspond to point 2 of the inverse geodesic problem.
func (*Geodesic) LineWithCapabilities ¶
func (g *Geodesic) LineWithCapabilities( lat1_deg, lon1_deg, azi1_deg float64, capabilities uint64, ) GeodesicLine
Line returns a GeodesicLine. This allows points along a geodesic starting at lat1_deg, lon1_deg with azimuth azi1_deg to be found.
type GeodesicLine ¶
type GeodesicLine struct {
// contains filtered or unexported fields
}
func NewGeodesicLine ¶
func NewGeodesicLine( geod Geodesic, lat1, lon1, azi1 float64, ) GeodesicLine
NewGeodesicLine creates a GeodesicLine, with `caps` of STANDARD | DISTANCE_IN
func NewGeodesicLineWithCapability ¶
func NewGeodesicLineWithCapability( geod Geodesic, lat1, lon1, azi1 float64, caps uint64, ) GeodesicLine
NewGeodesicLineWithCapability is the same as NewGeodesicLine but the user specifies a `caps` field.
func (GeodesicLine) PositionStandard ¶
func (g GeodesicLine) PositionStandard(s12_m float64) PositionResultStandard
PositionStandard finds the position on the line given s12_m [meters]. It uses the STANDARD capabilities, and returns a PositionResultStandard struct
func (GeodesicLine) PositionWithCapabilities ¶
func (g GeodesicLine) PositionWithCapabilities(s12_m float64, capabilities uint64) PositionResult
PositionWithCapabilities finds the position on the line given s12_m [meters]. It uses whatever capabilities are handed in. Any results not asked for with the capabilities will be math.NaN()
type LatLon ¶
type LatLon struct {
LatDeg, LonDeg float64
}
LatLon represents latitude and longitude of a point. All units in degrees
type LatLonAzi ¶
type LatLonAzi struct {
LatDeg, LonDeg, AziDeg float64
}
LatLonAzi represents latitude, longitude, and azimuth of a point. All units in degrees
type LatLonAziGeodesicScales ¶
type LatLonAziGeodesicScales struct {
LatDeg float64 // Latitude [degrees]
LonDeg float64 // Longitude [degrees]
AziDeg float64 // Azimuth [degrees]
M12 float64 // Geodesic scale of point 2 relative to point 1 [dimensionless]
M21 float64 // Geodesic scale of point 1 relative to point 2 [dimensionless]
}
LatLonAziGeodesicScales: All units in degrees. Scales are dimensionless
type LatLonAziReducedLength ¶
type LatLonAziReducedLength struct {
LatDeg float64 // Latitude [degrees]
LonDeg float64 // Longitude [degrees]
AziDeg float64 // Azimuth [degrees]
ReducedLengthM float64 // Reduced length of the geodesic [meters]
}
LatLonAziReducedLength: All units in degrees and meters
type LatLonAziReducedLengthGeodesicScales ¶
type LatLonAziReducedLengthGeodesicScales struct {
LatDeg float64 // Latitude [degrees]
LonDeg float64 // Longitude [degrees]
AziDeg float64 // Azimuth [degrees]
ReducedLengthM float64 // Reduced length of the geodesic [meters]
M12 float64 // Geodesic scale of point 2 relative to point 1 [dimensionless]
M21 float64 // Geodesic scale of point 1 relative to point 2 [dimensionless]
}
LatLonAziReducedLengthGeodesicScales: All units in degrees and meters. Scales are dimensionless
type PolygonArea ¶
type PolygonArea struct {
Earth Geodesic
Polyline bool
Area0_M2 float64
Num int
Lat1_Deg float64
Lon1_Deg float64
// contains filtered or unexported fields
}
func NewPolygonArea ¶
func NewPolygonArea(g Geodesic, is_polyline bool) PolygonArea
NewPolygonArea creates a new struct for calculating area and perimeter of a polygon, or for calculating the perimeter of a polyline (a set of connected lines). Takes inputs:
- g Geodesic on which you wish to calculate
- is_polyline if true, then assume all points added will only form a polyline. No area will be calculated
func (*PolygonArea) AddEdge ¶
func (p *PolygonArea) AddEdge(azi_deg, s_m float64)
AddEdge adds the next edge to the polygon. This specifies the new vertex in terms of the edge from the current vertex. INPUTS: - azi_deg: the azimuth at the current point in degrees - s_m: the length of the edge in meters
func (*PolygonArea) AddPoint ¶
func (p *PolygonArea) AddPoint(lat_deg, lon_deg float64)
AddPoint adds the next vertex to the polygon. This adds an edge from the current vertex to the new vertex
func (*PolygonArea) Compute ¶
func (p *PolygonArea) Compute(reverse, sign bool) PolygonResult
Compute the properties of the polygon
INPUTS:
- reverse: if true then clockwise (instead of counter-clockwise) traversal counts as a positive area
- sign: if true then return a signed result for the area if the polygon is traversed in the "wrong" direction instead of returning the area for the rest of the earth
Arbitrarily complex polygons are allowed. In the case of self-intersecting polygons the area is accumulated "algebraically", e.g., the areas of the 2 loops in a figure-8 polygon will partially cancel.
If the object is a polygon (and not a polyline), the perimeter includes the length of a final edge connecting the current point to the initial point. If the object is a polyline, then area is nan.
More points can be added to the polygon after this call.
func (*PolygonArea) TestEdge ¶
func (p *PolygonArea) TestEdge( azi_deg float64, s_m float64, reverse bool, sign bool, ) PolygonResult
TestEdge returns the results assuming a tentative final test point is added via an azimuth and distance; however, the data for the test point is not saved. This lets you report a running result for the perimeter and area as the user moves the mouse cursor. Ordinary floating point arithmetic is used to accumulate the data for the test point; thus the area and perimeter returned are less accurate than if AddPoint and Compute are used.
INPUTS:
- azi_deg: azimuth at the current point [degrees]
- s_m: distance from the current point to the final test point [meters]
- reverse: if true then clockwise (instead of counter-clockwise) traversal counts as a positive area
- sign: if true then return a signed result for the area if the polygon is traversed in the "wrong" direction instead of returning the area for the rest of the earth
func (*PolygonArea) TestPoint ¶
func (p *PolygonArea) TestPoint( lat_deg float64, lon_deg float64, reverse bool, sign bool, ) PolygonResult
TestPoint return the results assuming a tentative final test point is added; however, the data for the test point is not saved. This lets you report a running result for the perimeter and area as the user moves the mouse cursor. Ordinary floating point arithmetic is used to accumulate the data for the test point; thus the area and perimeter returned are less accurate than if AddPoint and Compute are used.
INPUTS:
- lat_deg: the latitude of the test point [degrees]. Should be in the range [-90, 90]
- lon_deg: the longitude of the test point [degrees]
- reverse: if true then clockwise (instead of counter-clockwise) traversal counts as a positive area
- sign: if true then return a signed result for the area if the polygon is traversed in the "wrong" direction instead of returning the area for the rest of the earth
type PolygonResult ¶
type PositionResult ¶
type PositionResult struct {
Lat1Deg float64 // Latitude of point 1 [degrees]
Lon1Deg float64 // Longitude of point 1 [degrees]
Azi1Deg float64 // Azimuth of point 1 [degrees]
Lat2Deg float64 // Latitude of point 2 [degrees]
Lon2Deg float64 // Longitude of point 2 [degrees]
Azi2Deg float64 // Azimuth of point 2 [degrees]
DistanceM float64 // Distance from point 1 to point 2 [meters]
ArcLengthDeg float64 // Arc length between point 1 and point 2 [degrees]
ReducedLengthM float64 // Reduced length of the geodesic [meters]
M12 float64 // Geodesic scale of point 2 relative to point 1 [dimensionless]
M21 float64 // Geodesic scale of point 1 relative to point 2 [dimensionless]
S12M2 float64 // Area under the geodesic [meters^2]
}
type PositionResultStandard ¶
type PositionResultStandard struct {
Lat1Deg float64 // Latitude of point 1 [degrees]
Lon1Deg float64 // Longitude of point 1 [degrees]
Azi1Deg float64 // Azimuth of point 1 [degrees]
Lat2Deg float64 // Latitude of point 2 [degrees]
Lon2Deg float64 // Longitude of point 2 [degrees]
Azi2Deg float64 // Azimuth of point 2 [degrees]
DistanceM float64 // Distance from point 1 to point 2 [meters]
}