in CSharp/BotBuilderLocation/Dialogs/LocationRetrieverDialogBase.cs [63:86]
private async Task TryReverseGeocodeAddress(Location location)
{
// If user passed ReverseGeocode flag and dialog returned a geo point,
// then try to reverse geocode it using BingGeoSpatialService.
if (this.options.HasFlag(LocationOptions.ReverseGeocode) && location != null && location.Address == null && location.Point != null)
{
var results = await this.geoSpatialService.GetLocationsByPointAsync(location.Point.Coordinates[0], location.Point.Coordinates[1]);
var geocodedLocation = results?.Locations?.FirstOrDefault();
if (geocodedLocation?.Address != null)
{
// We don't trust reverse geo-coder on the street address level,
// so copy all fields except it.
// TODO: do we need to check the returned confidence level?
location.Address = new Bing.Address
{
CountryRegion = geocodedLocation.Address.CountryRegion,
AdminDistrict = geocodedLocation.Address.AdminDistrict,
AdminDistrict2 = geocodedLocation.Address.AdminDistrict2,
Locality = geocodedLocation.Address.Locality,
PostalCode = geocodedLocation.Address.PostalCode
};
}
}
}