Dummy categories working

This commit is contained in:
misaochan 2016-01-05 19:40:00 +13:00
parent e311753988
commit b0f8af7b37
2 changed files with 21 additions and 8 deletions

View file

@ -12,22 +12,23 @@ import java.util.List;
public class CacheController {
private Context context;
private double decLongitude;
private double decLatitude;
private double x;
private double y;
private QuadTree quadTree;
private List<String> categoryList;
private Point[] pointsFound;
public CacheController(Context context, double decLongitude, double decLatitude) {
this.context = context;
this.decLongitude = decLongitude;
this.decLatitude = decLatitude;
x = decLongitude;
y = decLatitude;
}
public void initQuadTree() {
quadTree = new QuadTree(-180, -90, +180, +90);
Log.d("Cache", "New QuadTree created");
Log.d("Cache", "X (longitude) value: " + decLongitude + ", Y (latitude) value: " + decLatitude);
Log.d("Cache", "X (longitude) value: " + x + ", Y (latitude) value: " + y);
}
@ -37,11 +38,21 @@ public class CacheController {
categoryList = new ArrayList<String>();
categoryList.add("UK");
categoryList.add("US");
quadTree.set(decLongitude, decLatitude, categoryList);
quadTree.set(x, y, categoryList);
}
public void findCategory() {
//TODO: Convert decLatitude and decLongitude to a range
quadTree.searchWithin(final double xmin, final double ymin, final double xmax, final double ymax);
//TODO: Convert decLatitude and decLongitude to a range with proper formula, for testing just use 10
pointsFound = quadTree.searchWithin(x-10, y-10, x+10, y+10);
Log.d("Cache", "Points found: " + pointsFound.toString());
double x;
Object cat = null;
//TODO: This does not truly iterate, just for testing. In future probably need to store results in Array
for (Point point: pointsFound) {
x = point.getX();
cat = point.getValue();
}
Log.d("Cache", "Categories found: " + cat.toString());
}
}

View file

@ -194,6 +194,8 @@ public class ShareActivity
CacheController cacheObj = new CacheController(this, decLongitude, decLatitude);
cacheObj.initQuadTree();
cacheObj.cacheCategory();
cacheObj.findCategory();
//TODO: If no categories found from cache in that area, call MW API
//asynchronous calls to MediaWiki Commons API to match image coords with nearby Commons categories