Azure / Azure/azure-sdk-for-python

Return bad results from MapsSearchClient::get_reverse_geocoding()

Offen
#45,199 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug customer-reported Maps needs-team-attention Service Attention
Vorherrschende Sprache
Python
Sterne
5.6k
Forks
3.4k
Ø Merge
2 T.
Gemergte PRs (30 T.)
217

Beschreibung

- **Package Name**: azure.maps.search
- **Package Version**: latest
- **Operating System**: Windows
- **Python Version**: 3.12.7

**Describe the bug**

I wrote a function to geocode a location given an address using the library. That works fine. But if I reverse geocode a location it returns the wrong address.

**To Reproduce**
Steps to reproduce the behavior:

1. Run the code at the bottom in a Jupyter notebook. It looks like about 41 pct of the reverse lookups are wrong. See image below.

Image

2. This code was test on a Databricks cluster also with the same results. I had a total of 234 sample addresses.

Image

**Expected behavior**

This is basic math. x = sqrt(sqr(x))

The same should be with the maps functions. a = reverse-geocode(geocode(a))

**Screenshots**

Bad reverse lookup.

Image

Using another tool comes up with correct location.

Image

**Additional context**

The python function output shows what is wrong. If we geocode an address to get coordinates. The reverse geo-code of those coordinates should produce the same result.

#
# Test Maps Search Client
#

from azure.core.credentials import AzureKeyCredential
from azure.maps.search import MapsSearchClient
api_key = ""

def get_additional_address_info(api_key, raw_address):

# create object
azmaps = MapsSearchClient(credential=AzureKeyCredential(api_key))

# initialize variables
longitude = 0.0
latitude = 0.0
address = {'formattedAddress': '', 'postalCode': ''}
coordinates = [0.0, 0.0]

# Perform geocoding
try:
retval1 = azmaps.get_geocoding(query=raw_address)

if retval1.get('features'):
coordinates = retval1['features'][0]['geometry']['coordinates']
print(coordinates)
longitude, latitude = coordinates

except Exception as e:
pass

# Reverse geocoding
try:
retval2 = azmaps.get_reverse_geocoding(coordinates=coordinates)

if retval2.get('features'):
address = retval2['features'][0]['properties']['address']

except Exception as e:
pass

return { "address": address['formattedAddress'], "postalCode": address['postalCode'], "longitude": longitude, "latitude": latitude }

#
# Test function
#

raw_address = "780 Lynnway, Lynn, MA, United States 01905"
retval3 = get_additional_address_info(api_key, raw_address)
print(retval3)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, azure.maps.search und den Einstiegspunkt MapsSearchClient::get_reverse_geocoding() zu lokalisieren. Reproduziere das Problem mit dem bereitgestellten Jupyter-Notebook-Code und der Beispieladresse und vergleiche anschließend die Geocoding-Koordinaten und die zurückgegebene Feature-Adresse, um festzustellen, ob die Abweichung im SDK-Aufruf oder in der Service-Antwort liegt; abgeschlossen ist die Aufgabe, wenn das gemeldete Reverse-Geocoding-Ergebnis erklärt oder korrigiert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
api
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.