use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapControlsLayer method navigateButton.
public void navigateButton() {
if (!OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION);
} else {
final MapContextMenu menu = mapActivity.getContextMenu();
final LatLon latLon = menu.getLatLon();
final PointDescription pointDescription = menu.getPointDescriptionForTarget();
menu.hide();
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) {
DirectionsDialogs.addWaypointDialogAndLaunchMap(mapActivity, latLon.getLatitude(), latLon.getLongitude(), pointDescription);
} else if (targets.getIntermediatePoints().isEmpty()) {
startRoutePlanningWithDestination(latLon, pointDescription, targets);
menu.close();
} else {
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
bld.setTitle(R.string.new_directions_point_dialog);
final int[] defaultVls = new int[] { 0 };
bld.setSingleChoiceItems(new String[] { mapActivity.getString(R.string.clear_intermediate_points), mapActivity.getString(R.string.keep_intermediate_points) }, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
defaultVls[0] = which;
}
});
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (defaultVls[0] == 0) {
targets.removeAllWayPoints(false, true);
targets.navigateToPoint(latLon, true, -1, pointDescription);
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true);
menu.close();
} else {
targets.navigateToPoint(latLon, true, -1, pointDescription);
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true);
menu.close();
}
}
});
bld.setNegativeButton(R.string.shared_string_cancel, null);
bld.show();
}
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapMarkersLayer method applyNewObjectPosition.
@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable ApplyMovedObjectCallback callback) {
boolean result = false;
MapMarker newObject = null;
if (o instanceof MapMarker) {
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
MapMarker marker = (MapMarker) o;
PointDescription originalDescription = marker.getOriginalPointDescription();
if (originalDescription.isLocation()) {
originalDescription.setName(PointDescription.getSearchAddressStr(map));
}
markersHelper.moveMapMarker(marker, position);
int index = markersHelper.getMapMarkers().indexOf(marker);
if (index != -1) {
newObject = markersHelper.getMapMarkers().get(index);
}
result = true;
}
if (callback != null) {
callback.onApplyMovedObject(result, newObject == null ? o : newObject);
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class QuickSearchListItem method getName.
public static String getName(OsmandApplication app, SearchResult searchResult) {
switch(searchResult.objectType) {
case STREET:
if (searchResult.localeName.endsWith(")")) {
int i = searchResult.localeName.indexOf('(');
if (i > 0) {
return searchResult.localeName.substring(0, i).trim();
}
}
break;
case STREET_INTERSECTION:
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
return searchResult.localeName + " - " + searchResult.localeRelatedObjectName;
}
break;
case RECENT_OBJ:
HistoryEntry historyEntry = (HistoryEntry) searchResult.object;
PointDescription pd = historyEntry.getName();
return pd.getSimpleName(app, false);
case LOCATION:
LatLon latLon = searchResult.location;
return PointDescription.getLocationNamePlain(app, latLon.getLatitude(), latLon.getLongitude());
}
return searchResult.localeName;
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class POIMapLayer method getObjectName.
@Override
public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) {
Amenity a = (Amenity) o;
String preferredMapLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
String preferredMapAppLang = preferredMapLang;
if (Algorithms.isEmpty(preferredMapAppLang)) {
preferredMapAppLang = app.getLanguage();
}
boolean transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
return new PointDescription(PointDescription.POINT_TYPE_POI, a.getName(a.getType().isWiki() ? preferredMapAppLang : preferredMapLang, transliterateNames));
}
return null;
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class PointNavigationLayer method applyNewObjectPosition.
@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable ContextMenuLayer.ApplyMovedObjectCallback callback) {
boolean result = false;
TargetPoint newTargetPoint = null;
if (o instanceof TargetPoint) {
TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
TargetPoint oldPoint = (TargetPoint) o;
if (oldPoint.start) {
targetPointsHelper.setStartPoint(position, true, null);
newTargetPoint = targetPointsHelper.getPointToStart();
} else if (oldPoint == targetPointsHelper.getPointToNavigate()) {
targetPointsHelper.navigateToPoint(position, true, -1, null);
newTargetPoint = targetPointsHelper.getPointToNavigate();
} else if (oldPoint.intermediate) {
List<TargetPoint> points = targetPointsHelper.getIntermediatePointsWithTarget();
int i = points.indexOf(oldPoint);
if (i != -1) {
newTargetPoint = new TargetPoint(position, new PointDescription(PointDescription.POINT_TYPE_LOCATION, ""));
points.set(i, newTargetPoint);
targetPointsHelper.reorderAllTargetPoints(points, true);
}
}
result = true;
}
if (callback != null) {
callback.onApplyMovedObject(result, newTargetPoint == null ? o : newTargetPoint);
}
}
Aggregations