Added osmId links

This commit is contained in:
Alexey Kulish 2017-03-29 22:37:14 +03:00
parent 649fca26bc
commit fb2fc4af71
2 changed files with 32 additions and 0 deletions

View file

@ -25,10 +25,12 @@ import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
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.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.views.POIMapLayer; import net.osmand.plus.views.POIMapLayer;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
@ -467,6 +469,18 @@ public class AmenityMenuBuilder extends MenuBuilder {
} }
OsmandSettings st = ((OsmandApplication) mapActivity.getApplicationContext()).getSettings(); OsmandSettings st = ((OsmandApplication) mapActivity.getApplicationContext()).getSettings();
boolean osmEditingEnabled = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null;
if (osmEditingEnabled) {
String link;
if (amenity.getId() % 2 == 0) {
link = "http://www.openstreetmap.org/node/";
} else {
link = "http://www.openstreetmap.org/way/";
}
buildRow(view, R.drawable.ic_action_info_dark, link + (amenity.getId() >> 1),
0, false, null, true, 0, true, null);
}
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app, buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true) amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true)
.replaceAll("\n", " "), 0, false, null, false, 0, false, null); .replaceAll("\n", " "), 0, false, null, false, 0, false, null);

View file

@ -1,11 +1,14 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import net.osmand.NativeLibrary.RenderedObject; import net.osmand.NativeLibrary.RenderedObject;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandPlugin;
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.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -76,4 +79,19 @@ public class RenderedObjectMenuController extends MenuController {
public boolean needStreetName() { public boolean needStreetName() {
return !getPointDescription().isAddress(); return !getPointDescription().isAddress();
} }
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
super.addPlainMenuItems(typeStr, pointDescription, latLon);
boolean osmEditingEnabled = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null;
if (osmEditingEnabled) {
String link;
if ((renderedObject.getId() >> 6) % 2 == 0) {
link = "http://www.openstreetmap.org/node/";
} else {
link = "http://www.openstreetmap.org/way/";
}
addPlainMenuItem(R.drawable.ic_action_info_dark, link + (renderedObject.getId() >> 7), true, true, null);
}
}
} }