DurgNomis-drol / mytoyota

Python client for Toyota Connected Services API
MIT License
74 stars 28 forks source link

Reverse geocoding missing? #320

Closed rzarajczyk closed 7 months ago

rzarajczyk commented 7 months ago

Hi!

First of all thank you for this project! It's great!

Previously I was playing around with the old toyota API (I used https://github.com/calmjm/tojota as a client) and I saw that the basic trip information contained also the start and end address of the trip (in a human readable form f.ex. "Warsaw, Jerozolimiskie 156") .

But as far as I know your client can return only lat/lon.

Does this mean that Toyota stopped publishing addresses in their APIs? Is there any chances to get those addresses from Toyota, or do I have to look for some 3rd party libraries for this?

Thanks in advance!

joro75 commented 7 months ago

I'm using the geopy library to convert the coordinates back to an easy to use address. Some code I'm using for this is:

    def _lookup_address(self, coords: Tuple[str, ...]) -> str:     # pylint:disable=no-self-use
        """Determines the address of the given coordinates"""
        coord_str = ','.join(coordinate.strip().lower() for coordinate in coords[0:2])
        geolocator = Nominatim(user_agent=NOMINATIM_USER_AGENT)
        location = geolocator.reverse(coord_str)
        return (location.address if location else '')

For more details see: https://geopy.readthedocs.io/en/stable/#nominatim

A simple example is available at: https://spatial-dev.guru/2023/03/12/geocoding-and-reverse-geocoding-in-python-using-geopy/

CM000n commented 7 months ago

So far, we have not found any direct information about address data for journeys in the endpoints of the current Toyota API. So, like @joro75, you would have to rely on a 3rd party library to convert the GPS coordinates into addresses.