Documentation ¶
Index ¶
- Constants
- type Point
- func (p *Point) BearingTo(p2 *Point) float64
- func (p *Point) GreatCircleDistance(p2 *Point) float64
- func (p *Point) Lat() float64
- func (p *Point) Lng() float64
- func (p *Point) MarshalBinary() ([]byte, error)
- func (p *Point) MarshalJSON() ([]byte, error)
- func (p *Point) MidpointTo(p2 *Point) *Point
- func (p *Point) PointAtDistanceAndBearing(dist float64, bearing float64) *Point
- func (p *Point) UnmarshalBinary(data []byte) error
- func (p *Point) UnmarshalJSON(data []byte) error
- type Polygon
Constants ¶
const (
// According to Wikipedia, the Earth's radius is about 6,371km
EARTH_RADIUS = 6371
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Represents a Physical Point in geographic notation [lat, lng].
func NewPoint ¶
Returns a new Point populated by the passed in latitude (lat) and longitude (lng) values.
func (*Point) BearingTo ¶
Calculates the initial bearing (sometimes referred to as forward azimuth) Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) GreatCircleDistance ¶
Calculates the Haversine distance between two points in kilometers. Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) MarshalBinary ¶
Renders the current point to a byte slice. Implements the encoding.BinaryMarshaler Interface.
func (*Point) MarshalJSON ¶
Renders the current Point to valid JSON. Implements the json.Marshaller Interface.
func (*Point) MidpointTo ¶
Calculates the midpoint between 'this' point and the supplied point. Original implementation from http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) PointAtDistanceAndBearing ¶
Returns a Point populated with the lat and lng coordinates by transposing the origin point the passed in distance (in kilometers) by the passed in compass bearing (in degrees). Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) UnmarshalBinary ¶
func (*Point) UnmarshalJSON ¶
Decodes the current Point from a JSON body. Throws an error if the body of the point cannot be interpreted by the JSON body
type Polygon ¶
type Polygon struct {
// contains filtered or unexported fields
}
A Polygon is carved out of a 2D plane by a set of (possibly disjoint) contours. It can thus contain holes, and can be self-intersecting.
func NewPolygon ¶
Creates and returns a new pointer to a Polygon composed of the passed in points. Points are considered to be in order such that the last point forms an edge with the first point.