Révision 648
Ajouté par mukis il y a presque 4 ans
branch/KIS/sp4a12/main.c | ||
---|---|---|
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <strings.h>
|
||
#include <strings.h>
|
||
#include <math.h>
|
||
#include "trame.h"
|
||
|
||
//Trames de tests ? modifier si n?cessaire.
|
||
... | ... | |
}
|
||
}
|
||
|
||
float decode_int(char ch)
|
||
int decode_int(char ch)
|
||
{
|
||
float dec;
|
||
int dec;
|
||
|
||
if(ch<='9' && ch>='0')
|
||
{
|
||
... | ... | |
|
||
float conversion_latitude (char *lat_c)
|
||
{
|
||
int i, k=2;
|
||
int i=0, k=2;
|
||
float lat_f=0;
|
||
|
||
for (i=0;i<'\0';i++)
|
||
for (i=0;i< 9;i++)
|
||
{
|
||
if (lat_c[i]<='9' && lat_c[i]>='0')
|
||
{
|
||
if (i<=2)
|
||
if (i<=1)
|
||
{
|
||
lat_f = lat_f*10 + decode_int(lat_c[i])*10^(k);
|
||
k--;
|
||
lat_f = lat_f + decode_int(lat_c[i])*powf(10,k);
|
||
|
||
}
|
||
else
|
||
{
|
||
lat_f = lat_f*10 + decode_int(lat_c[i])/(6*10^(k));
|
||
lat_f = lat_f + decode_int(lat_c[i])/(6*powf(10,k));
|
||
k++;
|
||
}
|
||
}
|
||
... | ... | |
continue;
|
||
}
|
||
}
|
||
lat_f = lat_f/10^6;
|
||
printf("\nlatitude :%d\n",lat_f);
|
||
return lat_f;
|
||
}
|
||
|
||
/*float conversion_longitude (char *long_c)
|
||
float conversion_longitude (char *long_c)
|
||
{
|
||
int i, k=2;
|
||
int i, k=3;
|
||
float long_f=0;
|
||
|
||
for (i=0;i<'\0';i++)
|
||
for (i=0;i<10;i++)
|
||
{
|
||
if (long_c[i]<='9' && long_c[i]>='0')
|
||
{
|
||
if (i<=2)
|
||
{
|
||
long_f = long_f*10 + decode_int(long_c[i])*10^(k);
|
||
k--;
|
||
long_f = long_f + decode_int(long_c[i])*powf(10,k);
|
||
}
|
||
else
|
||
{
|
||
long_f = long_f*10 + decode_int(long_c[i])/(6*10^(k));
|
||
long_f = long_f + decode_int(long_c[i])/(6*powf(10,k));
|
||
k++;
|
||
}
|
||
}
|
||
... | ... | |
continue;
|
||
}
|
||
}
|
||
long_f = long_f/10^6;
|
||
return long_f;
|
||
}*/
|
||
}
|
||
|
||
float conversion_lat_long (char *c)
|
||
{
|
||
int i=0;
|
||
|
||
while (c[i] != '.')
|
||
{
|
||
i++;
|
||
}
|
||
|
||
if (i<=4)
|
||
{
|
||
conversion_latitude (c);
|
||
}
|
||
if (i>=5)
|
||
{
|
||
conversion_longitude (c);
|
||
}
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
... | ... | |
printf ("Erreur Test unitaire decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
if (conversion_latitude("10345,1234")!=1){
|
||
printf ("Erreur Test unitaire conversion latitude.\n");
|
||
if ((conversion_lat_long("7501.2000") < (0.93*75.02)) || (conversion_lat_long("7501.2000") > (1.03*75.02))){
|
||
printf ("Erreur Test unitaire conversion lat_long.\n");
|
||
exit(-1);
|
||
}
|
||
/* if (conversion_latitude("10345,1234")!=1){
|
||
/*if ((conversion_latitude("7501.2000") < (0.93*75.02)) || (conversion_latitude("7501.2000") > (1.03*75.02))){
|
||
printf ("Erreur Test unitaire conversion latitude.\n");
|
||
exit(-1);
|
||
}
|
||
if ((conversion_longitude("10345.1234") < (0.93*103.752056)) || (conversion_longitude("7501.2000") > (1.03*103.752056))){
|
||
printf ("Erreur Test unitaire conversion longitude.\n");
|
||
exit(-1);
|
||
}*/
|
||
}
|
||
|
||
... | ... | |
|
||
return 0;
|
||
}
|
||
|
Formats disponibles : Unified diff
Fin du TP1