From c8066d7b17acfa9455fe90453adb8ac7297fba56 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:33:53 -0600 Subject: [PATCH] overlappping squares become points --- cmd/run.go | 41 ++++++++++++++++++++++++++--------------- mise.toml | 3 +++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 14373f1..b9de86d 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -35,6 +35,7 @@ func Run(ctx context.Context) error { } `json:"geometry"` } type Area [1][5][2]float64 + type Point [2]float64 geoJsons := []geoJson{} for _, town := range towns { for search, area := range searches { @@ -55,8 +56,11 @@ func Run(ctx context.Context) error { var a geoJson a.Type = "Feature" a.Properties.Name = path.Join(search, results[i].Name) + if strings.Contains(search, "school") { + a.Properties.Name = " " + } a.Geometry.Type = "Point" - a.Geometry.Coordinates = []any{results[i].Lng, results[i].Lat} + a.Geometry.Coordinates = Point{results[i].Lng, results[i].Lat} if *doArea { a.Geometry.Type = "Polygon" x, y := results[i].Lng, results[i].Lat @@ -80,20 +84,27 @@ func Run(ctx context.Context) error { return fmt.Sprint(a.Geometry.Coordinates) == fmt.Sprint(b.Geometry.Coordinates) }) if *doArea { - for i := 0; i < len(geoJsons); i++ { - areaI := geoJsons[i].Geometry.Coordinates.(Area)[0] - j := i + 1 - for j < len(geoJsons) { - areaJ := geoJsons[j].Geometry.Coordinates.(Area)[0] - // if diamond i contains j, then drop j - iAbove := areaI[0][1] > areaJ[0][1] - iRight := areaI[1][0] > areaJ[1][0] - iBelow := areaI[2][1] < areaJ[2][1] - iLeft := areaI[3][0] < areaJ[3][0] - if iAbove && iRight && iBelow && iLeft { - geoJsons = append(geoJsons[:j], geoJsons[j+1:]...) - } else { - j += 1 + for i := range geoJsons { + areaI, ok := geoJsons[i].Geometry.Coordinates.(Area) + if ok { + areaI := areaI[0] + for j := i + 1; j < len(geoJsons); j++ { + areaJ, ok := geoJsons[j].Geometry.Coordinates.(Area) + if ok { + areaJ := areaJ[0] + // if diamond i contains j, then drop j + iAbove := areaI[0][1] > areaJ[0][1] + iRight := areaI[1][0] > areaJ[1][0] + iBelow := areaI[2][1] < areaJ[2][1] + iLeft := areaI[3][0] < areaJ[3][0] + if iAbove && iRight && iBelow && iLeft { + geoJsons[j].Geometry.Type = "Point" + geoJsons[j].Geometry.Coordinates = Point{ + (areaJ[1][0] + areaJ[3][0]) / 2.0, + (areaJ[0][1] + areaJ[2][1]) / 2.0, + } + } + } } } } diff --git a/mise.toml b/mise.toml index 5be7ee0..c36e4f4 100644 --- a/mise.toml +++ b/mise.toml @@ -11,5 +11,8 @@ run = "mise run search -- {olympia,lacey,tumwater}', wa'" [tasks.bend] run = "mise run search -- 'bend, or'" +[tasks.ridgefield] +run = "mise run search -- {ridgefield,vancouver,'mt vista','hazel dell',felida,'brush prarie','battle ground'}', or'" + [tasks.bellingham] run = "mise run search -- {burlington,sedro-wooley,'mt vernon',bellingham,ferndale}', wa'"