On 2014-04-05 20:17, Linus Torvalds wrote:
Oh. Please don't do that. Just fix the printing of the latitude/longitude. %f is wrong, wrong, wrong, for this and other reasons. We try to avoid floating point in subsurface for a reason.See (for example) save-git.c: put_degrees()/show_gps() on how to do it right. Linus
I was ignorant of the %f problem. I fixed the patch, Is this right ? -- Regards, Gehad Elrobey
>From a44bf034915b90bf3b460dec3c2fa0c732bd9a42 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Sat, 5 Apr 2014 20:44:35 +0200 Subject: [PATCH] Fixing the printing of lat/lon in worldmap exporter. Fixing the printing formate because the former floating point number caused some failures. Signed-off-by: Gehad elrobey <[email protected]> --- worldmap-save.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/worldmap-save.c b/worldmap-save.c index 0c40bc3..64257a9 100644 --- a/worldmap-save.c +++ b/worldmap-save.c @@ -83,6 +83,18 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive) } } +static void put_degrees(struct membuffer *b, degrees_t value, const char *supp) +{ + int udeg = value.udeg; + const char *sign = ""; + + if (udeg < 0) { + udeg = -udeg; + sign = "-"; + } + put_format(b, "%s%u.%06u%s", sign, FRACTION(udeg, 1000000), supp); +} + void writeMarkers(struct membuffer *b) { int i, dive_no = 0; @@ -94,8 +106,9 @@ void writeMarkers(struct membuffer *b) if (dive->latitude.udeg == 0 && dive->longitude.udeg == 0) continue; - put_format(b, "temp = new google.maps.Marker({position: new google.maps.LatLng(%f,%f)});\n", - dive->latitude.udeg / 1000000.0, dive->longitude.udeg / 1000000.0); + put_format(b, "temp = new google.maps.Marker({position: new google.maps.LatLng("); + put_degrees(b, dive->latitude, ","); + put_degrees(b, dive->longitude, ")});\n"); put_string(b, "markers.push(temp);\ntempinfowindow = new google.maps.InfoWindow({content: '<div id=\"content\">'+'<div id=\"siteNotice\">'+'</div>'+'<div id=\"bodyContent\">"); put_HTML_date(b, dive); put_duration(b, dive->duration, "<p>duration=", " min</p>"); -- 1.8.3.2
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
