Fixed x and y, should be ints not string for quadtree

This commit is contained in:
misaochan 2016-01-05 19:10:44 +13:00
parent f12428814f
commit 651fd61189
3 changed files with 29 additions and 12 deletions

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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);