use of net.osmand.plus.views.layers.geometry.GpxGeometryWay in project Osmand by osmandapp.
the class GPXLayer method drawSelectedFileSegments.
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
GPXFile gpxFile = selectedGpxFile.getGpxFileToDisplay();
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
String coloringTypeName = getAvailableOrDefaultColoringType(selectedGpxFile);
ColoringType coloringType = ColoringType.getNonNullTrackColoringTypeByName(coloringTypeName);
String routeIndoAttribute = ColoringType.getRouteInfoAttribute(coloringTypeName);
boolean visible = QuadRect.trivialOverlap(tileBox.getLatLonBounds(), calculateTrackBounds(selectedGpxFile.getPointsToDisplay()));
if (!gpxFile.hasTrkPt() && coloringType.isGradient() || !visible) {
segmentsCache.remove(selectedGpxFile.getGpxFile().path);
return;
}
List<TrkSegment> segments = new ArrayList<>();
if (coloringType.isTrackSolid() || coloringType.isRouteInfoAttribute()) {
segments.addAll(selectedGpxFile.getPointsToDisplay());
} else {
segments.addAll(getCachedSegments(selectedGpxFile, coloringType.toGradientScaleType()));
}
for (int segmentIdx = 0; segmentIdx < segments.size(); segmentIdx++) {
TrkSegment ts = segments.get(segmentIdx);
String width = getTrackWidthName(gpxFile, defaultTrackWidthPref.get());
int color = getTrackColor(gpxFile, ts.getColor(cachedColor));
if (ts.renderer == null && !ts.points.isEmpty()) {
Renderable.RenderableSegment renderer;
if (currentTrack) {
renderer = new Renderable.CurrentTrack(ts.points);
} else {
renderer = new Renderable.StandardTrack(ts.points, 17.2);
}
ts.renderer = renderer;
renderer.setGeometryWay(new GpxGeometryWay(wayContext));
}
updatePaints(color, width, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
if (ts.renderer instanceof Renderable.RenderableSegment) {
Renderable.RenderableSegment renderableSegment = (Renderable.RenderableSegment) ts.renderer;
renderableSegment.setTrackColoringParams(coloringType, routeIndoAttribute, borderPaint);
if (coloringType.isRouteInfoAttribute()) {
renderableSegment.setRoute(getCachedTrack(selectedGpxFile).getCachedRouteSegments(segmentIdx));
boolean drawArrows = isShowArrowsForTrack(selectedGpxFile.getGpxFile());
renderableSegment.drawGeometry(canvas, tileBox, correctedQuadRect, paint.getColor(), paint.getStrokeWidth(), drawArrows);
} else {
renderableSegment.drawSegment(view.getZoom(), paint, canvas, tileBox);
}
}
}
}
Aggregations