Search in sources :

Example 31 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class OsmandAidlApi method getActiveGpx.

boolean getActiveGpx(List<ASelectedGpxFile> files) {
    if (files != null) {
        List<SelectedGpxFile> selectedGpxFiles = app.getSelectedGpxHelper().getSelectedGPXFiles();
        String gpxPath = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath();
        for (SelectedGpxFile selectedGpxFile : selectedGpxFiles) {
            String path = selectedGpxFile.getGpxFile().path;
            if (!Algorithms.isEmpty(path)) {
                if (path.startsWith(gpxPath)) {
                    path = path.substring(gpxPath.length() + 1);
                }
                files.add(new ASelectedGpxFile(path));
            }
        }
        return true;
    }
    return false;
}
Also used : ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile)

Example 32 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class GPXLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (contextMenuLayer.getMoveableObject() instanceof WptPt) {
        WptPt objectInMotion = (WptPt) contextMenuLayer.getMoveableObject();
        PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
        SelectedGpxFile gpxFile = pointFileMap.get(objectInMotion);
        if (gpxFile != null) {
            drawBigPoint(canvas, objectInMotion, getFileColor(gpxFile), pf.x, pf.y, isSynced(gpxFile));
        }
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) PointF(android.graphics.PointF)

Example 33 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class GPXLayer method drawSelectedFilesPoints.

private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
    if (tileBox.getZoom() >= startZoom) {
        float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0, true).getIntrinsicWidth() * 3 / 2.5f;
        QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
        List<LatLon> fullObjectsLatLon = new ArrayList<>();
        List<LatLon> smallObjectsLatLon = new ArrayList<>();
        // request to load
        final QuadRect latLonBounds = tileBox.getLatLonBounds();
        for (SelectedGpxFile g : selectedGPXFiles) {
            List<WptPt> pts = getListStarPoints(g);
            List<WptPt> fullObjects = new ArrayList<>();
            @ColorInt int fileColor = getFileColor(g);
            boolean synced = isSynced(g);
            for (WptPt o : pts) {
                if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top && o.lon >= latLonBounds.left && o.lon <= latLonBounds.right && o != contextMenuLayer.getMoveableObject()) {
                    if (synced) {
                        if (mapMarkersHelper.getMapMarker(o) == null) {
                            continue;
                        }
                    }
                    cache.add(o);
                    float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
                    float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
                    if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
                        @ColorInt int pointColor = getPointColor(o, fileColor);
                        paintIcon.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.MULTIPLY));
                        canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
                        smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
                    } else {
                        fullObjects.add(o);
                        fullObjectsLatLon.add(new LatLon(o.lat, o.lon));
                    }
                }
                pointFileMap.put(o, g);
            }
            for (WptPt o : fullObjects) {
                float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
                float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
                drawBigPoint(canvas, o, fileColor, x, y, synced);
            }
        }
        if (trackChartPoints != null) {
            LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
            if (highlightedPoint != null) {
                if (highlightedPoint.getLatitude() >= latLonBounds.bottom && highlightedPoint.getLatitude() <= latLonBounds.top && highlightedPoint.getLongitude() >= latLonBounds.left && highlightedPoint.getLongitude() <= latLonBounds.right) {
                    float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
                    float y = tileBox.getPixYFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
                    paintIcon.setColorFilter(null);
                    canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
                }
            }
        }
        this.fullObjectsLatLon = fullObjectsLatLon;
        this.smallObjectsLatLon = smallObjectsLatLon;
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint) LatLon(net.osmand.data.LatLon) ColorInt(android.support.annotation.ColorInt) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)

Example 34 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class GPXLayer method getWptFromPoint.

public void getWptFromPoint(RotatedTileBox tb, PointF point, List<? super WptPt> res) {
    int r = getDefaultRadiusPoi(tb);
    int ex = (int) point.x;
    int ey = (int) point.y;
    for (SelectedGpxFile g : selectedGpxHelper.getSelectedGPXFiles()) {
        List<WptPt> pts = getListStarPoints(g);
        // int fcolor = g.getColor() == 0 ? clr : g.getColor();
        for (WptPt n : pts) {
            int x = (int) tb.getPixXFromLatLon(n.lat, n.lon);
            int y = (int) tb.getPixYFromLatLon(n.lat, n.lon);
            if (calculateBelongs(ex, ey, x, y, r)) {
                res.add(n);
            }
        }
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) Paint(android.graphics.Paint)

Example 35 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class GPXLayer method drawSelectedFileSegments.

private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    GpxDataItem gpxDataItem = null;
    if (!currentTrack) {
        gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path));
    }
    List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
    for (TrkSegment ts : segments) {
        int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
        if (currentTrack) {
            color = currentTrackColor;
        }
        if (color == 0) {
            color = ts.getColor(cachedColor);
        }
        if (// only do once (CODE HERE NEEDS TO BE UI INSTEAD)
        ts.renders.isEmpty() && !ts.points.isEmpty()) {
            // hmmm. 0-point tracks happen, but.... how?
            if (currentTrack) {
                ts.renders.add(new Renderable.CurrentTrack(ts.points));
            } else {
                ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2));
            }
        }
        updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
        ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
    }
}
Also used : GpxDataItem(net.osmand.plus.GPXDatabase.GpxDataItem) TrkSegment(net.osmand.plus.GPXUtilities.TrkSegment) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File) Paint(android.graphics.Paint)

Aggregations

SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)35 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)18 File (java.io.File)13 ArrayList (java.util.ArrayList)9 View (android.view.View)7 GpxSelectionHelper (net.osmand.plus.GpxSelectionHelper)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 GpxDataItem (net.osmand.plus.GPXDatabase.GpxDataItem)6 WptPt (net.osmand.plus.GPXUtilities.WptPt)6 Paint (android.graphics.Paint)5 AdapterView (android.widget.AdapterView)4 ArrayAdapter (android.widget.ArrayAdapter)4 GpxDisplayGroup (net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup)4 SuppressLint (android.annotation.SuppressLint)3 DialogInterface (android.content.DialogInterface)3 AlertDialog (android.support.v7.app.AlertDialog)3 ViewGroup (android.view.ViewGroup)3 CompoundButton (android.widget.CompoundButton)3