Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions geocoding_batch_reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
type BatchReverseGeocodeRequest struct {
// Queries are the coordinates to reverse geocode. Must contain 1–1000 items.
Queries []ReverseGeocodeQuery
// Permanent requests Permanent tier geocoding, which permits storing results.
// Defaults to Temporary tier when false.
Permanent bool
}

// ReverseGeocodeQuery is a single query in a batch reverse geocode request.
Expand All @@ -28,6 +31,7 @@ type batchGeocodeQuery struct {
Types string `json:"types"`
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
Permanent bool `json:"permanent"`
}

// BatchReverseGeocode performs a batch reverse geocode lookup using Geocoding v6 Batch.
Expand All @@ -53,6 +57,7 @@ func (c *Client) BatchReverseGeocode(ctx context.Context, req *BatchReverseGeoco
Types: "address",
Longitude: q.Longitude,
Latitude: q.Latitude,
Permanent: req.Permanent,
}
}

Expand Down
6 changes: 6 additions & 0 deletions geocoding_reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type ReverseGeocodeRequest struct {
Longitude float64
// Latitude is the coordinate to reverse geocode.
Latitude float64
// Permanent requests Permanent tier geocoding, which permits storing results.
// Defaults to Temporary tier when false.
Permanent bool
}

// ReverseGeocode performs a single reverse geocode lookup using Geocoding v6.
Expand All @@ -29,6 +32,9 @@ func (c *Client) ReverseGeocode(ctx context.Context, req *ReverseGeocodeRequest)
params := url.Values{}
params.Set("longitude", strconv.FormatFloat(req.Longitude, 'f', -1, 64))
params.Set("latitude", strconv.FormatFloat(req.Latitude, 'f', -1, 64))
if req.Permanent {
params.Set("permanent", "true")
}

endpoint := c.baseURL + "/search/geocode/v6/reverse?" + params.Encode()
httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
Expand Down