dedupe points across searches but not across towns

This commit is contained in:
Bel LaPointe
2026-03-17 12:39:55 -06:00
parent c8066d7b17
commit 2d53b0639b

View File

@@ -37,20 +37,30 @@ func Run(ctx context.Context) error {
type Area [1][5][2]float64 type Area [1][5][2]float64
type Point [2]float64 type Point [2]float64
geoJsons := []geoJson{} geoJsons := []geoJson{}
for _, town := range towns {
for search, area := range searches { for search, area := range searches {
radius := area / convertToMiles results := []Location{}
radiusX := 2 * radius / 2 for _, town := range towns {
radiusY := 2 * radius / 3
m, err := NewMapsOf(ctx, town) m, err := NewMapsOf(ctx, town)
if err != nil { if err != nil {
return err return err
} }
results, err := m.Search(ctx, search, *searchRadius) more, err := m.Search(ctx, search, *searchRadius)
if err != nil { if err != nil {
return err return err
} }
results = append(results, more...)
}
slices.SortFunc(results, func(a, b Location) int {
return strings.Compare(a.Name, b.Name)
})
slices.CompactFunc(results, func(a, b Location) bool {
return a.Name == b.Name
})
radius := area / convertToMiles
radiusX := 2 * radius / 2
radiusY := 2 * radius / 3
for i := range results { for i := range results {
var a geoJson var a geoJson
@@ -75,7 +85,6 @@ func Run(ctx context.Context) error {
geoJsons = append(geoJsons, a) geoJsons = append(geoJsons, a)
} }
} }
}
log.Println(len(geoJsons)) log.Println(len(geoJsons))
slices.SortFunc(geoJsons, func(a, b geoJson) int { slices.SortFunc(geoJsons, func(a, b geoJson) int {
return strings.Compare(fmt.Sprint(a.Geometry.Coordinates), fmt.Sprint(b.Geometry.Coordinates)) return strings.Compare(fmt.Sprint(a.Geometry.Coordinates), fmt.Sprint(b.Geometry.Coordinates))