明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1236|回复: 8

利用大神函数经纬度展点,多段线到十进制经纬度

  [复制链接]
发表于 2021-6-21 18:18 | 显示全部楼层 |阅读模式
利用大神函数经纬度展点,多段线到十进制经纬度
谷歌地图KML文件经纬度是十进制的 奥维也是
以下是KML文件样表  红色子可以改动
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
        <name>CCCC巴中停车场.kml</name>
        <Style id="s_ylw-pushpin_hl21">
                <IconStyle>
                        <scale>1.3</scale>
                        <Icon>
                                <href></href>
                        </Icon>
                        <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
                </IconStyle>
                <LineStyle>
                        <color>ff0000ff</color>
                        <width>3</width>
                </LineStyle>
        </Style>
        <Style id="s_ylw-pushpin11">
                <IconStyle>
                        <scale>1.1</scale>
                        <Icon>
                                <href></href>
                        </Icon>
                        <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
                </IconStyle>
                <LineStyle>
                        <color>ff0000ff</color>
                        <width>3</width>
                </LineStyle>
        </Style>
        <StyleMap id="m_ylw-pushpin21">
                <Pair>
                        <key>normal</key>
                        <styleUrl>#s_ylw-pushpin11</styleUrl>
                </Pair>
                <Pair>
                        <key>highlight</key>
                        <styleUrl>#s_ylw-pushpin_hl21</styleUrl>
                </Pair>
        </StyleMap>
        <Placemark>
                <name>未命CCCCBB名路径</name>
                <styleUrl>#m_ylw-pushpin21</styleUrl>
                <LineString>
                        <tessellate>1</tessellate>
                        <coordinates>
                                113.235146862,22.957426436
113.235051235,22.957391803
113.235063160,22.957363577
113.235074058,22.957367525
113.235084711,22.957342288
113.235071549,22.957337522
                </coordinates>
                </LineString>
        </Placemark>
</Document>
</kml>


  1. ;;;功能:投影换带
  2. ;;作者:HUA
  3. ;;;创建日期:2020-8-18
  4. ;;;最后编辑日期:2020-8-20
  5. ;;;
  6. ;;;秒转度分秒 s->dd.mmss
  7. (defun Second2Dms(second / sign degree miniute second  dms)
  8.   (setq   sign (< second 0)
  9.       second (/ (abs second) 3600.0)
  10.       degree (fix second)
  11.       second (* (- second degree) 60.0)
  12.       miniute (fix second)
  13.       second (* (- second miniute) 60.0)
  14.       dms (+ degree (/ miniute 100.0) (/ second 10000.0))
  15.   )
  16.   (if sign (setq dms (- 0 dms)))
  17.   dms
  18. )
  19. ;;;
  20. ;;;角度转弧度 dd.mmss->rad
  21. (defun Dms2Rad(dms / sign degree miniute second rad)
  22.   (setq  sign  (<  dms 0)
  23.          dms  (abs dms)
  24.        degree (fix dms)
  25.        dms (* (- dms degree) 100)
  26.        miniute (fix dms)
  27.        second (* (- dms miniute) 100)   
  28.        rad (/ (* (+ degree (/ miniute 60.0) (/ second 3600.0)) PI) 180.0)
  29.   )
  30.   (if sign (setq rad  (- 0 rad)))
  31.   rad
  32. )
  33. ;;;
  34. ;;;弧度转角度 rad->dd.mmss
  35. (defun Rad2Dms(rad / sign degree miniute second dms)
  36.   (setq   sign (< rad 0)
  37.           rad (abs rad)
  38.       rad (/ (* rad 180.0) PI)
  39.       degree (fix rad)
  40.       rad (* (- rad degree) 60.0)
  41.       miniute (fix rad)
  42.       second (* (- rad miniute) 60.0)
  43.       dms (+ degree (/ miniute 100.0) (/ second 10000.0))
  44.   )
  45.   (if sign (setq dms (- 0 dms)))
  46.   dms
  47. )
  48. ;;;
  49. ;;;十进制角度转弧度 dd->rad
  50. (defun Degree2Rad(degree / sign rad)
  51.   (setq  sign  (<  degree 0)
  52.          degree   (abs degree )      
  53.        rad (/ (* degree  PI) 180.0)
  54.   )
  55.   (if sign (setq rad  (- 0 rad)))
  56.   rad
  57. )
  58. ;;;十进制角度转DD.MMSS

  59. (DEFUN 10-DDMMSS ( A / B C D E )
  60. (SETQ B (Rad2Dms (Degree2Rad A)) )
  61. (setq c (fix b)) (setq d (fix(*(- b c) 100)))
  62. (setq e (- (* 10000 b) (* c 10000)  (* d 100) ) )
  63.   (strcat (rtos c 2 0) "度" (rtos d 2 0) "分"  (rtos e 2 6) "秒")
  64.   )

  65. ;;;弧度转十进制角度 rad->dd
  66. (defun Rad2Degree(rad / sign degree)
  67.   (setq  sign  (<  rad 0)
  68.          rad (abs rad)
  69.          degree (/ (* rad 180.0) PI)
  70.   )
  71.   (if sign (setq degree  (- 0 degree)))
  72.   degree
  73. )
  74. ;;;
  75. ;;;54坐标系参数
  76. (defun PrjPoint_Krasovsky( / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 tf )
  77.   (setq  a 6378245.0
  78.       f 298.3
  79.       tf (/ (- f 1) f)
  80.       e2  (- 1 (* tf tf))
  81.       tf (/ f (- f 1))
  82.       e12 (- (* tf tf) 1)
  83.       A1 6367558.4968749800000000
  84.       A2  -16036.4802694116000000
  85.       A3  16.8280668841393000
  86.       A4  -0.0219753089548841
  87.       A5 0.0000311310026601
  88.       A6 -0.0000000459827472
  89.       A7 0.0000000000679857      
  90.   )
  91.   (list a f e2 e12 A1 A2 A3 A4 A5 A6 A7)  
  92. )
  93. ;;;
  94. ;;;80坐标系参数
  95. (defun PrjPoint_IUGG1975(/ a f e2 e12 A1 A2 A3 A4 A5 A6 A7 tf)
  96.   (setq  a    6378140.0
  97.       f    298.257
  98.       tf (/ (- f 1) f)
  99.       e2  (- 1 (* tf tf))
  100.       tf (/ f (- f 1))
  101.       e12 (- (* tf tf) 1)
  102.       A1    6367452.1327884300000000
  103.       A2    -16038.5282286966000000
  104.       A3    16.8326464353061000
  105.       A4    -0.0219844636486152
  106.       A5    0.0000311484690908
  107.       A6    -0.0000000460151868
  108.       A7    0.0000000000680433      
  109.   )
  110.   (list a f e2 e12 A1 A2 A3 A4 A5 A6 A7)  
  111. )
  112. ;;;
  113. ;;;2000坐标系参数
  114. (defun PrjPoint_2000(/ a f e2 e12 A1 A2 A3 A4 A5 A6 A7 tf)
  115.   (setq  a    6378137.0
  116.       f    298.257222101
  117.       tf (/ (- f 1) f)
  118.       e2  (- 1 (* tf tf))
  119.       tf (/ f (- f 1))
  120.       e12 (- (* tf tf) 1)
  121.       A1    6367449.1457710400000000
  122.       A2    -16038.5087415914000000
  123.       A3    16.8326134276660000
  124.       A4    -0.0219844041401628
  125.       A5    0.0000311483615430
  126.       A6    -0.0000000460149936
  127.       A7    0.0000000000680429      
  128.   )
  129.    (list a f e2 e12 A1 A2 A3 A4 A5 A6 A7)  
  130. )
  131. ;;;
  132. ;;;BL转cadx,cady
  133. ;;;输入参数
  134. ;;;B,L为点位纬度和经度,单位为弧度
  135. ;;;L0为中央经线,单位为弧度
  136. ;;;prjType取值为0:北京54坐标系,1:西安80坐标系,2:CGCS2000坐标系
  137. ;;;输出CAD坐标x,y
  138. (defun PrjPoint:BL2xy(B L L0 prjType / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 X N tanB tanB2 m m2 ng2 sinB cosB cadx cady)   
  139.     (cond
  140.     ((= 0 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_Krasovsky)))
  141.     ((= 1 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_IUGG1975)))
  142.     ((= 2 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_2000)))
  143.     (T (alert "未知prjType参数值")(exit))
  144.   )
  145.   (setq  X       (+ (* A1 B) (* A2 (sin (* 2 B))) (*  A3 (sin (* 4 B))) (* A4 (sin (* 6 B))) (* A5  (sin (* 8 B))) (* A6 (sin (* 10 B))) (* A7 (sin (* 12 B))))
  146.       sinB   (sin B)  cosB   (cos B) tanB   (/ (sin B) (cos B))   tanB2   (* tanB tanB)
  147.       N      (/ a (sqrt (- 1 (* e2 sinB sinB))))
  148.       m      (* cosB (- L L0))  m2 (* m m)
  149.       ng2      (/ (* cosB cosB e2) (- 1 e2))
  150.       cady    (+ X (* N tanB (* (+ 0.5 (* (+ (/ (+ (- 5 tanB2) (* 9 ng2) (* 4 ng2 ng2)) 24.0) (/ (* (+ (- 61 (* 58 tanB2)) (* tanB2 tanB2)) m2) 72.0)) m2)) m2)))
  151.       cadx    (+ 500000 (* N m  (+ 1 (* m2 (+ (/ (+ (- 1 tanB2) ng2) 6.0) (/ (* m2 (-  (+ 5 (* tanB2 tanB2) (* 14 ng2)) (* 18 tanB2) (* 58 ng2 tanB2))) 120.0))))))   
  152.   )
  153.   (list cadx cady)  
  154. )
  155. ;;;
  156. ;;;cadx,cady转BL
  157. ;;;输入参数
  158. ;;;;pt为点位cad点坐标,
  159. ;;;L0为中央经线,单位为弧度
  160. ;;;prjType取值为0:北京54坐标系,1:西安80坐标系,2:CGCS2000坐标系
  161. ;;;输出经纬度B,L表,单位为dd.mmss
  162. (defun PrjPoint:xy2BL(pt L0 prjType / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 sinB cosB tanB tanB2 N ng2 V yN preB0 B0 eta x y )
  163.   (cond
  164.     ((= 0 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_Krasovsky)))
  165.     ((= 1 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_IUGG1975)))
  166.     ((= 2 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_2000)))
  167.     (T (alert "未知prjType参数值")(exit))
  168.   )
  169.   (setq   x    (cadr pt)
  170.       y    (- (car pt) 500000)
  171.       B0   (/ x A1)
  172.       eta  1
  173.   )  
  174.   (while (> eta  0.000000000048)
  175.     (setq  preB0  B0
  176.         B0   (/ (- x (+ (* A2 (sin (* 2 B0))) (* A3 (sin (* 4 B0))) (* A4 (sin (* 6 B0))) (* A5 (sin (* 8 B0))) (* A6 (sin (* 10 B0))) (* A7 (sin (* 12 B0))))) A1)
  177.         eta (abs (- B0 preB0))
  178.     )  
  179.   )  
  180.   (setq   sinB  (sin B0)
  181.       cosB   (cos B0)
  182.       tanB    (/ (sin B0) (cos B0))
  183.       tanB2   (* tanB tanB)
  184.       N      (/ a (sqrt (- 1 (* e2 sinB sinB))))
  185.       ng2      (/ (* cosB cosB e2) (- 1 e2))
  186.       V    (sqrt (+ 1 ng2))
  187.       yN    (/ y N)   
  188.       B    (- B0 (* (+ (- (* yN yN) (/ (* (- (+ 5 (* 3 tanB2) ng2) (* 9 ng2 tanB2)) yN yN yN yN) 12.0)) (/ (* (+ 61 (* 90 tanB2) (* 45 tanB2 tanB2)) yN yN yN yN yN yN) 360.0)) V V tanB 0.5))      
  189.       L    (+ L0 (/ (+ (- yN (/ (* (+ 1 (* 2 tanB2) ng2) yN yN yN) 6.0 )) (/ (* (+ 5 (* 28 tanB2) (* 24 tanB2 tanB2) (* 6 ng2) (* 8 ng2 tanB2)) yN yN yN yN yN) 120.0)) cosB))   
  190.   )
  191.   (list (Rad2Dms B) (Rad2Dms L))
  192. )
  193. ;;;
  194. ;;;cadx,cady转BL
  195. ;;;输入参数
  196. ;;;;pt为点位cad点坐标,
  197. ;;;L0为中央经线,单位为弧度
  198. ;;;prjType取值为0:北京54坐标系,1:西安80坐标系,2:CGCS2000坐标系
  199. ;;;输出经纬度B,L表,单位为十进制
  200. (defun PrjPoint:xy2BL2(pt L0 prjType / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 sinB cosB tanB tanB2 N ng2 V yN preB0 B0 eta x y )
  201.   (cond
  202.     ((= 0 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_Krasovsky)))
  203.     ((= 1 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_IUGG1975)))
  204.     ((= 2 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_2000)))
  205.     (T (alert "未知prjType参数值")(exit))
  206.   )
  207.   (setq   x    (cadr pt)
  208.       y    (- (car pt) 500000)
  209.       B0   (/ x A1)
  210.       eta  1
  211.   )  
  212.   (while (> eta  0.000000000048)
  213.     (setq  preB0  B0
  214.         B0   (/ (- x (+ (* A2 (sin (* 2 B0))) (* A3 (sin (* 4 B0))) (* A4 (sin (* 6 B0))) (* A5 (sin (* 8 B0))) (* A6 (sin (* 10 B0))) (* A7 (sin (* 12 B0))))) A1)
  215.         eta (abs (- B0 preB0))
  216.     )  
  217.   )  
  218.   (setq   sinB  (sin B0)
  219.       cosB   (cos B0)
  220.       tanB    (/ (sin B0) (cos B0))
  221.       tanB2   (* tanB tanB)
  222.       N      (/ a (sqrt (- 1 (* e2 sinB sinB))))
  223.       ng2      (/ (* cosB cosB e2) (- 1 e2))
  224.       V    (sqrt (+ 1 ng2))
  225.       yN    (/ y N)   
  226.       B    (- B0 (* (+ (- (* yN yN) (/ (* (- (+ 5 (* 3 tanB2) ng2) (* 9 ng2 tanB2)) yN yN yN yN) 12.0)) (/ (* (+ 61 (* 90 tanB2) (* 45 tanB2 tanB2)) yN yN yN yN yN yN) 360.0)) V V tanB 0.5))      
  227.       L    (+ L0 (/ (+ (- yN (/ (* (+ 1 (* 2 tanB2) ng2) yN yN yN) 6.0 )) (/ (* (+ 5 (* 28 tanB2) (* 24 tanB2 tanB2) (* 6 ng2) (* 8 ng2 tanB2)) yN yN yN yN yN) 120.0)) cosB))   
  228.   )
  229.   (list (Rad2Degree L) (Rad2Degree B) )
  230. )

  231. ;;;;;;;;;;;;;;;;;;;;;;;;;;;


  232. (defun c:jw-2000 (   / l0 bb ll vvv str  )

  233. (setq l0 (getreal "\n请输入中央子午线经度dd.mmss:"))
  234. (setq bb (getreal "\n请输入待求点纬度dd.mmss:"))
  235. (setq ll (getreal "\n请输入待求点经度dd.mmss:"))

  236. (setq vvv(append(PrjPoint:BL2xy (dms2rad bb) (dms2rad ll) (dms2rad l0)2)'(0)))
  237. (setq str(strcat (rtos bb 2 12 )","(rtos ll 2 12 )))
  238. (entmake (list '(0 . "TEXT")'(8 . "jwd") (cons 1 str) (cons 10 vvv) (cons 40 2)))
  239. (entmake (list '(0 . "POINT")'(8 . "jwd") (cons 10 vvv)))
  240.   
  241.   )

  242. (defun vxs(e / p a b n ob q et d d1 en et)
  243.     (setq a(entget e)ob(vlax-ename->vla-object e)et(cdr(assoc 0 a))n 0 p nil d nil)
  244.     (cond((="LWPOLYLINE"et)
  245.     (repeat(length a)(setq b (nth n a) n (+ n 1))
  246.       (if (= 10 (car b))(progn
  247.         (setq q(list (cadr b) (caddr b))d1(vlax-curve-getDistAtPoint ob q))
  248.         (if p (if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
  249.           (setq p (list q)))))))
  250.    ((="POLYLINE"et)
  251.     (SETQ EN (ENTGET (SETQ E (ENTNEXT E))))
  252.     (WHILE (/= (CDR (ASSOC 0 EN)) "SEQEND")
  253.       (SETQ q (CDR (ASSOC 10 EN))d1(vlax-curve-getDistAtPoint ob q)q(reverse(cdr(reverse q))))
  254.       (if p(if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))(setq p(list q)))
  255.       (SETQ EN (ENTGET (SETQ E (ENTNEXT E)))))
  256.     (setq p(reverse p))))P)

  257. (defun c:lw-bl2000 ( / p l0 zb jwd );;;2000坐标多段线TXT转经纬度文件,经纬度为10进制

  258.   (vl-load-com)
  259. (setq l0 (getreal "\n请输入中央子午线经度dd.mmss:"))
  260. (setq p (car(entsel "\n请选择2000或者wgs84坐标多段线:")))

  261.   (setq zb (vxs p))
  262. (setq ffn (getfiled "选取/建立数据导出10进制经纬度文件" "" "txt" 1))
  263.   (setq ff (open ffn "w"))
  264. (foreach x zb
  265. (setq jwd (PrjPoint:xy2BL2 x (Dms2Rad l0) 2))

  266. (write-line (strcat (rtos (car jwd)2 9)","(rtos (cadr jwd)2 9)) ff)

  267.   )
  268. (close ff)
  269.        )

  270. ;;;;;;;;;;;;;;;;;;;;;;;;;
  271. (defun c:bl-2000 (  /  l0 fn f ll k lll bbb lllbbb str)  ;;;经纬度文件TXT转2000坐标,图上经纬度为度分秒
  272. (vl-load-com)
  273. (setq l0 (getreal "\n请输入中央子午线经度dd.mmss:"))
  274. (setq fn (getfiled "Select Log file请打开10进制经纬度数据文件:格式为:经度,纬度" "" "txt" 8))

  275. (setq f (open (findfile fn) "r"))

  276. (while (setq k (read-line f))
  277.     (setq ll (cons k  ll ) )
  278.   )
  279. (close f)
  280. ;(String:Split (car ll) ",")
  281. (foreach x ll
  282. (setq lll (atof (car(String:Split x ","))))
  283. (setq bbb (atof (cadr(String:Split x ","))))

  284. (setq lllbbb( PrjPoint:BL2xy(Degree2Rad bbb) (Degree2Rad lll) (dms2rad l0) 2))
  285.   (setq str(strcat (10-DDMMSS bbb )","(10-DDMMSS lll )))
  286. (entmake (list '(0 . "TEXT")'(8 . "jwd") (cons 1 str) (cons 10 lllbbb) (cons 40 2)))
  287. (entmake (list '(0 . "POINT")'(8 . "jwd") (cons 10 lllbbb)))
  288.   )
  289.   (princ)
  290. )

  291. (defun String:Split (str delimiter / post strlst stl)
  292.     (if        str
  293.       (progn
  294.         (setq stl (strlen delimiter))
  295.         (while (vl-string-search delimiter str)
  296.           (setq        post   (vl-string-search delimiter str)
  297.                 strlst (cons (substr str 1 post) strlst)
  298.                 str    (substr str (+ 1 post stl))
  299.           )
  300.         )
  301.         (reverse (vl-remove "" (cons str strlst)))
  302.       )
  303.     )
  304.   )



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2021-6-22 08:40 | 显示全部楼层
谢谢分享啊
发表于 2021-6-22 10:29 | 显示全部楼层
兄弟你qq多少可以加你一下吗
 楼主| 发表于 2021-6-22 14:47 | 显示全部楼层
根据4参数算坐标?


  1. ;;;角度转弧度 dd.mmss->rad
  2. (defun Dms2Rad(dms / sign degree miniute second rad)
  3.   (setq  sign  (<  dms 0)
  4.          dms  (abs dms)
  5.        degree (fix dms)
  6.        dms (* (- dms degree) 100)
  7.        miniute (fix dms)
  8.        second (* (- dms miniute) 100)   
  9.        rad (/ (* (+ degree (/ miniute 60.0) (/ second 3600.0)) PI) 180.0)
  10.   )
  11.   (if sign (setq rad  (- 0 rad)))
  12.   rad
  13. )
  14. ;;;
  15. (setq pp'(40 50))

  16. (setq aa(Dms2Rad(getreal "\n请输入旋转角度dd.mmss:")))
  17. (setq kk(getreal "\n请输入尺度1.00000:"))

  18. ;;;;;;;;;;;;;;;;;;;
  19. (defun zbzh ( pp aa kk /   xx yy x0 y0 )


  20. (setq xx (cadr pp) yy  (car pp) )

  21. (setq x0   (* (cos aa)  (- (* xx kk)    (* (/ (sin aa) (cos aa)) (* kk  yy) )              )  )     )

  22. ;

  23. (setq y0 (+  (/ (* kk  yy) (cos aa))   (* (/ (sin aa) (cos aa)) x0 )      ))
  24.   
  25.   (list y0 x0)

  26.   )

 楼主| 发表于 2021-6-22 17:16 | 显示全部楼层
地方坐标系或者自定义坐标根据4参数多段线转经纬度文件TXT,经纬度为10进制,可以复制到KML文件用\n"  "可以将手薄里面参与求控制点的WGS84经纬度换算成坐标\n" "然后用COORD笑脸软件求地方坐标--》WGS84坐标的4参数抄下来用113.47228431,22.986922997
113.472186361,22.986816298
113.472054915,22.986774606
113.4719921,22.986754673
113.471037673,22.984983334
113.471092087,22.984715313
113.470541912,22.985446895
113.470968935,22.985462633
113.471749262,22.986910865
113.471755997,22.986923274
113.471762811,22.986935665
113.471769664,22.98694801
113.471776604,22.986960328
113.471783612,22.98697261
113.471790689,22.986984865
113.471797844,22.986997093
113.471805047,22.987009266
113.471812319,22.987021422
113.471819678,22.987033532
113.471827087,22.987045624
113.471834553,22.987057671
113.471842108,22.987069681
113.47184972,22.987081638
113.471857401,22.987093585
113.471865131,22.987105478
113.471872949,22.987117353
113.471880815,22.987129182
113.471888769,22.987140957
113.471896772,22.987152715
113.471904843,22.987164427
113.471912982,22.987176102
113.47192117,22.987187742
113.471929445,22.987199327
113.471937769,22.987210886
113.471946172,22.987222408
113.471954613,22.987233894
113.471963142,22.987245325
113.471971719,22.987256721


  1. ;;;功能:投影换带
  2. ;;作者:HUA
  3. ;;;创建日期:2020-8-18
  4. ;;;最后编辑日期:2020-8-20
  5. ;;;
  6. ;;;秒转度分秒 s->dd.mmss
  7. (defun Second2Dms(second / sign degree miniute second  dms)
  8.   (setq   sign (< second 0)
  9.       second (/ (abs second) 3600.0)
  10.       degree (fix second)
  11.       second (* (- second degree) 60.0)
  12.       miniute (fix second)
  13.       second (* (- second miniute) 60.0)
  14.       dms (+ degree (/ miniute 100.0) (/ second 10000.0))
  15.   )
  16.   (if sign (setq dms (- 0 dms)))
  17.   dms
  18. )
  19. ;;;
  20. ;;;角度转弧度 dd.mmss->rad
  21. (defun Dms2Rad(dms / sign degree miniute second rad)
  22.   (setq  sign  (<  dms 0)
  23.          dms  (abs dms)
  24.        degree (fix dms)
  25.        dms (* (- dms degree) 100)
  26.        miniute (fix dms)
  27.        second (* (- dms miniute) 100)   
  28.        rad (/ (* (+ degree (/ miniute 60.0) (/ second 3600.0)) PI) 180.0)
  29.   )
  30.   (if sign (setq rad  (- 0 rad)))
  31.   rad
  32. )
  33. ;;;
  34. ;;;弧度转角度 rad->dd.mmss
  35. (defun Rad2Dms(rad / sign degree miniute second dms)
  36.   (setq   sign (< rad 0)
  37.           rad (abs rad)
  38.       rad (/ (* rad 180.0) PI)
  39.       degree (fix rad)
  40.       rad (* (- rad degree) 60.0)
  41.       miniute (fix rad)
  42.       second (* (- rad miniute) 60.0)
  43.       dms (+ degree (/ miniute 100.0) (/ second 10000.0))
  44.   )
  45.   (if sign (setq dms (- 0 dms)))
  46.   dms
  47. )
  48. ;;;
  49. ;;;十进制角度转弧度 dd->rad
  50. (defun Degree2Rad(degree / sign rad)
  51.   (setq  sign  (<  degree 0)
  52.          degree   (abs degree )      
  53.        rad (/ (* degree  PI) 180.0)
  54.   )
  55.   (if sign (setq rad  (- 0 rad)))
  56.   rad
  57. )
  58. ;;;十进制角度转DD.MMSS

  59. (DEFUN 10-DDMMSS ( A / B C D E )
  60. (SETQ B (Rad2Dms (Degree2Rad A)) )
  61. (setq c (fix b)) (setq d (fix(*(- b c) 100)))
  62. (setq e (- (* 10000 b) (* c 10000)  (* d 100) ) )
  63.   (strcat (rtos c 2 0) "度" (rtos d 2 0) "分"  (rtos e 2 6) "秒")
  64.   )

  65. ;;;弧度转十进制角度 rad->dd
  66. (defun Rad2Degree(rad / sign degree)
  67.   (setq  sign  (<  rad 0)
  68.          rad (abs rad)
  69.          degree (/ (* rad 180.0) PI)
  70.   )
  71.   (if sign (setq degree  (- 0 degree)))
  72.   degree
  73. )
  74. ;;;
  75. ;;;54坐标系参数
  76. (defun PrjPoint_Krasovsky( / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 tf )
  77.   (setq  a 6378245.0
  78.       f 298.3
  79.       tf (/ (- f 1) f)
  80.       e2  (- 1 (* tf tf))
  81.       tf (/ f (- f 1))
  82.       e12 (- (* tf tf) 1)
  83.       A1 6367558.4968749800000000
  84.       A2  -16036.4802694116000000
  85.       A3  16.8280668841393000
  86.       A4  -0.0219753089548841
  87.       A5 0.0000311310026601
  88.       A6 -0.0000000459827472
  89.       A7 0.0000000000679857      
  90.   )
  91.   (list a f e2 e12 A1 A2 A3 A4 A5 A6 A7)  
  92. )
  93. ;;;
  94. ;;;80坐标系参数
  95. (defun PrjPoint_IUGG1975(/ a f e2 e12 A1 A2 A3 A4 A5 A6 A7 tf)
  96.   (setq  a    6378140.0
  97.       f    298.257
  98.       tf (/ (- f 1) f)
  99.       e2  (- 1 (* tf tf))
  100.       tf (/ f (- f 1))
  101.       e12 (- (* tf tf) 1)
  102.       A1    6367452.1327884300000000
  103.       A2    -16038.5282286966000000
  104.       A3    16.8326464353061000
  105.       A4    -0.0219844636486152
  106.       A5    0.0000311484690908
  107.       A6    -0.0000000460151868
  108.       A7    0.0000000000680433      
  109.   )
  110.   (list a f e2 e12 A1 A2 A3 A4 A5 A6 A7)  
  111. )
  112. ;;;
  113. ;;;2000坐标系参数
  114. (defun PrjPoint_2000(/ a f e2 e12 A1 A2 A3 A4 A5 A6 A7 tf)
  115.   (setq  a    6378137.0
  116.       f    298.257222101
  117.       tf (/ (- f 1) f)
  118.       e2  (- 1 (* tf tf))
  119.       tf (/ f (- f 1))
  120.       e12 (- (* tf tf) 1)
  121.       A1    6367449.1457710400000000
  122.       A2    -16038.5087415914000000
  123.       A3    16.8326134276660000
  124.       A4    -0.0219844041401628
  125.       A5    0.0000311483615430
  126.       A6    -0.0000000460149936
  127.       A7    0.0000000000680429      
  128.   )
  129.    (list a f e2 e12 A1 A2 A3 A4 A5 A6 A7)  
  130. )
  131. ;;;
  132. ;;;BL转cadx,cady
  133. ;;;输入参数
  134. ;;;B,L为点位纬度和经度,单位为弧度
  135. ;;;L0为中央经线,单位为弧度
  136. ;;;prjType取值为0:北京54坐标系,1:西安80坐标系,2:CGCS2000坐标系
  137. ;;;输出CAD坐标x,y
  138. (defun PrjPoint:BL2xy(B L L0 prjType / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 X N tanB tanB2 m m2 ng2 sinB cosB cadx cady)   
  139.     (cond
  140.     ((= 0 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_Krasovsky)))
  141.     ((= 1 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_IUGG1975)))
  142.     ((= 2 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_2000)))
  143.     (T (alert "未知prjType参数值")(exit))
  144.   )
  145.   (setq  X       (+ (* A1 B) (* A2 (sin (* 2 B))) (*  A3 (sin (* 4 B))) (* A4 (sin (* 6 B))) (* A5  (sin (* 8 B))) (* A6 (sin (* 10 B))) (* A7 (sin (* 12 B))))
  146.       sinB   (sin B)  cosB   (cos B) tanB   (/ (sin B) (cos B))   tanB2   (* tanB tanB)
  147.       N      (/ a (sqrt (- 1 (* e2 sinB sinB))))
  148.       m      (* cosB (- L L0))  m2 (* m m)
  149.       ng2      (/ (* cosB cosB e2) (- 1 e2))
  150.       cady    (+ X (* N tanB (* (+ 0.5 (* (+ (/ (+ (- 5 tanB2) (* 9 ng2) (* 4 ng2 ng2)) 24.0) (/ (* (+ (- 61 (* 58 tanB2)) (* tanB2 tanB2)) m2) 72.0)) m2)) m2)))
  151.       cadx    (+ 500000 (* N m  (+ 1 (* m2 (+ (/ (+ (- 1 tanB2) ng2) 6.0) (/ (* m2 (-  (+ 5 (* tanB2 tanB2) (* 14 ng2)) (* 18 tanB2) (* 58 ng2 tanB2))) 120.0))))))   
  152.   )
  153.   (list cadx cady)  
  154. )
  155. ;;;
  156. ;;;cadx,cady转BL
  157. ;;;输入参数
  158. ;;;;pt为点位cad点坐标,
  159. ;;;L0为中央经线,单位为弧度
  160. ;;;prjType取值为0:北京54坐标系,1:西安80坐标系,2:CGCS2000坐标系
  161. ;;;输出经纬度B,L表,单位为dd.mmss
  162. (defun PrjPoint:xy2BL(pt L0 prjType / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 sinB cosB tanB tanB2 N ng2 V yN preB0 B0 eta x y )
  163.   (cond
  164.     ((= 0 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_Krasovsky)))
  165.     ((= 1 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_IUGG1975)))
  166.     ((= 2 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_2000)))
  167.     (T (alert "未知prjType参数值")(exit))
  168.   )
  169.   (setq   x    (cadr pt)
  170.       y    (- (car pt) 500000)
  171.       B0   (/ x A1)
  172.       eta  1
  173.   )  
  174.   (while (> eta  0.000000000048)
  175.     (setq  preB0  B0
  176.         B0   (/ (- x (+ (* A2 (sin (* 2 B0))) (* A3 (sin (* 4 B0))) (* A4 (sin (* 6 B0))) (* A5 (sin (* 8 B0))) (* A6 (sin (* 10 B0))) (* A7 (sin (* 12 B0))))) A1)
  177.         eta (abs (- B0 preB0))
  178.     )  
  179.   )  
  180.   (setq   sinB  (sin B0)
  181.       cosB   (cos B0)
  182.       tanB    (/ (sin B0) (cos B0))
  183.       tanB2   (* tanB tanB)
  184.       N      (/ a (sqrt (- 1 (* e2 sinB sinB))))
  185.       ng2      (/ (* cosB cosB e2) (- 1 e2))
  186.       V    (sqrt (+ 1 ng2))
  187.       yN    (/ y N)   
  188.       B    (- B0 (* (+ (- (* yN yN) (/ (* (- (+ 5 (* 3 tanB2) ng2) (* 9 ng2 tanB2)) yN yN yN yN) 12.0)) (/ (* (+ 61 (* 90 tanB2) (* 45 tanB2 tanB2)) yN yN yN yN yN yN) 360.0)) V V tanB 0.5))      
  189.       L    (+ L0 (/ (+ (- yN (/ (* (+ 1 (* 2 tanB2) ng2) yN yN yN) 6.0 )) (/ (* (+ 5 (* 28 tanB2) (* 24 tanB2 tanB2) (* 6 ng2) (* 8 ng2 tanB2)) yN yN yN yN yN) 120.0)) cosB))   
  190.   )
  191.   (list (Rad2Dms B) (Rad2Dms L))
  192. )
  193. ;;;
  194. ;;;cadx,cady转BL
  195. ;;;输入参数
  196. ;;;;pt为点位cad点坐标,
  197. ;;;L0为中央经线,单位为弧度
  198. ;;;prjType取值为0:北京54坐标系,1:西安80坐标系,2:CGCS2000坐标系
  199. ;;;输出经纬度B,L表,单位为十进制
  200. (defun PrjPoint:xy2BL2(pt L0 prjType / a f e2 e12 A1 A2 A3 A4 A5 A6 A7 sinB cosB tanB tanB2 N ng2 V yN preB0 B0 eta x y )
  201.   (cond
  202.     ((= 0 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_Krasovsky)))
  203.     ((= 1 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_IUGG1975)))
  204.     ((= 2 prjType) (mapcar 'set (list 'a 'f 'e2 'e12 'A1 'A2 'A3 'A4 'A5 'A6 'A7) (PrjPoint_2000)))
  205.     (T (alert "未知prjType参数值")(exit))
  206.   )
  207.   (setq   x    (cadr pt)
  208.       y    (- (car pt) 500000)
  209.       B0   (/ x A1)
  210.       eta  1
  211.   )  
  212.   (while (> eta  0.000000000048)
  213.     (setq  preB0  B0
  214.         B0   (/ (- x (+ (* A2 (sin (* 2 B0))) (* A3 (sin (* 4 B0))) (* A4 (sin (* 6 B0))) (* A5 (sin (* 8 B0))) (* A6 (sin (* 10 B0))) (* A7 (sin (* 12 B0))))) A1)
  215.         eta (abs (- B0 preB0))
  216.     )  
  217.   )  
  218.   (setq   sinB  (sin B0)
  219.       cosB   (cos B0)
  220.       tanB    (/ (sin B0) (cos B0))
  221.       tanB2   (* tanB tanB)
  222.       N      (/ a (sqrt (- 1 (* e2 sinB sinB))))
  223.       ng2      (/ (* cosB cosB e2) (- 1 e2))
  224.       V    (sqrt (+ 1 ng2))
  225.       yN    (/ y N)   
  226.       B    (- B0 (* (+ (- (* yN yN) (/ (* (- (+ 5 (* 3 tanB2) ng2) (* 9 ng2 tanB2)) yN yN yN yN) 12.0)) (/ (* (+ 61 (* 90 tanB2) (* 45 tanB2 tanB2)) yN yN yN yN yN yN) 360.0)) V V tanB 0.5))      
  227.       L    (+ L0 (/ (+ (- yN (/ (* (+ 1 (* 2 tanB2) ng2) yN yN yN) 6.0 )) (/ (* (+ 5 (* 28 tanB2) (* 24 tanB2 tanB2) (* 6 ng2) (* 8 ng2 tanB2)) yN yN yN yN yN) 120.0)) cosB))   
  228.   )
  229.   (list (Rad2Degree L) (Rad2Degree B) )
  230. )

  231. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  232. ;;;;;;;;;;;;;;;

  233. (defun vxs(e / p a b n ob q et d d1 en et)
  234.     (setq a(entget e)ob(vlax-ename->vla-object e)et(cdr(assoc 0 a))n 0 p nil d nil)
  235.     (cond((="LWPOLYLINE"et)
  236.     (repeat(length a)(setq b (nth n a) n (+ n 1))
  237.       (if (= 10 (car b))(progn
  238.         (setq q(list (cadr b) (caddr b))d1(vlax-curve-getDistAtPoint ob q))
  239.         (if p (if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
  240.           (setq p (list q)))))))
  241.    ((="POLYLINE"et)
  242.     (SETQ EN (ENTGET (SETQ E (ENTNEXT E))))
  243.     (WHILE (/= (CDR (ASSOC 0 EN)) "SEQEND")
  244.       (SETQ q (CDR (ASSOC 10 EN))d1(vlax-curve-getDistAtPoint ob q)q(reverse(cdr(reverse q))))
  245.       (if p(if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))(setq p(list q)))
  246.       (SETQ EN (ENTGET (SETQ E (ENTNEXT E)))))
  247.     (setq p(reverse p))))P)


  248. ;;;;;;;;;;;;;;;;;;;
  249. (defun zbzh ( pp aa kk /   xx yy x0 y0 )


  250. (setq xx (cadr pp) yy  (car pp) )

  251. (setq x0   (* (cos aa)  (- (* xx kk)    (* (/ (sin aa) (cos aa)) (* kk  yy) )              )  )     )

  252. ;

  253. (setq y0 (+  (/ (* kk  yy) (cos aa))   (* (/ (sin aa) (cos aa)) x0 )      ))
  254.   
  255.   (list (+ y0 (car syd))  (+ x0 (cadr syd))  )

  256.   )
  257. ;3、点表生成多段线
  258. (defun makepl (lst / pt)
  259. (entmake (append    (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(8 . "ctpzx") (cons 90 (length lst)) (cons 70 129))
  260.       (mapcar '(lambda (pt)(cons 10 pt)) lst ))
  261.   ) )
  262. ;;;;;;

  263. (defun c:dflw-bl2000 ( / p l0 zb jwd syd aa kk xzb  lll);;;地方坐标系或者自定义坐标根据4参数多段线转经纬度文件TXT,经纬度为10进制,可以复制到KML文件用
  264. (alert (strcat "地方坐标系或者自定义坐标根据4参数多段线转经纬度文件TXT,经纬度为10进制,可以复制到KML文件用\n"  "可以将手薄里面参与求控制点的WGS84经纬度换算成坐标\n" "然后用COORD笑脸软件求地方坐标--》WGS84坐标的4参数抄下来用"))
  265.   (vl-load-com)
  266. (setq l0 (getreal "\n请输入中央子午线经度dd.mmss:"))
  267. (setq p (car(entsel "\n请选择地方坐标系或者自定义坐标多段线:")))

  268. ;(setq pp '(62295.5790 17258.584))

  269. (setq syd'(454891.370478 2529629.687669 )) ;4参数x y位移人工输入

  270. (setq aa (Dms2Rad 0.0047650491))   ;4参数旋转参数人工输入dd.mmss
  271. (setq kk 1.00000515799711)      ;4参数缩放比列因子人工输入
  272.     (setq zb (vxs p))
  273. (setq lll '())
  274. (foreach y zb
  275.     (setq lll (zbzh y aa kk))
  276.     (setq xzb (cons lll xzb))
  277.   )
  278.   (makepl xzb)
  279. (setq ffn (getfiled "选取/建立数据导出10进制经纬度文件" "" "txt" 1))
  280.   (setq ff (open ffn "w"))
  281. (foreach x xzb
  282. (setq jwd (PrjPoint:xy2BL2 x (Dms2Rad l0) 2))

  283. (write-line (strcat (rtos (car jwd)2 9)","(rtos (cadr jwd)2 9)) ff)

  284.   )
  285. (close ff)
  286.        )


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2021-6-22 21:32 | 显示全部楼层
牛逼的哥们,每次都是好代码
发表于 2021-8-24 08:07 | 显示全部楼层

谢谢分享啊
谢谢分享啊
发表于 2024-3-31 20:58 | 显示全部楼层
厉害,正需要转经纬度
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-6-16 15:04 , Processed in 0.175442 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表