Documentation
¶
Index ¶
- Constants
- Variables
- func CountyCount() int
- func GobDump(filename string, obj interface{}) error
- func GobLoad(filename string, obj interface{}) error
- func InitCountyLookup(counties []CountyGeo)
- func LoadCachedCountyGeo(filename string) error
- func ProcessJSONData(source, saved string) error
- type CountyGeo
- type CountyMeta
- type Location
- type Point
- type Points
- type Rect
Constants ¶
View Source
const ( // CountyJSONFile is the default data source for county polygon info // as generated from github.com/paulstuart/counties CountyJSONFile = "county_poly.json" CountyGOBFile = "county_geo.gob.gz" )
Variables ¶
View Source
var ( // locations are indexed by GeoID CountyLookupMeta = make(map[int]Location) )
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
func CountyCount ¶
func CountyCount() int
func InitCountyLookup ¶
func InitCountyLookup(counties []CountyGeo)
InitCountyLookup prepares data for searching for counties
func LoadCachedCountyGeo ¶
LoadCachedCountyGeo uses GOB encoded geodata to build county lookup functions
func ProcessJSONData ¶
ProcessJSONData loads the json data file from the data as sourced from https://github.com/paulstuart/counties It will save it as a GOB datafile for faster loading
Types ¶
type CountyGeo ¶
type CountyGeo struct {
GeoID int `json:"geoid"`
Name string `json:"name"`
Full string `json:"fullname"`
State string `json:"state"`
BBox Rect `json:"bbox"`
Poly Points `json:"polygon"`
}
CountyGeo is ready for consumption
func LoadCountyJSON ¶
LoadCountyJSON loads the json dump file from the data as prepared using https://github.com/paulstuart/counties
func (CountyGeo) Meta ¶
func (cg CountyGeo) Meta() CountyMeta
type CountyMeta ¶
CountyMeta is the principle county meta data
func FindCounty ¶
func FindCounty(lat, lon float64) (CountyMeta, error)
FindCounty returns the county associated with the given location
Click to show internal directories.
Click to hide internal directories.