Use embedded address location rather than external location on geocode
This commit is contained in:
parent
3c62fe2ca1
commit
cadf6afb5f
6 changed files with 22 additions and 23 deletions
|
|
@ -40,6 +40,7 @@ func ByGID(ctx context.Context, gid string) (*GeocodeResult, error) {
|
|||
GID: feature.Properties.GID,
|
||||
ID: &id,
|
||||
Locality: feature.Properties.Context.WhosOnFirst.Locality.Name,
|
||||
Location: &location,
|
||||
Number: feature.Properties.AddressComponents.Number,
|
||||
PostalCode: feature.Properties.AddressComponents.PostalCode,
|
||||
Raw: feature.Properties.FormattedAddressLine,
|
||||
|
|
@ -47,7 +48,6 @@ func ByGID(ctx context.Context, gid string) (*GeocodeResult, error) {
|
|||
Street: feature.Properties.AddressComponents.Street,
|
||||
Unit: "",
|
||||
},
|
||||
Cell: cell,
|
||||
Location: location,
|
||||
Cell: cell,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@ import (
|
|||
)
|
||||
|
||||
type GeocodeResult struct {
|
||||
Address types.Address
|
||||
Cell h3.Cell
|
||||
Location types.Location
|
||||
Address types.Address
|
||||
Cell h3.Cell
|
||||
}
|
||||
|
||||
var client *stadia.StadiaMaps
|
||||
|
|
@ -115,9 +114,13 @@ func toGeocodeResult(resp stadia.GeocodeResponse, address_msg string) (*GeocodeR
|
|||
// Depending on what kind of request we made we'll get wildly different result structures
|
||||
// This first structure generally works for forword geocoding
|
||||
address := types.Address{
|
||||
Country: country_s,
|
||||
GID: feature.Properties.GID,
|
||||
Locality: feature.Properties.Locality,
|
||||
Country: country_s,
|
||||
GID: feature.Properties.GID,
|
||||
Locality: feature.Properties.Locality,
|
||||
Location: &types.Location{
|
||||
Longitude: feature.Geometry.Coordinates[0],
|
||||
Latitude: feature.Geometry.Coordinates[1],
|
||||
},
|
||||
Number: feature.Properties.HouseNumber,
|
||||
PostalCode: feature.Properties.PostalCode,
|
||||
Region: feature.Properties.Region,
|
||||
|
|
@ -136,10 +139,6 @@ func toGeocodeResult(resp stadia.GeocodeResponse, address_msg string) (*GeocodeR
|
|||
return &GeocodeResult{
|
||||
Address: address,
|
||||
Cell: cell,
|
||||
Location: types.Location{
|
||||
Longitude: feature.Geometry.Coordinates[0],
|
||||
Latitude: feature.Geometry.Coordinates[1],
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue