liquor

package
v0.0.0-...-83beb85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2014 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnexpectedLength     = errors.New("liquor: unexpected csv row length")
	UnparsableTimestamp  = errors.New("liquor: unparsable timestamp")
	UnparsableCoordinate = errors.New("liquor: unparsable coordinate")
)
View Source
var Hearings = aspect.Table("hearings",
	aspect.Column("id", aspect.Integer{PrimaryKey: true}),
	aspect.Column("notice_link", aspect.String{}),
	aspect.Column("name", aspect.String{}),
	aspect.Column("address", aspect.String{}),
	aspect.Column("latitude", aspect.Real{}),
	aspect.Column("longitude", aspect.Real{}),
	aspect.Column("time", aspect.Timestamp{}),
	aspect.Column("outcome", aspect.String{}),
	aspect.Column("location", postgis.Geometry{postgis.Point{}, 4326}),
)
View Source
var Licenses = aspect.Table("licenses",
	aspect.Column("id", aspect.String{PrimaryKey: true}),
	aspect.Column("bfn", aspect.String{}),
	aspect.Column("license", aspect.String{}),
	aspect.Column("name", aspect.String{}),
	aspect.Column("address", aspect.String{}),
	aspect.Column("code", aspect.String{}),
	aspect.Column("category", aspect.String{}),
	aspect.Column("license_name", aspect.String{}),
	aspect.Column("description", aspect.String{}),
	aspect.Column("issued", aspect.Timestamp{WithTimezone: true}),
	aspect.Column("expires", aspect.Timestamp{WithTimezone: true}),
	aspect.Column("status", aspect.String{}),
	aspect.Column("add_id", aspect.String{}),
	aspect.Column("external_address_id", aspect.String{}),
	aspect.Column("police_district", aspect.String{}),
	aspect.Column("council_district", aspect.String{}),
	aspect.Column("census_tract", aspect.String{}),
	aspect.Column("override", aspect.String{}),
	aspect.Column("longitude", aspect.Real{}),
	aspect.Column("latitude", aspect.Real{}),
	aspect.Column("location", postgis.Geometry{postgis.Point{}, 4326}),
)

Functions

func ById

func ById(ls []License) (byId map[string]License)

func NormalizedHeader

func NormalizedHeader() []string

func ParseHearingsHTML

func ParseHearingsHTML(content []byte) (hearings []rawHearing, err error)

func ParseTimestamp

func ParseTimestamp(input string) (time.Time, error)

TODO Assume that timestamps are mountain time?

Types

type ByUniqueId

type ByUniqueId struct {
	OrderedLicenses
}

func (ByUniqueId) Less

func (a ByUniqueId) Less(i, j int) bool

Sort by the unique Id string

type Change

type Change struct {
	// contains filtered or unexported fields
}

type Hearing

type Hearing struct {
	Id         int64     `json:"id"`
	NoticeLink string    `json:"notice_link"`
	Name       string    `json:"name"`
	Address    string    `json:"address"`
	Latitude   float64   `json:"latitude"`
	Longitude  float64   `json:"longitude"`
	Time       time.Time `json:"time"`
	Outcome    string    `json:"outcome"`
}

Hearing is a public hearing with a time and location

func CleanHearings

func CleanHearings(raws []rawHearing, g geocode.Geocoder) ([]Hearing, error)

func ParseHearingsJSON

func ParseHearingsJSON(contents []byte) (hearings []Hearing, err error)

type HearingsAPI

type HearingsAPI struct {
	// contains filtered or unexported fields
}

func NewHearingsAPI

func NewHearingsAPI(db *aspect.DB) *HearingsAPI

func (*HearingsAPI) Get

func (api *HearingsAPI) Get(parameters url.Values) argo.Response

type License

type License struct {
	UniqueId    string    `db:"id" json:"id"`
	BFN         string    `db:"bfn" json:"-"`
	LicenseId   string    `db:"license" json:"-"`
	Name        string    `db:"name" json:"name"`
	Address     string    `db:"address" json:"address"`
	Code        string    `db:"code" json:"-"`
	Category    string    `db:"category" json:"type"`
	LicenseName string    `db:"license_name" json:"-"`
	Description string    `db:"description" json:"-"`
	Issued      time.Time `db:"issued" json:"issued" csv:"2006-01-02"`
	Expires     time.Time `db:"expires" json:"expires" csv:"2006-01-02"`
	Status      string    `db:"status" json:"status"`
	AddId       string    `db:"add_id" json:"-"`
	ExtAddId    string    `db:"external_address_id" json:"-"`
	Police      string    `db:"police_district" json:"-"`
	Council     string    `db:"council_district" json:"-"`
	Census      string    `db:"census_tract" json:"-"`
	Override    string    `db:"override" json:"-"`
	Xcoord      float64   `db:"longitude" json:"longitude"`
	Ycoord      float64   `db:"latitude" json:"latitude"`
}

func Normalize

func Normalize(originals []License) ([]License, error)

Normalize will: * Remove duplicate unique ids * Convert the Colorado state plane coordinates to latitude and longitude * Sort the licenses by unique id

func ParseLicense

func ParseLicense(raw []string) (License, error)

func ParseLicensesCSV

func ParseLicensesCSV(path string) ([]License, error)

func ParseNormalizedLicensesCSV

func ParseNormalizedLicensesCSV(path string) (licenses []License, err error)

func StatePlaneToLatLong

func StatePlaneToLatLong(licenses []License) ([]License, error)

Convert an array of licenses to latitude and longitude

func (License) CSV

func (l License) CSV() []string

Convert the record into a string array that can be written to a CSV

func (License) Changes

func (l License) Changes(other License) map[string]interface{}

Save the changes between the licenses to a map

func (License) Equals

func (l License) Equals(other License) bool

Are the two licenses equal? TODO There's not a better way to do this - use reflect deep equals

func (License) NormalizedCSV

func (l License) NormalizedCSV() []string

The normalized CSV output increases the number of significant digits for the x and y coords, since they are now latitude and longitudes

func (License) String

func (l License) String() string

type LicensesAPI

type LicensesAPI struct {
	// contains filtered or unexported fields
}

func NewLicensesAPI

func NewLicensesAPI(db *aspect.DB) *LicensesAPI

func (*LicensesAPI) Get

func (api *LicensesAPI) Get(parameters url.Values) argo.Response

Example lat/long query: /v1/licenses/?latitude=39.739167&longitude=-104.984722

type OrderedLicenses

type OrderedLicenses []License

func (OrderedLicenses) Len

func (a OrderedLicenses) Len() int

Implement the sort.Interface for sorting

func (OrderedLicenses) Sort

func (a OrderedLicenses) Sort()

func (OrderedLicenses) Swap

func (a OrderedLicenses) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL