Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.emacs.help > #60677
| Path | csiph.com!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail |
|---|---|
| From | Richard Smith <null@void.com> |
| Newsgroups | gnu.emacs.help |
| Subject | elisp program nautical - more elegant way? |
| Date | Wed, 15 Mar 2023 07:47:05 +0000 |
| Organization | BlueWorld Hosting Usenet (https://usenet.blueworldhosting.com) |
| Message-ID | <lybkkupibq.fsf@void.com> (permalink) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | nnrp.usenet.blueworldhosting.com; logging-data="15078"; mail-complaints-to="usenet@blueworldhosting.com" |
| User-Agent | Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin) |
| Cancel-Lock | sha1:aFoCpiGjIhrWlTZZS6XKad99QB8= sha1:rZB2ceaFRqiV5tasaPyPeUf/TSw= sha256:y1YU7MhsCzQcM5aJdDMiB/gFRUCncupzWR0rOgnh21A= sha1:Q0fR3E6POcYJ4JLwDt1Fi15471g= sha256:R51Rh529USQ6ZegS2kLU4DHevhUq4OdZx2qlXa1XkIg= |
| Xref | csiph.com gnu.emacs.help:60677 |
Show key headers only | View raw
Hi there.
Pardon asking on
gnu.emacs.help
with simple programming question.
Program runs inside emacs, but does a nautical calculation - converts
Google Maps' latitude and longitude in degrees-decimal to the Degrees
Minutes and Seconds of a nautical chart - the human-usable type which
has been around for centuries.
Question is - is there a better way of doing my calculation?
My skills are centred on metals and welding - hence what I have done
which seems to work might be a risible way of doing the task.
I looked on the web, and if I understand rightly those using an "algol
family" eg. BASIC language do something like.
The printed format with zero-padding - that is for the nautical
purpose of reminding you to state the zero's on radio-messages.
;;; When copying-and-pasting "Google Maps" degdeci lat. and long.,
;;; delete the comma between the values !!!
(defun lat-long-degdeci-to-dms (latdeci longdeci)
(format "%s %s %s"
(abs-degdeci-to-abs-deg-min-sec (abs latdeci) (if (minusp latdeci) 'S 'N))
" " ;; easy jdi customisable way to separate lat. and long. output
(abs-degdeci-to-abs-deg-min-sec (abs longdeci) (if (minusp longdeci) 'W 'E))))
(defun abs-degdeci-to-abs-deg-min-sec (absdegdeci dirncardinal)
"Deg-decimal to DMS format output"
(if (minusp absdegdeci)
"error - cannot handle negative arguments"
(let ((decix60 (* (mod absdegdeci 1) 60)))
(format "%03dd %02d' %04.1f'' %s" (truncate absdegdeci) (truncate decix60) (* (mod decix60 1) 60) dirncardinal))))
;; (lat-long-degdeci-to-dms 50.39954886056384 -3.483553379652956)
;; "050d 23' 58.4'' N 003d 29' 00.8'' W"
;;; 050 23' 58.4" N 003 29' 00.8" W
;;; will go back into Google Maps
;;; Will find you a lighthouse (maritime navigation)
Back to gnu.emacs.help | Previous | Next — Next in thread | Find similar
elisp program nautical - more elegant way? Richard Smith <null@void.com> - 2023-03-15 07:47 +0000 Re: elisp program nautical - more elegant way? Richard Smith <null@void.com> - 2023-03-17 10:09 +0000
csiph-web