Documentation
¶
Index ¶
- Constants
- type LatLng
- type MathUtil
- func (mu *MathUtil) ArcHav(x float64) float64
- func (mu *MathUtil) Clamp(x, low, high float64) float64
- func (mu *MathUtil) FloatEqual(a, b float64) bool
- func (mu *MathUtil) Hav(x float64) float64
- func (mu *MathUtil) HavDistance(lat1, lat2, dLng float64) float64
- func (mu *MathUtil) HavFromSin(x float64) float64
- func (mu *MathUtil) InverseMercator(y float64) float64
- func (mu *MathUtil) Mercator(lat float64) float64
- func (mu *MathUtil) Mod(x, m float64) float64
- func (mu *MathUtil) SinFromHav(h float64) float64
- func (mu *MathUtil) SinSumFromHav(x, y float64) float64
- func (mu *MathUtil) Wrap(n, min, max float64) float64
- type PolyUtil
- func (pu *PolyUtil) ContainsLocation(latitude, longitude float64, polygon []LatLng, geodesic bool) bool
- func (pu *PolyUtil) Decode(encodedPath string) []LatLng
- func (pu *PolyUtil) DistanceBetweenPoints(from, to LatLng) float64
- func (pu *PolyUtil) DistanceToLine(p, start, end LatLng) float64
- func (pu *PolyUtil) Encode(path []LatLng) string
- func (pu *PolyUtil) Intersects(lat1, lat2, lng2, lat3, lng3 float64, geodesic bool) bool
- func (pu *PolyUtil) IsLocationOnEdge(point LatLng, polygon []LatLng, geodesic bool, tolerance float64) bool
- func (pu *PolyUtil) IsLocationOnEdgeWithDefaultTolerance(point LatLng, polygon []LatLng, geodesic bool) bool
- func (pu *PolyUtil) IsLocationOnPath(point LatLng, polyline []LatLng, geodesic bool, tolerance float64) bool
- func (pu *PolyUtil) IsLocationOnPathWithDefaultTolerance(point LatLng, polyline []LatLng, geodesic bool) bool
- func (pu *PolyUtil) MercatorLatRhumb(lat1, lat2, lng2, lng3 float64) float64
- func (pu *PolyUtil) Simplify(poly []LatLng, tolerance float64) []LatLng
- func (pu *PolyUtil) TanLatGC(lat1, lat2, lng2, lng3 float64) float64
- type SphericalUtil
- func (su *SphericalUtil) ComputeArea(path []LatLng) float64
- func (su *SphericalUtil) ComputeDistanceBetween(from, to LatLng) float64
- func (su *SphericalUtil) ComputeHeading(from, to LatLng) float64
- func (su *SphericalUtil) ComputeLength(path []LatLng) float64
- func (su *SphericalUtil) ComputeOffset(from LatLng, distance, heading float64) LatLng
- func (su *SphericalUtil) ComputeOffsetOrigin(to LatLng, distance, heading float64) *LatLng
- func (su *SphericalUtil) ComputeSignedArea(path []LatLng) float64
- func (su *SphericalUtil) Interpolate(from, to LatLng, fraction float64) LatLng
Constants ¶
const DEFAULT_EARTH_RADIUS = float64(6378137)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MathUtil ¶
type MathUtil struct {
EarthRadius float64
}
MathUtil contains utility functions used by both PolyUtil and SphericalUtil
func NewMathUtil ¶
NewMathUtil creates a new MathUtil instance with the specified earth radius
func (*MathUtil) FloatEqual ¶
func (*MathUtil) HavDistance ¶
HavDistance returns hav() of distance from (lat1, lng1) to (lat2, lng2) on the unit sphere
func (*MathUtil) HavFromSin ¶
HavFromSin returns hav(asin(x))
func (*MathUtil) InverseMercator ¶
InverseMercator returns latitude from mercator Y
func (*MathUtil) SinFromHav ¶
SinFromHav given h==hav(x), returns sin(abs(x))
func (*MathUtil) SinSumFromHav ¶
SinSumFromHav returns sin(arcHav(x) + arcHav(y))
type PolyUtil ¶
type PolyUtil struct {
EarthRadius float64
Math *MathUtil
Spherical *SphericalUtil
}
func NewPolyUtil ¶
NewPolyUtil creates a new PolyUtil instance with the specified earth radius
func (*PolyUtil) ContainsLocation ¶
func (pu *PolyUtil) ContainsLocation(latitude, longitude float64, polygon []LatLng, geodesic bool) bool
ContainsLocation computes whether the given point lies inside the specified polygon
func (*PolyUtil) DistanceBetweenPoints ¶
func (*PolyUtil) DistanceToLine ¶
DistanceToLine computes the distance on the sphere between the point p and the line segment start to end
func (*PolyUtil) Intersects ¶
Intersects computes whether the vertical segment (lat3, lng3) to South Pole intersects the segment (lat1, lng1) to (lat2, lng2)
func (*PolyUtil) IsLocationOnEdge ¶
func (pu *PolyUtil) IsLocationOnEdge(point LatLng, polygon []LatLng, geodesic bool, tolerance float64) bool
IsLocationOnEdge computes whether the given point lies on or near the edge of a polygon, within a specified tolerance in meters
func (*PolyUtil) IsLocationOnEdgeWithDefaultTolerance ¶
func (pu *PolyUtil) IsLocationOnEdgeWithDefaultTolerance(point LatLng, polygon []LatLng, geodesic bool) bool
IsLocationOnEdgeWithDefaultTolerance is the same as IsLocationOnEdge with a default tolerance of 0.1 meters
func (*PolyUtil) IsLocationOnPath ¶
func (pu *PolyUtil) IsLocationOnPath(point LatLng, polyline []LatLng, geodesic bool, tolerance float64) bool
IsLocationOnPath computes whether the given point lies on or near a polyline, within a specified tolerance in meters
func (*PolyUtil) IsLocationOnPathWithDefaultTolerance ¶
func (pu *PolyUtil) IsLocationOnPathWithDefaultTolerance(point LatLng, polyline []LatLng, geodesic bool) bool
IsLocationOnPathWithDefaultTolerance is the same as IsLocationOnPath with a default tolerance of 0.1 meters
func (*PolyUtil) MercatorLatRhumb ¶
MercatorLatRhumb returns mercator(latitude-at-lng3) on the Rhumb line (lat1, lng1) to (lat2, lng2)
type SphericalUtil ¶
type SphericalUtil struct {
EarthRadius float64
}
SphericalUtil contains utility functions for spherical calculations
func NewSphericalUtil ¶
func NewSphericalUtil(earthRadius float64) *SphericalUtil
NewSphericalUtil creates a new SphericalUtil instance with the specified earth radius
func (*SphericalUtil) ComputeArea ¶
func (su *SphericalUtil) ComputeArea(path []LatLng) float64
ComputeArea returns the area of a closed path on Earth
func (*SphericalUtil) ComputeDistanceBetween ¶
func (su *SphericalUtil) ComputeDistanceBetween(from, to LatLng) float64
ComputeDistanceBetween returns the distance between two LatLngs, in meters
func (*SphericalUtil) ComputeHeading ¶
func (su *SphericalUtil) ComputeHeading(from, to LatLng) float64
ComputeHeading returns the heading from one LatLng to another LatLng
func (*SphericalUtil) ComputeLength ¶
func (su *SphericalUtil) ComputeLength(path []LatLng) float64
ComputeLength returns the length of the given path, in meters, on Earth
func (*SphericalUtil) ComputeOffset ¶
func (su *SphericalUtil) ComputeOffset(from LatLng, distance, heading float64) LatLng
ComputeOffset returns the LatLng resulting from moving a distance from an origin in the specified heading
func (*SphericalUtil) ComputeOffsetOrigin ¶
func (su *SphericalUtil) ComputeOffsetOrigin(to LatLng, distance, heading float64) *LatLng
ComputeOffsetOrigin returns the location of origin when provided with a LatLng destination, meters travelled and original heading
func (*SphericalUtil) ComputeSignedArea ¶
func (su *SphericalUtil) ComputeSignedArea(path []LatLng) float64
ComputeSignedArea returns the signed area of a closed path on Earth
func (*SphericalUtil) Interpolate ¶
func (su *SphericalUtil) Interpolate(from, to LatLng, fraction float64) LatLng
Interpolate returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng