### Install and Import rgeo Go Package Source: https://github.com/sams96/rgeo/blob/main/README.md This snippet demonstrates how to download the rgeo Go package using `go get` and then import it into your Go project file to begin using the library. ```Shell go get github.com/sams96/rgeo ``` ```Go import "github.com/sams96/rgeo" ``` -------------------------------- ### Complete rgeo Reverse Geocoding Example with Output Source: https://github.com/sams96/rgeo/blob/main/README.md A comprehensive example demonstrating the initialization of `rgeo` with a specific dataset and then performing a reverse geocode operation. It shows how to access and print various fields of the returned `Location` struct, along with the expected output. ```go r, err := rgeo.New(Countries110) if err != nil { // Handle error } loc, err := r.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 ``` -------------------------------- ### Initialize and Reverse Geocode with rgeo in Go Source: https://github.com/sams96/rgeo/blob/main/README.md Demonstrates the basic workflow of initializing the rgeo library with datasets and then performing a reverse geocode operation on a given coordinate, handling potential errors. ```go r, err := New(Provinces10, Cities10) if err != nil { // Handle error } loc, err := r.ReverseGeocode([]float64{141.35, 43.07}) if err != nil { // Handle error } fmt.Println(loc) // Output: Sapporo, Hokkaidō, Japan (JPN), Asia ``` -------------------------------- ### rgeo.New Function Signature Source: https://github.com/sams96/rgeo/blob/main/README.md API documentation for the `rgeo.New` function, which initializes the Rgeo instance. It accepts a variadic number of dataset functions and returns an `*Rgeo` pointer and an error. ```APIDOC func New(datasets ...func() []byte) (*Rgeo, error) ``` -------------------------------- ### Run datagen Go command Source: https://github.com/sams96/rgeo/blob/main/datagen/README.md Executes the datagen tool to convert a GeoJSON file into a Go file, specifying the output file name. The generated variable containing the data will be named `outfile.gz`. ```Shell go run datagen.go -o outfile infile.geojson ``` -------------------------------- ### Location Struct Definition Source: https://github.com/sams96/rgeo/blob/main/README.md API documentation for the `Location` struct, which represents the geocoded location information returned by `ReverseGeocode`. It includes fields for country, province, city, and continent details, with JSON omitempty tags. ```APIDOC type Location struct { // Commonly used country name Country string `json:"country,omitempty"` // Formal name of country CountryLong string `json:"country_long,omitempty"` // ISO 3166-1 alpha-1 and alpha-2 codes CountryCode2 string `json:"country_code_2,omitempty"` CountryCode3 string `json:"country_code_3,omitempty"` Continent string `json:"continent,omitempty"` Region string `json:"region,omitempty"` SubRegion string `json:"subregion,omitempty"` Province string `json:"province,omitempty"` // ISO 3166-2 code ProvinceCode string `json:"province_code,omitempty"` City string `json:"city,omitempty"` } ``` -------------------------------- ### Rgeo.ReverseGeocode Method Signature Source: https://github.com/sams96/rgeo/blob/main/README.md API documentation for the `ReverseGeocode` method of the `Rgeo` struct. It takes a `geom.Coord` (a `[]float64{lon, lat}`) and returns a `Location` struct and an error. ```APIDOC func (r *Rgeo) ReverseGeocode(loc geom.Coord) (Location, error) ``` -------------------------------- ### rgeo GeoJSON Property Mappings Source: https://github.com/sams96/rgeo/blob/main/datagen/README.md Defines the specific GeoJSON properties that the `rgeo` library reads for location information, mapping common geographical attributes to their expected field names within the GeoJSON structure. ```APIDOC - Country: "ADMIN" or "admin" - CountryLong: "FORMAL_EN" - CountryCode2: "ISO_A2" - CountryCode3: "ISO_A3" - Continent: "CONTINENT" - Region: "REGION_UN" - SubRegion: "SUBREGION" - Province: "name" - ProvinceCode: "iso_3166_2" - City: "name_conve" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.