GPS Help


i'm working on gps program takes current location , compares destination location , returns distance in miles if it's more 1 mile , feet if it's less mile.  the program works fine till less 4,000 feet destination.  at point returns i'm @ destination.  i'm using tinygps , using f_get_position command works fine.  just reason when difference between 2 numbers small enough program rounds 0.

i'm not concerned being extremely accurate distance  (just enough know you're getting closer destination) i'm using simple pathagoren theorem figure distance.  

all variables declared float , destlat , destlon random point within mile of current location testing.

what need able can find distance when i'm within 20ft

code: [select]

 while (nss.available())
 {
   int c = nss.read();
   if (gps.encode(c))
   {
     gps.f_get_position(&lat, &lon);
     
 
     //calculates distance between 2 points
     if (destlat > lat)
     {
       deltalat = destlat - lat;
     }
     else
     {
       deltalat = lat - destlat;
     }
 
     int deg, mins;
     float temp;
     
     deg = deltalat/1;
     temp = deltalat -deg;
     mins = temp*60.00;
     //convert degs miles.
     deltalat = (deg*69.00)+(mins*1.15);
     
     
     if (destlon > lon)
     {
       deltalon = destlon - (0-lon);
     }
     else
     {
       deltalon = (0-lon) - destlon;
     }
     
     deg = deltalon/1;
     temp = deltalon -deg;
     mins = temp*60.00;
     //convert degs miles
     deltalon = (deg*53.00)+(mins*.88);
     
     
     float temp1, temp2;
     temp1 = sq(deltalat);
     temp2 = sq(deltalon);
     hyp = sqrt(temp1 + temp2);
     feet = hyp*5280;
   }
 }

you don't give clues types of variables lat, lon, deltalat etc etc.  the 4000 feet thing imediately suggests rounding integral number of miles - thats guess.

btw can't work out distance lat & lon without using sort of cosine term in latitude - may not critical unless planning go poles, lead big errors outside tropics.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > GPS Help


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums