Révision 390
Ajouté par Stephen LOPEZ il y a presque 3 ans
branch/LOPEZ_Stephen/tp_sp4_2022_LOPEZ_Stephen/sp4a12/main.c | ||
---|---|---|
{
|
||
static int cpt=0;
|
||
cpt++;
|
||
if(trame_cmp(trame,"GPGGA"))
|
||
{
|
||
printf ("> %s\n",trame);
|
||
decode_trame("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D",&p1);
|
||
printf("lat=%f long=%f \n ",p1.latitude,p1.longitude);
|
||
... | ... | |
printf("lat=%f long=%f \n ",p1.latitude,p1.longitude);
|
||
decode_trame("$GPGGA,141919.00,4545.1210,N,00306.6040,E,1,05,3.4,500.2,M,,M,,*75",&p1);
|
||
printf("lat=%f long=%f \n ",p1.latitude,p1.longitude);
|
||
}
|
||
|
||
/*if (trame_cmp(trame, "GPGGA")==1)
|
||
{
|
||
printf ("> %s\n",trame);
|
||
}*/
|
||
|
||
|
||
}
|
||
int trame_cmp(char *trame,char*type)
|
||
{
|
||
... | ... | |
return T;
|
||
}
|
||
|
||
float calcul_distance(position *p1, position *p2)
|
||
float calcule_distance(position p1, position p2)
|
||
{
|
||
float distance;
|
||
distance=(2*3.14*6370/360)*sqrt(pow((p2->latitude-p1->latitude),2)*pow((p2->longitude-p1->longitude),2));
|
||
distance=(2*3.14*6370/360)*sqrt(pow((p2.latitude-p1.latitude),2)*pow((p2.longitude-p1.longitude),2));
|
||
return distance;
|
||
}
|
||
|
||
float calcule_vitesse(position p1, position p2)
|
||
{
|
||
|
||
float vitesse;
|
||
vitesse=calcule_distance(p1,p2)*3600;
|
||
return vitesse;
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
void tests_unitaires(void){
|
||
... | ... | |
p1.longitude=longitude("00306.6036");
|
||
p2.latitude=latitude("4545.0242");
|
||
p2.longitude=longitude("00306.6039");
|
||
if((calcul_distance(p1,p2)-0.044>0.1)){
|
||
printf("Erreur Test unitaire calcul_distance");}
|
||
exit(-1);
|
||
if((calcule_distance(p1,p2)-0.044)>2)
|
||
{
|
||
printf("Erreur test unitaire calcul distance\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
Formats disponibles : Unified diff
Fonction Calcule_vitesse terminée