Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9869e2955b
4 changed files with 159 additions and 10 deletions
|
@ -28,4 +28,5 @@
|
||||||
<string name="hint_value">Value</string>
|
<string name="hint_value">Value</string>
|
||||||
<string name="clear_updates_proposition_message">"You can remove downloaded updates and free "</string>
|
<string name="clear_updates_proposition_message">"You can remove downloaded updates and free "</string>
|
||||||
<string name="add_time_span">Add time span</string>
|
<string name="add_time_span">Add time span</string>
|
||||||
|
<string name="road_blocked">Road blocked</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -21,6 +22,7 @@ import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController;
|
||||||
|
import net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
||||||
|
@ -105,6 +107,9 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
} else if (pointDescription.isMyLocation()) {
|
} else if (pointDescription.isMyLocation()) {
|
||||||
menuController = new MyLocationMenuController(app, mapActivity, pointDescription);
|
menuController = new MyLocationMenuController(app, mapActivity, pointDescription);
|
||||||
}
|
}
|
||||||
|
} else if (object instanceof RouteDataObject) {
|
||||||
|
menuController = new ImpassibleRoadsMenuController(app, mapActivity,
|
||||||
|
pointDescription, (RouteDataObject) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuController == null) {
|
if (menuController == null) {
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import net.osmand.binary.RouteDataObject;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
|
||||||
|
public class ImpassibleRoadsMenuController extends MenuController {
|
||||||
|
|
||||||
|
private RouteDataObject route;
|
||||||
|
|
||||||
|
public ImpassibleRoadsMenuController(final OsmandApplication app, final MapActivity mapActivity,
|
||||||
|
PointDescription pointDescription, RouteDataObject route) {
|
||||||
|
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||||
|
this.route = route;
|
||||||
|
rightTitleButtonController = new TitleButtonController() {
|
||||||
|
@Override
|
||||||
|
public void buttonPressed() {
|
||||||
|
app.getDefaultRoutingConfig().removeImpassableRoad(
|
||||||
|
ImpassibleRoadsMenuController.this.route);
|
||||||
|
RoutingHelper rh = app.getRoutingHelper();
|
||||||
|
if (rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
|
||||||
|
rh.recalculateRouteDueToSettingsChange();
|
||||||
|
}
|
||||||
|
getMapActivity().getContextMenu().close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
|
||||||
|
rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setObject(Object object) {
|
||||||
|
route = (RouteDataObject) object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeStr() {
|
||||||
|
return getMapActivity().getString(R.string.road_blocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable getLeftIcon() {
|
||||||
|
return getMapActivity().getResources().getDrawable(R.drawable.ic_action_road_works_dark);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,26 +4,32 @@ import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PointF;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.binary.RouteDataObject;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
|
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmPoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||||
* Created by Denis on
|
|
||||||
* 20.03.2015.
|
|
||||||
*/
|
|
||||||
public class ImpassableRoadsLayer extends OsmandMapLayer {
|
|
||||||
|
|
||||||
private static final int startZoom = 10;
|
private static final int startZoom = 10;
|
||||||
private final MapActivity activity;
|
private final MapActivity activity;
|
||||||
private Bitmap roadWorkIcon;
|
private Bitmap roadWorkIcon;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
private Map<Long, Location> missingRoads;
|
private Map<Long, Location> missingRoadLocations;
|
||||||
|
private List<RouteDataObject> missingRoads;
|
||||||
|
|
||||||
public ImpassableRoadsLayer(MapActivity activity) {
|
public ImpassableRoadsLayer(MapActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
|
@ -44,8 +50,8 @@ public class ImpassableRoadsLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
for (long id : getMissingRoads().keySet()) {
|
for (long id : getMissingRoadLocations().keySet()) {
|
||||||
Location location = getMissingRoads().get(id);
|
Location location = getMissingRoadLocations().get(id);
|
||||||
float x = tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
float x = tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||||
float y = tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
float y = tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||||
float left = x - roadWorkIcon.getWidth() / 2;
|
float left = x - roadWorkIcon.getWidth() / 2;
|
||||||
|
@ -55,9 +61,16 @@ public class ImpassableRoadsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Long, Location> getMissingRoads() {
|
public Map<Long, Location> getMissingRoadLocations() {
|
||||||
|
if(missingRoadLocations == null) {
|
||||||
|
missingRoadLocations = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations();
|
||||||
|
}
|
||||||
|
return missingRoadLocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RouteDataObject> getMissingRoads() {
|
||||||
if(missingRoads == null) {
|
if(missingRoads == null) {
|
||||||
missingRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations();
|
missingRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoads();
|
||||||
}
|
}
|
||||||
return missingRoads;
|
return missingRoads;
|
||||||
}
|
}
|
||||||
|
@ -71,4 +84,82 @@ public class ImpassableRoadsLayer extends OsmandMapLayer {
|
||||||
public boolean drawInScreenPixels() {
|
public boolean drawInScreenPixels() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRadiusPoi(RotatedTileBox tb){
|
||||||
|
int r = 0;
|
||||||
|
if(tb.getZoom() < startZoom){
|
||||||
|
r = 0;
|
||||||
|
} else {
|
||||||
|
r = 15;
|
||||||
|
}
|
||||||
|
return (int) (r * tb.getDensity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||||
|
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean disableSingleTap() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean disableLongPressOnMap() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
|
||||||
|
int ex = (int) point.x;
|
||||||
|
int ey = (int) point.y;
|
||||||
|
int compare = getRadiusPoi(tileBox);
|
||||||
|
int radius = compare * 3 / 2;
|
||||||
|
|
||||||
|
for (RouteDataObject road : getMissingRoads()) {
|
||||||
|
Location location = getMissingRoadLocations().get(road.getId());
|
||||||
|
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||||
|
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||||
|
if (calculateBelongs(ex, ey, x, y, compare)) {
|
||||||
|
compare = radius;
|
||||||
|
o.add(road);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LatLon getObjectLocation(Object o) {
|
||||||
|
if (o instanceof OsmPoint) {
|
||||||
|
return new LatLon(((OsmPoint)o).getLatitude(),((OsmPoint)o).getLongitude());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getObjectDescription(Object o) {
|
||||||
|
if(o instanceof OsmPoint) {
|
||||||
|
OsmPoint point = (OsmPoint) o;
|
||||||
|
return OsmEditingPlugin.getEditName(point);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointDescription getObjectName(Object o) {
|
||||||
|
if(o instanceof OsmPoint) {
|
||||||
|
OsmPoint point = (OsmPoint) o;
|
||||||
|
String name = "";
|
||||||
|
String type = "";
|
||||||
|
if (point.getGroup() == OsmPoint.Group.POI){
|
||||||
|
name = ((OpenstreetmapPoint) point).getName();
|
||||||
|
type = PointDescription.POINT_TYPE_OSM_NOTE;
|
||||||
|
} else if (point.getGroup() == OsmPoint.Group.BUG) {
|
||||||
|
name = ((OsmNotesPoint) point).getText();
|
||||||
|
type = PointDescription.POINT_TYPE_OSM_BUG;
|
||||||
|
}
|
||||||
|
return new PointDescription(type, name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue