// NewCrimeFinder creates a new CrimeFinder loaded from CSV data.
NewCrimeFinder creates a new CrimeFinder loaded from CSV data.
// NewCrimeFinder creates a new CrimeFinder loaded from CSV data .
func NewCrimeFinder(filename string) (CrimeFinder, error) {
	var err error
	finder := CrimeFinder{}
	rows, err := readCrimes(filename)
	if err != nil {
		return finder, err
	}
	err = finder.loadFromCsv(rows)
	if err != nil {
		return finder, err
	}
	nodes := make([]*kdtree.Node, 0)
	for _, location := range finder.LocationLookup {
		node := kdtree.Node{}
		node.Coordinates = Coordinates{location.Point.Lat, location.Point.Lng}
		nodes = append(nodes, &node)
	}
	finder.Tree = kdtree.BuildTree(nodes)
	return finder, nil
}
func NewCrimeFinder ( filename string ) ( CrimeFinder , error ) { var err error finder := CrimeFinder { } rows , err := readCrimes ( filename ) if err != nil { return finder , err } err = finder . loadFromCsv ( rows ) if err != nil { return finder , err } nodes := make ( [ ] * kdtree . Node , 0 ) for _ , location := range finder . LocationLookup { node := kdtree . Node { } node . Coordinates = Coordinates { location . Point . Lat , location . Point . Lng } nodes = append ( nodes , & node ) } finder . Tree = kdtree . BuildTree ( nodes ) return finder , nil }
NewCrimeFinder creates a new CrimeFinder loaded from CSV data.
NewCrimeFinder creates a new CrimeFinder loaded from CSV data .