24 |
AndroidTimeoutCache<String, List<StationBean>> stationCache = new AndroidTimeoutCache<String, List<StationBean>>(CACHE_TIMEOUT); |
AndroidTimeoutCache<String, List<StationBean>> stationCache = new AndroidTimeoutCache<String, List<StationBean>>(CACHE_TIMEOUT); |
25 |
|
|
26 |
|
|
27 |
|
double roundToPlaces(double value, int places) { |
28 |
|
double pow = Math.pow(10, places); |
29 |
|
double temp = Math.round( value*pow ); |
30 |
|
|
31 |
|
return temp / pow; |
32 |
|
} |
33 |
|
|
34 |
@Override |
@Override |
35 |
public List<StationBean> lookupStations(Location location) { |
public List<StationBean> lookupStations(Location location) { |
36 |
String url = XmlUtil.SERVICE_BASE + "/LocateStations?latitude=" + (float)location.getLatitude() + "&longitude=" + (float)location.getLongitude(); |
double lat = roundToPlaces(location.getLatitude(), 4); |
37 |
|
double lng = roundToPlaces(location.getLongitude(), 4); |
38 |
|
|
39 |
|
String url = XmlUtil.SERVICE_BASE + "/LocateStations?latitude=" + lat + "&longitude=" + lng; |
40 |
Log.i("url", url); |
Log.i("url", url); |
41 |
return lookupStationsWorker(url); |
return lookupStationsWorker(url); |
42 |
} |
} |