Search in sources :

Example 66 with PointDescription

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();
        }
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LatLon(net.osmand.data.LatLon) DialogInterface(android.content.DialogInterface) PointDescription(net.osmand.data.PointDescription) OnClickListener(android.view.View.OnClickListener) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Example 67 with PointDescription

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);
    }
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) PointDescription(net.osmand.data.PointDescription) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint)

Example 68 with PointDescription

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;
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) FavouritePoint(net.osmand.data.FavouritePoint)

Example 69 with PointDescription

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;
}
Also used : Amenity(net.osmand.data.Amenity) PointDescription(net.osmand.data.PointDescription)

Example 70 with PointDescription

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);
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) Paint(android.graphics.Paint)

Aggregations

PointDescription (net.osmand.data.PointDescription)72 LatLon (net.osmand.data.LatLon)44 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 ArrayList (java.util.ArrayList)13 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)13 FavouritePoint (net.osmand.data.FavouritePoint)12 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)11 OsmandApplication (net.osmand.plus.OsmandApplication)10 OsmandSettings (net.osmand.plus.OsmandSettings)10 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)8 Amenity (net.osmand.data.Amenity)7 WptPt (net.osmand.plus.GPXUtilities.WptPt)7 RoutingHelper (net.osmand.plus.routing.RoutingHelper)7 Intent (android.content.Intent)6 Paint (android.graphics.Paint)6 LinearLayout (android.widget.LinearLayout)6 Location (net.osmand.Location)6 DialogInterface (android.content.DialogInterface)5