radar

package
v0.0.0-...-00cd1a6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2014 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const HALF_MILE_LAT = 0.00714

One half mile of latitude in the WGS84 coordinate system in Oregon.

View Source
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

func GetCoordinateKey(x float64, y float64) string

GetCoordinateKey returns a pair of float64 coordinates as strings.

Types

type Coordinates

type Coordinates []float64

type Crime

type Crime struct {
	Id   int64
	Date string
	Time string
	Type string
}

Data for a single crime in the City's CSV data (one row).

func (Crime) String

func (c Crime) String() string

String formats a string version of a Crime.

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

type CrimeLocation struct {
	Point  *Point
	Crimes []*Crime
}

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 Crimes

type Crimes []*Crime

type CsvRow

type CsvRow []string

type CsvRows

type CsvRows []CsvRow

type LocationLookup

type LocationLookup map[string]*CrimeLocation

This will help us find the CrimeLocation that a kd-tree node refers to.

type Point

type Point struct {
	Lat float64
	Lng float64
}

A Point represents a latitude and longitude coordinate pair.

type Points

type Points []*Point

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.

Jump to

Keyboard shortcuts

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