geoutil

package
v1.8.55 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Types and functions for working with Geospatial Data

Index

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 ParseDistance(in interface{}) (Distance, error)

func (Distance) Beyond

func (self Distance) Beyond(other Distance) bool

func (Distance) Equal

func (self Distance) Equal(other Distance) bool

func (Distance) ImperialString

func (self Distance) ImperialString() string

func (Distance) MarshalJSON

func (self Distance) MarshalJSON() ([]byte, error)

func (Distance) MetricString

func (self Distance) MetricString() string

func (Distance) String

func (self Distance) String() string

func (*Distance) UnmarshalJSON

func (self *Distance) UnmarshalJSON(data []byte) error

func (Distance) Within

func (self Distance) Within(other Distance) bool

type Locatable added in v1.7.1

type Locatable interface {
	GetCoordinates() (float64, float64, time.Time)
}

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 NewLocation(latitude float64, longitude float64) *Location

func NullIsland

func NullIsland() *Location

func (*Location) BearingTo

func (self *Location) BearingTo(other Locatable) float64

func (*Location) CardinalDirection

func (self *Location) CardinalDirection() CardinalDirection

func (Location) GetCoordinates added in v1.7.1

func (self Location) GetCoordinates() (float64, float64, time.Time)

func (*Location) HasCoordinates

func (self *Location) HasCoordinates() bool

func (*Location) HaversineDistance

func (self *Location) HaversineDistance(other Locatable) Distance

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

func (self *Location) MarshalJSON() ([]byte, error)

func (*Location) SpeedFrom

func (self *Location) SpeedFrom(other Locatable) Speed

func (*Location) String

func (self *Location) String() string

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) Equal

func (self Speed) Equal(other Speed) bool

func (Speed) FasterThan

func (self Speed) FasterThan(other Speed) bool

func (Speed) MarshalJSON

func (self Speed) MarshalJSON() ([]byte, error)

func (Speed) SlowerThan

func (self Speed) SlowerThan(other Speed) bool

func (Speed) String

func (self Speed) String() string

func (*Speed) UnmarshalJSON

func (self *Speed) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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