Jump to content

Recommended Posts

Posted

I need your help to modify this lisp a lisp credit to Mr. "Mc Lee" instead of coordinates i want to plot thru "latitude and longitude"

 

attached file:

:)

test.txt

BDimp.LSP

Posted

This is a re-write of the original (but still in Cartesian):

 

(defun c:bdimp (/ StrBrk mk_pt mk_txt FILE LST NL PT)
 (vl-load-com)

 (defun StrBrk (str chrc / pos lst)
   (while (setq pos (vl-string-position chrc str))
     (setq lst (cons (substr str 1 pos) lst)
           str (substr str (+ pos 4)))) ;;Mod
   (reverse (cons str lst)))
 
 (defun mk_pt (p) (entmake (list '(0 . "POINT") '(8 . "COORD") (cons 10 p))))
   
 (defun mk_txt  (pt val)
   (entmake (list (cons 0 "TEXT")
                  (cons 8 "POINT NUMBER")
                  (cons 10 pt)
                  (cons 40 1.6)
                  (cons 1  val))))
   
 (if (setq file (getfiled "Select Text File" (if *load$file* *load$file* "") "txt" 16))
   (progn
     (setq *load$file* file file (open file "r"))
     
     (while (setq nl (read-line file))
       (setq lst (cons (StrBrk nl 32) lst))) (close file)
     
     (foreach line lst        
       (mk_pt (setq pt (mapcar 'distof (list (cadr line) (caddr line) "0"))))
       (mk_txt pt (car line)))))
   
 (princ))  

Posted

i got error Mr. Lee

"bad DXF group: (10 nil nil 0.0)"

Posted
i got error Mr. Lee

"bad DXF group: (10 nil nil 0.0)"

 

I did say that the above was for Cartesian. I'm guessing you tried it with Longitude/Latitude.

Posted

I've never converted Longitude to Latitude, so this is a bit of a learning exercise for me, but my method in this code is:

  • Convert Deg-Min-Sec to Radians
  • Using Spherical Polars, convert Radians to Cartesian (using radius of Earth).
  • Plot the result.

;; Plotting Longitude/Latitude  ~  Lee McDonnell (Lee Mac)  ~  12.12.2009

(defun c:bdimp (/ rad StrBrk mk_pt mk_txt get_radians get_cartesian FILE LST NL PT)
 (vl-load-com)

 (setq rad 6378.1) [color=Red][b] ;; Radius of Earth (km)[/b][/color]

 (defun StrBrk (str chrc shift / pos lst)
   (while (setq pos (vl-string-position chrc str))
     (setq lst (cons (substr str 1 pos) lst)
           str (substr str (+ pos shift 2)))) ;;Mod
   (reverse (cons str lst)))
 
 (defun mk_pt (p) (entmake (list '(0 . "POINT") '(8 . "COORD") (cons 10 p))))
   
 (defun mk_txt  (pt val)
   (entmake (list (cons 0 "TEXT")
                  (cons 8 "POINT NUMBER")
                  (cons 10 pt)
                  (cons 40 1.6)
                  (cons 1  val))))

[color=Red][b]  (defun get_radians (deg mins secs)
   (* pi (/ (+ deg (/ mins 60.) (/ secs 3600.)) 180.)))

 (defun get_cartesian (r theta phi)
   (mapcar (function (lambda (x) (if (equal x 0. 1e- 0. x)))
     (list (* r (cos theta) (cos phi))
           (* r (cos theta) (sin phi))
           (* r (sin theta)))))[/b][/color] 
   
 (if (setq file (getfiled "Select Text File" (if *load$file* *load$file* "") "txt" 16))
   (progn
     (setq *load$file* file file (open file "r"))
     
     (while (setq nl (read-line file))
       (setq lst (cons (StrBrk nl 32 2) lst))) (close file)
     
     (foreach line lst  
       (mk_pt (setq pt
                (apply 'get_cartesian
                  (cons rad
                    (mapcar
                      (function
                        (lambda (x)
                          (apply 'get_radians (mapcar 'distof (StrBrk x 45 0))))) (cdr line))))))
       (mk_txt pt (car line)))))
   
 (princ))  

 

I would greatly appreciate it if someone could verify my method, so that I may further my knowledge :)

Posted
I did say that the above was for Cartesian. I'm guessing you tried it with Longitude/Latitude.

i guess i screwed Mr. Lee, how to work this, i tried too this sample...

 

1 123-44-10 8-03-43

2 123-44-12 8-03-41

3 123-44-06 8-03-37

4 123-44-04 8-03-39

5 123-44-03 8-03-34

6 123-44-01 8-03-37

 

base on my file.

 

:(

Posted

My latest code post should work with Longitude/Latitude, assuming a 3-space delimiter.

Posted

its works Mr. Lee..but there is an error the lat. and long is different..

 

snap38.jpg

Posted

Yes, it could be any number of things - the radius, and my method for example.

Posted

well wait Mr. Lee, hear u tomorrow its almost 1:30 am here..and thank you.

Posted
Oliver,

 

How are you retrieving the information in the blue box?

i'm using Land desktop 2009 on the MENU BAR called inquiry lat/long.

 

:)

Posted
i'm using Land desktop 2009 on the MENU BAR called inquiry lat/long.

 

:)

 

Ahh, Ok, I'm not sure ACAD has that capability.

 

Its all in the method used to convert lat/long to cartesian - I wouldn't know the method that the program uses :geek:

Posted

Oliver,

 

I am not sure why you want Lee Mac to write you a lisp when you already have the answer.

 

In your screen shot, you show a Northing and Easting which is then converted to a Grid Northing and a Grid Easting, which then reports the Convergence and Scale factor before it gives you a Latitude and Longitude.

 

You have not defined your grid system and the datum point in Latitude and Longitude, and yet you chide Lee Mac for not giving you the correct answer.

 

I just wonder if you are presuming too much on Lee Mac's good nature. Perhaps more information from you will clarify the situation.

Posted

From the Latitude and Longitude quoted, you may or may not be in the Philippines.

 

This article may give more information.

Posted
You have not defined your grid system and the datum point in Latitude and Longitude, and yet you chide Lee Mac for not giving you the correct answer.

 

I just wonder if you are presuming too much on Lee Mac's good nature. Perhaps more information from you will clarify the situation.

 

Thanks Eldon - appreciate it.

Posted

@ eldon..thanks for info, since the beginning the cadastral in the phil are using local coordinates which all references from the different city and municipalities(mostly N-40000.00, E-40000.00) are the same, but the lat & long are true..in other word to compute the exact location of lot, from local coor to geographic position base on lat/long.

 

@ Mr. Lee

thanks all the effort, appreciate it.

 

oliver

Posted

Again I am not sure why you want this lisp if you already have the answer from Land desktop. :? Surely you have all the local factors for your locality built in? If not, then contact AutoCAD.

 

Perhaps it is to save time, but Lee Mac has already been asked to write a lisp to make coffee, and I understand it is still on the wish list :D

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...