¿Cómo hacer que el trazado de rutas sea más eficiente?

Este es el código que estoy usando para dibujar la ruta. Cuando tengo 1000 puntos, la ruta se ralentiza mucho. ¿Tal vez alguien podría proporcionar un fragmento de código o un enlace que explique cómo hacer un trazado de ruta de manera más eficiente? Sé que una forma de resolver esto es almacenar en caché la ruta al mapa de bits, pero no tengo idea de cómo hacerlo.

public class PathOverlay extends Overlay{

private GeoPoint startPoint;
private GeoPoint finishPoint;
private ArrayList<GeoPoint> pathPoints;
private Paint paint;
private Path path;
private Point pathStartPoint;
private Point pathEndPoint;

private float dx;
private float dy;


public PathOverlay(GeoPoint startPoint, GeoPoint finishPoint, ArrayList<GeoPoint> pathPoints, int color){
    this.startPoint = startPoint;
    this.finishPoint = finishPoint;
    this.pathPoints = pathPoints;
    this.paint = new Paint();
    this.paint.setAntiAlias(true);
    this.paint.setDither(true);
    this.paint.setColor(color);
    this.paint.setAlpha(150);
    this.paint.setStrokeWidth(4);
    this.paint.setStyle(Paint.Style.STROKE);
}

@Override
public void draw(Canvas overlayCanvas, MapView mapView, boolean shadow) {
    if(path == null) {
        path = getPath(mapView);
    } else {
        path = transformPath(mapView);
    }
    overlayCanvas.drawPath(path, paint);
    super.draw(overlayCanvas, mapView, shadow);
}

private Path getPath(MapView mapView) {
    Projection projection = mapView.getProjection();
    if(path == null) {
        path = new Path();
        path.setFillType(FillType.WINDING);
    } else {
        path.rewind();
    }
    Point point = new Point();
    pathStartPoint = new Point();
    pathEndPoint = new Point();

    projection.toPixels(startPoint, point);
    projection.toPixels(startPoint, pathStartPoint);
    path.moveTo(point.x, point.y);
    path.addCircle(point.x, point.y, (float) 2.0, Direction.CCW);
    if (pathPoints != null) {
        for(int i=0;i<pathPoints.size();i++) {
            projection.toPixels(pathPoints.get(i), point);
            path.lineTo(point.x, point.y);
        }
    }
    projection.toPixels(finishPoint, point);
    projection.toPixels(finishPoint, pathEndPoint);
    path.lineTo(point.x-5, point.y);
    path.addCircle(point.x-5, point.y, (float) 2.0, Direction.CCW);


    return path;
}

private Path transformPath(MapView mapView) {
    Projection projection = mapView.getProjection();

    Point sPoint = new Point();
    Point ePoint = new Point();
    projection.toPixels(startPoint, sPoint);
    projection.toPixels(finishPoint, ePoint);

    float sx = ((float)ePoint.x - (float)sPoint.x)/((float)pathEndPoint.x - (float)pathStartPoint.x);
    float sy = ((float)ePoint.y - (float)sPoint.y)/((float)pathEndPoint.y - (float)pathStartPoint.y);

    if(sx != 1.0 && sy != 1.0) {
        Log.i("PathOverlay", "resized");
        return getPath(mapView);
    } else {
        Log.i("PathOverlay", "moved");
        Matrix matrix, = new Matrix();

        dx = (float)sPoint.x - (float)pathStartPoint.x;
        dy = (float)sPoint.y - (float)pathStartPoint.y;

        matrix.postTranslate(dx, dy);
        pathStartPoint = sPoint;
        pathEndPoint = ePoint;
        path.transform(matrix);

        return path;
    }
}

}

Respuestas a la pregunta(3)

Su respuesta a la pregunta