Search in sources :

Example 56 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class NavigatePointFragment method select.

public void select(int mode) {
    try {
        LatLon loc = parseLocation();
        double lat = loc.getLatitude();
        double lon = loc.getLongitude();
        PointDescription pd = new PointDescription(lat, lon);
        if (mode == SHOW_ON_MAP) {
            OsmandApplication app = (OsmandApplication) getActivity().getApplication();
            app.getSettings().setMapLocationToShow(lat, lon, Math.max(12, app.getSettings().getLastKnownMapZoom()), pd);
            MapActivity.launchMapActivityMoveToTop(getActivity());
        }
    } catch (RuntimeException e) {
        view.findViewById(R.id.ValidateTextView).setVisibility(View.VISIBLE);
        ((TextView) view.findViewById(R.id.ValidateTextView)).setText(R.string.invalid_locations);
        // $NON-NLS-1$
        Log.w(PlatformUtil.TAG, "Convertion failed", e);
    }
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) PointDescription(net.osmand.data.PointDescription)

Example 57 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class MapMarkersHelper method addMarkers.

private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MapMarkersGroup group, @Nullable List<FavouritePoint> favouritePoints, @Nullable List<WptPt> wptPts, @Nullable List<String> mapObjNames) {
    if (points.size() > 0) {
        int colorIndex = -1;
        List<MapMarker> addedMarkers = new ArrayList<>();
        for (int i = 0; i < points.size(); i++) {
            LatLon point = points.get(i);
            PointDescription historyName = historyNames.get(i);
            FavouritePoint favouritePoint = favouritePoints == null ? null : favouritePoints.get(i);
            WptPt wptPt = wptPts == null ? null : wptPts.get(i);
            String mapObjName = mapObjNames == null ? null : mapObjNames.get(i);
            final PointDescription pointDescription;
            if (historyName == null) {
                pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
            } else {
                pointDescription = historyName;
            }
            if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
                pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
            }
            if (colorIndex == -1) {
                if (mapMarkers.size() > 0) {
                    colorIndex = (mapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
                } else {
                    colorIndex = 0;
                }
            } else {
                colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
            }
            MapMarker marker = new MapMarker(point, pointDescription, colorIndex, false, 0);
            if (group != null) {
                marker.id = group.getId() + marker.getName(ctx);
                // TODO ???????
                if (markersDbHelper.getMarker(marker.id) != null) {
                    continue;
                }
                marker.groupName = group.getName();
                marker.groupKey = group.getId();
            }
            marker.history = false;
            marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
            marker.favouritePoint = favouritePoint;
            marker.wptPt = wptPt;
            marker.mapObjectName = mapObjName;
            markersDbHelper.addMarker(marker);
            addToMapMarkersList(0, marker);
            addedMarkers.add(marker);
            reorderActiveMarkersIfNeeded();
            lookupAddress(marker);
        }
        addMarkersToGroups(addedMarkers);
    }
}
Also used : LatLon(net.osmand.data.LatLon) WptPt(net.osmand.plus.GPXUtilities.WptPt) FavouritePoint(net.osmand.data.FavouritePoint) PointDescription(net.osmand.data.PointDescription) ArrayList(java.util.ArrayList) LocationPoint(net.osmand.data.LocationPoint) FavouritePoint(net.osmand.data.FavouritePoint)

Example 58 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class FavoritesListFragment method showOnMap.

public static void showOnMap(FavouritePoint point, Activity activity) {
    OsmandApplication app = (OsmandApplication) activity.getApplication();
    final OsmandSettings settings = app.getSettings();
    LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
    settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true, // $NON-NLS-1$
    point);
    MapActivity.launchMapActivityMoveToTop(activity);
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) PointDescription(net.osmand.data.PointDescription) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 59 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class FavoritesTreeFragment method selectMapMarkersImpl.

private void selectMapMarkersImpl() {
    if (getSelectedFavoritesCount() > 0) {
        MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
        List<LatLon> points = new ArrayList<>();
        List<PointDescription> names = new ArrayList<>();
        for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
            FavoriteGroup favGr = helper.getGroup(entry.getKey());
            MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(favGr);
            if (entry.getValue().size() == favGr.points.size()) {
                markersHelper.addOrEnableGroup(markersGr);
            } else {
                for (FavouritePoint fp : entry.getValue()) {
                    points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
                    names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
                }
                markersHelper.addMapMarkers(points, names, markersGr);
                points.clear();
                names.clear();
            }
        }
        MapActivity.launchMapActivityMoveToTop(getActivity());
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) FavouritePoint(net.osmand.data.FavouritePoint) FavoriteGroup(net.osmand.plus.FavouritesDbHelper.FavoriteGroup) ArrayList(java.util.ArrayList) LatLon(net.osmand.data.LatLon) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) PointDescription(net.osmand.data.PointDescription) MapMarkersGroup(net.osmand.plus.MapMarkersHelper.MapMarkersGroup) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 60 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class TargetPointsHelper method setStartPoint.

public void setStartPoint(final LatLon startPoint, boolean updateRoute, PointDescription name) {
    if (startPoint != null) {
        final PointDescription pointDescription;
        if (name == null) {
            pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
        } else {
            pointDescription = name;
        }
        if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
            pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
        }
        settings.setPointToStart(startPoint.getLatitude(), startPoint.getLongitude(), pointDescription);
    } else {
        settings.clearPointToStart();
    }
    readFromSettings();
    updateRouteAndRefresh(updateRoute);
}
Also used : PointDescription(net.osmand.data.PointDescription)

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