- if (!gLastDrawnPoint || (gLastDrawnPoint == trackpoint) || !gLastDrawnPoint.optimized) {
- // Start drawing a segment.
- gTrackContext.beginPath();
- gTrackContext.arc(mappos.x, mappos.y,
- gTrackContext.lineWidth, 0, Math.PI * 2, false);
- gTrackContext.fill();
+ if (!trackpoint.skip_drawing) {
+ if (gLastDrawnPoint && gLastDrawnPoint.skip_drawing && !gLastDrawnPoint.segmentEnd) {
+ // If the last point was skipped but the current one isn't, draw a segment start
+ // for the off-screen previous one as well as a connection line.
+ gTrackContext.beginPath();
+ gTrackContext.arc(gLastDrawnPoint.mappos.x, gLastDrawnPoint.mappos.y,
+ gTrackContext.lineWidth, 0, Math.PI * 2, false);
+ gTrackContext.fill();
+ gTrackContext.lineTo(trackpoint.mappos.x, trackpoint.mappos.y);
+ }
+ else if (!gLastDrawnPoint || !gLastDrawnPoint.optimized) {
+ // Start drawing a segment with the current point.
+ gTrackContext.beginPath();
+ gTrackContext.arc(trackpoint.mappos.x, trackpoint.mappos.y,
+ gTrackContext.lineWidth, 0, Math.PI * 2, false);
+ gTrackContext.fill();
+ }
+ else if (!trackpoint.segmentEnd && gLastDrawnPoint &&
+ (Math.abs(gLastDrawnPoint.mappos.x - trackpoint.mappos.x) <= 1) &&
+ (Math.abs(gLastDrawnPoint.mappos.y - trackpoint.mappos.y) <= 1)) {
+ // We would draw the same or almost the same point, don't do any actual drawing.
+ update_drawnpoint = false;
+ }
+ else {
+ // Continue drawing segment, close if needed.
+ gTrackContext.lineTo(trackpoint.mappos.x, trackpoint.mappos.y);
+ if (!trackpoint.optimized)
+ gTrackContext.stroke();
+ }