fixing some issues with filter

git-svn-id: https://osmand.googlecode.com/svn/trunk@156 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-12 12:27:50 +00:00
parent 748dd85321
commit 3096a83555
13 changed files with 197 additions and 110 deletions

View file

@ -27,12 +27,12 @@ public class ToDoConstants {
// 31. Translation.
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
// ( 1) predefined filters, 2) choose subtype's, 3) filter by name, 4) opening hours (filter))
// [TODO database support]
// 41. POI layer over map (shows poi by selected filter)
// 41. POI layer over map (shows poi by selected filter) [TODO]
// 8. Enable change POI directly on map (requires OSM login)
// 33. Build transport locations. Create transport index (transport-stops) (investigate)
// 39. Support old-versionned resources (1) odb indexes, 2) favourites table, 3) atomic settings (?))
// 38. Add button in search "navigate to".
// 33. Build transport locations. Create transport index (transport-stops) (investigate) [TODO]
// 39. Support old-versionned resources (1) odb indexes, 2) favourites table, 3) atomic settings (?)) [TODO]
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
// 36. Postcode search
@ -47,7 +47,6 @@ public class ToDoConstants {
// 20. Implement save track/route to gpx (?)
// BUGS Android
// 5. Improvement : Implement caching files existing on FS, implement specific method in RM
// Introducing cache of file names that are on disk (creating new File() consumes a lot of memory)
@ -64,6 +63,7 @@ public class ToDoConstants {
// DONE ANDROID :
// 38. Add button in search "navigate to"
// 16. Support open street bugs api (supports viewing, deleting).
// 13. Save point as favorite & introduce favorite points dialog
// 29. Show opened/closed amenities (in search poi).

View file

@ -52,6 +52,8 @@
<TableRow android:id="@+id/TableRow" android:layout_marginLeft = "5dp" >
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_span="3" android:gravity="right|bottom" android:layout_marginRight = "5dp" android:layout_marginTop = "10dp">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/NavigateTo" android:text="@string/navigate_to">
</Button>
<Button android:text="Show on map" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ShowOnMap">
</Button>

View file

@ -3,9 +3,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_gravity="right" android:text="@string/search_POI_level_btn" android:id="@+id/SearchPOILevelButton" android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:text="@string/search_POI_level_btn" android:id="@+id/SearchPOILevelButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"></Button>
<TextView android:layout_width="wrap_content" android:text="" android:id="@+id/SearchAreaText" android:layout_height="wrap_content"/>
</LinearLayout>
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent"></ListView>
</LinearLayout>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="navigate_to">Navigate to</string>
<string name="update_tile">Update map</string>
<string name="reload_tile">Reload tile</string>
<string name="user_name_descr">Input user name to communicate osm</string>

View file

@ -34,6 +34,7 @@ public class AmenityIndexRepository {
private double cBottomLatitude;
private double cLeftLongitude;
private double cRightLongitude;
private int cZoom;
private String cFilterId;
@ -86,15 +87,16 @@ public class AmenityIndexRepository {
cRightLongitude = 0;
cLeftLongitude = 0;
cFilterId = null;
cZoom = 0;
}
public void evaluateCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int limit, PoiFilter filter, List<Amenity> toFill){
cachedAmenities.clear();
public void evaluateCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, int limit, PoiFilter filter, List<Amenity> toFill){
cTopLatitude = topLatitude + (topLatitude -bottomLatitude);
cBottomLatitude = bottomLatitude - (topLatitude -bottomLatitude);
cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude);
cRightLongitude = rightLongitude + (rightLongitude - leftLongitude);
cFilterId = filter == null? null :filter.getFilterId();
cZoom = zoom;
// first of all put all entities in temp list in order to not freeze other read threads
ArrayList<Amenity> tempList = new ArrayList<Amenity>();
searchAmenities(cTopLatitude, cLeftLongitude, cBottomLatitude, cRightLongitude, limit, filter, tempList);
@ -103,15 +105,15 @@ public class AmenityIndexRepository {
cachedAmenities.addAll(tempList);
}
checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, filter.getFilterId(), toFill);
checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, cZoom, filter.getFilterId(), toFill);
}
public synchronized boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, String filterId, List<Amenity> toFill, boolean fillFound){
public synchronized boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, String filterId, List<Amenity> toFill, boolean fillFound){
if (db == null) {
return true;
}
boolean inside = cTopLatitude >= topLatitude && cLeftLongitude <= leftLongitude && cRightLongitude >= rightLongitude
&& cBottomLatitude <= bottomLatitude;
&& cBottomLatitude <= bottomLatitude && zoom == cZoom;
if((inside || fillFound) && toFill != null && Algoritms.objectEquals(filterId, cFilterId)){
for(Amenity a : cachedAmenities){
LatLon location = a.getLocation();
@ -123,8 +125,8 @@ public class AmenityIndexRepository {
}
return inside;
}
public boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, String filterId, List<Amenity> toFill){
return checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, filterId, toFill, false);
public boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, String filterId, List<Amenity> toFill){
return checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filterId, toFill, false);
}
public void initialize(final IProgress progress, File file) {

View file

@ -22,7 +22,7 @@ public class PoiFilter {
private String name;
private final boolean isStandardFilter;
private final static int finalZoom = 8;
private final static int finalZoom = 6;
private final static int initialZoom = 13;
private final static int maxCount = 200;
private int zoom = initialZoom;
@ -67,8 +67,8 @@ public class PoiFilter {
}
public String getSearchArea(){
if(zoom <= 15){
int d = (int) (1.5 * (1 << (zoom - 15)));
if(zoom <= 14){
int d = (int) (1 * (1 << (14 - zoom)));
return " < " + d + " km";
} else {
return " < 500 m";
@ -78,7 +78,7 @@ public class PoiFilter {
public List<Amenity> initializeNewSearch(double lat, double lon, int firstTimeLimit){
zoom = initialZoom;
if(areAllTypesAccepted()){
zoom += 2;
zoom += 1;
}
List<Amenity> amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxCount);
MapUtils.sortListOfMapObject(amenityList, lat, lon);

View file

@ -42,15 +42,55 @@ public class PoiFiltersHelper {
list.add("car_wash");
list.add("car_repair");
types.put(AmenityType.TRANSPORTATION, list);
list = new ArrayList<String>();
list.add("car");
list.add("car_repair");
types.put(AmenityType.SHOP, list);
filters.add(new PoiFilter("Car aid", null, types));
types.clear();
types.put(AmenityType.HISTORIC, null);
types.put(AmenityType.TOURISM, null);
list = new ArrayList<String>();
list.add("internet_access");
list.add("bench");
list.add("embassy");
list.add("emergency_phone");
list.add("marketplace");
list.add("post_office");
list.add("recycling");
list.add("telephone");
list.add("toilets");
list.add("waste_basket");
list.add("waste_disposal");
types.put(AmenityType.OTHER, list);
filters.add(new PoiFilter("For tourists", null, types));
types.clear();
list = new ArrayList<String>();
list.add("fuel");
types.put(AmenityType.TRANSPORTATION, list);
filters.add(new PoiFilter("Fuel", null, types));
types.clear();
list = new ArrayList<String>();
list.add("alcohol");
list.add("bakery");
list.add("beverages");
list.add("butcher");
list.add("convenience");
list.add("department_store");
list.add("convenience");
list.add("farm");
list.add("general");
list.add("ice_cream");
list.add("kiosk");
list.add("supermarket");
list.add("variety_store");
types.put(AmenityType.SHOP, list);
filters.add(new PoiFilter("Food shop", null, types));
types.clear();
return filters;
}

View file

@ -207,16 +207,16 @@ public class ResourceManager {
// //////////////////////////////////////////// Working with amenities ////////////////////////////////////////////////
public List<Amenity> searchAmenities(PoiFilter filter, double latitude, double longitude, int zoom, int limit) {
double tileNumberX = Math.floor(MapUtils.getTileNumberX(zoom, longitude));
double tileNumberY = Math.floor(MapUtils.getTileNumberY(zoom, latitude));
double topLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY);
double bottomLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY + 1);
double leftLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX);
double rightLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX + 1);
double tileNumberX = MapUtils.getTileNumberX(zoom, longitude);
double tileNumberY = MapUtils.getTileNumberY(zoom, latitude);
double topLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY - 0.5);
double bottomLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY + 0.5);
double leftLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX - 0.5);
double rightLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX + 0.5);
List<Amenity> amenities = new ArrayList<Amenity>();
for (AmenityIndexRepository index : amenityRepositories) {
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
if (!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, filter.getFilterId(), amenities)) {
if (!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filter.getFilterId(), amenities)) {
index.searchAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, limit, filter, amenities);
}
}
@ -225,13 +225,13 @@ public class ResourceManager {
return amenities;
}
public void searchAmenitiesAsync(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, PoiFilter filter, List<Amenity> toFill){
public void searchAmenitiesAsync(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, PoiFilter filter, List<Amenity> toFill){
String filterId = filter == null ? null : filter.getFilterId();
for(AmenityIndexRepository index : amenityRepositories){
if(index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)){
if(!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, filterId, toFill, true)){
if(!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filterId, toFill, true)){
asyncLoadingTiles.requestToLoadAmenities(
new AmenityLoadRequest(index, topLatitude, leftLongitude, bottomLatitude, rightLongitude, filter));
new AmenityLoadRequest(index, topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filter));
}
}
}
@ -318,15 +318,17 @@ public class ResourceManager {
public final double leftLongitude;
public final double rightLongitude;
public final PoiFilter filter;
public final int zoom;
public AmenityLoadRequest(AmenityIndexRepository repository, double topLatitude, double leftLongitude,
double bottomLatitude, double rightLongitude, PoiFilter filter) {
double bottomLatitude, double rightLongitude, int zoom, PoiFilter filter) {
super();
this.bottomLatitude = bottomLatitude;
this.leftLongitude = leftLongitude;
this.repository = repository;
this.rightLongitude = rightLongitude;
this.topLatitude = topLatitude;
this.zoom = zoom;
this.filter = filter;
}
@ -359,7 +361,7 @@ public class ResourceManager {
if(!amenityLoaded){
AmenityLoadRequest r = (AmenityLoadRequest) req;
r.repository.evaluateCachedAmenities(r.topLatitude, r.leftLongitude,
r.bottomLatitude, r.rightLongitude, POIMapLayer.LIMIT_POI, r.filter, null);
r.bottomLatitude, r.rightLongitude, r.zoom, POIMapLayer.LIMIT_POI, r.filter, null);
amenityLoaded = true;
}
}

View file

@ -12,7 +12,6 @@ import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@ -42,8 +41,10 @@ import com.osmand.osm.MapUtils;
*/
public class FavouritesActivity extends ListActivity {
public static final int DELETE_ITEM = 0;
public static final int EDIT_ITEM = 1;
public static final int NAVIGATE_TO = 0;
public static final int DELETE_ITEM = 1;
public static final int EDIT_ITEM = 2;
private List<FavouritePoint> favouritesList;
private FavouritesDbHelper helper;
@ -67,28 +68,31 @@ public class FavouritesActivity extends ListActivity {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.setHeaderTitle("Context menu");
menu.add(0, EDIT_ITEM, 0, "Edit favourite");
menu.add(0, DELETE_ITEM, 1, "Delete favourite");
menu.add(0, NAVIGATE_TO, 0, "Navigate to");
menu.add(0, EDIT_ITEM, 1, "Edit favourite");
menu.add(0, DELETE_ITEM, 2, "Delete favourite");
}
});
}
public void onListItemClick(ListView parent, View v, int position, long id) {
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
if (prefs != null) {
FavouritePoint point = favouritesList.get(position);
OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
}
FavouritePoint point = favouritesList.get(position);
OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
}
@Override
public boolean onContextItemSelected(MenuItem aItem) {
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
final FavouritePoint point = (FavouritePoint) favouritesList.get(menuInfo.position);
if(aItem.getItemId() == EDIT_ITEM){
if(aItem.getItemId() == NAVIGATE_TO){
OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude());
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
} else if(aItem.getItemId() == EDIT_ITEM){
Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Input new name of favourite point");
final EditText editText = new EditText(this);

View file

@ -50,7 +50,7 @@ public class NavigatePointActivity extends Activity {
setContentView(R.layout.navigate_point);
setTitle("Navigate to point");
initUI(loc.getLatitude(), loc.getLongitude());
((Button) findViewById(R.id.Cancel)).setVisibility(View.INVISIBLE);
((Button) findViewById(R.id.Cancel)).setText(getString(R.string.navigate_to));
}
@Override
@ -101,31 +101,42 @@ public class NavigatePointActivity extends Activity {
((Button) findViewById(R.id.Cancel)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
close();
if(dlg == null){
showOnMap(true);
} else {
close();
}
}
});
((Button) findViewById(R.id.ShowOnMap)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
// TODO there is a bug in that convert if min = 59.23 or sec = 59.32 or deg=179.3
double lat = Location.convert(((TextView) findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
// in case when it is dialog
if(activity != null) {
activity.setMapLocation(lat, lon);
} else {
OsmandSettings.setMapLocationToShow(NavigatePointActivity.this, lat, lon);
}
close();
} catch (RuntimeException e) {
((TextView) findViewById(R.id.ValidateTextView)).setText("Locations are invalid");
Log.w(LogUtil.TAG, "Convertion failed", e);
}
showOnMap(false);
}
});
}
public void showOnMap(boolean navigate){
try {
// TODO there is a bug in android implementation : doesn't convert if min = 59.23 or sec = 59.32 or deg=179.3
double lat = Location.convert(((TextView) findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
// in case when it is dialog
if(activity != null) {
activity.setMapLocation(lat, lon);
} else {
OsmandSettings.setMapLocationToShow(this, lat, lon);
}
if(navigate){
OsmandSettings.setPointToNavigate(this, lat, lon);
}
close();
} catch (RuntimeException e) {
((TextView) findViewById(R.id.ValidateTextView)).setText("Locations are invalid");
Log.w(LogUtil.TAG, "Convertion failed", e);
}
}
// THIS code is copied from Location.convert() in order to change locale
public static final int FORMAT_DEGREES = 0;

View file

@ -31,6 +31,7 @@ public class SearchAddressActivity extends Activity {
private Button cityButton;
private Button countryButton;
private Button buildingButton;
private Button navigateTo;
private RegionAddressRepository region = null;
private City city = null;
@ -39,6 +40,7 @@ public class SearchAddressActivity extends Activity {
private Street street2 = null;
private boolean radioBuilding = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -46,6 +48,7 @@ public class SearchAddressActivity extends Activity {
setContentView(R.layout.search_address);
showOnMap = (Button) findViewById(R.id.ShowOnMap);
navigateTo = (Button) findViewById(R.id.NavigateTo);
streetButton = (Button) findViewById(R.id.StreetButton);
cityButton = (Button) findViewById(R.id.CityButton);
countryButton = (Button) findViewById(R.id.CountryButton);
@ -84,47 +87,16 @@ public class SearchAddressActivity extends Activity {
}
}
});
navigateTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showOnMap(true);
}
});
showOnMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon l = null;
int zoom = 12;
if (street2 != null && street != null) {
region.preloadWayNodes(street2);
region.preloadWayNodes(street);
Node inters = null;
for(Way w : street2.getWayNodes()){
for(Way w2 : street.getWayNodes()){
for(Node n : w.getNodes()){
for(Node n2 : w2.getNodes()){
if(n.getId() == n2.getId()){
inters = n;
break;
}
}
}
}
}
if(inters != null){
l = inters.getLatLon();
zoom = 16;
}
} else if (building != null) {
l = building.getLocation();
zoom = 16;
} else if (street != null) {
l = street.getLocation();
zoom = 14;
} else if (city != null) {
l = city.getLocation();
zoom = 12;
}
if (l != null) {
OsmandSettings.setMapLocationToShow(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
OsmandSettings.setLastKnownMapZoom(SearchAddressActivity.this, zoom);
startActivity(new Intent(SearchAddressActivity.this, MapActivity.class));
}
showOnMap(false);
}
});
findViewById(R.id.ResetBuilding).setOnClickListener(new View.OnClickListener(){
@ -180,6 +152,50 @@ public class SearchAddressActivity extends Activity {
});
}
public void showOnMap(boolean navigateTo){
LatLon l = null;
int zoom = 12;
if (street2 != null && street != null) {
region.preloadWayNodes(street2);
region.preloadWayNodes(street);
Node inters = null;
for(Way w : street2.getWayNodes()){
for(Way w2 : street.getWayNodes()){
for(Node n : w.getNodes()){
for(Node n2 : w2.getNodes()){
if(n.getId() == n2.getId()){
inters = n;
break;
}
}
}
}
}
if(inters != null){
l = inters.getLatLon();
zoom = 16;
}
} else if (building != null) {
l = building.getLocation();
zoom = 16;
} else if (street != null) {
l = street.getLocation();
zoom = 14;
} else if (city != null) {
l = city.getLocation();
zoom = 12;
}
if (l != null) {
if(navigateTo){
OsmandSettings.setPointToNavigate(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
}
OsmandSettings.setMapLocationToShow(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
OsmandSettings.setLastKnownMapZoom(SearchAddressActivity.this, zoom);
startActivity(new Intent(SearchAddressActivity.this, MapActivity.class));
}
}
protected void updateBuildingSection(){
if(radioBuilding){
((TextView)findViewById(R.id.BuildingText)).setText("Building");

View file

@ -36,23 +36,26 @@ import com.osmand.osm.MapUtils;
*/
public class SearchPOIActivity extends ListActivity {
public static final String AMENITY_FILTER = "amenity_filter";
public static final String AMENITY_FILTER = "com.osmand.amenity_filter";
private Button searchPOILevel;
private PoiFilter filter;
private AmenityAdapter amenityAdapter;
private LatLon lastKnownMapLocation;
private TextView searchArea;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.searchpoi);
searchPOILevel = (Button) findViewById(R.id.SearchPOILevelButton);
searchArea = (TextView) findViewById(R.id.SearchAreaText);
searchPOILevel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
amenityAdapter.setNewModel(filter.searchFurther(lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
searchArea.setText(filter.getSearchArea());
searchPOILevel.setEnabled(filter.isSearchFurtherAvailable());
}
@ -60,13 +63,15 @@ public class SearchPOIActivity extends ListActivity {
Bundle bundle = this.getIntent().getExtras();
String filterId = bundle.getString(AMENITY_FILTER);
if (filterId != null) {
lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(this);
filter = PoiFiltersHelper.getFilterById(this, filterId);
amenityAdapter = new AmenityAdapter(filter.initializeNewSearch(lastKnownMapLocation.getLatitude(),
lastKnownMapLocation.getLongitude(), 40));
lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(this);
filter = PoiFiltersHelper.getFilterById(this, filterId);
if (filter != null) {
amenityAdapter = new AmenityAdapter(filter.initializeNewSearch(lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude(), 40));
setListAdapter(amenityAdapter);
searchArea.setText(filter.getSearchArea());
}
// ListActivity has a ListView, which you can get with:
ListView lv = getListView();
@ -74,7 +79,7 @@ public class SearchPOIActivity extends ListActivity {
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
Amenity amenity = ((AmenityAdapter)getListAdapter()).getItem(pos);
Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(pos);
String format = amenity.getSimpleFormat(OsmandSettings.usingEnglishNames(v.getContext()));
if (amenity.getOpeningHours() != null) {
format += "\nOpening hours : " + amenity.getOpeningHours();
@ -85,6 +90,8 @@ public class SearchPOIActivity extends ListActivity {
});
}
public void onListItemClick(ListView parent, View v, int position, long id) {
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
if (prefs != null) {

View file

@ -20,7 +20,7 @@ import com.osmand.osm.MapUtils;
public class POIMapLayer implements OsmandMapLayer {
// it is very slow to use with 15 level
private static final int startZoom = 10;
public static final int LIMIT_POI = 100;
public static final int LIMIT_POI = 200;
private Paint pointAltUI;
@ -117,7 +117,7 @@ public class POIMapLayer implements OsmandMapLayer {
double rightLongitude = MapUtils.getLongitudeFromTile(view.getZoom(), tileRect.right);
objects.clear();
resourceManager.searchAmenitiesAsync(topLatitude, leftLongitude, bottomLatitude, rightLongitude, filter, objects);
resourceManager.searchAmenitiesAsync(topLatitude, leftLongitude, bottomLatitude, rightLongitude, view.getZoom(), filter, objects);
for (Amenity o : objects) {
int x = view.getMapXForPoint(o.getLocation().getLongitude());
int y = view.getMapYForPoint(o.getLocation().getLatitude());