(setq c (* 2 (atan (sqrt a) (sqrt (- 1 a)))))
M、 R。
所以当你拿到2012年的时候,你可能会这样研究。。。
gpsareasph new new new。lsp ***问题已解决***
这正是你应该得到的:
GPS坐标之间的面积为:741875.0平方米
这是我最后一段也是最有效的代码——当然只适用于一个地球半球,我认为它适用于2011年及以后的版本。。。2012年测试。。。
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; gpspronsph function takes GPS coordinates from CSV file, ;;;
;;; and project between points edges as arcs on sphere with radius of planet Earth. ;;;
;;; ;;;
;;; 25.07.2012. Marko Ribar, d.i.a. - first and final release ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:gpspronsph ( / file f csvrow Latt Long gpsdata ER ptx pty ptz pt ptlst k p1 p2 pm pmv1 pmsph )
(vl-cmdf "_.UCS" "w")
(if (ssget "_X")
(progn
(alert "\nDWG must be empty - empty it and start over")
(exit)
)
)
(setq file (getfiled "Select file with GPS coordiantes" "" "csv" 2))
(setq f (open file "r"))
(while (setq csvrow (read-line f))
(setq Latt (substr csvrow 1 (vl-string-position (ascii ",") csvrow)))
(setq Long (substr csvrow (+ (vl-string-position (ascii ",") csvrow) 2) (- (strlen csvrow) (vl-string-position (ascii ",") csvrow) 1)))
(setq gpsdata (cons (list (read Latt) (read Long)) gpsdata))
)
(setq gpsdata (reverse gpsdata))
(setq ER 6371000.0) ; Radius of Earth in m
(foreach gps gpsdata
(setq Latt (car gps))
(setq Long (cadr gps))
(setq ptx (* ER (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians"))))
(setq pty (* ER (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians"))))
(setq ptz (* ER (sin (cvunit Latt "degrees" "radians"))))
(setq pt (list ptx pty ptz))
(setq ptlst (cons pt ptlst))
)
(setq ptlst (reverse ptlst))
(setq k -1)
(repeat (length ptlst)
(setq p1 (nth (setq k (1+ k)) ptlst))
(if (/= k (- (length ptlst) 1))
(setq p2 (nth (+ k 1) ptlst))
(setq p2 (car ptlst))
)
(setq pm (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2))
(setq pmv1 (mapcar '(lambda ( a ) (/ a (distance '(0.0 0.0 0.0) pm))) pm))
(setq pmsph (mapcar '(lambda ( a ) (* a ER)) pmv1))
(vl-cmdf "_.UCS" "3" '(0.0 0.0 0.0) p1 p2)
(vl-cmdf "_.ARC" (trans p1 0 1) "s" (trans pmsph 0 1) (trans p2 0 1))
(vl-cmdf "_.UCS" "p")
)
(vl-cmdf "_.ZOOM" "_E")
(princ)
)
致以崇高的敬意,
M、 R。
gpsareasph new new new。lsp 非常感谢,你的lisp很灵活,我也在写lisp,但我的还处于初级水平,我还在学习,但你的lisp远超我,出于我自己的好奇心,为什么你必须使用“z”坐标?这就是公式的工作原理吗?或者你真的需要一个“z”?
我已经检查了你的立体图,计算很完美,从我的手机上我只能得到周长:5888.34米。
最好的口哨,
克里斯蒂安
克里斯蒂安,谢谢你的评论,不过我必须指出,画弧的lsp是可以的。。。你总是可以用它来获得长度-距离。。。但获取区域的lsp很难预测2个GPS坐标附近的天气角度是大还是小,所以我建议2011年或+并使用我的两个代码-第四个用于大角度,第五个用于小角度,就像你的情况一样。。。我认为将它们结合到sinlge代码中并不是一个很好的解决方案,但可能存在这样的情况,即既有大角度,也有小角度-在这种情况下,你必须找到中间解,并且只需要ACAD将pline转换为区域。。。
M、 R。
Thanks Marko,
I have tried all your codes, but this one works the best for me, since I have just Autocad 2009, and as you said, your last code does not work for me yet, maybe in one day when I will have 2012 version.
Thanks again,
Cristian Thanks Cristian, I've modified further more 3rd code - better finding solid to intersect with on north hemisphere (SURFSCULPT is between regions and north dome surface)... Still with your GPS coordinates I can't convert PLINES into REGIONS, but with some other (larger angles) it does the job...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; gpsareasph function takes GPS coordinates from CSV file, ;;;;;; and project between points edges as arcs on sphere with radius of planet Earth, ;;;;;; determines contour shape of peace of ground, ;;;;;; for witch if finds approx. correct area value. ;;;;;; 30.07.2012. Marko Ribar, d.i.a. - fourth and final release ;;;;;; *** use this code for large distances between GPS coordinates *** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(vl-load-com)(defun c:gpsareasph ( / osm file f csvrow Latt Long gpsdata ER ptx pty ptz pt ptlst sph1 sph2 sph k ss p1 p2 ar ) (vl-cmdf "_.UCS" "w") (if (ssget "_X") (progn (alert "\nDWG must be empty - empty it and start over") (exit) ) ) (setq osm (getvar 'osmode)) (setvar 'osmode 0) (setq file (getfiled "Select file with GPS coordiantes" "" "csv" 2)) (setq f (open file "r")) (while (setq csvrow (read-line f)) (setq Latt (substr csvrow 1 (vl-string-position (ascii ",") csvrow))) (setq Long (substr csvrow (+ (vl-string-position (ascii ",") csvrow) 2) (- (strlen csvrow) (vl-string-position (ascii ",") csvrow) 1))) (setq gpsdata (cons (list (read Latt) (read Long)) gpsdata)) ) (setq gpsdata (reverse gpsdata)) (setq ER 6371000.0) ; Radius of Earth in m(foreach gps gpsdata (setq Latt (car gps)) (setq Long (cadr gps)) (setq ptx (* (* ER 2.0) (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians")))) (setq pty (* (* ER 2.0) (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians")))) (setq ptz (* (* ER 2.0) (sin (cvunit Latt "degrees" "radians")))) (setq pt (list ptx pty ptz)) (setq ptlst (cons pt ptlst)) ) (setq ptlst (reverse ptlst)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) ER) (setq sph1 (entlast)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (- ER 1e-4)) (setq sph2 (entlast)) (vl-cmdf "_.SUBTRACT" sph1 "" sph2 "") (setq sph (entlast)) (vl-cmdf "_.PLAN" "") (setq k -1) (setq ss (ssadd)) (repeat (length ptlst) (setq p1 (nth (setq k (1+ k)) ptlst)) (if (= k (- (length ptlst) 1)) (setq p2 (nth 0 ptlst)) (setq p2 (nth (1+ k) ptlst))) (vl-cmdf "_.UCS" "3" '(0.0 0.0 0.0) p1 p2) (vl-cmdf "_.PLINE" '(0.0 0.0 0.0) (trans p1 0 1) (trans p2 0 1) "c") (vl-cmdf "_.REGION" (entlast) "") (ssadd (entlast) ss) (vl-cmdf "_.UCS" "_P") ) (vl-cmdf "_.ZOOM" "_E") (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (* ER 1.25)) (vl-cmdf "_.CONVTOSURFACE" (entlast) "") (vl-cmdf "_.SLICE" (entlast) "" "XY" "" "") (entdel (entlast)) (ssadd (entlast) ss) (vl-cmdf "_.SURFSCULPT" ss "") (vl-cmdf "_.INTERSECT" sph (entlast) "") (vl-cmdf "_.ZOOM" "_E") (vl-cmdf "_.AREA" "o" (entlast) "") (setq ar (getvar 'area)) (setq ar (/ ar 2.0) (prompt "\nArea between GPS coordinates is : ") (princ ar) (prompt " square meters") (setvar 'osmode osm) (princ))
M.R.
So maybe when you get A2012, you'll look into this way...
gpsareasph-new-new-new.lsp *** PROBLEM SOLVED ***
This is exactly what you should get :
Area between GPS coordinates is : 741875.0 square meters
Here is my last and the most efficient code - of course only for one Earth hemisphere and works I think for A2011 and +... Tested on A2012...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; gpsareasph function takes GPS coordinates from CSV file, ;;;;;; and project between points edges as arcs on sphere with radius of planet Earth, ;;;;;; determines contour shape of peace of ground, ;;;;;; for witch if finds approx. correct area value. ;;;;;; 31.07.2012. Marko Ribar, d.i.a. - fifth and final release ;;;;;; *** improved possibility of making REGION objects *** ;;;;;; *** use this code for small distances between GPS coordinates *** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(vl-load-com)(defun c:gpsareasph ( / osm file f csvrow Latt Long gpsdata ER pt1x pt1y pt1z pt1 pt1lst pt2x pt2y pt2z pt2 pt2lst sph1 sph2 sph k ss p1 p2 p3 p4 ar ) (vl-cmdf "_.UCS" "w") (if (ssget "_X") (progn (alert "\nDWG must be empty - empty it and start over") (exit) ) ) (setq osm (getvar 'osmode)) (setvar 'osmode 0) (setq file (getfiled "Select file with GPS coordiantes" "" "csv" 2)) (setq f (open file "r")) (while (setq csvrow (read-line f)) (setq Latt (substr csvrow 1 (vl-string-position (ascii ",") csvrow))) (setq Long (substr csvrow (+ (vl-string-position (ascii ",") csvrow) 2) (- (strlen csvrow) (vl-string-position (ascii ",") csvrow) 1))) (setq gpsdata (cons (list (read Latt) (read Long)) gpsdata)) ) (setq gpsdata (reverse gpsdata)) (setq ER 6371000.0) ; Radius of Earth in m(foreach gps gpsdata (setq Latt (car gps)) (setq Long (cadr gps)) (setq pt1x (* (* ER 1.02) (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians")))) (setq pt1y (* (* ER 1.02) (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians")))) (setq pt1z (* (* ER 1.02) (sin (cvunit Latt "degrees" "radians")))) (setq pt1 (list pt1x pt1y pt1z)) (setq pt1lst (cons pt1 pt1lst)) (setq pt2x (* (* ER 0.98) (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians")))) (setq pt2y (* (* ER 0.98) (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians")))) (setq pt2z (* (* ER 0.98) (sin (cvunit Latt "degrees" "radians")))) (setq pt2 (list pt2x pt2y pt2z)) (setq pt2lst (cons pt2 pt2lst)) ) (setq pt1lst (reverse pt1lst)) (setq pt2lst (reverse pt2lst)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) ER) (setq sph1 (entlast)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (- ER 1e-4)) (setq sph2 (entlast)) (vl-cmdf "_.SUBTRACT" sph1 "" sph2 "") (setq sph (entlast)) (vl-cmdf "_.PLAN" "") (setq k -1) (setq ss (ssadd)) (repeat (length pt1lst) (setq p1 (nth (setq k (1+ k)) pt1lst)) (if (= k (- (length pt1lst) 1)) (setq p2 (nth 0 pt1lst)) (setq p2 (nth (1+ k) pt1lst))) (setq p3 (nth k pt2lst)) (if (= k (- (length pt2lst) 1)) (setq p4 (nth 0 pt2lst)) (setq p4 (nth (1+ k) pt2lst))) (vl-cmdf "_.UCS" "3" p1 p2 p3) (vl-cmdf "_.PLINE" (trans p1 0 1) (trans p2 0 1) (trans p4 0 1) (trans p3 0 1) "c") (vl-cmdf "_.REGION" (entlast) "") (ssadd (entlast) ss) (vl-cmdf "_.UCS" "_P") ) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (* ER 1.01)) (vl-cmdf "_.CONVTOSURFACE" (entlast) "") (vl-cmdf "_.SLICE" (entlast) "" "XY" "" "") (entdel (entlast)) (ssadd (entlast) ss) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (* ER 0.99)) (vl-cmdf "_.CONVTOSURFACE" (entlast) "") (vl-cmdf "_.SLICE" (entlast) "" "XY" "" "") (entdel (entlast)) (ssadd (entlast) ss) (vl-cmdf "_.SURFSCULPT" ss "") (vl-cmdf "_.INTERSECT" sph (entlast) "") (vl-cmdf "_.ZOOM" "_E") (vl-cmdf "_.AREA" "o" (entlast) "") (setq ar (getvar 'area)) (setq ar (/ ar 2.0)) (prompt "\nArea between GPS coordinates is : ") (princ ar) (prompt " square meters") (setvar 'osmode osm) (princ))
Many regards,
M.R.
gpsareasph-new-new-new-new.lsp Thank you very much, your lisp's are briliant, i am writing lisp's as well, but mine are just at beginer level, I am still learning, but your lisp's are way above me, for my own curiosity, why did you had to use a "z" coordinate? is this how the formula works? or you really need a "z"?
I have checked your solid, and the calculation is perfect, from my phone I can get only the perimeter which is: 5888.34m.
Best whishes,
Cristian
Cristian, thank you for your comments, however I have to point that lsp for drawing arcs is OK... You can always use it to get lengths - distances... But lsp for getting area is difficult to predict weather angles between 2 near GPS coordinates are going to be large or small, so I suggest A2011 or + and using both of mine codes - fourth for large angles, andfifth for small as in your case... I think that combine them into sinlge code isn't soo good solution, but there maybe cases where you have both large angles and also small - in this case you have to find middle solution and only prey that ACAD will convert plines to regions...
M.R.
页:
1
[2]