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);
}
}
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);
}
}
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);
}
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());
}
}
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);
}
Aggregations