Révision 362
Ajouté par Clement ROCHE il y a presque 3 ans
main.c | ||
---|---|---|
//test_decode_latitude();
|
||
//test_decode_longitude();
|
||
//test_decode_lat_long();
|
||
test_decode_trame();
|
||
//test_decode_trame();
|
||
//test_calcul_distance();
|
||
|
||
Position P1,P2 ;
|
||
|
||
... | ... | |
if (trame_cmp(trame,"GPGGA") == 1) {
|
||
printf ("> %s\n",trame);
|
||
decode_trame(trame, &P1);
|
||
printf("\nLatitude : %f Longitude : %f\n\n", P1.latitude, P2.longitude);
|
||
printf("\nLatitude : %f Longitude : %f\n\n", P1.latitude, P1.longitude);
|
||
}
|
||
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
//tests_unitaires();
|
||
//test_decode_int();
|
||
//test_decode_nombre();
|
||
//test_decode_latitude();
|
||
//test_decode_longitude();
|
||
//test_decode_lat_long();
|
||
//test_decode_trame();
|
||
|
||
int decode_nombre(char * ch, int n) {
|
||
int i=0,res=0,b,p;
|
||
for (i=0;i<n;i++) {
|
||
... | ... | |
(*P).latitude = decode_lat_long(lat); //ne pas mettre de chiffre cela na aps de sens
|
||
(*P).longitude = decode_lat_long(lon);
|
||
}
|
||
|
||
float calcule_distance(Position p_1,Position p_2) {
|
||
float x,y,res;
|
||
x=(p_2.longitude - p_1.longitude)*cos((p_2.latitude + p_1.latitude) / 2);
|
||
y=(p_2.latitude - p_1.latitude);
|
||
res = (sqrt((x*x)+(y*y)))*1.852*60;
|
||
return res;
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
/*void tests_unitaires_trame_cmp(void){
|
||
... | ... | |
|
||
|
||
}
|
||
|
||
|
||
void test_calcul_distance(void) {
|
||
Position P1,P2;
|
||
float a;
|
||
decode_trame("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*79",&P1);
|
||
decode_trame("$GPGGA,141915.00,4545.0242,N,00306.6039,E,1,05,3.4,499.5,M,,M,,*75",&P2);
|
||
a = 0.044932 - calcule_distance(P1,P2);
|
||
|
||
if (a*a > 0.000001) {
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
Formats disponibles : Unified diff
Calcul distance + test ok