// FindNear returns a SearchResult containing LocationLookup within a half-mile of ``query``
FindNear returns a SearchResult containing LocationLookup within a half-mile of ``query``
// FindNear returns a SearchResult containing LocationLookup within a half - mile of ` ` query ` `
func (finder *CrimeFinder) FindNear(query Point) (SearchResult, error) {
	nearby := SearchResult{}
	nearby.Query = &query
	nearby.Locations = make([]*CrimeLocation, 0)
	ranges := map[int]kdtree.Range{
		0: {query.Lat - HALF_MILE_LAT, query.Lat + HALF_MILE_LAT},
		1: {query.Lng - HALF_MILE_LNG, query.Lng + HALF_MILE_LNG}}
	results, err := finder.Tree.FindRange(ranges)
	if err != nil {
		return nearby, err
	}
	for i := 0; i < len(results); i++ {
		node := results[i]
		key := GetCoordinateKey(node.Coordinates[0], node.Coordinates[1])
		location, exists := finder.LocationLookup[key]
		if exists {
			nearby.Locations = append(nearby.Locations, location)
		}
	}
	return nearby, nil
}
func ( finder * CrimeFinder ) FindNear ( query Point ) ( SearchResult , error ) { nearby := SearchResult { } nearby . Query = & query nearby . Locations = make ( [ ] * CrimeLocation , 0 ) ranges := map [ int ] kdtree . Range { 0 : { query . Lat - HALF_MILE_LAT , query . Lat + HALF_MILE_LAT } , 1 : { query . Lng - HALF_MILE_LNG , query . Lng + HALF_MILE_LNG } } results , err := finder . Tree . FindRange ( ranges ) if err != nil { return nearby , err } for i := 0 ; i < len ( results ) ; i ++ { node := results [ i ] key := GetCoordinateKey ( node . Coordinates [ 0 ] , node . Coordinates [ 1 ] ) location , exists := finder . LocationLookup [ key ] if exists { nearby . Locations = append ( nearby . Locations , location ) } } return nearby , nil }
FindNear returns a SearchResult containing LocationLookup within a half-mile of ``query``
FindNear returns a SearchResult containing LocationLookup within a half - mile of ` ` query ` `
// If we have a record for this coordinate, add it to ``nearby``.