Change click radius for waypoints, markers and favorites; extract common code to superclass
This commit is contained in:
parent
a59372e210
commit
49981b8358
5 changed files with 22 additions and 37 deletions
|
@ -75,7 +75,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
}
|
||||
|
||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||
return (Math.abs(objx - ex) <= radius * 2 && Math.abs(objy - ey) <= radius * 2) ;
|
||||
return (Math.abs(objx - ex) <= radius * 1.5 && Math.abs(objy - ey) <= radius * 1.5) ;
|
||||
// return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
|
||||
//return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
}
|
||||
|
||||
public void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List<? super FavouritePoint> res) {
|
||||
int r = (int) (15 * tb.getDensity());
|
||||
int r = getDefaultRadiusPoi(tb);
|
||||
int ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
for (FavouritePoint n : getPoints()) {
|
||||
|
|
|
@ -533,12 +533,12 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
|
||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||
return (Math.abs(objx - ex) <= radius * 2 && Math.abs(objy - ey) <= radius * 2);
|
||||
return (Math.abs(objx - ex) <= radius * 1.5 && Math.abs(objy - ey) <= radius * 1.5);
|
||||
// return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
|
||||
}
|
||||
|
||||
public void getWptFromPoint(RotatedTileBox tb, PointF point, List<? super WptPt> res) {
|
||||
int r = (int) (15 * tb.getDensity());
|
||||
int r = getDefaultRadiusPoi(tb);
|
||||
int ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
for (SelectedGpxFile g : selectedGpxHelper.getSelectedGPXFiles()) {
|
||||
|
|
|
@ -519,7 +519,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
|
||||
OsmandApplication app = map.getMyApplication();
|
||||
int r = getRadiusPoi(tileBox);
|
||||
int r = getDefaultRadiusPoi(tileBox);
|
||||
boolean selectMarkerOnSingleTap = app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get();
|
||||
|
||||
for (MapMarker marker : app.getMapMarkersHelper().getMapMarkers()) {
|
||||
|
@ -563,22 +563,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
|
||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius && (objy - ey) <= 2.5 * radius;
|
||||
}
|
||||
|
||||
public int getRadiusPoi(RotatedTileBox tb) {
|
||||
int r;
|
||||
final double zoom = tb.getZoom();
|
||||
if (zoom <= 15) {
|
||||
r = 10;
|
||||
} else if (zoom <= 16) {
|
||||
r = 14;
|
||||
} else if (zoom <= 17) {
|
||||
r = 16;
|
||||
} else {
|
||||
r = 18;
|
||||
}
|
||||
return (int) (r * tb.getDensity());
|
||||
return Math.abs(objx - ex) <= radius * 1.5 && (ey - objy) <= radius * 1.5 && (objy - ey) <= 2.5 * radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -261,6 +261,21 @@ public abstract class OsmandMapLayer {
|
|||
return res;
|
||||
}
|
||||
|
||||
public int getDefaultRadiusPoi(RotatedTileBox tb) {
|
||||
int r;
|
||||
final double zoom = tb.getZoom();
|
||||
if (zoom <= 15) {
|
||||
r = 10;
|
||||
} else if (zoom <= 16) {
|
||||
r = 14;
|
||||
} else if (zoom <= 17) {
|
||||
r = 16;
|
||||
} else {
|
||||
r = 18;
|
||||
}
|
||||
return (int) (r * tb.getDensity());
|
||||
}
|
||||
|
||||
public abstract class MapLayerData<T> {
|
||||
public int ZOOM_THRESHOLD = 1;
|
||||
public RotatedTileBox queriedBox;
|
||||
|
|
|
@ -188,7 +188,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements
|
|||
if (tileBox.getZoom() >= 3) {
|
||||
TargetPointsHelper tg = map.getMyApplication().getTargetPointsHelper();
|
||||
List<TargetPoint> intermediatePoints = tg.getAllPoints();
|
||||
int r = getRadiusPoi(tileBox);
|
||||
int r = getDefaultRadiusPoi(tileBox);
|
||||
for (int i = 0; i < intermediatePoints.size(); i++) {
|
||||
TargetPoint tp = intermediatePoints.get(i);
|
||||
LatLon latLon = tp.point;
|
||||
|
@ -209,21 +209,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements
|
|||
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius && (objy - ey) <= 2.5 * radius;
|
||||
}
|
||||
|
||||
public int getRadiusPoi(RotatedTileBox tb) {
|
||||
int r;
|
||||
final double zoom = tb.getZoom();
|
||||
if (zoom <= 15) {
|
||||
r = 10;
|
||||
} else if (zoom <= 16) {
|
||||
r = 14;
|
||||
} else if (zoom <= 17) {
|
||||
r = 16;
|
||||
} else {
|
||||
r = 18;
|
||||
}
|
||||
return (int) (r * tb.getDensity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLon getObjectLocation(Object o) {
|
||||
if (o instanceof TargetPoint) {
|
||||
|
|
Loading…
Reference in a new issue