Révision 374
Ajouté par Youssef MORSY il y a presque 3 ans
branch/MORSY/sp4a12/main.c | ||
---|---|---|
#include "trame.h"
|
||
|
||
|
||
#define PI 3.14159
|
||
|
||
|
||
typedef struct {
|
||
float latitude;
|
||
float longtitude;
|
||
}position;
|
||
|
||
position p;
|
||
|
||
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
char * trames[]= {"$GPGSV,3,2,10,15,03,077,,18,04,041,42,19,85,271,,20,08,214,*7C",
|
||
"$GPGSV,3,3,10,22,39,053,50,28,15,320,*7E",
|
||
... | ... | |
|
||
|
||
}
|
||
float calcul_distance(position*p1,position*p2){
|
||
float distance;
|
||
distance=acos(sin(PI * p1 ->latitude/180)*sin(PI * p2 ->latitude/180)+cos(PI* p1 ->latitude/180)*cos(PI* p2 ->latitude/180)*cos(PI*(fabs(p1 ->longtitude - p2 ->longtitude))/180))*6371;
|
||
return distance;
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
|
||
void tests_unitaires(void){
|
||
position p,p1,p2;
|
||
p1.latitude=35.968723;
|
||
p1.longtitude=256.652056;
|
||
p2.longtitude=156.831330;
|
||
p2.latitude=55.806160;
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
exit(-1);
|
||
... | ... | |
printf ("Erreur Test unitaire trame_cmp25\n");
|
||
exit(-1);
|
||
}
|
||
//////////
|
||
|
||
if(fabs(calcul_distance(&p1,&p2)-7328.429126) >0.000001){
|
||
printf ("Erreur Test unitaire trame_cmp30\n");
|
||
printf("a");
|
||
exit(-1);
|
||
|
||
|
||
}
|
||
float a= calcul_distance(&p1,&p2);
|
||
printf("%f",a);
|
||
|
||
}
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
... | ... | |
while (trames[i])
|
||
traitement(trames[i++]);
|
||
|
||
// if (!trame_init())
|
||
// exit(-1);
|
||
if (!trame_init())
|
||
exit(-1);
|
||
// Affichage des trames du fichier gps.log
|
||
char *trame;
|
||
printf ("Trames de tests du fichier gps.log\n");
|
Formats disponibles : Unified diff
q3 tp2