param
This commit is contained in:
@@ -48,7 +48,7 @@ func (m *Maps) textSearchOne(ctx context.Context, query string) (Location, error
|
|||||||
return results[0], nil
|
return results[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Maps) Search(ctx context.Context, query string) ([]Location, error) {
|
func (m *Maps) Search(ctx context.Context, query string, radius_miles float64) ([]Location, error) {
|
||||||
results, err := m.search(ctx, query)
|
results, err := m.search(ctx, query)
|
||||||
for i := len(results) - 1; i >= 0; i-- {
|
for i := len(results) - 1; i >= 0; i-- {
|
||||||
shouldKeep := true
|
shouldKeep := true
|
||||||
@@ -57,7 +57,7 @@ func (m *Maps) Search(ctx context.Context, query string) ([]Location, error) {
|
|||||||
a := m.around.Lat - results[i].Lat
|
a := m.around.Lat - results[i].Lat
|
||||||
b := m.around.Lng - results[i].Lng
|
b := m.around.Lng - results[i].Lng
|
||||||
dist := math.Sqrt(a*a + b*b)
|
dist := math.Sqrt(a*a + b*b)
|
||||||
shouldKeep = dist*convertToMiles < 5.0
|
shouldKeep = dist*convertToMiles < radius_miles
|
||||||
}
|
}
|
||||||
if !shouldKeep {
|
if !shouldKeep {
|
||||||
results = append(results[:i], results[i+1:]...)
|
results = append(results[:i], results[i+1:]...)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func Run(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
results, err := m.Search(ctx, os.Args[2])
|
results, err := m.Search(ctx, os.Args[2], 5.0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user