use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class SplitSegmentDialogFragment method collectDisplayItemsFromGroup.
private List<GpxDisplayItem> collectDisplayItemsFromGroup(GpxDisplayGroup group) {
List<GpxDisplayItem> splitSegments = new ArrayList<>();
boolean generalTrack = gpxItem.isGeneralTrack();
boolean generalGroup = group.isGeneralTrack();
if ((group.isSplitDistance() || group.isSplitTime()) && (!generalGroup && !generalTrack || generalGroup && generalTrack)) {
boolean itemsForSelectedSegment = false;
for (GpxDisplayItem item : group.getModifiableList()) {
itemsForSelectedSegment = trkSegment.points.get(0).equals(item.locationStart) || itemsForSelectedSegment;
if (itemsForSelectedSegment) {
splitSegments.add(item);
}
if (trkSegment.points.get(trkSegment.points.size() - 1).equals(item.locationEnd)) {
break;
}
}
}
return splitSegments;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class EditTrackGroupDialogFragment method deleteGroupItems.
private void deleteGroupItems() {
Set<GpxDisplayItem> items = new HashSet<>(group.getModifiableList());
new DeletePointsTask(app, group.getGpx(), items, this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class SegmentGPXAdapter method getView.
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View row = convertView;
boolean create = false;
if (row == null) {
create = true;
row = createGpxTabsView(parent, nightMode);
}
GpxDisplayItem item = getItem(position);
if (item != null) {
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
pager.setAdapter(new GPXItemPagerAdapter(app, item, displayHelper, nightMode, listener, false, false));
if (create) {
tabLayout.setViewPager(pager);
} else {
tabLayout.notifyDataSetChanged(true);
}
}
return row;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class GPXLayer method drawSplitItems.
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
final QuadRect latLonBounds = tileBox.getLatLonBounds();
int r = (int) (12 * tileBox.getDensity());
paintTextIcon.setTextSize(r);
int dr = r * 3 / 2;
float px = -1;
float py = -1;
for (int k = 0; k < items.size(); k++) {
GpxDisplayItem i = items.get(k);
WptPt point = i.locationEnd;
if (point != null && point.lat >= latLonBounds.bottom && point.lat <= latLonBounds.top && point.lon >= latLonBounds.left && point.lon <= latLonBounds.right) {
float x = tileBox.getPixXFromLatLon(point.lat, point.lon);
float y = tileBox.getPixYFromLatLon(point.lat, point.lon);
if (px != -1 || py != -1) {
if (Math.abs(x - px) <= dr && Math.abs(y - py) <= dr) {
continue;
}
}
px = x;
py = y;
String name = i.splitName;
if (name != null) {
int ind = name.indexOf(' ');
if (ind > 0) {
name = name.substring(0, ind);
}
Rect bounds = new Rect();
paintTextIcon.getTextBounds(name, 0, name.length(), bounds);
float nameHalfWidth = bounds.width() / 2f;
float nameHalfHeight = bounds.height() / 2f;
float density = (float) Math.ceil(tileBox.getDensity());
RectF rect = new RectF(x - nameHalfWidth - 2 * density, y + nameHalfHeight + 3 * density, x + nameHalfWidth + 3 * density, y - nameHalfHeight - 2 * density);
canvas.drawRoundRect(rect, 0, 0, paintInnerRect);
canvas.drawRoundRect(rect, 0, 0, paintOuterRect);
canvas.drawText(name, x, y + nameHalfHeight, paintTextIcon);
}
}
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class MapActivity method readLocationToShow.
public void readLocationToShow() {
showMapControls();
OsmandMapTileView mapView = getMapView();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow);
Object toShow = settings.getAndClearObjectToShow();
boolean editToShow = settings.getAndClearEditObjectToShow();
int status = settings.isRouteToPointNavigateAndClear();
String searchRequestToShow = settings.getAndClearSearchRequestToShow();
if (status != 0 || searchRequestToShow != null || latLonToShow != null) {
dismissSettingsScreens();
}
if (status != 0) {
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
Location loc = new Location("map");
loc.setLatitude(mapView.getLatitude());
loc.setLongitude(mapView.getLongitude());
getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true);
if (dashboardOnMap.isVisible()) {
dashboardOnMap.hideDashboard();
}
}
if (trackDetailsMenu.isVisible()) {
trackDetailsMenu.show();
}
if (searchRequestToShow != null) {
showQuickSearch(searchRequestToShow);
}
if (latLonToShow != null) {
if (dashboardOnMap.isVisible()) {
dashboardOnMap.hideDashboard();
}
// remember if map should come back to isMapLinkedToLocation=true
getMapViewTrackingUtilities().setMapLinkedToLocation(false);
if (mapLabelToShow != null && !mapLabelToShow.contextMenuDisabled()) {
mapContextMenu.setMapCenter(latLonToShow);
mapContextMenu.setMapPosition(mapView.getMapPosition());
mapContextMenu.setCenterMarker(true);
RotatedTileBox tb = mapView.getCurrentRotatedTileBox().copy();
LatLon prevCenter = tb.getCenterLatLon();
double border = 0.8;
int tbw = (int) (tb.getPixWidth() * border);
int tbh = (int) (tb.getPixHeight() * border);
tb.setPixelDimensions(tbw, tbh);
tb.setLatLonCenter(latLonToShow.getLatitude(), latLonToShow.getLongitude());
tb.setZoom(ZOOM_LABEL_DISPLAY);
while (!tb.containsLatLon(prevCenter.getLatitude(), prevCenter.getLongitude()) && tb.getZoom() > MIN_ZOOM_LABEL_DISPLAY) {
tb.setZoom(tb.getZoom() - 1);
}
// mapContextMenu.setMapZoom(settings.getMapZoomToShow());
mapContextMenu.setMapZoom(tb.getZoom());
if (toShow instanceof GpxDisplayItem) {
trackDetailsMenu.setGpxItem((GpxDisplayItem) toShow);
trackDetailsMenu.show();
} else if (mapRouteInfoMenu.isVisible()) {
mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow);
mapRouteInfoMenu.updateMenu();
MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude());
} else if (toShow instanceof GPXFile) {
hideContextAndRouteInfoMenues();
GPXFile gpxFile = (GPXFile) toShow;
SelectedGpxFile selectedGpxFile;
if (gpxFile.showCurrentTrack) {
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
} else {
selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(gpxFile, true, false, false, false, false);
}
TrackAppearanceFragment.showInstance(this, selectedGpxFile, null);
} else if (toShow instanceof QuadRect) {
QuadRect qr = (QuadRect) toShow;
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
} else if (toShow instanceof NewGpxPoint) {
NewGpxPoint newGpxPoint = (NewGpxPoint) toShow;
QuadRect qr = newGpxPoint.getRect();
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newGpxPoint);
} else if (toShow instanceof GpxData) {
hideContextAndRouteInfoMenues();
GpxData gpxData = (GpxData) toShow;
QuadRect qr = gpxData.getRect();
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
MeasurementEditingContext editingContext = new MeasurementEditingContext(app);
editingContext.setGpxData(gpxData);
MeasurementToolFragment.showInstance(getSupportFragmentManager(), editingContext);
} else {
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
}
if (editToShow) {
mapContextMenu.openEditor();
}
} else if (!latLonToShow.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(), settings.getMapZoomToShow(), true);
}
}
}
Aggregations