rcb007 Posted May 13, 2021 Posted May 13, 2021 I am working with a routine that is supposed to list the long and lat of a picked point within the geolocation map inside civil3d. It seems like the Latitude that it show when I pick a spot on the map shows all negative degrees mins and seconds. Not sure how to fix that. Hopefully its something i missed. ; Convert Decimal Degrees to dms. (defun convertDDdms (x1 / deg mins sec ) (setq deg (rtos (fix X1)2 0) ;- degrees mins (rtos (fix (* (- X1 (fix X1))60))2 0) ; - minutes sec (rtos (* (- (* X1 60) (fix (* x1 60)))60) 2 4) ;- seconds ) (strcat deg " D " mins " M " sec " S ") ) (defun c:longlat (/ as_cor ll lat lon pkpt) (Alert "A Coordinate System Must be set.\nPick Point...") (setq as_cor (ade_projgetwscode)) (if (/= "" as_cor) ;checks for an assigned coordinate system (progn (ade_projsetsrc as_cor) (ade_projsetdest "LL84") ; uses lat/lon with no datum change as needed (while (not (setq pkpt (getpoint "\nSelect a point: ")))) (progn (setq ll (ade_projptforward pKpt)) (setq lat (car ll) lon (car (cdr ll)) ) (setq desc (ade_projgetinfo "LL84" "description")) (alert (strcat "\nLatitude: " (convertDDdms lat) "\nLongitude:" (convertDDdms lon) "\nHorizontal Datum: NAD83" "\n " "\nConverted from: "as_cor "\nConverted to: " desc ) ) (princ) );progn );progn (asg_coor) );if );defun Thank you for any help!! Quote
mhupp Posted May 13, 2021 Posted May 13, 2021 (edited) You can set the mins and seconds to positive by adding abs function. ; Convert Decimal Degrees to dms. (defun convertDDdms (x1 / deg mins sec) (setq deg (rtos (fix X1) 2 0) ;- degrees mins (rtos (abs (fix (* (- X1 (fix X1)) 60))) 2 0) ; - minutes sec (rtos (abs (* (- (* X1 60) (fix (* x1 60))) 60)) 2 4) ;- seconds ) (strcat deg "° " mins "' " sec "\"")) ) So -16.1382675 is showing up as Latitude: -16° -8' -17.7630" with abs added it will look like this Latitude: -16° 8' 17.7630" Edited May 13, 2021 by mhupp 1 Quote
rcb007 Posted May 13, 2021 Author Posted May 13, 2021 Great idea about that. It does make sense what you are showing. I did run the function and it works, but i am getting a difference result with the degrees mins secs in the Alert Box. Not really sure why either. -86° 4' 26.2201" 39° 54' 18.6891" ; Convert Decimal Degrees to dms. (defun convertDDdms (x1 / deg mins sec) (setq deg (rtos (fix X1) 2 0) ;- degrees mins (rtos (abs (fix (* (- X1 (fix X1)) 60))) 2 0) ; - minutes sec (rtos (abs (* (- (* X1 60) (fix (* x1 60))) 60)) 2 4) ;- seconds ) (strcat deg "° " mins "' " sec "\"") ) (defun c:longlat (/ as_cor ll lat lon pkpt) (Alert "A Coordinate System Must be set.\nPick Point...") (setq as_cor (ade_projgetwscode)) (if (/= "" as_cor) ;checks for an assigned coordinate system (progn (ade_projsetsrc as_cor) (ade_projsetdest "LL84") ; uses lat/lon with no datum change as needed (while (not (setq pkpt (getpoint "\nSelect a point: ")))) (progn (setq ll (ade_projptforward pKpt)) (setq lat (car ll) lon (car (cdr ll)) ) (setq desc (ade_projgetinfo "LL84" "description")) (alert (strcat "\nLatitude: " (convertDDdms lat) "\nLongitude:" (convertDDdms lon) "\nHorizontal Datum: NAD83" "\n " "\nConverted from: "as_cor "\nConverted to: " desc ) ) (princ) );progn );progn (asg_coor) );if );defun Quote
mhupp Posted May 13, 2021 Posted May 13, 2021 (edited) 54 minutes ago, rcb007 said: Great idea about that. It does make sense what you are showing. I did run the function and it works, but i am getting a difference result with the degrees mins secs in the Alert Box. Not really sure why either. Not 100% but might be a rounding error. rtos Function Is the same value being used? maybe @ronjonp or @BIGAL can fill you in. -16.1382 returns Latitude: -16° 8' 17.5200" -16.1382675 returns Latitude: -16° 8' 17.7630" Edited May 13, 2021 by mhupp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.