7

If degrees is zero, how should Degree Minute Second notation reflect the positive/negative hemisphere? What is the appropriate behavior when degree is zero? Basically this is a Signed Zero problem. https://en.wikipedia.org/wiki/Signed_zero

We have a software system in C/Python that converts GPS NMEA coordinates to DMS (degree (integer), minute (integer), second (float)). Normally hemisphere would be indicted by a positive or negative degree.

Given, for example, the University of Reading.

$GPGGA,100612,5126.48,N,00056.51,W,1,9,0.9,54.9,M,47.0,M,,*54

Decimal Degrees is 51.441400, -0.941800. DMS is 51°26'29.040000"N, 0°56'30.480000"W

Converting to integer, integer, float, we get:

longitude degree=0 minute=56 second=30.479999999999734  

We lose hemisphere because no signed zero.

Is it appropriate to use negative minutes when degree is zero? Continuing, is it appropriate to use negative seconds if both degree and minute are zero?

For example: longitude degree=0 minute=-56 second=30.479999999999734

Using negative minutes, negative seconds (fixing the bug) would allow us to preserve backwards compatibility with existing code. Adding a "hemisphere" is an option but would imply dropping sign entirely which might cause backwards compatibility problems.

2
  • 1
    What about including a new parameter for sign: longitude sign='-' degree=0 minute=56 second=30.479999999999734 ?
    – Midavalo
    Sep 23, 2016 at 18:34
  • That's a good idea. It's similar to adding the hemisphere but requires less computation to convert S,W to negative. But it's a little less intuitive and does tend to deviate from standard practice. Sep 25, 2016 at 16:11

1 Answer 1

3

If possible, stay in decimal degrees and eschew DMS, but sounds like you must.

Negative minutes and Negative seconds seems the most appropriate path, placing the negative on the degrees, then the minutes and then the seconds.

Because putting a negative on a zero is wrong, put it in on the minute if it is not zero first and then the second if both degree and minute are zero.

However assigning a hemisphere is also correct.

Both solutions of negative and hemisphere notation are used, so not a problem as for as precedent.

Doing them together would be wrong.

It is accounting for the misuse and programming around it that is challenging.

Here is how this company does it and they are much wiser and math inclined than I:

http://www.mathworks.com/help/map/ref/dms2degrees.html?requestedDomain=www.mathworks.com

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.