mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixed x and y, should be ints not string for quadtree
This commit is contained in:
parent
f12428814f
commit
651fd61189
3 changed files with 29 additions and 12 deletions
|
|
@ -9,15 +9,23 @@ import android.util.Log;
|
|||
public class CacheController {
|
||||
|
||||
private Context context;
|
||||
private String coords;
|
||||
private double decLongitude;
|
||||
private double decLatitude;
|
||||
private QuadTree quadTree;
|
||||
private String category = "test";
|
||||
|
||||
public CacheController(Context context, String coords) {
|
||||
public CacheController(Context context, double decLongitude, double decLatitude) {
|
||||
this.context = context;
|
||||
this.coords = coords;
|
||||
this.decLongitude = decLongitude;
|
||||
this.decLatitude = decLatitude;
|
||||
|
||||
}
|
||||
|
||||
public String getCoords() {
|
||||
Log.d("Cache", "Coords passed to cache: " + coords);
|
||||
return coords;
|
||||
|
||||
public void callQuadTree() {
|
||||
quadTree = new QuadTree(-180, -90, +180, +90);
|
||||
Log.d("Cache", "New QuadTree created");
|
||||
Log.d("Cache", "X (longitude) value: " + decLongitude + ", Y (latitude) value: " + decLatitude);
|
||||
quadTree.set(decLongitude, decLatitude, category);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.io.IOException;
|
|||
public class GPSExtractor {
|
||||
|
||||
private String filePath;
|
||||
private double decLatitude, decLongitude;
|
||||
|
||||
public GPSExtractor(String filePath){
|
||||
this.filePath = filePath;
|
||||
|
|
@ -56,10 +57,18 @@ public class GPSExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
public double getDecLatitude() {
|
||||
return decLatitude;
|
||||
}
|
||||
|
||||
public double getDecLongitude() {
|
||||
return decLongitude;
|
||||
}
|
||||
|
||||
//Converts format of coords into decimal coords as required by MediaWiki API
|
||||
private String getDecimalCoords(String latitude, String latitude_ref, String longitude, String longitude_ref) {
|
||||
|
||||
double decLatitude, decLongitude;
|
||||
|
||||
|
||||
if(latitude_ref.equals("N")){
|
||||
decLatitude = convertToDegree(latitude);
|
||||
|
|
|
|||
|
|
@ -185,16 +185,16 @@ public class ShareActivity
|
|||
GPSExtractor imageObj = new GPSExtractor(filePath);
|
||||
//decimalCoords for MediaWiki API, xyCoords for Quadtree
|
||||
String decimalCoords = imageObj.getCoords(false);
|
||||
String xyCoords = imageObj.getCoords(true);
|
||||
|
||||
double decLongitude = imageObj.getDecLongitude();
|
||||
double decLatitude = imageObj.getDecLatitude();
|
||||
|
||||
if (decimalCoords != null) {
|
||||
Log.d("Coords", "Decimal coords of image: " + decimalCoords);
|
||||
Log.d("Coords", "XY coords of image: " + xyCoords);
|
||||
|
||||
//TODO: Insert cache query here, only send API request if no cached categories
|
||||
CacheController cacheObj = new CacheController(this, xyCoords);
|
||||
cacheObj.getCoords();
|
||||
|
||||
CacheController cacheObj = new CacheController(this, decLongitude, decLatitude);
|
||||
cacheObj.callQuadTree();
|
||||
|
||||
//asynchronous calls to MediaWiki Commons API to match image coords with nearby Commons categories
|
||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue