android - Saving gps cords into Array -



android - Saving gps cords into Array -

this may sound basic im wondering what's standard. collecting gps cords, , saving lats , long in (preferably )an array, algorithm brings best performance ? way good? other (better) suggestion? thanks

public void onlocationchanged(location loc) { // new , j, in increment givemeiandj() array[i][j]=(loc.getlatitude()); array[i][j]=(loc.getlongitude());

the best performance means of memory saving store lat , longitude in different arrays:

int[] longitudes = new int[maxsize]; int[] latitudes = new int[maxsize]; longitudes[i] = loc.getlongitude() * 1e7; / 1e7 = 1000000: converts integer latitudes[i] = loc.getlatitdue() * 1e7;

where maxsize max buffer size before write storage.

two dimensional arrays in java need more space (than in c) because 2d array 1d array of objects of type int[], looses 20 bytes per (1-d) entry.

if want, can store lat/lon in 1 int[] array:

int[] latlongs= new int[2 * maxsize]; latlongs[2*i] = (int) (loc.getlongitude() * 1e7); latlongs[2*i + 1] = (int) (loc.getlatitude() * 1e7);

if want ommit faktor 1e7, utilize double[] (or float[]) array.

android arrays gps save increment

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -