Documentation ¶
Overview ¶
Types and functions for working with Geospatial Data
Index ¶
- Constants
- Variables
- type CardinalDirection
- type Country
- type CountryData
- type Distance
- func (self Distance) Beyond(other Distance) bool
- func (self Distance) Equal(other Distance) bool
- func (self Distance) ImperialString() string
- func (self Distance) MarshalJSON() ([]byte, error)
- func (self Distance) MetricString() string
- func (self Distance) String() string
- func (self *Distance) UnmarshalJSON(data []byte) error
- func (self Distance) Within(other Distance) bool
- type Locatable
- type Location
- func (self *Location) BearingTo(other Locatable) float64
- func (self *Location) CardinalDirection() CardinalDirection
- func (self Location) GetCoordinates() (float64, float64, time.Time)
- func (self *Location) HasCoordinates() bool
- func (self *Location) HaversineDistance(other Locatable) Distance
- func (self *Location) MarshalJSON() ([]byte, error)
- func (self *Location) SpeedFrom(other Locatable) Speed
- func (self *Location) String() string
- type LocationError
- type MeasurementSystem
- type Speed
Constants ¶
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` )
const ( North CardinalDirection = `N` NorthEast = `NE` East = `E` SouthEast = `SE` South = `S` SouthWest = `SW` West = `W` NorthWest = `NW` )
const ( Meter = 1 Kilometer = 1000 Foot = 0.3048 Yard = 0.9144 Mile = 1609.344 NauticalMile = 1852 )
const ( MetersPerSecond = 1 KPH = 0.277778 FeetPerSecond = 0.3048 MPH = 0.44704 Mach = 340.29 )
Variables ¶
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.)
var DistanceDisplayUnit = MeasurementSystem(Imperial)
var SpeedDisplayUnit = MeasurementSystem(Imperial)
Functions ¶
This section is empty.
Types ¶
type CardinalDirection ¶
type CardinalDirection string
func GetDirectionFromBearing ¶
func GetDirectionFromBearing(bearing float64) CardinalDirection
type CountryData ¶ added in v1.9.7
func (CountryData) Get ¶ added in v1.9.7
func (self CountryData) Get(nameOrCode interface{}) Country
type Distance ¶
type Distance float64
const EarthRadius Distance = geo.EARTH_RADIUS * Kilometer
func MustParseDistance ¶
func MustParseDistance(in interface{}) Distance
func ParseDistance ¶
func (Distance) ImperialString ¶
func (Distance) MarshalJSON ¶
func (Distance) MetricString ¶
func (*Distance) UnmarshalJSON ¶
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 NullIsland ¶
func NullIsland() *Location
func (*Location) CardinalDirection ¶
func (self *Location) CardinalDirection() CardinalDirection
func (Location) GetCoordinates ¶ added in v1.7.1
func (*Location) HasCoordinates ¶
func (*Location) HaversineDistance ¶
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 ¶
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