Documentation
¶
Overview ¶
Package rgeo is a fast, simple solution for local reverse geocoding
Rather than relying on external software or online APIs, rgeo packages all of the data it needs in your binary. This means it will only ever work down to the level of cities (though currently just countries), but if that's all you need then this is the library for you.
rgeo uses data from https://naturalearthdata.com.
Installation
go get github.com/sams96/rgeo
Contributing ¶
Contributions are welcome, I haven't got any guidelines or anything so maybe just make an issue first.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Location ¶
type Location struct { // Commonly used country name Country string // Formal name of country CountryLong string // Two and three letter ISO 3166 codes CountryCode2 string CountryCode3 string Continent string Region string SubRegion string }
Location is the return type for ReverseGeocode
func ReverseGeocode ¶
ReverseGeocode returns the country in which the given coordinate is located
The input is a geom.Coord, which is just a []float64 with the longitude in the zeroth position and the latitude in the first position. (i.e. []float64{lon, lat})
When run without a type rgeo it re-creates the polygons every time
Example ¶
loc, err := ReverseGeocode([]float64{0, 52}) if err != nil { // Handle error } fmt.Printf("%s\n", loc.Country) fmt.Printf("%s\n", loc.CountryLong) fmt.Printf("%s\n", loc.CountryCode2) fmt.Printf("%s\n", loc.CountryCode3) fmt.Printf("%s\n", loc.Continent) fmt.Printf("%s\n", loc.Region) fmt.Printf("%s\n", loc.SubRegion)
Output: United Kingdom United Kingdom of Great Britain and Northern Ireland GB GBR Europe Europe Northern Europe