geo

package
v0.0.0-...-9ca37bf Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package geo provides earth geometry functions and constants.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const (
	DistLimit      float64 = 5000
	ScopeDistLimit float64 = 50
	DefaultDist    float64 = 2
)
View Source
const (
	EarthRadiusKm = 6371 // Earth radius in km
)
View Source
const Meter = 0.00001

Variables

This section is empty.

Functions

func Deg

func Deg(km float64) float64

Deg returns the approximate distance in decimal degrees, see https://en.wikipedia.org/wiki/Decimal_degrees.

func DegToRad

func DegToRad(d float64) float64

DegToRad converts a value from degrees to radians.

func Km

func Km(p, q Position) (km float64)

Km returns the shortest path between two positions in km.

func Randomize

func Randomize(value, diameter float64) float64

Randomize adds a random offset to a value.

Types

type Movement

type Movement struct {
	Start Position
	End   Position
}

Movement represents a position change in degrees per second.

func NewMovement

func NewMovement(pos1, pos2 Position) (m Movement)

NewMovement returns the movement between two positions and points in time.

func (*Movement) AverageAltitude

func (m *Movement) AverageAltitude() float64

AverageAltitude returns the average altitude.

func (*Movement) Closest

func (m *Movement) Closest(t time.Time) Position

Closest returns the position closest in time, either start or end.

func (*Movement) Deg

func (m *Movement) Deg() (lat, lng float64)

Deg calculates the position change in degrees.

func (*Movement) DegLat

func (m *Movement) DegLat() float64

DegLat calculates the latitude change in degrees.

func (*Movement) DegLng

func (m *Movement) DegLng() float64

DegLng calculates the longitude change in degrees.

func (*Movement) DegPerSecond

func (m *Movement) DegPerSecond() (latSec, lngSec float64)

DegPerSecond returns the position change in degrees per second.

func (*Movement) Duration

func (m *Movement) Duration() time.Duration

Duration calculates the movement duration.

func (*Movement) EstimateAccuracy

func (m *Movement) EstimateAccuracy(t time.Time) int

EstimateAccuracy returns the position estimate accuracy in meter.

func (*Movement) EstimateAltitude

func (m *Movement) EstimateAltitude(t time.Time) float64

EstimateAltitude estimates the altitude at a given time.

func (*Movement) EstimateAltitudeInt

func (m *Movement) EstimateAltitudeInt(t time.Time) int

EstimateAltitudeInt returns the estimated altitude as integer.

func (*Movement) EstimatePosition

func (m *Movement) EstimatePosition(t time.Time) Position

EstimatePosition returns the estimated position at a given time.

func (*Movement) Hours

func (m *Movement) Hours() float64

Hours returns the movement duration in hours.

func (*Movement) Km

func (m *Movement) Km() float64

Km calculates the movement distance in km.

func (*Movement) Meter

func (m *Movement) Meter() float64

Meter calculates the movement distance in m.

func (*Movement) Midpoint

func (m *Movement) Midpoint() Position

Midpoint returns the movement midpoint position.

func (*Movement) Realistic

func (m *Movement) Realistic() bool

Realistic tests if the movement may have happened in the real world.

func (*Movement) Seconds

func (m *Movement) Seconds() float64

Seconds returns the movement duration in seconds.

func (*Movement) Speed

func (m *Movement) Speed() float64

Speed calculates the average movement speed in km/h.

func (*Movement) String

func (m *Movement) String() string

String returns the movement information as string for logging.

type Position

type Position struct {
	Name     string    // Optional name
	Time     time.Time // Optional time
	Lat      float64   // In degree
	Lng      float64   // In degree
	Altitude float64   // In meter
	Accuracy int       // In meter
	Estimate bool
}

Position represents a geo coordinate.

func (Position) AltitudeInt

func (p Position) AltitudeInt() int

AltitudeInt returns the altitude as integer.

func (*Position) InRange

func (p *Position) InRange(lat, lng, r float64) bool

InRange tests if coordinates are within a certain range of the position.

func (Position) Km

func (p Position) Km(other Position) float64

Km calculates the distance to another position in km.

func (*Position) Randomize

func (p *Position) Randomize(diameter float64)

Randomize adds a random offset to the coordinates.

func (Position) String

func (p Position) String() string

String returns the position information as string for logging.

Jump to

Keyboard shortcuts

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