还有一个将点转换为平铺名称的例程。
这一个不需要assoc列表。
- (defun floor (x) (if (minusp (rem x 1)) (- (fix x) 1) (fix x)))
- ;; Translated to Autolisp from a C# routine by Alex@UEA ;
- ;; http://www.codeproject.com/Articles/13577/GPS-Deriving-British-Ordnance-Survey-Grid-Referenc ;
- (defun pt->ngr (p / eing ex ning nx tm)
- (setq ex (/ (car p) 500000)
- nx (/ (cadr p) 500000)
- tm (+ (- (floor ex) (* 5 (floor nx))) 17)
- nx (* 5 (- nx (floor nx)))
- ex (+ (- 20 (* 5 (floor nx)) (floor (* 5 (- ex (floor ex))))))
- ex (if (> ex 7) (1+ ex) ex)
- tm (if (> tm 7) (1+ tm) tm)
- eing (rtos (car p) 2 0)
- ning (rtos (cadr p) 2 0)
- eing (substr eing 2 (- (strlen eing) 4))
- ning (substr ning 2 (- (strlen ning) 4))
- )
- (strcat (chr (+ tm 65)) (chr (+ ex 65)) eing ning)
- )
|