Added constant, renamed cacheObj to app

This commit is contained in:
misaochan 2016-01-11 16:55:17 +13:00
parent 881acda52d
commit e62760ebc0
3 changed files with 6 additions and 9 deletions

View file

@ -147,8 +147,6 @@ public class CommonsApplication extends Application {
return bitmapSize / 1024;
}
};
}
//For caching area -> categories

View file

@ -18,6 +18,7 @@ public class CacheController {
private double xMinus, xPlus, yMinus, yPlus;
private static final String TAG = CacheController.class.getName();
private static final int EARTH_RADIUS = 6378137;
public CacheController() {
quadTree = new QuadTree(-180, -90, +180, +90);
@ -75,14 +76,12 @@ public class CacheController {
double lat = y;
double lon = x;
//Earths radius, sphere
double radius=6378137;
//offsets in meters
double offset = 100;
//Coordinate offsets in radians
double dLat = offset/radius;
double dLon = offset/(radius*Math.cos(Math.PI*lat/180));
double dLat = offset/EARTH_RADIUS;
double dLon = offset/(EARTH_RADIUS*Math.cos(Math.PI*lat/180));
//OffsetPosition, decimal degrees
yPlus = lat + dLat * 180/Math.PI;

View file

@ -64,7 +64,7 @@ public class ShareActivity
if (cacheFound == false) {
//Has to be called after apiCall.request()
cacheObj.cacheData.cacheCategory();
app.cacheData.cacheCategory();
Log.d(TAG, "Cache the categories found");
}
@ -205,11 +205,11 @@ public class ShareActivity
if (decimalCoords != null) {
Log.d(TAG, "Decimal coords of image: " + decimalCoords);
cacheObj.cacheData.setQtPoint(decLongitude, decLatitude);
app.cacheData.setQtPoint(decLongitude, decLatitude);
MwVolleyApi apiCall = new MwVolleyApi(this);
List displayCatList = cacheObj.cacheData.findCategory();
List displayCatList = app.cacheData.findCategory();
//if no categories found in cache, call MW API to match image coords with nearby Commons categories
if (displayCatList.size() == 0) {