implement search amenities by type

git-svn-id: https://osmand.googlecode.com/svn/trunk@96 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-05-29 10:08:37 +00:00
parent 635625e813
commit 72bb0e9fd4
3 changed files with 8 additions and 6 deletions

View file

@ -37,8 +37,6 @@ public class ToDoConstants {
// 5. Call ResourceManager.close when it is needed
// 6. Understand concept of application where to save/restore global setting.
// (for example reset navigate to point, reset link map with location). It should be reset after user call exit.
// 7. Implement search amenities by type (!).
// Rewrite search activity in order to limit amenities not to all types.
// 8. Introduce activity search by location (unify with existing dialog)
// 9. When all features will be ready we can remove show location from context menu

View file

@ -38,9 +38,13 @@ public class AmenityIndexRepository {
private final String[] columns = IndexConstants.generateColumnNames(IndexPoiTable.values());
public List<Amenity> searchAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int limit, List<Amenity> amenities){
public List<Amenity> searchAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int limit, AmenityType type, List<Amenity> amenities){
long now = System.currentTimeMillis();
Cursor query = db.query(IndexPoiTable.getTable(), columns, "? < latitude AND latitude < ? AND ? < longitude AND longitude < ?",
String squery = "? < latitude AND latitude < ? AND ? < longitude AND longitude < ?";
if(type != null){
squery += " AND type = " + AmenityType.valueToString(type);
}
Cursor query = db.query(IndexPoiTable.getTable(), columns, squery,
new String[]{Double.toString(bottomLatitude),
Double.toString(topLatitude), Double.toString(leftLongitude), Double.toString(rightLongitude)}, null, null, null);
if(query.moveToFirst()){
@ -82,7 +86,7 @@ public class AmenityIndexRepository {
cBottomLatitude = bottomLatitude - (topLatitude -bottomLatitude);
cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude);
cRightLongitude = rightLongitude + (rightLongitude - leftLongitude);
searchAmenities(cTopLatitude, cLeftLongitude, cBottomLatitude, cRightLongitude, -1, cachedAmenities);
searchAmenities(cTopLatitude, cLeftLongitude, cBottomLatitude, cRightLongitude, -1, null, cachedAmenities);
checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, toFill);
}

View file

@ -187,7 +187,7 @@ public class ResourceManager {
for(AmenityIndexRepository index : amenityRepositories){
if(index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)){
if(!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, amenities)){
index.searchAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, limit, amenities);
index.searchAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, limit, null, amenities);
}
}
}