I have a ArrayList
that stores GPS coordinate objects and their elements are always compared to the double values returned by the getLatitude()
and getLongitude()
methods of Interface .
Problem
From the tests I've done, I realized that it's very difficult for the user's Smartphone to capture a GPS coordinate exactly like any of my ArrayList
elements. So the solution I encounter for this problem is to round out the double
values of the objects of my ArrayList
and also round the double values returned by the getLatitude()
and getLongitude()
methods of Interface Location to be able to detect with more success when the user is near the places that I intend to control.
Does anyone know how to best round the doubles values returned by the getLatitude()
and getLongitude()
methods or indicate another solution to this problem?
Below is my ArrayList
:
ArrayList<Coordenada> coordenadasPKs = new ArrayList<>();
coordenadasPKs.add(new Coordenada(41.148185, -8.584755, 336.1));
coordenadasPKs.add(new Coordenada(40.82614, -8.59654, 296));
coordenadasPKs.add(new Coordenada(40.168235, -8.62813666666667, 199));
coordenadasPKs.add(new Coordenada(39.69546, -8.50684666666667, 135));
coordenadasPKs.add(new Coordenada(39.6148033333333, -8.49502833333333, 125));
coordenadasPKs.add(new Coordenada(39.411415, -8.52799166666667, 99));
coordenadasPKs.add(new Coordenada(39.1335366666667, -8.761665, 59));