Search in sources :

Example 31 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class SegmentsCard method updateLocationOnMap.

private void updateLocationOnMap(@NonNull List<GpxDisplayItem> displayItems) {
    if (gpxPoint != null) {
        for (GpxDisplayItem item : displayItems) {
            TrkSegment segment = GPXItemPagerAdapter.getSegmentForAnalysis(item, item.analysis);
            if (segment != null && (segment.points.contains(gpxPoint.getSelectedPoint()) || segment.points.contains(gpxPoint.getPrevPoint()) && segment.points.contains(gpxPoint.getNextPoint()))) {
                item.locationOnMap = gpxPoint.getSelectedPoint();
                listener.onPointSelected(segment, item.locationOnMap.lat, item.locationOnMap.lon);
            }
        }
    }
}
Also used : GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) TrkSegment(net.osmand.GPXUtilities.TrkSegment)

Example 32 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class TrackPointsCard method onChildClick.

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
    if (item != null && item.locationStart != null) {
        notifyButtonPressed(OPEN_WAYPOINT_INDEX);
        LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
        PointDescription description = new PointDescription(PointDescription.POINT_TYPE_WPT, item.name);
        MapContextMenu contextMenu = mapActivity.getContextMenu();
        contextMenu.setCenterMarker(true);
        contextMenu.show(location, description, item.locationStart);
    }
    return true;
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu)

Example 33 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class DisplayPointsGroupsHelper method filterItems.

private Map<String, List<GpxDisplayItem>> filterItems(Map<String, List<GpxDisplayItem>> itemsMap, Set<?> filteredItems) {
    Map<String, List<GpxDisplayItem>> itemsMapFiltered = new HashMap<>();
    for (Entry<String, List<GpxDisplayItem>> e : itemsMap.entrySet()) {
        String category = e.getKey();
        List<GpxDisplayItem> items = e.getValue();
        if (filteredItems.contains(category)) {
            itemsMapFiltered.put(category, items);
        } else {
            for (GpxDisplayItem i : items) {
                if (filteredItems.contains(i)) {
                    List<GpxDisplayItem> itemsFiltered = itemsMapFiltered.get(category);
                    if (itemsFiltered == null) {
                        itemsFiltered = new ArrayList<>();
                        itemsMapFiltered.put(category, itemsFiltered);
                    }
                    itemsFiltered.add(i);
                }
            }
        }
    }
    return itemsMapFiltered;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) ArrayList(java.util.ArrayList) List(java.util.List)

Example 34 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class DisplayPointsGroupsHelper method setCollectedItems.

private void setCollectedItems(GpxDisplayGroup group, Map<String, List<GpxDisplayItem>> itemsMap) {
    List<String> categories = new ArrayList<>(itemsMap.keySet());
    Collections.sort(categories, comparator);
    for (String category : categories) {
        List<GpxDisplayItem> values = itemsMap.get(category);
        GpxDisplayGroup headerGroup = group.cloneInstance();
        headerGroup.setName(category);
        for (GpxDisplayItem i : values) {
            if (i.locationStart != null && i.locationStart.getColor() != 0) {
                headerGroup.setColor(i.locationStart.getColor(group.getColor()));
                break;
            }
        }
        List<GpxDisplayItem> headerGroupItems = headerGroup.getModifiableList();
        headerGroupItems.clear();
        headerGroupItems.addAll(values);
        itemGroups.put(headerGroup, values);
        this.groups.add(headerGroup);
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) ArrayList(java.util.ArrayList) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)

Example 35 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class GpxUiHelper method makeGpxDisplayItem.

public static GpxDisplayItem makeGpxDisplayItem(@NonNull OsmandApplication app, @NonNull GPXFile gpxFile, @NonNull ChartPointLayer chartPointLayer) {
    GpxDisplayGroup group = null;
    if (!Algorithms.isEmpty(gpxFile.tracks)) {
        GpxSelectionHelper helper = app.getSelectedGpxHelper();
        String groupName = helper.getGroupName(gpxFile);
        group = helper.buildGpxDisplayGroup(gpxFile, 0, groupName);
    }
    if (group != null && group.getModifiableList().size() > 0) {
        GpxDisplayItem gpxItem = group.getModifiableList().get(0);
        if (gpxItem != null) {
            gpxItem.chartPointLayer = chartPointLayer;
        }
        return gpxItem;
    }
    return null;
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) SpannableString(android.text.SpannableString)

Aggregations

GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)35 ArrayList (java.util.ArrayList)8 GPXFile (net.osmand.GPXUtilities.GPXFile)7 TrkSegment (net.osmand.GPXUtilities.TrkSegment)7 WptPt (net.osmand.GPXUtilities.WptPt)7 LatLon (net.osmand.data.LatLon)7 MapActivity (net.osmand.plus.activities.MapActivity)7 GpxDisplayGroup (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup)7 View (android.view.View)5 LineData (com.github.mikephil.charting.data.LineData)5 List (java.util.List)5 QuadRect (net.osmand.data.QuadRect)5 OrderedLineDataSet (net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet)5 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 Matrix (android.graphics.Matrix)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 NonNull (androidx.annotation.NonNull)3 LinkedHashMap (java.util.LinkedHashMap)3