Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
since_1995
Contributor III
Contributor III

Distance matrix Api in talend

Hi,

I have address data from 2 different tables tables as origin and destination with coordinates.

now I need to calculate the distance from the each origin to destination

coordinates using goggle distance matrix api.

I have 25 origins and 3000 destination so

I'm exporting the destination to a file and splitting into several files. like (out1.csv,out2.csv,out3.csv,etc)Total i have 135 files with 25 rows in it.

I'm iterating the each origin from origin table to the tfilelist

TDBROW--->Main--->TflowtoIterate--->tfilelist--->iterate--->tfileinputdelimited--->Tjavarow--->oncomponentok-->thttprequest(REST)-->textractjson-->tmap-->Tdboutput.

Basically, i want one origin has to be iterated with each file and then it should go to the REST api which will find the distance between 1 origin and 25 destinations , so one origin should be iterated with all 135 files. , But it doesn't seem to be working and only one row is getting iterated with the same file(i,e OUT1.csv) So is there a way to fix this.

Labels (5)
1 Reply
Anonymous
Not applicable

I'm afraid we will need more information about your job if this is about what is not working in your job. A few screenshots and any code you are using should be a good start.

 

On another note, I see you are calculating distance between GPS coords (I assume "coordinates" means GPS). Are you looking for straight line distance or distance by road? If you are looking for straight line distance, there may be a quicker way of calculating these without calling the Google API (this will take a LONG time with so many calls). Have a look at the Haversine Distance algorithm. This can be built into a routine and then you would just be calling local code to get this data. It may even make your job simpler.

 

Here is a GitHub page with a version written in Java....

 

https://gist.github.com/vananth22/888ed9a22105670e7a4092bdcf0d72e4