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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
class PositionGPS {
private PositionGPS util;
private SerialGPS gps;
private String longitude;
private String latitude;
private String horaire;
private String tr;
public PositionGPS()
{
util = new PositionGPS();
gps = new SerialGPS(util);
tr=gps.Gettrame();
}
public void setGPS(SerialGPS gps)
{
this.gps = gps ;
}
public Position recupererPos() {
Position pos = new Position();
pos.stockerPos(gethor(), getlongi(), getlat());
return pos;
}
String gethoraire() {
horaire = tr.substring(12,20);
return horaire;
}
float gethor(){
//Récupérer l'horaire
gethoraire();
//Convertion du string horaire en float
float h = Float.parseFloat(horaire);
return h;
}
String getlatitude() {
latitude = tr.substring(21,33);
return latitude;
}
float getlat(){
//Récupérer la latitude
getlatitude();
//Convertion du String latitude en float
float lt = Float.parseFloat(latitude);
return lt;
}
String getlongitude() {
longitude = tr.substring(34,47);
return longitude;
}
float getlongi(){
//Récupérer la longitude
getlongitude();
//Convertion du String longitude en float
float lg = Float.parseFloat(longitude);
System.out.println(lg);
return lg;
}
public void transferertrame(String a){
try
{
//tr=gps.Gettrame();
if(tr!=null)
{
System.out.println("la trame finale est maintenant : " + tr );
}
else
System.out.println("aucune trame");
}
catch(Exception e)
{
}
horaire = tr.substring(12,20);
System.out.println("heure:" + horaire);
//Latitude
latitude = tr.substring(21,33);
System.out.println("latitude:" + latitude);
//Longitude
longitude = tr.substring(34,47);
System.out.println("longitude:" + longitude);
System.out.println("");
}
} |
Partager