Skip to content
Snippets Groups Projects
Select Git revision
  • 2f20bca23c7f503ee400858e6c238ce36dd8a623
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

area.go

Blame
  • area.go 764 B
    package iac
    
    import (
    	"math"
    
    	olc "github.com/google/open-location-code/go"
    	"github.com/iotaledger/iota.go/trinary"
    )
    
    type Area struct {
    	olc.CodeArea
    	IACCode trinary.Trytes
    	OLCCode string
    }
    
    func (area *Area) Distance(other *Area) float64 {
    	lat1, lng1 := area.Center()
    	lat2, lng2 := other.Center()
    
    	return distance(lat1, lng1, lat2, lng2)
    }
    
    func distance(lat1, lon1, lat2, lon2 float64) float64 {
    	la1 := lat1 * math.Pi / 180
    	lo1 := lon1 * math.Pi / 180
    	la2 := lat2 * math.Pi / 180
    	lo2 := lon2 * math.Pi / 180
    
    	return 2 * EARTH_RADIUS_IN_METERS * math.Asin(math.Sqrt(hsin(la2-la1)+math.Cos(la1)*math.Cos(la2)*hsin(lo2-lo1)))
    }
    
    func hsin(theta float64) float64 {
    	return math.Pow(math.Sin(theta/2), 2)
    }
    
    const (
    	EARTH_RADIUS_IN_METERS = 6371000
    )