Documentation ¶
Overview ¶
Types and functions for working with Geospatial Data
Index ¶
- Constants
- Variables
- type CardinalDirection
- type Distance
- func (self Distance) Beyond(other Distance) bool
- func (self Distance) Equal(other Distance) bool
- func (self Distance) ImperialString() string
- func (self Distance) MarshalJSON() ([]byte, error)
- func (self Distance) MetricString() string
- func (self Distance) String() string
- func (self *Distance) UnmarshalJSON(data []byte) error
- func (self Distance) Within(other Distance) bool
- type Locatable
- type Location
- func (self *Location) BearingTo(other Locatable) float64
- func (self *Location) CardinalDirection() CardinalDirection
- func (self Location) GetCoordinates() (float64, float64, time.Time)
- func (self *Location) HasCoordinates() bool
- func (self *Location) HaversineDistance(other Locatable) Distance
- func (self *Location) MarshalJSON() ([]byte, error)
- func (self *Location) SpeedFrom(other Locatable) Speed
- func (self *Location) String() string
- type LocationError
- type MeasurementSystem
- type Speed
Constants ¶
View Source
const ( North CardinalDirection = `N` NorthEast = `NE` East = `E` SouthEast = `SE` South = `S` SouthWest = `SW` West = `W` NorthWest = `NW` )
View Source
const ( Meter = 1 Kilometer = 1000 Foot = 0.3048 Yard = 0.9144 Mile = 1609.344 NauticalMile = 1852 )
View Source
const ( MetersPerSecond = 1 KPH = 0.277778 FeetPerSecond = 0.3048 MPH = 0.44704 Mach = 340.29 )
Variables ¶
View Source
var DistanceDisplayUnit = MeasurementSystem(Imperial)
View Source
var SpeedDisplayUnit = MeasurementSystem(Imperial)
Functions ¶
This section is empty.
Types ¶
type CardinalDirection ¶
type CardinalDirection string
func GetDirectionFromBearing ¶
func GetDirectionFromBearing(bearing float64) CardinalDirection
type Distance ¶
type Distance float64
func MustParseDistance ¶
func MustParseDistance(in interface{}) Distance
func ParseDistance ¶
func (Distance) ImperialString ¶
func (Distance) MarshalJSON ¶
func (Distance) MetricString ¶
func (*Distance) UnmarshalJSON ¶
type Location ¶
type Location struct { Latitude float64 `json:"latitude,omitempty"` Longitude float64 `json:"longitude,omitempty"` Bearing float64 `json:"bearing,omitempty"` Timestamp time.Time `json:"timestamp,omitempty"` Altitude Distance `json:"altitude,omitempty"` Speed Speed `json:"speed,omitempty"` Accuracy float64 `json:"accuracy,omitempty"` Error *LocationError `json:"error,omitempty"` Direction CardinalDirection `json:"direction,omitempty"` Source string `json:"source,omitempty"` Properties map[string]interface{} `json:"properties,omitempty"` }
Specifies a three-dimensional location within a coordinate reference system.
func NewLocation ¶
func NullIsland ¶
func NullIsland() *Location
func (*Location) CardinalDirection ¶
func (self *Location) CardinalDirection() CardinalDirection
func (Location) GetCoordinates ¶ added in v1.7.1
func (*Location) HasCoordinates ¶
func (*Location) HaversineDistance ¶
Return the distance (in meters) between this point and another. This calulates the great-circle distance (shortest distance two points on the surface of a sphere) between this Location and another. Since this (incorrectly) assumes the Earth to be a true sphere, this is only reasonably accurate for short-ish distances (is only accurate to within ~0.5%).
func (*Location) MarshalJSON ¶
type LocationError ¶
type LocationError struct { Latitude Distance `json:"latitude"` Longitude Distance `json:"longitude"` Altitude Distance `json:"altitude"` Bearing float64 `json:"bearing"` Speed Speed `json:"speed"` Timestamp float64 `json:"timestamp"` }
Describes the error margin (+/-) for each of the named values.
type MeasurementSystem ¶
type MeasurementSystem string
const ( Metric MeasurementSystem = `metric` Imperial = `imperial` )
type Speed ¶
type Speed float64
func (Speed) FasterThan ¶
func (Speed) MarshalJSON ¶
func (Speed) SlowerThan ¶
func (*Speed) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.