Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-03 11:03:50 +02:00
commit b9f35bc682
10 changed files with 205 additions and 248 deletions

View file

@ -48,7 +48,6 @@
android:layout_marginRight="2dip"
android:button="@drawable/ic_btn_wocheckbox"
android:focusable="false"
android:clickable="false"
/>
</LinearLayout>

View file

@ -46,8 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dip"
android:focusable="false"
android:clickable="false"/>
android:focusable="false"/>
</LinearLayout>
</LinearLayout>

View file

@ -14,9 +14,6 @@ import net.osmand.ResultMatcher;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.util.MapUtils;
import org.apache.http.client.protocol.ClientContext;
import android.content.Context;
public class PoiFilter {
@ -173,9 +170,8 @@ public class PoiFilter {
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
return app.getResourceManager().searchAmenities(this,
topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, matcher);
topLatitude, leftLongitude, bottomLatitude, rightLongitude, matcher);
}
public List<Amenity> searchAgain(double lat, double lon) {

View file

@ -0,0 +1,54 @@
package net.osmand.plus;
import java.io.IOException;
import java.util.HashMap;
import net.osmand.Location;
import net.osmand.binary.RouteDataObject;
import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.router.RoutePlannerFrontEnd;
import net.osmand.router.RoutingConfiguration;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
import net.osmand.util.MapUtils;
public class SearchOnTheRouteHelper {
private OsmandApplication app;
private PoiFilter filter;
private Thread calculatingThread;
public SearchOnTheRouteHelper(OsmandApplication app) {
this.app = app;
}
public void searchOnTheRoute(RouteCalculationResult route) {
scheduleRouteSegmentFind(route);
}
private void scheduleRouteSegmentFind(final RouteCalculationResult route){
}
private static double getOrthogonalDistance(RouteDataObject r, Location loc){
double d = 1000;
if (r.getPointsLength() > 0) {
double pLt = MapUtils.get31LatitudeY(r.getPoint31YTile(0));
double pLn = MapUtils.get31LongitudeX(r.getPoint31XTile(0));
for (int i = 1; i < r.getPointsLength(); i++) {
double lt = MapUtils.get31LatitudeY(r.getPoint31YTile(i));
double ln = MapUtils.get31LongitudeX(r.getPoint31XTile(i));
double od = MapUtils.getOrthogonalDistance(loc.getLatitude(), loc.getLongitude(), pLt, pLn, lt, ln);
if (od < d) {
d = od;
}
pLt = lt;
pLn = ln;
}
}
return d;
}
}

View file

@ -21,16 +21,4 @@ public interface AmenityIndexRepository {
ResultMatcher<Amenity> matcher);
public void clearCache();
public boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom,
String filterId, List<Amenity> toFill, boolean fillFound);
public void evaluateCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom,
PoiFilter filter, ResultMatcher<Amenity> matcher);
public boolean hasChange();
public void clearChange();
}

View file

@ -2,7 +2,6 @@ package net.osmand.plus.resources;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -15,9 +14,7 @@ import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.LatLon;
import net.osmand.plus.PoiFilter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
@ -40,17 +37,6 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
}
}
@Override
public boolean hasChange() {
return false; //no change ever
}
@Override
public void clearChange() {
//nothing to do
}
@Override
public boolean checkContains(double latitude, double longitude) {
return index.containsPoiData(latitude, longitude);
@ -62,7 +48,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
}
public Map<AmenityType, List<String>> searchAmenityCategoriesByName(String query, Map<AmenityType, List<String>> map) {
public synchronized Map<AmenityType, List<String>> searchAmenityCategoriesByName(String query, Map<AmenityType, List<String>> map) {
try {
return index.searchPoiCategoriesByName(query, map);
} catch (IOException e) {
@ -72,7 +58,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
}
public List<Amenity> searchAmenitiesByName(int x, int y, int l, int t, int r, int b, String query, ResultMatcher<Amenity> resulMatcher) {
public synchronized List<Amenity> searchAmenitiesByName(int x, int y, int l, int t, int r, int b, String query, ResultMatcher<Amenity> resulMatcher) {
long now = System.currentTimeMillis();
List<Amenity> amenities = Collections.emptyList();
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(x, y, query, l, r, t, b,resulMatcher);
@ -95,7 +81,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
}
@Override
public List<Amenity> searchAmenities(int stop, int sleft, int sbottom, int sright, int zoom,
public synchronized List<Amenity> searchAmenities(int stop, int sleft, int sbottom, int sright, int zoom,
final PoiFilter filter, final List<Amenity> amenities, ResultMatcher<Amenity> matcher) {
long now = System.currentTimeMillis();
SearchPoiTypeFilter poiTypeFilter = new SearchPoiTypeFilter(){
@ -120,70 +106,4 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
return amenities;
}
// Work with cache (for map copied from AmenityIndexRepositoryOdb)
private String cFilterId;
protected List<Amenity> cachedObjects = new ArrayList<Amenity>();
protected double cTopLatitude;
protected double cBottomLatitude;
protected double cLeftLongitude;
protected double cRightLongitude;
protected int cZoom;
@Override
public synchronized boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
int zoom, String filterId, List<Amenity> toFill, boolean fillFound){
boolean inside = cTopLatitude >= topLatitude && cLeftLongitude <= leftLongitude && cRightLongitude >= rightLongitude
&& cBottomLatitude <= bottomLatitude && zoom == cZoom;
boolean noNeedToSearch = inside && Algorithms.objectEquals(filterId, cFilterId);
if((inside || fillFound) && toFill != null && Algorithms.objectEquals(filterId, cFilterId)){
for(Amenity a : cachedObjects){
LatLon location = a.getLocation();
if (location.getLatitude() <= topLatitude && location.getLongitude() >= leftLongitude && location.getLongitude() <= rightLongitude
&& location.getLatitude() >= bottomLatitude) {
toFill.add(a);
}
}
}
return noNeedToSearch;
}
@Override
public void clearCache() {
cachedObjects.clear();
cTopLatitude = 0;
cBottomLatitude = 0;
cRightLongitude = 0;
cLeftLongitude = 0;
cZoom = 0;
cFilterId = null;
}
@Override
public void evaluateCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom,
PoiFilter filter, ResultMatcher<Amenity> matcher) {
cTopLatitude = topLatitude ;
cBottomLatitude = bottomLatitude ;
cLeftLongitude = leftLongitude ;
cRightLongitude = rightLongitude ;
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>();
int sleft = MapUtils.get31TileNumberX(cLeftLongitude);
int sright = MapUtils.get31TileNumberX(cRightLongitude);
int sbottom = MapUtils.get31TileNumberY(cBottomLatitude);
int stop = MapUtils.get31TileNumberY(cTopLatitude);
searchAmenities(stop, sleft, sbottom, sright, zoom, filter, tempList, matcher);
synchronized (this) {
cachedObjects.clear();
cachedObjects.addAll(tempList);
}
}
}

View file

@ -8,16 +8,12 @@ import java.util.Stack;
import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher;
import net.osmand.data.Amenity;
import net.osmand.data.RotatedTileBox;
import net.osmand.data.TransportStop;
import net.osmand.map.ITileSource;
import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.plus.BusyIndicator;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.PoiFilter;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -37,7 +33,6 @@ public class AsyncLoadingThread extends Thread {
private Handler asyncLoadingTransport;
Stack<Object> requests = new Stack<Object>();
AmenityLoadRequest poiLoadRequest = null;
TransportLoadRequest transportLoadRequest = null;
@ -68,8 +63,6 @@ public class AsyncLoadingThread extends Thread {
progress = BusyIndicator.STATUS_ORANGE;
} else if (!requests.isEmpty()) {
progress = BusyIndicator.STATUS_BLACK;
} else if (poiLoadRequest != null && poiLoadRequest.isRunning()) {
progress = BusyIndicator.STATUS_BLACK;
} else if (transportLoadRequest != null && transportLoadRequest.isRunning()) {
progress = BusyIndicator.STATUS_BLACK;
}
@ -96,18 +89,6 @@ public class AsyncLoadingThread extends Thread {
if (req instanceof TileLoadDownloadRequest) {
TileLoadDownloadRequest r = (TileLoadDownloadRequest) req;
tileLoaded |= resourceManger.getRequestedImageTile(r) != null;
} else if (req instanceof AmenityLoadRequest) {
if (!amenityLoaded) {
if (poiLoadRequest == null || asyncLoadingPoi == null) {
startPoiLoadingThread();
poiLoadRequest = (AmenityLoadRequest) req;
asyncLoadingPoi.post(poiLoadRequest.prepareToRun());
} else if (poiLoadRequest.recalculateRequest((AmenityLoadRequest) req)) {
poiLoadRequest = (AmenityLoadRequest) req;
asyncLoadingPoi.post(poiLoadRequest.prepareToRun());
}
amenityLoaded = true;
}
} else if (req instanceof TransportLoadRequest) {
if (!transportLoaded) {
if (transportLoadRequest == null || asyncLoadingTransport == null) {
@ -155,10 +136,6 @@ public class AsyncLoadingThread extends Thread {
requests.push(req);
}
public void requestToLoadAmenities(AmenityLoadRequest req) {
requests.push(req);
}
public void requestToLoadMap(MapLoadRequest req) {
requests.push(req);
}
@ -240,72 +217,7 @@ public class AsyncLoadingThread extends Thread {
}
protected class AmenityLoadRequest extends MapObjectLoadRequest<Amenity> {
private final List<AmenityIndexRepository> res;
private final PoiFilter filter;
private final int zoom;
private String filterByName;
public AmenityLoadRequest(List<AmenityIndexRepository> repos, int zoom, PoiFilter filter, String nameFilter) {
super();
this.res = repos;
this.zoom = zoom;
this.filter = filter;
this.filterByName = nameFilter;
if(this.filterByName != null) {
this.filterByName = this.filterByName.toLowerCase().trim();
}
}
@Override
public boolean publish(Amenity object) {
if(filterByName == null || filterByName.length() == 0) {
return true;
} else {
String lower = OsmAndFormatter.getPoiStringWithoutType(object, resourceManger.getContext().getSettings().usingEnglishNames()).toLowerCase();
return lower.indexOf(filterByName) != -1;
}
}
public Runnable prepareToRun() {
final double ntopLatitude = topLatitude + (topLatitude - bottomLatitude) / 2;
final double nbottomLatitude = bottomLatitude - (topLatitude - bottomLatitude) / 2;
final double nleftLongitude = leftLongitude - (rightLongitude - leftLongitude) / 2;
final double nrightLongitude = rightLongitude + (rightLongitude - leftLongitude) / 2;
setBoundaries(ntopLatitude, nleftLongitude, nbottomLatitude, nrightLongitude);
return new Runnable() {
@Override
public void run() {
start();
try {
for (AmenityIndexRepository repository : res) {
repository.evaluateCachedAmenities(ntopLatitude, nleftLongitude, nbottomLatitude, nrightLongitude, zoom,
filter, AmenityLoadRequest.this);
}
} finally {
finish();
}
}
};
}
private boolean repoHasChange() {
for (AmenityIndexRepository r : res) {
if (r.hasChange()) {
r.clearChange();
return true;
}
}
return false;
}
public boolean recalculateRequest(AmenityLoadRequest req) {
if (this.zoom != req.zoom || !Algorithms.objectEquals(this.filter, req.filter) || req.repoHasChange()) {
return true;
}
return !isContains(req.topLatitude, req.leftLongitude, req.bottomLatitude, req.rightLongitude);
}
}
protected class TransportLoadRequest extends MapObjectLoadRequest<TransportStop> {
private final List<TransportIndexRepository> repos;

View file

@ -1,6 +1,8 @@
package net.osmand.plus.resources;
import gnu.trove.list.array.TIntArrayList;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -36,6 +38,7 @@ import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.OsmandRegions;
import net.osmand.plus.BusyIndicator;
import net.osmand.plus.NameFinderPoiFilter;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.PoiFilter;
@ -45,7 +48,6 @@ import net.osmand.plus.SearchByNameFilter;
import net.osmand.plus.Version;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.resources.AsyncLoadingThread.AmenityLoadRequest;
import net.osmand.plus.resources.AsyncLoadingThread.MapLoadRequest;
import net.osmand.plus.resources.AsyncLoadingThread.TileLoadDownloadRequest;
import net.osmand.plus.resources.AsyncLoadingThread.TransportLoadRequest;
@ -702,17 +704,57 @@ public class ResourceManager {
}
////////////////////////////////////////////// Working with amenities ////////////////////////////////////////////////
public List<Amenity> searchAmenities(PoiFilter filter,
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
double lat, double lon, ResultMatcher<Amenity> matcher) {
List<Amenity> amenities = new ArrayList<Amenity>();
for (AmenityIndexRepository index : amenityRepositories) {
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
index.searchAmenities(MapUtils.get31TileNumberY(topLatitude), MapUtils.get31TileNumberX(leftLongitude),
MapUtils.get31TileNumberY(bottomLatitude), MapUtils.get31TileNumberX(rightLongitude), -1, filter, amenities, matcher);
public boolean checkNameFilter(Amenity object, String filterByName) {
boolean publish = false;
if (filterByName == null || filterByName.length() == 0) {
publish = true;
} else {
String lower = OsmAndFormatter.getPoiStringWithoutType(object, context.getSettings().usingEnglishNames())
.toLowerCase();
publish = lower.indexOf(filterByName) != -1;
}
return publish;
}
public List<Amenity> searchAmenities(PoiFilter filter,
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
final List<Amenity> amenities = new ArrayList<Amenity>();
if(filter instanceof NameFinderPoiFilter || filter instanceof SearchByNameFilter){
List<Amenity> tempResults = filter instanceof NameFinderPoiFilter ?
((NameFinderPoiFilter) filter).getSearchedAmenities() :((SearchByNameFilter) filter).getSearchedAmenities() ;
for(Amenity a : tempResults){
LatLon l = a.getLocation();
if(l != null && l.getLatitude() <= topLatitude && l.getLatitude() >= bottomLatitude && l.getLongitude() >= leftLongitude && l.getLongitude() <= rightLongitude){
if(matcher.publish(a) ){
amenities.add(a);
}
}
}
} else {
final String filterByName = filter.getFilterByName();
for (AmenityIndexRepository index : amenityRepositories) {
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
index.searchAmenities(MapUtils.get31TileNumberY(topLatitude),
MapUtils.get31TileNumberX(leftLongitude), MapUtils.get31TileNumberY(bottomLatitude),
MapUtils.get31TileNumberX(rightLongitude), -1, filter, amenities,
new ResultMatcher<Amenity>() {
@Override
public boolean publish(Amenity object) {
if (checkNameFilter(object, filterByName)) {
return matcher.publish(object);
}
return false;
}
@Override
public boolean isCancelled() {
return matcher.isCancelled();
}
});
}
}
}
return amenities;
}
@ -772,31 +814,31 @@ public class ResourceManager {
return map;
}
public void searchAmenitiesAsync(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, PoiFilter filter, List<Amenity> toFill){
if(filter instanceof NameFinderPoiFilter || filter instanceof SearchByNameFilter){
List<Amenity> amenities = filter instanceof NameFinderPoiFilter ?
((NameFinderPoiFilter) filter).getSearchedAmenities() :((SearchByNameFilter) filter).getSearchedAmenities() ;
for(Amenity a : amenities){
LatLon l = a.getLocation();
if(l != null && l.getLatitude() <= topLatitude && l.getLatitude() >= bottomLatitude && l.getLongitude() >= leftLongitude && l.getLongitude() <= rightLongitude){
toFill.add(a);
}
}
} else {
String filterId = filter == null ? null : filter.getFilterId();
public void searchAmenitiesOnTheArea(TIntArrayList tiles16z, PoiFilter filter, ResultMatcher<Amenity> results) {
if (tiles16z.size() > 0) {
int z = 16;
int x = tiles16z.get(0) >> z;
int y = tiles16z.get(0) & ((1 << z) - 1);
List<AmenityIndexRepository> repos = new ArrayList<AmenityIndexRepository>();
double topLatitude = MapUtils.getLatitudeFromTile(z, y);
double bottomLatitude = MapUtils.getLatitudeFromTile(z, y + 1);
double leftLongitude = MapUtils.getLongitudeFromTile(z, x);
double rightLongitude = MapUtils.getLongitudeFromTile(z, x + 1);
for (int k = 1; k < tiles16z.size(); k++) {
topLatitude = Math.max(topLatitude, MapUtils.getLatitudeFromTile(z, y));
bottomLatitude = Math.min(bottomLatitude, MapUtils.getLatitudeFromTile(z, y + 1));
leftLongitude = Math.min(leftLongitude, MapUtils.getLongitudeFromTile(z, x));
rightLongitude = Math.max(rightLongitude, MapUtils.getLongitudeFromTile(z, x + 1));
}
for (AmenityIndexRepository index : amenityRepositories) {
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
if (!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filterId, toFill,
true)) {
repos.add(index);
}
}
}
if (!repos.isEmpty()) {
AmenityLoadRequest req = asyncLoadingThread.new AmenityLoadRequest(repos, zoom, filter, filter.getFilterByName());
req.setBoundaries(topLatitude, leftLongitude, bottomLatitude, rightLongitude);
asyncLoadingThread.requestToLoadAmenities(req);
for(AmenityIndexRepository r : repos) {
// r.searchAmenities(stop, sleft, sbottom, sright, zoom, filter, amenities, matcher)
}
}
}
}
@ -811,6 +853,7 @@ public class ResourceManager {
return addressMap.values();
}
////////////////////////////////////////////// Working with transport ////////////////////////////////////////////////
public List<TransportIndexRepository> searchTransportRepositories(double latitude, double longitude) {
List<TransportIndexRepository> repos = new ArrayList<TransportIndexRepository>();
@ -950,9 +993,6 @@ public class ResourceManager {
public void onLowMemory() {
log.info("On low memory : cleaning tiles - size = " + cacheOfImages.size()); //$NON-NLS-1$
clearTiles();
for(AmenityIndexRepository r : amenityRepositories){
r.clearCache();
}
for(RegionAddressRepository r : addressMap.values()){
r.clearCache();
}

View file

@ -18,6 +18,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.SearchOnTheRouteHelper;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
@ -76,6 +77,7 @@ public class RoutingHelper {
//private long wrongMovementDetected = 0;
private RouteCalculationProgressCallback progressRoute;
private SearchOnTheRouteHelper searchOnTheRouteHelper;
// private ProgressBar progress;
// private Handler progressHandler;
@ -87,9 +89,14 @@ public class RoutingHelper {
public RoutingHelper(OsmandApplication context, CommandPlayer player){
this.app = context;
settings = context.getSettings();
searchOnTheRouteHelper = new SearchOnTheRouteHelper(context);
voiceRouter = new VoiceRouter(this, settings, player);
}
public SearchOnTheRouteHelper getSearchOnTheRouteHelper() {
return searchOnTheRouteHelper;
}
public boolean isFollowingMode() {
return isFollowingMode;
}
@ -553,6 +560,8 @@ public class RoutingHelper {
}
}
searchOnTheRouteHelper.searchOnTheRoute(route);
app.runInUIThread(new Runnable() {
@Override
public void run() {

View file

@ -1,9 +1,11 @@
package net.osmand.plus.views;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
@ -43,14 +45,46 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
private Paint paintIcon;
private Paint point;
private OsmandMapTileView view;
private List<Amenity> objects = new ArrayList<Amenity>();
private final static int MAXIMUM_SHOW_AMENITIES = 5;
private ResourceManager resourceManager;
private PoiFilter filter;
private MapTextLayer mapTextLayer;
/// cache for displayed POI
// Work with cache (for map copied from AmenityIndexRepositoryOdb)
private MapLayerData<List<Amenity>> data;
public POIMapLayer(MapActivity activity) {
data = new OsmandMapLayer.MapLayerData<List<Amenity>>() {
{
ZOOM_THRESHOLD = 0;
}
@Override
public boolean isInterrupted() {
return super.isInterrupted();
}
@Override
protected List<Amenity> calculateResult(RotatedTileBox tileBox) {
QuadRect latLonBounds = tileBox.getLatLonBounds();
return resourceManager.searchAmenities(filter, latLonBounds.top, latLonBounds.left,
latLonBounds.bottom, latLonBounds.right, new ResultMatcher<Amenity>() {
@Override
public boolean publish(Amenity object) {
return true;
}
@Override
public boolean isCancelled() {
return isInterrupted();
}
});
}
};
}
public PoiFilter getFilter() {
@ -59,9 +93,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
public void setFilter(PoiFilter filter) {
this.filter = filter;
data.clearCache();
}
public void getAmenityFromPoint(RotatedTileBox tb, PointF point, List<? super Amenity> am) {
List<Amenity> objects = data.getResults();
if (objects != null) {
int ex = (int) point.x;
int ey = (int) point.y;
@ -127,6 +163,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
mapTextLayer = view.getLayerByClass(MapTextLayer.class);
}
public int getRadiusPoi(RotatedTileBox tb) {
int r = 0;
final float zoom = tb.getZoom() + tb.getZoomScale();
@ -146,15 +183,17 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
objects.clear();
List<Amenity> objects = Collections.emptyList();
if (tileBox.getZoom() >= startZoom) {
final QuadRect latLonBounds = tileBox.getLatLonBounds();
resourceManager.searchAmenitiesAsync(latLonBounds.top, latLonBounds.left, latLonBounds.bottom,
latLonBounds.right, tileBox.getZoom(), filter, objects);
data.queryNewData(tileBox);
objects = data.getResults();
if (objects != null) {
int r = getRadiusPoi(tileBox);
for (Amenity o : objects) {
int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation()
.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation()
.getLongitude());
canvas.drawCircle(x, y, r, pointAltUI);
canvas.drawCircle(x, y, r, point);
String id = null;
@ -174,6 +213,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
}
}
}
}
mapTextLayer.putData(this, objects);
}