public void stationDetailDialog(String nom, int index) {

    AlertDialog.Builder ad = new AlertDialog.Builder(this);
    ad.setTitle(nom);
    ad.setMessage(gpStation.getLatitudeE6() / 1E6 + " - " + gpStation.getLongitudeE6() / 1E6);
    ad.setNeutralButton(
        android.R.string.ok,
        new android.content.DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int arg1) {
            mController.animateTo(gpStation);
          }
        });

    ad.setPositiveButton(
        "Go there",
        new android.content.DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int arg1) {
            new Thread(
                    new Runnable() {
                      public void run() {
                        goThere();
                      }
                    })
                .start();
          }
        });
    ad.show();
  }
  public void goThere() {
    gpMyLocation = myLocationOverlay.getMyLocation();

    if (gpMyLocation != null) {
      final double lat1 = gpStation.getLatitudeE6();
      final double lat2 = gpMyLocation.getLatitudeE6();
      final double lon1 = gpStation.getLongitudeE6();
      final double lon2 = gpMyLocation.getLongitudeE6();
      final GeoPoint gpMiddle =
          new GeoPoint((int) ((lat1 + lat2) / 2.0), (int) ((lon1 + lon2) / 2.0));
      final Document doc = UtilsWeb.getKml(gpMyLocation, gpStation);

      this.runOnUiThread(
          new Thread(
              new Runnable() {
                public void run() {
                  DrawPath(gpMyLocation, gpStation, Color.BLUE, mMap, doc);
                  mController.setCenter(gpMiddle);

                  final double spanLat;
                  final double spanLon;

                  if (lat1 > lat2) spanLat = (lat1 - lat2);
                  else spanLat = (lat2 - lat1);

                  if (lon1 > lon2) spanLon = (lon1 - lon2);
                  else spanLon = (lon2 - lon1);
                  mController.zoomToSpan((int) spanLat, (int) spanLon);
                  mMap.invalidate();
                }
              }));

    } else
      this.runOnUiThread(
          new Thread(
              new Runnable() {
                public void run() {
                  Toast.makeText(
                          MapStationActivity.this,
                          "Waiting GPS fix\nActivate network localisation in settings or enable you GPS.",
                          Toast.LENGTH_LONG)
                      .show();
                }
              }));
  }
 @Override
 public Point toPixels(GeoPoint in, Point out) {
   double[] coords = new double[] {in.getLatitudeE6() / 1E6, in.getLongitudeE6() / 1E6};
   int[] pixels = TileFactory.LatLngToPixel(coords, mView.getZoomLevel());
   Point center = mView.getController().getCenter();
   out.x = pixels[0] - center.x + mView.getWidth() / 2;
   out.y = pixels[1] - center.y + mView.getHeight() / 2;
   return out;
 }
  public static BoundingBoxE6 fromGeoPoints(final ArrayList<? extends GeoPoint> partialPolyLine) {
    int minLat = Integer.MAX_VALUE;
    int minLon = Integer.MAX_VALUE;
    int maxLat = Integer.MIN_VALUE;
    int maxLon = Integer.MIN_VALUE;
    for (GeoPoint gp : partialPolyLine) {
      final int latitudeE6 = gp.getLatitudeE6();
      final int longitudeE6 = gp.getLongitudeE6();

      minLat = Math.min(minLat, latitudeE6);
      minLon = Math.min(minLon, longitudeE6);
      maxLat = Math.max(maxLat, latitudeE6);
      maxLon = Math.max(maxLon, longitudeE6);
    }

    return new BoundingBoxE6(minLat, minLon, maxLat, maxLon);
  }