Révision 275
Ajouté par Clement ROCHE il y a environ 3 ans
branch/ROCHE/sp4a12/main.c | ||
---|---|---|
return res;
|
||
}
|
||
|
||
float decode_latitude (char c[]) {
|
||
int n=0, degre=0, cpt=0,i=-1,b,p;
|
||
float min=0, secondes=0, res=0;
|
||
|
||
|
||
do{
|
||
n++;
|
||
} while (c[n]!='.');
|
||
|
||
degre = (c[0]-48)*10+(c[1]-48);
|
||
min = (c[2]-48)*10+(c[3]-48);
|
||
|
||
n++;
|
||
do {
|
||
secondes= secondes + (c[n]-48)*pow(10,i);
|
||
i--;
|
||
n++;
|
||
} while (c[n]!='\0');
|
||
|
||
res = degre + (min+secondes)/60;
|
||
|
||
return res;
|
||
|
||
}
|
||
|
||
float decode_longitude (char c[]) {
|
||
int n=0, degre=0, cpt=0,i=-1,b,p;
|
||
float min=0, secondes=0, res=0;
|
||
|
||
|
||
do{
|
||
n++;
|
||
} while (c[n]!='.');
|
||
|
||
degre = (c[0]-48)*10+(c[1]-48)+(c[2]-48);
|
||
min = (c[2]-48)*10+(c[3]-48);
|
||
|
||
n++;
|
||
do {
|
||
secondes= secondes + (c[n]-48)*pow(10,i);
|
||
i--;
|
||
n++;
|
||
} while (c[n]!='\0');
|
||
|
||
res = degre + (min+secondes)/60;
|
||
|
||
return res;
|
||
|
||
}
|
||
|
||
float decode_lat_long (char c[]) {
|
||
int n=0, degre=0, cpt=0,i=-1;
|
||
float min=0, secondes=0, res=0;
|
||
int n=0, degre=0,i=1,b;
|
||
float min=0, secondes=0, res=0,p;
|
||
|
||
|
||
do{
|
||
... | ... | |
degre = (c[0]-48)*10+(c[1]-48);
|
||
min = (c[2]-48)*10+(c[3]-48);
|
||
} else {
|
||
degre = (c[0]-48)*100+(c[1]-48*10)+(c[2]-48);
|
||
min = (c[2]-48)*100+(c[3]-48)*10+(c[4]-48);
|
||
degre = (c[0]-48)*100+(c[1]-48)*10+(c[2]-48);
|
||
min = (c[3]-48)*10+(c[4]-48);
|
||
}
|
||
|
||
n++;
|
||
do {
|
||
secondes= secondes + (c[n]-48)*pow(10,i);
|
||
i--;
|
||
p=1;
|
||
for (b=0;b<i;b++) {
|
||
p=p*0.1;
|
||
}
|
||
secondes= secondes + (c[n]-48)*p;
|
||
i++;
|
||
n++;
|
||
} while (c[n]!='\0');
|
||
|
||
... | ... | |
}
|
||
}
|
||
|
||
void test_decode_latitude(void) {
|
||
if ((37,387458 - decode_latitude("3723.2475") > 0.0001) && (37,387458 - decode_latitude("3723.2475") < 0.0001)){
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
|
||
void test_decode_lat_long(void) {
|
||
float a,b,c,e;
|
||
a= 37.387458 - decode_lat_long("3723.2475");
|
||
c= 45.760703 - decode_lat_long("4545.6422");
|
||
b=3.11006 - decode_lat_long("00306.6036");
|
||
e= 3.110077 - decode_lat_long("00306.6046");
|
||
|
||
}
|
||
|
||
void test_decode_longitude(void) {
|
||
if ((3,11006 - decode_longitude("00306.6036") > 0.0001) && (3,11006 - decode_longitude("00306.6036") < 0.0001)){
|
||
if (a*a > 0.000001){
|
||
printf("erreur");
|
||
exit(-1);
|
||
}
|
||
}
|
||
|
||
void test_decode_lat_long(void) {
|
||
if ((37,387458 - decode_lat_long("3723.2475") > 0.0001) && (37,387458 - decode_lat_long("3723.2475") < 0.0001)){
|
||
printf("erreur");
|
||
if (b*b > 0.000001){
|
||
printf("erreur2");
|
||
exit(-1);
|
||
}
|
||
if ((3,11006 - decode_lat_long("00306.6036") > 0.0001) && (3,11006 - decode_lat_long("00306.6036") < 0.0001)){
|
||
printf("erreur");
|
||
if (c*c > 0.000001){
|
||
printf("erreur2");
|
||
exit(-1);
|
||
}
|
||
if (e*e > 0.000001){
|
||
printf("erreur2");
|
||
exit(-1);
|
||
}
|
||
|
||
}
|
||
|
Formats disponibles : Unified diff
fonction générique (long/lat) + test = ok (10)