Documentation
¶
Index ¶
Constants ¶
View Source
const ASSET_FULLPATH string = "data/" + DATABASE_FILENAME
View Source
const AUTHOR string = "Jonathan Hendler"
View Source
const DATABASE_FILENAME string = "zipcode.db"
View Source
const DISTANCE_BETWEEN_LAT_DEGREES = float64(69.172)
View Source
const EARTHRADIUS = float64(6371)
View Source
const KMTOMAILES = float64(0.621371192)
View Source
const LICENSE string = "MIT"
View Source
const PACKAGE string = "zipcode"
View Source
const VERSION string = "0.9.0"
Variables ¶
View Source
var ZipCodeDB *sql.DB
View Source
var ZipCodeDBPath string = "/tmp/" + DATABASE_FILENAME
Functions ¶
func Haversine ¶
* The haversine formula will calculate the spherical distance as the crow flies * between lat and lon for two given points in km * from https://play.golang.org/p/MZVh5bRWqN
func main() {
var locationName [2]string
var location [2][2]float64
// York - lat,lon
locationName[0] = "York"
location[0][0] = 1.0803
location[0][1] = 53.9583
// Bristol - lat,lon
locationName[1] = "Bristol"
location[1][0] = 2.5833
location[1][1] = 51.4500
// Use haversine to get the resulting diatance between the two values
var distance = Haversine(location[0][0], location[0][1], location[1][0], location[1][1])
// We wish to use miles so will alter the resulting distance
var distancemiles = distance * kmtomiles
fmt.Printf("The distance between %s and %s is %.02f miles as the crow flies", locationName[0], locationName[1], distancemiles)
}
Types ¶
type Zipcode ¶
type Zipcode struct {
// The 5 digit zip code
ZIP_CODE string
// The type of zip code according to USPS: 'UNIQUE', 'PO BOX', or 'STANDARD'"""
ZIP_CODE_TYPE string
// The primary city associated with the zip code according to USPS
CITY string
// The state associated with the zip code according to USPS
STATE string
// This value will always be 'Primary'. Secondary and 'Not Acceptable' placenames have been removed.
LOCATION_TYPE string
// The latitude associated with the zipcode according to the National Weather Service. This can be empty when there is no NWS Data
LAT float64
// The longitude associated with the zipcode according to the National Weather Service. This can be empty when there is no NWS Data
LONG float64
XAXIS string
YAXIS string
ZAXIS string
// This value will always be NA for North America
WORLD_REGION string
// This value will always be US for United States -- This includes Embassy's, Military Bases, and Territories
COUNTRY string
// The city with its state or territory. Example: 'Cleveland, OH' or 'Anasco, PR'
LOCATION_TEXT string
// "A string formatted as WORLD_REGION-COUNTRY-STATE-CITY. Example: 'NA-US-PR-ANASCO'
LOCATION string
// A boolean value that reveals if a zipcode is still in use
DECOMMISIONED string
// Number of tax returns filed for the zip code in 2008 according to the IRS
TAX_RETURNS_FILED string
// Estimated population in 2008 according to the IRS
ESTIMATED_POPULATION string
// Total wages according in 2008 according to the IRS"
TOTAL_WAGES string
// Not empty when there is no NWS data.
NOTES string
}
Click to show internal directories.
Click to hide internal directories.