Hello,

I've been trying to write unit tests for convert_dms_to_dec() function.
Judging by the name, and by quickly glancing at implementation, the
function should convert coordinate in DMS format into a double, so:
"120.20.30" -> some value
It would also seem that gdouble d, m, s variables would contain 120, 20 and
30 respectively. m and s are then (at the bottom of the function) divided
by 60 (minutes per degree) and 3600 (seconds per degree) and summed to form
proper value of degrees in DEC format.

However the function doesn't really work this way. g_strtod() used to
convert DMS string to doubles first consumes 120.20, and then remaining
.30, so the d and m values are set incorrectly, and s is not set at all.
This means that division (by 60 and 3600) and summation at the bottom of
the function *would* yield bad results.

I'm writing "would" because the function is never actually used to convert
string with coordinate in DMS format into double. If I see this correctly,
it it is always called to convert string in form "xx.yyyyyy" (with possible
-/w/W/s/S prefix) into double, so these usages will work correctly:
g_strtod() will be called only once, and only "gdouble d" will be set.

There is only a risk that someone someday will use the function for
conversion from DMS to DEC, and the conversion will fail. Also for the way
the function is currently used, its implementation is overly complicated :)

Please let me know if any of this makes sense.

Best regards,
Kamil
_______________________________________________
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/

Reply via email to