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