location

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InArea

func InArea(geometry []Point, point Point) (bool, error)

InArea will determine if a point exists in a geometry. The algorithm can be found here: https://www.eecs.umich.edu/courses/eecs380/HANDOUTS/PROJ2/InsidePoly.html

func InRangeLL

func InRangeLL(lat1 float64, lon1 float64, lat2 float64, lon2 float64, distance float64) (bool, error)

InRangeLL accepts latitude and longitude values to create 2 points. The points are used to determine their range, then the range is used to determine if the distance is less than that range.

Types

type Point

type Point struct {
	// Latitude degrees for the world coordinates
	Latitude float64 `json:"latitude,omitempty" xml:"latitude"`

	// Longitude degrees for the world coordinates
	Longitude float64 `json:"longitude,omitempty" xml:"longitude"`

	// Altitude in meters above sea level. Negative values
	// are considered to be depth.
	Altitude float64 `json:"altitude,omitempty" xml:"altitude"`
}

Point is a 3-Dimensional Point representation with fields for Latitude, Longitude, and Altitude

func Parse

func Parse(coordStr string) (Point, error)

Parse will parse the point from the string formatted data containing the latitude, longitude, [optional] altitude. Strings with spaces are allowed but newlines and tabs should be avoided

func (*Point) GetDistance

func (p *Point) GetDistance(other *Point) (float64, error)

GetDistance will get the distance between two points using the Haversine function for coordinates on the earth. The returned distance is in meters.

func (*Point) InRange

func (p *Point) InRange(other *Point, distance float64) (bool, error)

InRange will determine if this point is in range of another point. The range is provided as distance, and the units are assumed to be meters.

func (*Point) SetLatitude

func (p *Point) SetLatitude(latitude float64) error

SetLatitude adds some protection to the ability to set the latitude degrees for the global coordinates

func (*Point) SetLongitude

func (p *Point) SetLongitude(longitude float64) error

SetLongitude adds some protection to the ability to set the longitude degrees for the global coordinates

func (*Point) String

func (p *Point) String() string

String function returns the String format of the Point struct

func (*Point) X

func (p *Point) X() float64

Convenience functions for x,y,z coordinates of the Point

func (*Point) Y

func (p *Point) Y() float64

func (*Point) Z

func (p *Point) Z() float64

Jump to

Keyboard shortcuts

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