Use embedded address location rather than external location on geocode

This commit is contained in:
Eli Ribble 2026-04-14 01:32:32 +00:00
parent 3c62fe2ca1
commit cadf6afb5f
No known key found for this signature in database
6 changed files with 22 additions and 23 deletions

View file

@ -139,14 +139,17 @@ func geocodePool(ctx context.Context, txn bob.Tx, client *stadia.StadiaMaps, job
PostalCode: pool.AddressPostalCode,
Street: pool.AddressStreet,
}
address, err := geocode.GeocodeStructured(ctx, job.org, a)
geo, err := geocode.GeocodeStructured(ctx, job.org, a)
if err != nil {
addError(ctx, txn, job.csv, job.rownumber, 0, err.Error())
}
geom_query := geom.PostgisPointQuery(address.Location)
if geo.Address.Location == nil {
return fmt.Errorf("nil location")
}
geom_query := geom.PostgisPointQuery(*geo.Address.Location)
_, err = psql.Update(
um.Table("fileupload.pool"),
um.SetCol("h3cell").ToArg(address.Cell),
um.SetCol("h3cell").ToArg(geo.Cell),
um.SetCol("geom").To(geom_query),
um.Where(psql.Quote("id").EQ(psql.Arg(pool.ID))),
).Exec(ctx, txn)

View file

@ -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
}

View file

@ -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
}

View file

@ -16,16 +16,14 @@ type geocodeR struct {
router *router
}
type geocode struct {
Address types.Address `json:"address"`
Cell h3.Cell `json:"cell"`
Location types.Location `json:"location"`
Address types.Address `json:"address"`
Cell h3.Cell `json:"cell"`
}
func newGeocode(g *ngeocode.GeocodeResult) *geocode {
return &geocode{
Address: g.Address,
Cell: g.Cell,
Location: g.Location,
Address: g.Address,
Cell: g.Cell,
}
}

View file

@ -123,7 +123,7 @@ async function doAddressSuggestionDetails(suggestion: GeocodeSuggestion) {
console.log("suggestion located, zooming", data);
currentCamera.value.zoom = 15;
}
updateModel(data.address.gid, data.address.raw, data.location);
updateModel(data.address.gid, data.address.raw, data.address.location);
}
function doMapClick(location: Location) {
updateModel(props.modelValue.gid, props.modelValue.raw, location);

View file

@ -86,7 +86,6 @@ export interface GeocodeSuggestion {
export interface Geocode {
address: Address;
cell: number;
location: Location;
}
export interface LogEntryDTO {
created: string;