If i try to do it in a single line the arduino will explode.
Waiting for the hardware to be powered up is one thing. Waiting for the GPS to have acquired satellites and actually received a fix are two completely different things.
initdistance=calc_dist(latitude(),longitude(), inputlon, inputlat);// input long and latitude
initbearing=calc_bear(latitude(),longitude(), inputlon, inputlat);// initial bearing and distance
Declaring local variables that immediately go out of scope isn't useful.
float latitude()//get latitude
lat[i] = Serial.read();
There is so much wrong here that it's hard to know where to begin.
This function calls ID() which might return 0 in a char. Stupid, really, as ID should return false in a boolean. Regardless, if ID() doesn't return true, this function ends WITHOUT returning anything. Bullshit.
Since the purpose of the subtraction is to convert 'n' to n, 'n' - '0' is MUCH more obvious.
//process the data array
Suppose that the array contains "12345.6789". When this gets done, temp will contain 1234.
Then, you skip the decimal place, and read and process 5 of the next 4 characters. Nonsense.
Your Datatransfer function is an attempt to reinvent atof(). Why?
Why do you ASSUME that the GPS will return a specific number of digits after the decimal point?
Why do you assume that there are exactly 10 characters in each field of the $GPGGA sentence?
Why do you assume that there will be exactly 10 characters after the second comma that represents latitude? Why do you assume that every one of those 10 characters is either a decimal point or a character that represents a digit?
int motor = 0;
int motor2= 1;
The loop() function does NOT take arguments.
if(float dist =! 0 )
declaring a local variable, with no initial value, and then comparing that to a specific value is stupid.
It's no wonder why you don't get valid data, given all of the assumptions you are making but not validating.