Diff of /trunk/src/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by harbaum, Sat Jun 20 11:08:47 2009 UTC revision 34 by harbaum, Wed Jul 29 19:24:15 2009 UTC
# Line 65  void pos_lat_str(char *str, int len, flo Line 65  void pos_lat_str(char *str, int len, flo
65    char *c = _("N");    char *c = _("N");
66    float integral, fractional;    float integral, fractional;
67    
68    if(latitude < 0) { latitude = fabs(latitude); c = _("S"); }    if(isnan(latitude))
69    fractional = modff(latitude, &integral);      str[0] = 0;
70      else {
71        if(latitude < 0) { latitude = fabs(latitude); c = _("S"); }
72        fractional = modff(latitude, &integral);
73    
74    snprintf(str, len, "%s %02d° %06.3f'", c, (int)integral, fractional*60.0);      snprintf(str, len, "%s %02d° %06.3f'", c, (int)integral, fractional*60.0);
75      }
76  }  }
77    
78  GtkWidget *pos_lat(float latitude, int size, int strikethrough) {  GtkWidget *pos_lat(float latitude, int size, int strikethrough) {
# Line 82  void pos_lon_str(char *str, int len, flo Line 86  void pos_lon_str(char *str, int len, flo
86    char *c = _("E");    char *c = _("E");
87    float integral, fractional;    float integral, fractional;
88    
89    if(longitude < 0) { longitude = fabs(longitude); c = _("W"); }    if(isnan(longitude))
90    fractional = modff(longitude, &integral);      str[0] = 0;
91      else {
92        if(longitude < 0) { longitude = fabs(longitude); c = _("W"); }
93        fractional = modff(longitude, &integral);
94    
95    snprintf(str, len, "%s %03d° %06.3f'", c, (int)integral, fractional*60.0);      snprintf(str, len, "%s %03d° %06.3f'", c, (int)integral, fractional*60.0);
96      }
97  }  }
98    
99  GtkWidget *pos_lon(float longitude, int size, int strikethrough) {  GtkWidget *pos_lon(float longitude, int size, int strikethrough) {
# Line 233  pos_t *get_pos(appdata_t *appdata) { Line 241  pos_t *get_pos(appdata_t *appdata) {
241  }  }
242    
243  void distance_str(char *str, int len, float dist, gboolean imperial) {  void distance_str(char *str, int len, float dist, gboolean imperial) {
244    if(imperial) {    if(isnan(dist))
245        snprintf(str, len, "---");
246      else if(imperial) {
247      /* 1 mil = 1760 yd = 5280 ft ... */      /* 1 mil = 1760 yd = 5280 ft ... */
248      if(dist<0.018)      snprintf(str, len, "%.1f ft", dist*5280.0);      if(dist<0.018)      snprintf(str, len, "%.1f ft", dist*5280.0);
249      else if(dist<0.055) snprintf(str, len, "%.1f yd", dist*1760.0);      else if(dist<0.055) snprintf(str, len, "%.1f yd", dist*1760.0);

Legend:
Removed from v.1  
changed lines
  Added in v.34