Révision 100
Ajouté par Yannis SENOUCI il y a environ 3 ans
main.c | ||
---|---|---|
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include "trame.h"
|
||
#include<math.h>
|
||
#include<math.h>
|
||
|
||
typedef struct {
|
||
float latitude;
|
||
float longitude;
|
||
}position;
|
||
|
||
position pos;
|
||
|
||
//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",
|
||
... | ... | |
res3 = decode_nombre(ch,22,4);
|
||
|
||
res = res1 + (res2 + res3/10000)/60;
|
||
|
||
if(ch[27]=='S')
|
||
{
|
||
res = -res;
|
||
}
|
||
|
||
return res;
|
||
}
|
||
|
||
... | ... | |
res3 = decode_nombre(ch,35,4);
|
||
|
||
res = res1 + (res2 + res3/10000)/60;
|
||
if(ch)
|
||
|
||
if(ch[40]=='W')
|
||
{
|
||
res = -res;
|
||
}
|
||
|
||
return res;
|
||
}
|
||
|
||
position coordonnees(char *ch)
|
||
{
|
||
pos.latitude = latitude(ch);
|
||
pos.longitude = longitude(ch);
|
||
|
||
return pos;
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
... | ... | |
printf ("Erreur Test unitaire decode nombre.\n");
|
||
exit(-1);
|
||
}
|
||
if(fabs(latitude("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D")-45.75) > 10-6){
|
||
if(fabs(fabs(latitude("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D"))-45.75) > 10-6){
|
||
printf ("Erreur Test unitaire latitude.\n");
|
||
exit(-1);
|
||
}
|
||
if(fabs(longitude("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D")-3.11006) > 10-6){
|
||
if(fabs(fabs(longitude("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D"))-3.11006) > 10-6){
|
||
printf ("Erreur Test unitaire longitude.\n");
|
||
exit(-1);
|
||
}
|
||
}
|
||
pos = coordonnees("$GPGGA,141914.00,4645.5624,N,00306.0000,E,1,05,3.4,499.3,M,,M,,*7D");
|
||
printf("%f %f\n", pos.latitude,pos.longitude);
|
||
pos = coordonnees("$GPGGA,141914.00,4545.0000,N,00306.6036,E,1,05,3.4,499.3,M,,M,,*7D");
|
||
printf("%f %f\n", pos.latitude,pos.longitude);
|
||
}
|
||
|
||
|
Formats disponibles : Unified diff
unification fcts longitude et latitude dans fct coordonnees qu10