Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-11-01 10:47:15 +01:00
commit eb6cdb77de
5 changed files with 35 additions and 68 deletions

View file

@ -83,10 +83,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (tileBox.getZoom() >= startZoom) {
float iconSize = audio.getWidth() * 3 / 2.5f;
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
bounds.inset(-bounds.width()/4, -bounds.height()/4);
QuadTree<QuadRect> boundIntersections = new QuadTree<>(bounds, 4, 0.6f);
List<QuadRect> result = new ArrayList<>();
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
DataTileManager<Recording> recs = plugin.getRecordings();
final QuadRect latlon = tileBox.getLatLonBounds();
@ -96,21 +93,9 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
boolean intersects = false;
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
for (QuadRect r : result) {
if (QuadRect.intersects(r, visibleRect)) {
intersects = true;
break;
}
}
if (intersects) {
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
} else {
boundIntersections.insert(visibleRect,
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
fullObjects.add(o);
}
}

View file

@ -91,10 +91,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
if (tileBox.getZoom() >= startZoom) {
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
tileBox.getDensity()).getIntrinsicWidth() * 3 / 2.5f;
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
bounds.inset(-bounds.width()/4, -bounds.height()/4);
QuadTree<QuadRect> boundIntersections = new QuadTree<>(bounds, 4, 0.6f);
List<QuadRect> result = new ArrayList<>();
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
// request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds();
List<LocationPoint> fullObjects = new ArrayList<>();
@ -102,21 +100,9 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
boolean intersects = false;
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
for (QuadRect r : result) {
if (QuadRect.intersects(r, visibleRect)) {
intersects = true;
break;
}
}
if (intersects) {
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
} else {
boundIntersections.insert(visibleRect,
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
fullObjects.add(o);
}
}

View file

@ -12,6 +12,7 @@ import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.support.annotation.NonNull;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
@ -277,10 +278,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
if (tileBox.getZoom() >= startZoom) {
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
tileBox.getDensity()).getIntrinsicWidth() * 3 / 2.5f;
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
bounds.inset(-bounds.width()/4, -bounds.height()/4);
QuadTree<QuadRect> boundIntersections = new QuadTree<>(bounds, 4, 0.6f);
List<QuadRect> result = new ArrayList<>();
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
// request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds();
for (SelectedGpxFile g : selectedGPXFiles) {
@ -294,21 +293,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
boolean intersects = false;
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
for (QuadRect r : result) {
if (QuadRect.intersects(r, visibleRect)) {
intersects = true;
break;
}
}
if (intersects) {
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
} else {
boundIntersections.insert(visibleRect,
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
fullObjects.add(o);
}
}

View file

@ -2,10 +2,12 @@ package net.osmand.plus.views;
import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.util.MapAlgorithms;
@ -13,6 +15,7 @@ import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.view.MotionEvent;
public abstract class OsmandMapLayer {
@ -158,6 +161,27 @@ public abstract class OsmandMapLayer {
return cnt;
}
@NonNull
public QuadTree<QuadRect> initBoundIntersections(RotatedTileBox tileBox) {
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
bounds.inset(-bounds.width()/4, -bounds.height()/4);
return new QuadTree<>(bounds, 4, 0.6f);
}
public boolean intersects(QuadTree<QuadRect> boundIntersections, float x, float y, float width, float height) {
List<QuadRect> result = new ArrayList<>();
QuadRect visibleRect = calculateRect(x, y, width, height);
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
for (QuadRect r : result) {
if (QuadRect.intersects(r, visibleRect)) {
return true;
}
}
boundIntersections.insert(visibleRect,
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
return false;
}
public QuadRect calculateRect(float x, float y, float width, float height) {
QuadRect rf;
double left = x - width / 2.0d;

View file

@ -238,10 +238,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
objects = data.getResults();
if (objects != null) {
float iconSize = poiBackground.getWidth() * 3 / 2;
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
bounds.inset(-bounds.width()/4, -bounds.height()/4);
QuadTree<QuadRect> boundIntersections = new QuadTree<>(bounds, 4, 0.6f);
List<QuadRect> result = new ArrayList<>();
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
for (Amenity o : objects) {
float x = tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation()
@ -249,21 +246,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
float y = tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation()
.getLongitude());
boolean intersects = false;
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
for (QuadRect r : result) {
if (QuadRect.intersects(r, visibleRect)) {
intersects = true;
break;
}
}
if (intersects) {
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(poiBackgroundSmall, x - poiBackgroundSmall.getWidth() / 2, y - poiBackgroundSmall.getHeight() / 2, paintIconBackground);
} else {
boundIntersections.insert(visibleRect,
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
fullObjects.add(o);
}
}