accept flags and -d for a box

This commit is contained in:
Bel LaPointe
2026-03-14 22:40:20 -06:00
parent ab4c577825
commit 68f7ad68c6
2 changed files with 32 additions and 8 deletions

View File

@@ -39,7 +39,7 @@ type Location struct {
}
func (m *Maps) textSearchOne(ctx context.Context, query string) (Location, error) {
results, err := m.Search(ctx, query)
results, err := m.Search(ctx, query, 1.0)
if err != nil {
return Location{}, err
} else if len(results) < 1 {
@@ -48,12 +48,13 @@ func (m *Maps) textSearchOne(ctx context.Context, query string) (Location, error
return results[0], nil
}
var convertToMiles = 69.0
func (m *Maps) Search(ctx context.Context, query string, radius_miles float64) ([]Location, error) {
results, err := m.search(ctx, query)
for i := len(results) - 1; i >= 0; i-- {
shouldKeep := true
if m.around != (Location{}) {
convertToMiles := 69.0
a := m.around.Lat - results[i].Lat
b := m.around.Lng - results[i].Lng
dist := math.Sqrt(a*a + b*b)