geoutil

package
v1.11.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Types and functions for working with Geospatial Data

Index

Constants

View Source
const (
	Afghanistan                            = `af`
	Albania                                = `al`
	Algeria                                = `dz`
	AmericanSamoa                          = `as`
	Andorra                                = `ad`
	Angola                                 = `ao`
	Anguilla                               = `ai`
	Antarctica                             = `aq`
	AntiguaAndBarbuda                      = `ag`
	Argentina                              = `ar`
	Armenia                                = `am`
	Aruba                                  = `aw`
	Australia                              = `au`
	Austria                                = `at`
	Azerbaijan                             = `az`
	Bahamas                                = `bs`
	Bahrain                                = `bh`
	Bangladesh                             = `bd`
	Barbados                               = `bb`
	Belarus                                = `by`
	Belgium                                = `be`
	Belize                                 = `bz`
	Benin                                  = `bj`
	Bermuda                                = `bm`
	Bhutan                                 = `bt`
	Bolivia                                = `bo`
	BosniaAndHerzegovina                   = `ba`
	Botswana                               = `bw`
	BouvetIsland                           = `bv`
	Brazil                                 = `br`
	BritishIndianOceanTerritory            = `io`
	BritishVirginIslands                   = `vg`
	Brunei                                 = `bn`
	Bulgaria                               = `bg`
	BurkinaFaso                            = `bf`
	Burma                                  = `mm`
	Burundi                                = `bi`
	Cambodia                               = `kh`
	Cameroon                               = `cm`
	Canada                                 = `ca`
	CapeVerde                              = `cv`
	CaymanIslands                          = `ky`
	CentralAfricanRepublic                 = `cf`
	Chad                                   = `td`
	Chile                                  = `cl`
	China                                  = `cn`
	ChristmasIsland                        = `cx`
	CocosIslands                           = `cc`
	Colombia                               = `co`
	Comoros                                = `km`
	CongoDRC                               = `cd`
	CongoRepublic                          = `cg`
	CookIslands                            = `ck`
	CostaRica                              = `cr`
	CoteDIvoire                            = `ci`
	CôtedIvoire                            = `ci`
	Croatia                                = `hr`
	Cuba                                   = `cu`
	Cyprus                                 = `cy`
	CzechRepublic                          = `cz`
	Denmark                                = `dk`
	Djibouti                               = `dj`
	Dominica                               = `dm`
	DominicanRepublic                      = `do`
	Ecuador                                = `ec`
	Egypt                                  = `eg`
	ElSalvador                             = `sv`
	EquatorialGuinea                       = `gq`
	Eritrea                                = `er`
	Estonia                                = `ee`
	Ethiopia                               = `et`
	FalklandIslands                        = `fk`
	FaroeIslands                           = `fo`
	Fiji                                   = `fj`
	Finland                                = `fi`
	France                                 = `fr`
	FrenchGuiana                           = `gf`
	FrenchPolynesia                        = `pf`
	FrenchSouthernTerritories              = `tf`
	Gabon                                  = `ga`
	Gambia                                 = `gm`
	GazaStrip                              = `gz`
	Georgia                                = `ge`
	Germany                                = `de`
	Ghana                                  = `gh`
	Gibraltar                              = `gi`
	GreatBritain                           = `gb`
	Greece                                 = `gr`
	Greenland                              = `gl`
	Grenada                                = `gd`
	Guadeloupe                             = `gp`
	Guam                                   = `gu`
	Guatemala                              = `gt`
	Guernsey                               = `gg`
	Guinea                                 = `gn`
	GuineaBissau                           = `gw`
	Guyana                                 = `gy`
	Haiti                                  = `ht`
	HeardIslandAndMcDonaldIslands          = `hm`
	Honduras                               = `hn`
	HongKong                               = `hk`
	Hungary                                = `hu`
	Iceland                                = `is`
	India                                  = `in`
	Indonesia                              = `id`
	Iran                                   = `ir`
	Iraq                                   = `iq`
	Ireland                                = `ie`
	IslasMalvinas                          = `fk`
	IsleOfMan                              = `im`
	Israel                                 = `il`
	Italy                                  = `it`
	Jamaica                                = `jm`
	JanMayen                               = `sj`
	Japan                                  = `jp`
	Jersey                                 = `je`
	Jordan                                 = `jo`
	Kazakhstan                             = `kz`
	Kenya                                  = `ke`
	Kiribati                               = `ki`
	Kosovo                                 = `xk`
	Kuwait                                 = `kw`
	Kyrgyzstan                             = `kg`
	Laos                                   = `la`
	Latvia                                 = `lv`
	Lebanon                                = `lb`
	Lesotho                                = `ls`
	Liberia                                = `lr`
	Libya                                  = `ly`
	Liechtenstein                          = `li`
	Lithuania                              = `lt`
	Luxembourg                             = `lu`
	Macau                                  = `mo`
	Macedonia                              = `mk`
	Madagascar                             = `mg`
	Malawi                                 = `mw`
	Malaysia                               = `my`
	Maldives                               = `mv`
	Mali                                   = `ml`
	Malta                                  = `mt`
	MarshallIslands                        = `mh`
	Martinique                             = `mq`
	Mauritania                             = `mr`
	Mauritius                              = `mu`
	Mayotte                                = `yt`
	Mexico                                 = `mx`
	Micronesia                             = `fm`
	Miquelon                               = `pm`
	Moldova                                = `md`
	Monaco                                 = `mc`
	Mongolia                               = `mn`
	Montenegro                             = `me`
	Montserrat                             = `ms`
	Morocco                                = `ma`
	Mozambique                             = `mz`
	Myanmar                                = `mm`
	Namibia                                = `na`
	Nauru                                  = `nr`
	Nepal                                  = `np`
	Netherlands                            = `nl`
	NetherlandsAntilles                    = `an`
	NewCaledonia                           = `nc`
	NewZealand                             = `nz`
	Nicaragua                              = `ni`
	Niger                                  = `ne`
	Nigeria                                = `ng`
	Niue                                   = `nu`
	NorfolkIsland                          = `nf`
	NorthernMarianaIslands                 = `mp`
	NorthKorea                             = `kp`
	Norway                                 = `no`
	Oman                                   = `om`
	Pakistan                               = `pk`
	Palau                                  = `pw`
	Palestine                              = `ps`
	Panama                                 = `pa`
	PapuaNewGuinea                         = `pg`
	Paraguay                               = `py`
	Peru                                   = `pe`
	Philippines                            = `ph`
	PitcairnIslands                        = `pn`
	Poland                                 = `pl`
	Portugal                               = `pt`
	PuertoRico                             = `pr`
	Qatar                                  = `qa`
	Reunion                                = `re`
	Réunion                                = `re`
	Romania                                = `ro`
	Russia                                 = `ru`
	Rwanda                                 = `rw`
	SaintHelena                            = `sh`
	SaintKittsAndNevis                     = `kn`
	SaintLucia                             = `lc`
	SaintPierre                            = `pm`
	SaintPierreAndMiquelon                 = `pm`
	SaintVincent                           = `vc`
	SaintVincentAndTheGrenadines           = `vc`
	Samoa                                  = `ws`
	SanMarino                              = `sm`
	SaoTomeAndPrincipe                     = `st`
	SãoToméAndPríncipe                     = `st`
	SaudiArabia                            = `sa`
	Senegal                                = `sn`
	Serbia                                 = `rs`
	Seychelles                             = `sc`
	SierraLeone                            = `sl`
	Singapore                              = `sg`
	Slovakia                               = `sk`
	Slovenia                               = `si`
	SolomonIslands                         = `sb`
	Somalia                                = `so`
	SouthAfrica                            = `za`
	SouthGeorgia                           = `gs`
	SouthGeorgiaAndTheSouthSandwichIslands = `gs`
	SouthKorea                             = `kr`
	SouthSandwichIslands                   = `gs`
	SouthSudan                             = `ss`
	SovietUnion                            = `su`
	Spain                                  = `es`
	SriLanka                               = `lk`
	Sudan                                  = `sd`
	Suriname                               = `sr`
	Svalbard                               = `sj`
	SvalbardAndJanMayen                    = `sj`
	Swaziland                              = `sz`
	Sweden                                 = `se`
	Switzerland                            = `ch`
	Syria                                  = `sy`
	Taiwan                                 = `tw`
	Tajikistan                             = `tj`
	Tanzania                               = `tz`
	Thailand                               = `th`
	TheGrenadines                          = `vc`
	TimorLeste                             = `tl`
	Togo                                   = `tg`
	Tokelau                                = `tk`
	Tonga                                  = `to`
	TrinidadAndTobago                      = `tt`
	Tunisia                                = `tn`
	Turkey                                 = `tr`
	Turkmenistan                           = `tm`
	TurksAndCaicosIslands                  = `tc`
	Tuvalu                                 = `tv`
	Uganda                                 = `ug`
	UK                                     = `gb`
	Ukraine                                = `ua`
	UnitedArabEmirates                     = `ae`
	UnitedKingdom                          = `gb`
	UnitedStates                           = `us`
	UnitedStatesMinorOutlyingIslands       = `um`
	UnitedStatesVirginIslands              = `vi`
	Uruguay                                = `uy`
	Uzbekistan                             = `uz`
	Vanuatu                                = `vu`
	VaticanCity                            = `va`
	Venezuela                              = `ve`
	Vietnam                                = `vn`
	WallisAndFutuna                        = `wf`
	WesternSahara                          = `eh`
	Yemen                                  = `ye`
	Zambia                                 = `zm`
	Zimbabwe                               = `zw`
)
View Source
const (
	North     CardinalDirection = `N`
	NorthEast                   = `NE`
	East                        = `E`
	SouthEast                   = `SE`
	South                       = `S`
	SouthWest                   = `SW`
	West                        = `W`
	NorthWest                   = `NW`
)
View Source
const (
	Meter        = 1
	Kilometer    = 1000
	Foot         = 0.3048
	Yard         = 0.9144
	Mile         = 1609.344
	NauticalMile = 1852
)
View Source
const (
	MetersPerSecond = 1
	KPH             = 0.277778
	FeetPerSecond   = 0.3048
	MPH             = 0.44704
	Mach            = 340.29
)

Variables

View Source
var Countries = CountryData{}/* 247 elements not displayed */

A data structure that exposes standard information about countries of the world, keyed on their ISO3166-1 Alpha2 abbreviation (e.g.: "us", "gb", "de", etc.)

View Source
var DistanceDisplayUnit = MeasurementSystem(Imperial)
View Source
var SpeedDisplayUnit = MeasurementSystem(Imperial)

Functions

This section is empty.

Types

type CardinalDirection

type CardinalDirection string

func GetDirectionFromBearing

func GetDirectionFromBearing(bearing float64) CardinalDirection

type Country added in v1.9.7

type Country struct {
	Name      string
	Code      string
	CCTLD     string
	Latitude  float64
	Longitude float64
}

func (Country) IsValid added in v1.9.7

func (self Country) IsValid() bool

type CountryData added in v1.9.7

type CountryData map[string]Country

func (CountryData) Get added in v1.9.7

func (self CountryData) Get(nameOrCode interface{}) Country

type Distance

type Distance float64
const EarthKarmanHeight Distance = 100 * Kilometer
const EarthRadius Distance = geo.EARTH_RADIUS * Kilometer
const EarthStratosphereHeight Distance = 60 * Kilometer

func MustParseDistance

func MustParseDistance(in interface{}) Distance

func ParseDistance

func ParseDistance(in interface{}) (Distance, error)

func (Distance) Beyond

func (self Distance) Beyond(other Distance) bool

func (Distance) Equal

func (self Distance) Equal(other Distance) bool

func (Distance) ImperialString

func (self Distance) ImperialString() string

func (Distance) MarshalJSON

func (self Distance) MarshalJSON() ([]byte, error)

func (Distance) MetricString

func (self Distance) MetricString() string

func (Distance) String

func (self Distance) String() string

func (*Distance) UnmarshalJSON

func (self *Distance) UnmarshalJSON(data []byte) error

func (Distance) Within

func (self Distance) Within(other Distance) bool

type Locatable added in v1.7.1

type Locatable interface {
	GetCoordinates() (float64, float64, time.Time)
}

type Location

type Location struct {
	Latitude   float64                `json:"latitude,omitempty"`
	Longitude  float64                `json:"longitude,omitempty"`
	Bearing    float64                `json:"bearing,omitempty"`
	Timestamp  time.Time              `json:"timestamp,omitempty"`
	Altitude   Distance               `json:"altitude,omitempty"`
	Speed      Speed                  `json:"speed,omitempty"`
	Accuracy   float64                `json:"accuracy,omitempty"`
	Error      *LocationError         `json:"error,omitempty"`
	Direction  CardinalDirection      `json:"direction,omitempty"`
	Source     string                 `json:"source,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
}

Specifies a three-dimensional location within a coordinate reference system.

func NewLocation

func NewLocation(latitude float64, longitude float64) *Location

func NullIsland

func NullIsland() *Location

func (*Location) BearingTo

func (self *Location) BearingTo(other Locatable) float64

func (*Location) CardinalDirection

func (self *Location) CardinalDirection() CardinalDirection

func (Location) GetCoordinates added in v1.7.1

func (self Location) GetCoordinates() (float64, float64, time.Time)

func (*Location) HasCoordinates

func (self *Location) HasCoordinates() bool

func (*Location) HaversineDistance

func (self *Location) HaversineDistance(other Locatable) Distance

Return the distance (in meters) between this point and another. This calulates the great-circle distance (shortest distance two points on the surface of a sphere) between this Location and another. Since this (incorrectly) assumes the Earth to be a true sphere, this is only reasonably accurate for short-ish distances (is only accurate to within ~0.5%).

func (*Location) MarshalJSON

func (self *Location) MarshalJSON() ([]byte, error)

func (*Location) SpeedFrom

func (self *Location) SpeedFrom(other Locatable) Speed

func (*Location) String

func (self *Location) String() string

type LocationError

type LocationError struct {
	Latitude  Distance `json:"latitude"`
	Longitude Distance `json:"longitude"`
	Altitude  Distance `json:"altitude"`
	Bearing   float64  `json:"bearing"`
	Speed     Speed    `json:"speed"`
	Timestamp float64  `json:"timestamp"`
}

Describes the error margin (+/-) for each of the named values.

type MeasurementSystem

type MeasurementSystem string
const (
	Metric   MeasurementSystem = `metric`
	Imperial                   = `imperial`
)

type Speed

type Speed float64

func (Speed) Equal

func (self Speed) Equal(other Speed) bool

func (Speed) FasterThan

func (self Speed) FasterThan(other Speed) bool

func (Speed) MarshalJSON

func (self Speed) MarshalJSON() ([]byte, error)

func (Speed) SlowerThan

func (self Speed) SlowerThan(other Speed) bool

func (Speed) String

func (self Speed) String() string

func (*Speed) UnmarshalJSON

func (self *Speed) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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