Created
October 22, 2022 19:37
-
-
Save dansku/b885476e44db87d291318625dcef7bf8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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