geocalc

Minimalist coordinate computation library

Pure Nim score 16/100 · last commit 2020-09-09 · 6 stars · tests present · no docs generated

Summary

Latest Version Unknown
License Unknown
CI Status Failing
Stars 6
Forks 0
Open Issues 0
Last Commit 2020-09-09
Downloads 0
Last Indexed 2026-07-26 13:11

Installation

nimble install geocalc
choosenim install geocalc
git clone https://gitlab.com/psns/geocalc

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
geocalc - - - - - - -

Source

Repository https://gitlab.com/psns/geocalc
Homepage https://gitlab.com/psns/geocalc
Registry Source gitlab

README

Geocalc

Minimalist coordinate computation library

API Reference

All these formulas are for calculations on the basis of a spherical earth (ignoring ellipsoidal effects) – which is accurate enough for most purposes… In fact, the earth is very slightly ellipsoidal; using a spherical model gives errors typically up to 0.3%. More informations here.

Index

Constants
func Distance
func Intermediate
func DegreeToRad
func RadToDegree
type Point * func NewPoint * func Bearing * func Walk * func Degree

Constants

const (
    EarthRadius        = 6371e3                    // EarthRadius in meters
    EarthCircumference = 2 * EarthRadius * math.Pi // EarthCircumference in meters
)

func Distance

func Distance(p1, p2 Point) float64

Distance return the distance between two earth Point in meters

func Intermediate

func Intermediate(p1, p2 Point, fraction float64) Point

Intermediate calculate an intermediate point at any fraction along the great circle path between p1 and p2. Start path at p1, if fraction=0, returned Point is p1. If fraction=1, returned Point is p2. Number upper 1 can be used.

func DegreeToRad

func DegreeToRad(deg float64) float64

DegreeToRad convert given arc in degree to rad

func RadToDegree

func RadToDegree(rad float64) float64

RadToDegree convert given arc in rad to degree

type Point

type Point struct {
    Lat float64 // Latitude of the point in rad
    Lon float64 // Longitude of the point in rad
}

Point define an Earth point.

func NewPoint

func NewPoint(lat, lon float64) Point 

NewPoint create and return an new Point from given coordinates, lat and lon in radians.

func Bearing

func (p Point) Bearing(pt Point) float64

Bearing return the bearing in rad between current and given Point

func Walk

func (p Point) Walk(bearing, dist float64) Point

Walk return destination Point in function of given dist and bearing from start p Point. bearing in rad (clockwise from north) and dist in meters.

func Degree

func (p Point) Degree() (float64, float64)

Degree return degree value of Lat, Lon