Philip,
 
You can use the following _expression_ to get the DMS representation of any latitude or longitude decimal value:
 
Fix(-123.12345)+Chr$(176)+Abs(Fix(60*(-123.12345-Fix(-123.12345))))+"'"+Abs(3600*(-123.12345-Fix(-123.12345)-Fix(60*(-123.12345-Fix(-123.12345)))/60))+Chr$(34)
 
or to make it easier to search and replace:
 
Fix(LatOrLonVal)+Chr$(176)+Abs(Fix(60*(LatOrLonVal-Fix(LatOrLonVal))))+"'"+Abs(3600*(LatOrLonVal-Fix(LatOrLonVal)-Fix(60*(LatOrLonVal-Fix(LatOrLonVal)))/60))+Chr$(34)
 
 
 
If you evaluate the first example above in the MapBasic window with a print statement then you will get the following:   -123°7'24.42" which is the correct representation in DMS.  You can use the Format$() function on the portion of the _expression_ after the +"'"+ and before +Chr$(34) to vary the amount of decimal places in the seconds value.
 
Please note that this _expression_ will regardless of the sign (pos/neg) of the value due to the Abs() function used on the minutes and seconds values.
 
There may be a more elegant _expression_.  I'd love to see it.

 
Cheers,
John Hollingsworth
GIS Manager - Outdoor IT
Clear Channel Outdoor
w) 919-789-4100x4169
c) 919-332-1869
f) 919-789-4190
NAC: 8FGHR NZ2WZ
LEGAL NOTICE: Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this e-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this e-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lesnik, Phillip S
Sent: Friday, November 11, 2005 3:04 PM
To: MAPINFO Discusion Group
Subject: [Mapinfo-l] Converter from Degrees to Degrees, Minutes, Seconds

Group.
 
I'm using the "Converter" tool that I believe came with MapInfo.  When I take a lat/long in degrees and convert it to DMS, the program spits it out like this 67865.251
 
I need it to spit it out like
67o86' 5.251"
 
 
Can anyone help me?
 
 

Philip Lesnik

Research Systems Analyst

Market Research Dept.

General Growth Properties

www.generalgrowth.com

NYSE:  GGP

110 N. Wacker Drive

Chicago, IL  60606

Phone: 312-960-2998

BSC - 3N13G

 


+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Notice: This e-mail including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. §§ 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

_______________________________________________
Mapinfo-l mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to