Hi! I experimented and looked for answers but nothing worked. Hope someone will be able to help me out
I need to run a bunch of lopped nodes with an array as an input. I managed to make it work for all necessary API requests and Google Sheet update. But I
still have to do a reverse geolocation based on lat/long data retrieved from an API call (qrVehicleStateLoop) (returned json on screenshot)
from geopy.geocoders import Nominatim
def get_address(latitude, longitude):
# Ensure that the user_agent is specific to your application or use case
geolocator = Nominatim(user_agent="Dott")
location = geolocator.reverse((latitude, longitude), exactly_one=True)
return location.address if location else "Address not found"
# Example usage:
latitude = qrVehicleBrusselsCity.data[0].gnss.point._latitude # Example latitude (for New York City)
longitude = qrVehicleBrusselsCity.data[0].gnss.point._longitude # Example longitude
address = get_address(latitude, longitude)
return(f"The address for the coordinates is: {address}")
One thing you can try is to create a separate workflow with your python code that accepts the qrVehicleStateLoop lat/long output data as its input.
Then, you should be able to call upon that workflow as kind of a python subroutine for your loop in the main workflow to get the full set of data you need for the last googleSheetsAppend loop.
Caveat Emptor: this would be considered another workflow run, I think, so if you have a limited number of runs per cycle this might not be the most ideal solution.
I'll need a value from "qrVehicleStateLoop.data[0][0]", "qrVehicleStateLoop.data[1][0]", "qrVehicleStateLoop.data[2][0]" and so on for as entries as returned in the loop.
from geopy.geocoders import Nominatim
def get_address(latitude, longitude):
# Ensure that the user_agent is specific to your application or use case
geolocator = Nominatim(user_agent="Dott")
location = geolocator.reverse((latitude, longitude), exactly_one=True)
return location.address if location else "Address not found"
address = get_address(param1, param2)
return(address)
-> JS with input from qrVehicleStateLoop: "return (await function1.data)"
There's definitely something wrong with JS but I don't know what. Any help appreciated.
@andrei Hi! I tried to follow your logic but there's a lot of missing from my knowledge. Not sure if I managed to do anything right? I'd love to get some more input
I think this is a bit wonky in that you are saying "return location address" but then you are trying to do it based on conditions after the fact. I am pretty sure that this will just attempt to return location.address and ignore the if/else you wrote afterwards. I'd have written this more like:
if (location) return location.address
else return "Address not found"