Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var UsSateCodes = map[string]string{
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
"FL": "Florida",
"GA": "Georgia",
"HI": "Hawaii",
"ID": "Idaho",
"IL": "Illinois",
"IN": "Indiana",
"IA": "Iowa",
"KS": "Kansas",
"KY": "Kentucky",
"LA": "Louisiana",
"ME": "Maine",
"MD": "Maryland",
"MA": "Massachusetts",
"MI": "Michigan",
"MN": "Minnesota",
"MS": "Mississippi",
"MO": "Missouri",
"MT": "Montana",
"NE": "Nebraska",
"NV": "Nevada",
"NH": "New Hampshire",
"NJ": "New Jersey",
"NM": "New Mexico",
"NY": "New York",
"NC": "North Carolina",
"ND": "North Dakota",
"OH": "Ohio",
"OK": "Oklahoma",
"OR": "Oregon",
"PA": "Pennsylvania",
"RI": "Rhode Island",
"SC": "South Carolina",
"SD": "South Dakota",
"TN": "Tennessee",
"TX": "Texas",
"UT": "Utah",
"VT": "Vermont",
"VA": "Virginia",
"WA": "Washington",
"WV": "West Virginia",
"WI": "Wisconsin",
"WY": "Wyoming",
"AS": "American Samoa",
"DC": "District of Columbia",
"FM": "Federated States of Micronesia",
"GU": "Guam",
"MH": "Marshall Islands",
"MP": "Northern Mariana Islands",
"PW": "Palau",
"PR": "Puerto Rico",
"VI": "Virgin Islands",
"AA": "Armed Forces Americas",
"AE": "Armed Forces Europe",
"AP": "Armed Forces Pacific",
}
UsSateCodes is a handy map of US state codes to full names.
Functions ¶
This section is empty.
Types ¶
type CountryInfo ¶
type CountryInfo struct { Country string Capital string Area int32 Population int32 GeonameID int32 ISONumeric int16 ISO string ISO3 string Fips string Continent string Tld string CurrencyCode string CurrencyName string Phone string PostalCodeFormat string PostalCodeRegex string Languages string Neighbours string EquivalentFipsCode string }
CountryInfo contains information about each country from Geonames including; ISO codes, FIPS, country capital, area (sq km), population, etc. Particularly useful for validating a location string contains a country name which can help the search process. Adding to this info, a slice of partial geohashes to help narrow down reverse geocoding lookups (maps to country buckets).
type GeoBed ¶
type GeoBed struct {
// contains filtered or unexported fields
}
GeoBed contains all of the city and country data. Cities are split into buckets by country to increase lookup speed when the country is known.
func NewGeobed ¶
func NewGeobed() GeoBed
NewGeobed creates a new Geobed instance. You do not need more than one. Should be a singleton. There's a fair bit of data to load into memory.
func (*GeoBed) Geocode ¶
func (g *GeoBed) Geocode(n string, opts ...GeocodeOptions) GeobedCity
Geocode forward geocode, location string to lat/lng (returns a struct though). Calls exactMatchCity / fuzzyMatchLocation to perform a search.
func (*GeoBed) ReverseGeocode ¶
func (g *GeoBed) ReverseGeocode(lat float64, lng float64) GeobedCity
ReverseGeocode finds place name by latitude and longitude.
type GeobedCity ¶
type GeobedCity struct { City string CityAlt string // TODO: Think about converting this to a small int to save on memory // allocation. Lookup requests can have the strings converted to the // same int if there are any matches. // This could make lookup more accurate, easier, and faster even. IF // the int uses less bytes than the two letter code string. Country string Region string Latitude float64 Longitude float64 Population int32 Geohash string }
GeobedCity is combined city struct (the various data sets have different fields, this combines what's available and keeps things smaller).
type GeocodeOptions ¶
type GeocodeOptions struct {
ExactCity bool
}
GeocodeOptions contains options for geocoding. For now just an exact match on city name, but there will be potentially other options that can be set to adjust how searching/matching works.