When using "geo fix" from the console, some information is truncated
due to poor casting in the code of external/qemu/android/console.c. I
came across that problem when plugging in coordinates for my house and
realizing whatever location was being sent to the emulator was off by
a few blocks.
The stralloc_add_format statements were changed in order to print the
floating point values most accurately.
Plus, the stralloc_add_format for altitude was changed to %.1lf (long
float/double) instead of %.1g. g may use scientific notation and I
don't think that's what they want when there's only one digit after
the decimal point.
The original code was (~ line 2000):
---------------------------------------------
/* then the latitude */
hemi = 'N';
val = params[1];
if (val < 0) {
hemi = 'S';
val = -val;
}
deg = (int) val;
min = 60*(val - deg);
val = val - min/60.;
stralloc_add_format( s, ",%02d%02d.%04d,%c", deg, min, (int)
(val * 10000), hemi );
/* the longitude */
hemi = 'E';
val = params[0];
if (val < 0) {
hemi = 'W';
val = -val;
}
deg = (int) val;
min = 60*(val - deg);
val = val - min/60.;
stralloc_add_format( s, ",%02d%02d.%04d,%c", deg, min, (int)
(val * 10000), hemi );
/* bogus fix quality, empty satellite count and dilutions */
stralloc_add_str( s, ",1,,,," );
/* optional altitude */
if (n_params >= 3) {
stralloc_add_format( s, "%.1g", params[2] );
last_altitude = params[2];
} else {
stralloc_add_str( s, "," );
}
---------------------------------------------
Please fix the code to the following.
---------------------------------------------
/* first, the time */
stralloc_add_format( s, "$GPGGA,%06d", last_time );
last_time ++;
/* then the latitude */
hemi = 'N';
val = params[1];
if (val < 0) {
hemi = 'S';
val = -val;
}
deg = (int) val;
min = 60.0 * (val - deg);
stralloc_add_format( s, ",%02d%07.4lf,%c", deg, min, hemi );
/* the longitude */
hemi = 'E';
val = params[0];
if (val < 0) {
hemi = 'W';
val = -val;
}
deg = (int) val;
min = 60.0 * (val - deg);
stralloc_add_format( s, ",%02d%07.4lf,%c", deg, min, hemi );
/* bogus fix quality, empty satellite count and dilutions */
stralloc_add_str( s, ",1,,,," );
/* optional altitude */
if (n_params >= 3) {
stralloc_add_format( s, "%.1lf", params[2] );
last_altitude = params[2];
} else {
stralloc_add_str( s, "," );
}
---------------------------------------------
This code fixes the issue.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en