Skip to content

Instantly share code, notes, and snippets.

@dansku
Created October 22, 2022 19:37
Show Gist options
  • Save dansku/b885476e44db87d291318625dcef7bf8 to your computer and use it in GitHub Desktop.
Save dansku/b885476e44db87d291318625dcef7bf8 to your computer and use it in GitHub Desktop.
func getGeoBoundaries(hex string) string {
bondaries := h3.ToGeoBoundary(h3.FromString(hex))
// Iterate between all points
bondariesText := ""
for _, p := range bondaries {
bondariesText += fmt.Sprintf("%v %v,", p.Longitude, p.Latitude)
}
// Add first point again
i := 0
for _, p := range bondaries {
if i == 0 {
bondariesText += fmt.Sprintf("%v %v,", p.Longitude, p.Latitude)
break
}
}
// remove last char from string
bondariesText = bondariesText[:len(bondariesText)-1]
poligonQuery := fmt.Sprintf("SRID=4326;POLYGON((%v))", bondariesText)
return poligonQuery
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment