0

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?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Red M
  • 2,609
  • 3
  • 30
  • 50

1 Answers1

1

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.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127