Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

When representing latitude and longitude in degrees, minutes and seconds, with

  • -180 <= D <= 180 (or -90 and 90)
  • 0 <= M < 60 (0 if D is at an extreme)
  • 0 <= S < 60 (0 if D is at an extreme)

How can values between -1 degree and 0 degrees be represented? Since there is no distinction between 0 and -0, there is no way to distinguish between 0:12:34 and -0:12:34.

Is this just a limitation of this kind of representation, or is there some convention that allows it to cover this gap?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I assume you're talking programatically, in which case I would store angles in decimal degrees, and have a function that pretty-prints DMS on demand. It can get a little hairy with rounding, but nothing insurmountable.

If you want to store an angle in DMS form, then you'll need a hemisphere flag to cope with your corner case. You remove the rounding issue, but you do then introduce complexity when comparing and adding angles - nothing a sprinkling of operator overloads won't fix however.

share|improve this answer
    
We are storing angles in decimal degrees, but need to provide the Degrees Minutes and Seconds values on demand, individually (there could be a request for only the minutes of a particular latitude). –  Jim Oct 3 '12 at 15:59
    
(+1) The algorithm, Jim, is to convert the absolute value of DD into DMS and then just tack on the appropriate sign. If you're outputting D, M, and S as numerical values (rather than a string), then you must supply an extra bit of information, as MerseyViking says. This is conventionally done either via north-south-east-west indicators or quite literally as a sign bit. –  whuber Oct 3 '12 at 16:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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