geolib

package module
v0.0.0-...-c360161 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2017 License: MIT Imports: 2 Imported by: 1

README

go-geolib

Build Status Go Report Card GoDoc

About

Geographical functions for Golang apps!

Scope

Libraries/Functions/Utilities I often require in other projects!

installation

go get github.com/alouche/go-geolib

API Documentation

API

Example Usage

package main																																												

import (
	"fmt"
	"github.com/alouche/go-geolib"
)

func main() {
	haversine_distance := fmt.Sprintf("%2.f", geolib.Haversine_Distance(50.116667, 8.683333, 52.516667, 13.3833))
	println("Havesine Distance:", haversine_distance, "km")
}

Documentation

Overview

Package geolib provides Geographical functions for Golang apps!

Index

Constants

This section is empty.

Variables

View Source
var GreatEarthCircleRadiusKM = 6372.8

GreatEarthCircleRadiusKM varies between 6,378km and 6,357km (equatorial and polar). The local radius of curvature varies between 6,336km and 6,399km (equatorial meridian and polar)

Functions

func Bearing

func Bearing(flag int, φ1, λ1, φ2, λ2 float64) (float64, error)

Bearing {from, to} a point flag: 0 => Initial Bearing flag: 1 => Initial Bearing flag: nil => Bearing Result:

  • Type: float64
  • Metric: Degress from North

func Deg2Rad

func Deg2Rad(degree float64) float64

Deg2Rad converts a degree to randian Result:

  • Type: float64
  • Metric: Radian

func EquirectangularDistance

func EquirectangularDistance(φ1, λ1, φ2, λ2 float64) float64

EquirectangularDistance calculates the distance in KM of 2 points using Pythagoras’ theorem. It is a faster alternative to the Haversine_Distance function with less accuracy. Scope: small distance calculation Result:

  • Type: float64
  • Result: Distance (km)

func HaversineDistance

func HaversineDistance(φ1, λ1, φ2, λ2 float64) float64

HaversineDistance calculates the great-circle distance between 2 points. The function uses a spherical model, since the earth is more is oblate spheroidal, there will be an accuracy error margin. Scope: Distance computation below 0.3% accuracy error margin Result:

  • Type: float64
  • Metric: Distance (km)

func Rad2Deg

func Rad2Deg(radian float64) float64

Rad2Deg converts a randian to degree Result:

  • Type: float64
  • Metric: Degree

Types

type Point

type Point struct {
	// contains filtered or unexported fields
}

func Midpoint

func Midpoint(φ1, λ1, φ2, λ2 float64) Point

Midpoint calculates the half-way point along a great circle path between the two points Result:

  • Type: struct{float64, float64}
  • Metric: Radian

Jump to

Keyboard shortcuts

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