コード例 #1
0
  private void GenTrackProjection() {
    Coordinate coord = GlobalCore.getSelectedCoord();
    if (coord == null) coord = Locator.getCoordinate();

    ProjectionCoordinate pC =
        new ProjectionCoordinate(
            ActivityBase.ActivityRec(),
            Translation.Get("Projection"),
            coord,
            new CB_UI.GL_UI.Activitys.ProjectionCoordinate.ICoordReturnListener() {

              @Override
              public void returnCoord(
                  Coordinate targetCoord, Coordinate startCoord, double Bearing, double distance) {

                if (targetCoord == null || startCoord == null) return;

                float[] dist = new float[4];
                TrackColor = RouteOverlay.getNextColor();
                Track route = new Track(null, TrackColor);
                route.Name = "Projected Route";

                route.Points.add(
                    new TrackPoint(
                        targetCoord.getLongitude(), targetCoord.getLatitude(), 0, 0, new Date()));
                route.Points.add(
                    new TrackPoint(
                        startCoord.getLongitude(), startCoord.getLatitude(), 0, 0, new Date()));

                MathUtils.computeDistanceAndBearing(
                    CalculationType.ACCURATE,
                    targetCoord.getLatitude(),
                    targetCoord.getLongitude(),
                    startCoord.getLatitude(),
                    startCoord.getLongitude(),
                    dist);
                route.TrackLength = dist[0];

                route.ShowRoute = true;
                RouteOverlay.add(route);
                if (TrackListView.that != null) TrackListView.that.notifyDataSetChanged();
              }
            },
            Type.projetion,
            null);

    pC.show();
  }
コード例 #2
0
  private void GenTrackCircle() {
    Coordinate coord = GlobalCore.getSelectedCoord();
    if (coord == null) coord = Locator.getCoordinate();

    ProjectionCoordinate pC =
        new ProjectionCoordinate(
            ActivityBase.ActivityRec(),
            Translation.Get("centerPoint"),
            coord,
            new CB_UI.GL_UI.Activitys.ProjectionCoordinate.ICoordReturnListener() {

              @Override
              public void returnCoord(
                  Coordinate targetCoord, Coordinate startCoord, double Bearing, double distance) {

                if (targetCoord == null || startCoord == null) return;

                float[] dist = new float[4];
                TrackColor = RouteOverlay.getNextColor();
                Track route = new Track(null, TrackColor);
                route.Name = "Circle Route";

                route.ShowRoute = true;
                RouteOverlay.add(route);

                Coordinate Projektion = new CoordinateGPS(0, 0);
                Coordinate LastCoord = new CoordinateGPS(0, 0);

                for (int i = 0;
                    i <= 360;
                    i +=
                        10) // Achtung der Kreis darf nicht mehr als 50 Punkte haben, sonst gibt es
                            // Probleme
                // mit dem Reduktionsalgorythmus
                {
                  Projektion =
                      CoordinateGPS.Project(
                          startCoord.getLatitude(), startCoord.getLongitude(), i, distance);

                  route.Points.add(
                      new TrackPoint(
                          Projektion.getLongitude(), Projektion.getLatitude(), 0, 0, new Date()));

                  if (!LastCoord.isValid()) {
                    LastCoord = Projektion;
                    LastCoord.setValid(true);
                  } else {
                    MathUtils.computeDistanceAndBearing(
                        CalculationType.ACCURATE,
                        Projektion.getLatitude(),
                        Projektion.getLongitude(),
                        LastCoord.getLatitude(),
                        LastCoord.getLongitude(),
                        dist);
                    route.TrackLength += dist[0];
                    LastCoord = Projektion;
                    LastCoord.setValid(true);
                  }
                }
                if (TrackListView.that != null) TrackListView.that.notifyDataSetChanged();
              }
            },
            Type.circle,
            null);

    pC.show();
  }