Skip Menu |

This queue is for tickets about the Geo-Coordinates-DecimalDegrees CPAN distribution.

Report information
The Basics
Id: 22753
Status: resolved
Priority: 0/
Queue: Geo-Coordinates-DecimalDegrees

People
Owner: Nobody in particular
Requestors: tim.flohrer [...] aiub.unibe.ch
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: conversion of angle between -1 and 0
Date: Thu, 02 Nov 2006 12:40:48 +0100
To: bug-Geo-Coordinates-DecimalDegrees [...] rt.cpan.org
From: Tim Flohrer <tim.flohrer [...] aiub.unibe.ch>
Dear Walter, it appears that there is an error in Geo-Coordinates-DecimalDegrees in version 0.05. I am using perl v5.8.7 built for x86_64-linux-thread-multi on a "Linux aiuli1 2.6.13-15.10-smp #1 SMP Fri May 12 16:11:24 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux". Consider the following: perl -e 'use Geo::Coordinates::DecimalDegrees; printf("%d %d %f\n",decimal2dms(-0.987))' gives: 0 59 13.200000 which is wrong. Of course, the following: perl -e 'use Geo::Coordinates::DecimalDegrees; printf("%d %d %f\n",decimal2dms(-1.987))' returning: -1 59 13.20000 is correct. I guess, a possible fix would be to include the sign of the angle in the returned data explicitly and to require the user to handle this like "$deg*=-1 if($sign)", if i.e. decimal2dms reads like: sub decimal2dms { my ($decimal) = @_; $sign=''; $sign='-' if ($decimal<0.); $decimal=abs($decimal); my $degrees = int($decimal); # convert decimal part to minutes my $dec_min = abs($decimal - $degrees) * 60; my $minutes = int($dec_min); my $seconds = ($dec_min - $minutes) * 60; return ($sign, $degrees, $minutes, $seconds); } Best regards, Tim -- Show quoted text
________________________________________________________________________ Tim Flohrer eMail: tim.flohrer@aiub.unibe.ch Astronomical Institute www: http://www.aiub.unibe.ch/ University of Bern Sidlerstrasse 5 Phone: +41-31-631 38 92 CH-3012 Bern, Switzerland Fax: +41-31-631 38 69
________________________________________________________________________
I just uploaded a new version of Geo-Coordinates-DecimalDegrees to address this problem. I did essentially what Tim suggested, but with two minor changes: 1. I return the sign as 1, 0, or -1 instead of "-" or "". 2. I return the sign as the last element in the list returned by decimal2dms() and decimal2dm() instead of as the first element. This way it won't break the code of people who are already calling those functions.