Salut a tous
j'esepre avoir de l'aide svp
je suis entrain de programmé une application de transport en commun ; je travail sur la partie Maps distance ect ;
j'ai pu calculer la distance entre ma position actuelle et les différentes stations sur la carte , ainsi pour trouver la station la plus proche
je veux ajouter dans ma base une table station avec l'etat de chaque station ainsi si une station par exemple est en travaux elle ne sera pas pris en compte lors du calcule

voila comment je calcule la distance la plus proche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  public void drawPath() {
        //Getting both the coordinates
        LatLng from = new LatLng(Latitude1,Longitude1);
 
        double [][] StationTram = new double [25][2];
 
        //Station Le Rocher
        StationTram [0][0] = 35.2236078 ;
        StationTram [0][1] = -0.6092131;
 
 
        ////Station Mexique
        StationTram [24][0] = 35.2172748 ;
        StationTram [24][1] = -0.6394620;
 
        for(double[] point : StationTram) { 
 
 
        int distance = 999999999;
 
 
        for(double[] point : StationTram) { // si ton tableau de point c'est double[][] tableauDePoint
 
            LatLng to = new LatLng(point[0],point[1]);
            //Calculating the distance in meters
            int distanceLambda = (int)SphericalUtil.computeDistanceBetween(from, to);
 
            if ( distanceLambda < distance ) { // cette distance est donc plus petite que la plus petite distance déjà trouvée
                distance = distanceLambda ;
                Latitude1 = point[0];
                Longitude1 = point[1];
           }
 
        }
 
        Toast.makeText(this,String.valueOf(distance+" Meters"),Toast.LENGTH_LONG).show();
        moveMap();
 
    }
j'ai ajouter un tableaux de la même taille , les distance deja caluclcé en ordre decroissant ,ainsi je pourrais parcourir ma table en fonction des points de chaque distance
ma table contient 3 colonne longitude latitude l'etat par exemple si l'etat est off la station ne sera pas pris en compte

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 class DistancePoint {
 
            private final double[] point;
            private final int distance;
 
            public DistancePoint(double[] point, int distance) {
                this.point=point;
                this.distance=distance;
            }
 
            public double[] getPoint() {
                return point;
            }
 
            public int   getDistance() {
                return distance;
            }
 
        }
        DistancePoint[] distances = new DistancePoint[StationTram.length]; // on créé un tableau de la taille du tableau d'origine, pour stocker chaque distance
        int index=0; // un index pour avancer dans le tableau
 
            distances[index++] = new DistancePoint(point, distanceLambda); // on stocke la distance et son point associé
 
 
        Arrays.sort(distances,new Comparator<DistancePoint>() {
 
            public int compare(DistancePoint o1, DistancePoint o2) {
 
             int   d1=o1.getDistance();
               int d2=o2.getDistance();
                return  d2-d1 ;
            }
 
 
        });
        double[][] resultat = new double[distances.length][]; // on créé un tableau
        for(int i=0; i< distances.length; i++) {
            resultat[i] = distances[i].getPoint();
        }