mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Added constant, renamed cacheObj to app
This commit is contained in:
parent
881acda52d
commit
e62760ebc0
3 changed files with 6 additions and 9 deletions
|
|
@ -147,8 +147,6 @@ public class CommonsApplication extends Application {
|
||||||
return bitmapSize / 1024;
|
return bitmapSize / 1024;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//For caching area -> categories
|
//For caching area -> categories
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ public class CacheController {
|
||||||
private double xMinus, xPlus, yMinus, yPlus;
|
private double xMinus, xPlus, yMinus, yPlus;
|
||||||
|
|
||||||
private static final String TAG = CacheController.class.getName();
|
private static final String TAG = CacheController.class.getName();
|
||||||
|
private static final int EARTH_RADIUS = 6378137;
|
||||||
|
|
||||||
public CacheController() {
|
public CacheController() {
|
||||||
quadTree = new QuadTree(-180, -90, +180, +90);
|
quadTree = new QuadTree(-180, -90, +180, +90);
|
||||||
|
|
@ -75,14 +76,12 @@ public class CacheController {
|
||||||
double lat = y;
|
double lat = y;
|
||||||
double lon = x;
|
double lon = x;
|
||||||
|
|
||||||
//Earth’s radius, sphere
|
|
||||||
double radius=6378137;
|
|
||||||
//offsets in meters
|
//offsets in meters
|
||||||
double offset = 100;
|
double offset = 100;
|
||||||
|
|
||||||
//Coordinate offsets in radians
|
//Coordinate offsets in radians
|
||||||
double dLat = offset/radius;
|
double dLat = offset/EARTH_RADIUS;
|
||||||
double dLon = offset/(radius*Math.cos(Math.PI*lat/180));
|
double dLon = offset/(EARTH_RADIUS*Math.cos(Math.PI*lat/180));
|
||||||
|
|
||||||
//OffsetPosition, decimal degrees
|
//OffsetPosition, decimal degrees
|
||||||
yPlus = lat + dLat * 180/Math.PI;
|
yPlus = lat + dLat * 180/Math.PI;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class ShareActivity
|
||||||
|
|
||||||
if (cacheFound == false) {
|
if (cacheFound == false) {
|
||||||
//Has to be called after apiCall.request()
|
//Has to be called after apiCall.request()
|
||||||
cacheObj.cacheData.cacheCategory();
|
app.cacheData.cacheCategory();
|
||||||
Log.d(TAG, "Cache the categories found");
|
Log.d(TAG, "Cache the categories found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,11 +205,11 @@ public class ShareActivity
|
||||||
|
|
||||||
if (decimalCoords != null) {
|
if (decimalCoords != null) {
|
||||||
Log.d(TAG, "Decimal coords of image: " + decimalCoords);
|
Log.d(TAG, "Decimal coords of image: " + decimalCoords);
|
||||||
cacheObj.cacheData.setQtPoint(decLongitude, decLatitude);
|
app.cacheData.setQtPoint(decLongitude, decLatitude);
|
||||||
|
|
||||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
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 no categories found in cache, call MW API to match image coords with nearby Commons categories
|
||||||
if (displayCatList.size() == 0) {
|
if (displayCatList.size() == 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue