diff --git a/OsmAnd/src/net/osmand/data/PointDescription.java b/OsmAnd/src/net/osmand/data/PointDescription.java index da52048eb3..cf9770474c 100644 --- a/OsmAnd/src/net/osmand/data/PointDescription.java +++ b/OsmAnd/src/net/osmand/data/PointDescription.java @@ -8,10 +8,13 @@ import com.google.openlocationcode.OpenLocationCode; import com.jwetherell.openmap.common.LatLonPoint; import com.jwetherell.openmap.common.UTMPoint; +import java.util.LinkedHashMap; +import java.util.Map; import net.osmand.LocationConvert; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; import net.osmand.util.Algorithms; public class PointDescription { @@ -172,6 +175,40 @@ public class PointDescription { } } + public static Map getLocationData(MapActivity ctx, double lat, double lon, boolean sh) { + OsmandSettings settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings(); + Map results = new LinkedHashMap<>(); + + int f = settings.COORDINATES_FORMAT.get(); + + UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon)); + results.put(PointDescription.formatToHumanString(ctx, UTM_FORMAT), pnt.zone_number + "" + pnt.zone_letter + " " + ((long) pnt.easting) + " "+ ((long) pnt.northing)); + + try { + results.put(PointDescription.formatToHumanString(ctx, OLC_FORMAT), getLocationOlcName(lat, lon)); + } catch (RuntimeException e) { + results.put(PointDescription.formatToHumanString(ctx, OLC_FORMAT), "0, 0"); + } + + if (f == PointDescription.UTM_FORMAT || f == PointDescription.OLC_FORMAT) { + f = PointDescription.FORMAT_DEGREES; + } + + try { + results.put(PointDescription.formatToHumanString(ctx, f), + ctx.getString(sh ? R.string.short_location_on_map : R.string.location_on_map, LocationConvert.convert(lat, f), + LocationConvert.convert(lon, f))); + } catch (RuntimeException e) { + e.printStackTrace(); + results.put(PointDescription.formatToHumanString(ctx, f), + ctx.getString(sh ? R.string.short_location_on_map : R.string.location_on_map, 0, 0)); + } + final String httpUrl = "https://osmand.net/go?lat=" + (lat) + + "&lon=" + (lon) + "&z=" + ctx.getMapView().getZoom(); + results.put("URL", httpUrl); + return results; + } + public static String getLocationNamePlain(Context ctx, double lat, double lon) { OsmandSettings st = ((OsmandApplication) ctx.getApplicationContext()).getSettings(); int f = st.COORDINATES_FORMAT.get(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 48aea13a2d..c237b732ab 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -389,6 +389,10 @@ public class MenuBuilder { } } + protected void buildCoordinatesRow(View view) { + CollapsableView cv = getCollapsableTextView(app, true, "LatLon \n olc \n link \n utc"); + } + protected void buildNearestPhotosRow(View view) { if (!app.getSettings().isInternetConnectionAvailable()) { return; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index c6a718f4d5..9999a401ee 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -268,11 +268,19 @@ public abstract class MenuController extends BaseMenuController implements Colla protected void addMyLocationToPlainItems(LatLon latLon) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { + addPlainMenuItem(R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(mapActivity, latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", " "), false, false, null); } } + protected void addMyLocationCollapsableView(LatLon latlon) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + int iconId = R.drawable.ic_action_get_my_location; + } + } + public PointDescription getPointDescription() { return pointDescription; }