Documentation ¶
Index ¶
Constants ¶
const HALF_MILE_LAT = 0.00714
One half mile of latitude in the WGS84 coordinate system in Oregon.
const HALF_MILE_LNG = 0.00724
One half mile of longitude in the WGS84 coordinate system in Oregon.
Variables ¶
This section is empty.
Functions ¶
func GetCoordinateKey ¶
GetCoordinateKey returns a pair of float64 coordinates as strings.
Types ¶
type Coordinates ¶
type Coordinates []float64
type CrimeFinder ¶
type CrimeFinder struct { LocationLookup LocationLookup CrimeTypes CrimeTypes Tree *kdtree.Tree }
An object that can find crimes near a WGS84 coordinate.
func NewCrimeFinder ¶
func NewCrimeFinder(filename string) (CrimeFinder, error)
NewCrimeFinder creates a new CrimeFinder loaded from CSV data.
func (*CrimeFinder) All ¶
func (finder *CrimeFinder) All() SearchResult
All returns a SearchResult containing all LocationLookup in the CrimeFinder.
func (*CrimeFinder) FindNear ¶
func (finder *CrimeFinder) FindNear(query Point) (SearchResult, error)
FindNear returns a SearchResult containing LocationLookup within a half-mile of “query“
func (*CrimeFinder) Locations ¶
func (finder *CrimeFinder) Locations() []*CrimeLocation
Locations returned a slice of all the CrimeLocations in this CrimeFinder
type CrimeLocation ¶
A location in the City's data with a coordinate at which crimes occurred.
type CrimeTypes ¶
type CrimeTypes []string
We store a slice of all the types of crime in the CSV data. This isn't used anywhere in the code but is something we make available to clients.
func (CrimeTypes) Contains ¶
func (types CrimeTypes) Contains(crimeType string) bool
type LocationLookup ¶
type LocationLookup map[string]*CrimeLocation
This will help us find the CrimeLocation that a kd-tree node refers to.
type SearchResult ¶
type SearchResult struct { Query *Point Locations []*CrimeLocation }
The result of a search for crimes near a location.
func (SearchResult) Crimes ¶
func (r SearchResult) Crimes() Crimes
Crimes returns all of the Crimes in a SearchResult.
func (SearchResult) Points ¶
func (r SearchResult) Points() Points
Points returns all of the coordinates of a SearchResult's LocationLookup.
func (SearchResult) ToJson ¶
func (r SearchResult) ToJson() ([]byte, error)
ToJson returns a SearchResult marshalled to JSON bytes. XXX: This is terrible but gained several hundred requests/sec over json.Marshall.