Red M
Red M

Reputation: 2789

It takes almost 1 second to convert String address to lat and lng

I'm using the following algorithm to convert my string address to latitude and longitude and the string address is getting converted perfectly fine.

I have set two Log.i(tag, msg):

One before the logic, and one after it's done,

to figure out how long it's taking to convert. I found out that it is taking ALMOST 1 SEC just to do one conversion.

Result of loggers:

07-03 14:49:50.122 4510-4554/com.test.redmI/[com.test.redm.utils.CalculationUtil]= getLngLat begin: Current time is:
Tue Jul 03 14:49:50.122 2018

07-03 14:49:50.995 4510-4554/com.test.redmI/[com.test.redm.utils.CalculationUtil]= getLngLat end: Current time is:
Tue Jul 03 14:49:50.995 2018

In my app, I do have a list of dynamic strings that I want to convert. So as the list of address grows, the time to convert does grow as well.

Question: Can be achieved faster?

Upvotes: 0

Views: 56

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93542

Its going to take time. You don't have a list mapping every address in the world on your phone. You need to call out to Google's webservice, which requires a network request and time for it to process the request. The solution is to convert them once, store the answer, and use that stored result in the future- its not like the GPS coordinates of an address change on a non-geological timescale.

Upvotes: 1

Related Questions