Fix Nominatim geocoding
This commit is contained in:
parent
e6b36494e7
commit
39a3603c8e
@ -44,6 +44,7 @@ archives:
|
|||||||
- README.md
|
- README.md
|
||||||
- itd.toml
|
- itd.toml
|
||||||
- itd.service
|
- itd.service
|
||||||
|
allow_different_binary_count: true
|
||||||
nfpms:
|
nfpms:
|
||||||
- id: itd
|
- id: itd
|
||||||
file_name_template: >-
|
file_name_template: >-
|
||||||
|
@ -155,10 +155,12 @@ func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro
|
|||||||
func getLocation(ctx context.Context, loc string) (lat, lon float64, err error) {
|
func getLocation(ctx context.Context, loc string) (lat, lon float64, err error) {
|
||||||
// Create request URL and perform GET request
|
// Create request URL and perform GET request
|
||||||
reqURL := fmt.Sprintf("https://nominatim.openstreetmap.org/search.php?q=%s&format=jsonv2", url.QueryEscape(loc))
|
reqURL := fmt.Sprintf("https://nominatim.openstreetmap.org/search.php?q=%s&format=jsonv2", url.QueryEscape(loc))
|
||||||
|
println(reqURL)
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
req.Header.Set("User-Agent", fmt.Sprintf("ITD/%s gitea.elara.ws/Elara6331/itd", strings.TrimSpace(version)))
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -210,7 +212,7 @@ func getWeather(ctx context.Context, lat, lon float64) (*METResponse, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set identifying user agent as per NMI requirements
|
// Set identifying user agent as per NMI requirements
|
||||||
req.Header.Set("User-Agent", fmt.Sprintf("ITD/%s gitea.arsenm.dev/Arsen6331/itd", strings.TrimSpace(version)))
|
req.Header.Set("User-Agent", fmt.Sprintf("ITD/%s gitea.elara.ws/Elara6331/itd", strings.TrimSpace(version)))
|
||||||
|
|
||||||
// Perform request
|
// Perform request
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := http.DefaultClient.Do(req)
|
||||||
|
Loading…
Reference in New Issue
Block a user