【GUI界面】基于Python的WSG84三点定位系统(经纬度坐标与平面坐标转换法求解)

方法汇总:
blog.csdn.net/weixin_53403301/article/details/128441789
【精准三点定位求解汇总】利用Python或JavaScript高德地图开放平台实现精准三点定位(经纬度坐标与平面坐标转换法求解、几何绘图法求解)

众所周知,如果已知三个点的坐标,到一个未知点的距离,则可以利用以距离为半径画圆的方式来求得未知点坐标。
如果只有两个已知点,则只能得出两个未知点坐标,而第三个圆必定交于其中一个点

如图:

三个圆必定教于一个点

当然,如果第三个绿色圆圆心位于红蓝的圆心连线上,则依然交于两个点,所以在选择对照点时,应尽可能使对照点分布在未知点四周,多取几个点位未尝不是一门好事

主要用到这两个库:

import math
import pyproj

pyproj是用于坐标转换的 这里采用的是utm平面坐标与WGS84经纬度坐标

这里的半径r单位都是米

高德地图用的是GCJ02坐标(还有腾讯) GPS用的是WGS84坐标(谷歌也是) 百度地图用的是BD09坐标

所以在实际计算出来导入地图里面查看时 要么采用WGS84地图 要么就要涉及到坐标转换

首先是坐标转换
在utm坐标中 有个zone值 也就是经度分区 计算公式为int(lon/6+31)
在反坐标转换中 也要输入zone值 这里直接可以输入转换前求得的zone值

def lonlat2utm(lon,lat):z=int(lon/6+31)proj = pyproj.Proj(proj='utm',zone=z,ellps='WGS84')return proj(lon, lat),zdef utm2lonlat(x,y,z):proj = pyproj.Proj(proj='utm',zone=z,ellps='WGS84')return proj(x, y,inverse=True)

平面上求圆的交点

def insec(p1,r1,p2,r2):x = p1[0]y = p1[1]R = r1a = p2[0]b = p2[1]S = r2d = math.sqrt((abs(a-x))**2 + (abs(b-y))**2)if d > (R+S) or d < (abs(R-S)):
#        print ("没有公共点")return elif d == 0 and R==S :
#        print ("两个圆同心")returnelse:A = (R**2 - S**2 + d**2) / (2 * d)h = math.sqrt(R**2 - A**2)x2 = x + A * (a-x)/dy2 = y + A * (b-y)/dx3 = x2 - h * (b - y) / dy3 = y2 + h * (a - x) / dx4 = x2 + h * (b - y) / dy4 = y2 - h * (a - x) / dc1=[x3, y3]c2=[x4, y4]return c1,c2

经纬度上求两个圆交点坐标
在反坐标转换中 也要输入zone值 这里直接可以输入转换前求得的两个经纬度坐标的zone平均值
所以 两个要求的区域离得不远 误差就很小 离得太远了 误差就可能大 需要手动去调整 这里是通用函数

def location_trans(p1,r1,p2,r2):z1=lonlat2utm(p1[0],p1[1])z2=lonlat2utm(p2[0],p2[1])z=int((z1[1]+z2[1])/2)    C=insec(z1[0],r1,z2[0],r2)if C:a=utm2lonlat(C[0][0],C[0][1],z)b=utm2lonlat(C[1][0],C[1][1],z)return a,belse:return None,None

运行:

 a=[[114.304569,30.593354],300000]b=[[115.857972,28.682976],400000]c=[[116.378517,39.865246],900000]print(location_trans(b[0],b[1],c[0],c[1]))

输出:

([114.12482189881902, 31.962881802790577], [117.87031764680636, 31.841927527011755])

在求三个圆的交点时 最多会求出六个点
在六个点中筛选出离另外一个圆最近的点 即可得出三个相近点的坐标

求离得近的那个点的平面坐标

def location_min(p1,p2,p,r):d1=math.fabs(r-math.sqrt((p[0]-p1[0])**2+(p[1]-p1[1])**2))d2=math.fabs(r-math.sqrt((p[0]-p2[0])**2+(p[1]-p2[1])**2))if d1<d2:return p1else:return p2

得到三个点后 求三个点的中心点 即可算出大概位置
中心点的zone值是根据其他三个zone值求平均来确定的
所以 三个要求的区域离得不远 误差就很小 离得太远了 误差就可能大 需要手动去调整 这里是通用函数

def location_judg(p1,r1,p2,r2,p3,r3):li=[]z1=lonlat2utm(p1[0],p1[1])z2=lonlat2utm(p2[0],p2[1])z3=lonlat2utm(p3[0],p3[1])z12=int((z1[1]+z2[1])/2)z13=int((z1[1]+z3[1])/2)z23=int((z2[1]+z3[1])/2)z=int((z12+z13+z23)/3)C12=insec(z1[0],r1,z2[0],r2)C13=insec(z1[0],r1,z3[0],r3)C23=insec(z2[0],r2,z3[0],r3)if C12:m12=location_min(C12[0],C12[1],z3[0],r3)li.append(utm2lonlat(m12[0],m12[1],z12))else:li.append(None)if C13:m13=location_min(C13[0],C13[1],z2[0],r2)li.append(utm2lonlat(m13[0],m13[1],z13))else:li.append(None)if C23:m23=location_min(C23[0],C23[1],z1[0],r1)li.append(utm2lonlat(m23[0],m23[1],z23))else:li.append(None)if C12 and C13 and C23:
#        print("三个坐标作的圆都有公共点")m=[(m12[0]+m13[0]+m23[0])/3,(m12[1]+m13[1]+m23[1])/3]li.append(utm2lonlat(m[0],m[1],z))return lielif C12 or C13 or C23:
#        print("三个坐标作的圆不全有公共点")li.append(None)return lielse:
#        print("三个坐标作的圆都没有公共点")return 

最后返回的列表分别是12的最接近坐标 13的最接近坐标 23的最接近坐标 和这三个坐标的中心点坐标 如果不存在 则返回None

运行:

if __name__ == "__main__":a=[[114.304569,30.593354],300000]b=[[115.857972,28.682976],400000]c=[[116.378517,39.865246],900000]print(location_trans(b[0],b[1],c[0],c[1]))    print(location_judg(a[0],a[1],b[0],b[1],c[0],c[1]))

结果:

[(116.85351953263574, 32.18782636821823), (117.13697531307241, 31.774218803048125), (117.87031764680636, 31.841927527011755), (117.28744847106574, 31.935380071325877)]

整体代码:

# -*- coding: utf-8 -*-
import math
import pyprojdef lonlat2utm(lon,lat):z=int(lon/6+31)proj = pyproj.Proj(proj='utm',zone=z,ellps='WGS84')return proj(lon, lat),zdef utm2lonlat(x,y,z):proj = pyproj.Proj(proj='utm',zone=z,ellps='WGS84')return proj(x, y,inverse=True)def insec(p1,r1,p2,r2):x = p1[0]y = p1[1]R = r1a = p2[0]b = p2[1]S = r2d = math.sqrt((abs(a-x))**2 + (abs(b-y))**2)if d > (R+S) or d < (abs(R-S)):
#        print ("没有公共点")return elif d == 0 and R==S :
#        print ("两个圆同心")returnelse:A = (R**2 - S**2 + d**2) / (2 * d)h = math.sqrt(R**2 - A**2)x2 = x + A * (a-x)/dy2 = y + A * (b-y)/dx3 = x2 - h * (b - y) / dy3 = y2 + h * (a - x) / dx4 = x2 + h * (b - y) / dy4 = y2 - h * (a - x) / dc1=[x3, y3]c2=[x4, y4]return c1,c2def location_trans(p1,r1,p2,r2):z1=lonlat2utm(p1[0],p1[1])z2=lonlat2utm(p2[0],p2[1])z=int((z1[1]+z2[1])/2)    C=insec(z1[0],r1,z2[0],r2)if C:a=utm2lonlat(C[0][0],C[0][1],z)b=utm2lonlat(C[1][0],C[1][1],z)return a,belse:return None,Nonedef location_min(p1,p2,p,r):d1=math.fabs(r-math.sqrt((p[0]-p1[0])**2+(p[1]-p1[1])**2))d2=math.fabs(r-math.sqrt((p[0]-p2[0])**2+(p[1]-p2[1])**2))if d1<d2:return p1else:return p2def location_judg(p1,r1,p2,r2,p3,r3):li=[]z1=lonlat2utm(p1[0],p1[1])z2=lonlat2utm(p2[0],p2[1])z3=lonlat2utm(p3[0],p3[1])z12=int((z1[1]+z2[1])/2)z13=int((z1[1]+z3[1])/2)z23=int((z2[1]+z3[1])/2)z=int((z12+z13+z23)/3)C12=insec(z1[0],r1,z2[0],r2)C13=insec(z1[0],r1,z3[0],r3)C23=insec(z2[0],r2,z3[0],r3)if C12:m12=location_min(C12[0],C12[1],z3[0],r3)li.append(utm2lonlat(m12[0],m12[1],z12))else:li.append(None)if C13:m13=location_min(C13[0],C13[1],z2[0],r2)li.append(utm2lonlat(m13[0],m13[1],z13))else:li.append(None)if C23:m23=location_min(C23[0],C23[1],z1[0],r1)li.append(utm2lonlat(m23[0],m23[1],z23))else:li.append(None)if C12 and C13 and C23:
#        print("三个坐标作的圆都有公共点")m=[(m12[0]+m13[0]+m23[0])/3,(m12[1]+m13[1]+m23[1])/3]li.append(utm2lonlat(m[0],m[1],z))return lielif C12 or C13 or C23:
#        print("三个坐标作的圆不全有公共点")li.append(None)return lielse:
#        print("三个坐标作的圆都没有公共点")return if __name__ == "__main__":a=[[114.304569,30.593354],300000]b=[[115.857972,28.682976],400000]c=[[116.378517,39.865246],900000]print(location_trans(b[0],b[1],c[0],c[1]))    print(location_judg(a[0],a[1],b[0],b[1],c[0],c[1]))

参考图如下:
加上界面:

def central_win(win):win.resizable(0,0)                      # 不可缩放screenwidth = win.winfo_screenwidth()    # 获取屏幕分辨率宽screenheight = win.winfo_screenheight()  # 获取屏幕分辨率高win.update()  # 更新窗口width = win.winfo_width()    # 重新赋值height = win.winfo_height()size = '+%d+%d' % ((screenwidth - width)/2, (screenheight - height)/2)# 重新赋值大小 大小为屏幕大小/2win.geometry(size)   # 以新大小定义窗口  def gui_start():root=tk.Tk()root.title("WSG84三点定位系统 By 网易独家音乐人Mike Zhou")mainfram=tk.Frame(root,width=500, height=920)mainfram.grid_propagate(0)mainfram.grid()central_win(root)  labelName=tk.Label(root, text='经度(正E负W)', justify=tk.LEFT)labelName.place(x=120, y=20, width=180, height=50)labelName=tk.Label(root, text='纬度(正N负S)', justify=tk.LEFT)labelName.place(x=300, y=20, width=180, height=50)labelName=tk.Label(root, text='位置1:', justify=tk.LEFT)labelName.place(x=20, y=70, width=100, height=50)labelName=tk.Label(root, text='距离1:', justify=tk.LEFT)labelName.place(x=20, y=120, width=100, height=50)labelName=tk.Label(root, text='位置2:', justify=tk.LEFT)labelName.place(x=20, y=170, width=100, height=50)labelName=tk.Label(root, text='距离2:', justify=tk.LEFT)labelName.place(x=20, y=220, width=100, height=50)labelName=tk.Label(root, text='位置3:', justify=tk.LEFT)labelName.place(x=20, y=270, width=100, height=50)labelName=tk.Label(root, text='距离3:', justify=tk.LEFT)labelName.place(x=20, y=320, width=100, height=50)labelName=tk.Label(root, text='12推测点:', justify=tk.LEFT)labelName.place(x=20, y=440, width=100, height=50)labelName=tk.Label(root, text='13推测点:', justify=tk.LEFT)labelName.place(x=20, y=490, width=100, height=50)labelName=tk.Label(root, text='23推测点:', justify=tk.LEFT)labelName.place(x=20, y=540, width=100, height=50)labelName=tk.Label(root, text='中心推测点:', justify=tk.LEFT)labelName.place(x=20, y=590, width=100, height=50)labelName=tk.Label(root, text='米', justify=tk.LEFT)labelName.place(x=300, y=120, width=20, height=50)labelName=tk.Label(root, text='米', justify=tk.LEFT)labelName.place(x=300, y=220, width=20, height=50)labelName=tk.Label(root, text='米', justify=tk.LEFT)labelName.place(x=300, y=320, width=20, height=50)labelName=tk.Label(root, text='两点定位1:', justify=tk.LEFT)labelName.place(x=20, y=730, width=100, height=50)labelName=tk.Label(root, text='两点定位2:', justify=tk.LEFT)labelName.place(x=20, y=780, width=100, height=50)e1_lon = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e1_lon.delete(0, tk.END)  # 将输入框里面的内容清空e1_lon.insert(0, 114.304569)  e1_lon.place(x=120, y=70, width=180, height=50) e1_r = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e1_r.delete(0, tk.END)  # 将输入框里面的内容清空e1_r.insert(0, 300000)e1_r.place(x=120, y=120, width=180, height=50)    e2_lon = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e2_lon.delete(0, tk.END)  # 将输入框里面的内容清空e2_lon.insert(0, 115.857972)e2_lon.place(x=120, y=170, width=180, height=50) e2_r = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e2_r.delete(0, tk.END)  # 将输入框里面的内容清空e2_r.insert(0, 400000)e2_r.place(x=120, y=220, width=180, height=50)e3_lon = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e3_lon.delete(0, tk.END)  # 将输入框里面的内容清空e3_lon.insert(0, 116.378517)e3_lon.place(x=120, y=270, width=180, height=50)e3_r = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e3_r.delete(0, tk.END)  # 将输入框里面的内容清空e3_r.insert(0, 900000)e3_r.place(x=120, y=320, width=180, height=50)e1_lat = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e1_lat.delete(0, tk.END)  # 将输入框里面的内容清空e1_lat.insert(0, 30.593354)  e1_lat.place(x=300, y=70, width=180, height=50)e2_lat = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e2_lat.delete(0, tk.END)  # 将输入框里面的内容清空e2_lat.insert(0, 28.682976)  e2_lat.place(x=300, y=170, width=180, height=50)e3_lat = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e3_lat.delete(0, tk.END)  # 将输入框里面的内容清空e3_lat.insert(0, 39.865246)  e3_lat.place(x=300, y=270, width=180, height=50)ex1 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex1.delete(0, tk.END)  # 将输入框里面的内容清空ex1.insert(0, "")ex1.place(x=120, y=440, width=360, height=50)ex1.config(state='readonly')ex2 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex2.delete(0, tk.END)  # 将输入框里面的内容清空ex2.insert(0, "")ex2.place(x=120, y=490, width=360, height=50)ex2.config(state='readonly')ex3 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex3.delete(0, tk.END)  # 将输入框里面的内容清空ex3.insert(0, "")ex3.place(x=120, y=540, width=360, height=50)ex3.config(state='readonly')ex4 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex4.delete(0, tk.END)  # 将输入框里面的内容清空ex4.insert(0, "")ex4.place(x=120, y=590, width=360, height=50)ex4.config(state='readonly')ey1 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ey1.delete(0, tk.END)  # 将输入框里面的内容清空ey1.insert(0, "")ey1.place(x=120, y=730, width=360, height=50)ey1.config(state='readonly')ey2 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ey2.delete(0, tk.END)  # 将输入框里面的内容清空ey2.insert(0, "")ey2.place(x=120, y=780, width=360, height=50)ey2.config(state='readonly')def input_judg(e):try:s=float(str(e.get()))except:            e.delete(0, tk.END)e.insert(0, 0)s=0.0return sif e==e1_lat or e==e2_lat or e==e3_lat:if s<-90 or s>90:e.delete(0, tk.END)e.insert(0, 0)s=0.0elif e==e1_lon or e==e2_lon or e==e3_lon:if s<-180 or s>180:e.delete(0, tk.END)e.insert(0, 0)s=0.0elif e==e1_r or e==e2_r or e==e3_r:if s<0 or s>400750170:e.delete(0, tk.END)e.insert(0, 0)s=0.0return sdef view(e,s):s=str(s)e.config(state='normal')e.delete(0, tk.END)e.insert(0, s)e.config(state='readonly')def event():lat1 = input_judg(e1_lat)lon1 = input_judg(e1_lon)r1 = input_judg(e1_r)lat2 = input_judg(e2_lat)lon2 = input_judg(e2_lon)r2 = input_judg(e2_r)lat3 = input_judg(e3_lat)lon3 = input_judg(e3_lon)r3 = input_judg(e3_r)result = location_judg([lon1,lat1],r1,[lon2,lat2],r2,[lon3,lat3],r3)view(ex1,result[0])view(ex2,result[1])view(ex3,result[2])view(ex4,result[3])def double(n):lat1 = input_judg(e1_lat)lon1 = input_judg(e1_lon)r1 = input_judg(e1_r)lat2 = input_judg(e2_lat)lon2 = input_judg(e2_lon)r2 = input_judg(e2_r)lat3 = input_judg(e3_lat)lon3 = input_judg(e3_lon)r3 = input_judg(e3_r)if n==1:result = location_trans([lon1,lat1],r1,[lon2,lat2],r2)elif n==2:result = location_trans([lon1,lat1],r1,[lon3,lat3],r3)elif n==3:result = location_trans([lon2,lat2],r2,[lon3,lat3],r3)else:result = location_trans([lon1,lat1],r1,[lon2,lat2],r2)view(ey1,result[0])view(ey2,result[1])def clean():view(ex1,"")view(ex2,"")view(ex3,"")view(ex4,"")view(ey1,"")view(ey2,"")e1_lon.delete(0, tk.END)e1_lon.insert(0, "")e2_lon.delete(0, tk.END)e2_lon.insert(0, "")e3_lon.delete(0, tk.END)e3_lon.insert(0, "")e1_lat.delete(0, tk.END)e1_lat.insert(0, "")e2_lat.delete(0, tk.END)e2_lat.insert(0, "")e3_lat.delete(0, tk.END)e3_lat.insert(0, "")e1_r.delete(0, tk.END)e1_r.insert(0, "")e2_r.delete(0, tk.END)e2_r.insert(0, "")e3_r.delete(0, tk.END)e3_r.insert(0, "")def start_event():t=Thread(target=event)t.setDaemon(False)t.start()def start_clean():t=Thread(target=clean)t.setDaemon(False)t.start()def start_double(i):t=Thread(target=double,args=(i,))t.setDaemon(False)t.start()def button_event(s):if(s.keysym=='C' or s.keysym=='c'):start_event()elif(s.keysym=='D' or s.keysym=='d'):start_clean()b1=tk.Button(mainfram,width=30,text="计算123三点定位",command=start_event)b1.bind_all('C',button_event)b1.bind_all('c',button_event)b1.place(x=20, y=640, width=460, height=70)b2=tk.Button(mainfram,width=30,text="清空",command=start_clean)b2.bind_all('D',button_event)b2.bind_all('d',button_event)b2.place(x=20, y=370, width=460, height=50)b3=tk.Button(mainfram,width=30,text="计算12两点定位",command=lambda:start_double(1))b3.place(x=20, y=830, width=140, height=70)b4=tk.Button(mainfram,width=30,text="计算13两点定位",command=lambda:start_double(2))b4.place(x=180, y=830, width=140, height=70)b5=tk.Button(mainfram,width=30,text="计算23两点定位",command=lambda:start_double(3))b5.place(x=340, y=830, width=140, height=70)start_event()start_double(1)root.mainloop()

最后运行:

所有代码:

# -*- coding: utf-8 -*-
import math
import pyproj
import tkinter as tk
from threading import Threaddef lonlat2utm(lon,lat):z=int(lon/6+31)proj = pyproj.Proj(proj='utm',zone=z,ellps='WGS84')return proj(lon, lat),zdef utm2lonlat(x,y,z):proj = pyproj.Proj(proj='utm',zone=z,ellps='WGS84')return proj(x, y,inverse=True)def insec(p1,r1,p2,r2):x = p1[0]y = p1[1]R = r1a = p2[0]b = p2[1]S = r2d = math.sqrt((abs(a-x))**2 + (abs(b-y))**2)if d > (R+S) or d < (abs(R-S)):
#        print ("没有公共点")return elif d == 0 and R==S :
#        print ("两个圆同心")return else:A = (R**2 - S**2 + d**2) / (2 * d)h = math.sqrt(R**2 - A**2)x2 = x + A * (a-x)/dy2 = y + A * (b-y)/dx3 = x2 - h * (b - y) / dy3 = y2 + h * (a - x) / dx4 = x2 + h * (b - y) / dy4 = y2 - h * (a - x) / dc1=[x3, y3]c2=[x4, y4]return c1,c2def location_trans(p1,r1,p2,r2):z1=lonlat2utm(p1[0],p1[1])z2=lonlat2utm(p2[0],p2[1])z=int((z1[1]+z2[1])/2)    C=insec(z1[0],r1,z2[0],r2)if C:a=utm2lonlat(C[0][0],C[0][1],z)b=utm2lonlat(C[1][0],C[1][1],z)return a,belse:return None,Nonedef location_min(p1,p2,p,r):d1=math.fabs(r-math.sqrt((p[0]-p1[0])**2+(p[1]-p1[1])**2))d2=math.fabs(r-math.sqrt((p[0]-p2[0])**2+(p[1]-p2[1])**2))if d1<d2:return p1else:return p2def location_judg(p1,r1,p2,r2,p3,r3):li=[]z1=lonlat2utm(p1[0],p1[1])z2=lonlat2utm(p2[0],p2[1])z3=lonlat2utm(p3[0],p3[1])z12=int((z1[1]+z2[1])/2)z13=int((z1[1]+z3[1])/2)z23=int((z2[1]+z3[1])/2)z=int((z12+z13+z23)/3)C12=insec(z1[0],r1,z2[0],r2)C13=insec(z1[0],r1,z3[0],r3)C23=insec(z2[0],r2,z3[0],r3)if C12:m12=location_min(C12[0],C12[1],z3[0],r3)li.append(utm2lonlat(m12[0],m12[1],z12))else:li.append(None)if C13:m13=location_min(C13[0],C13[1],z2[0],r2)li.append(utm2lonlat(m13[0],m13[1],z13))else:li.append(None)if C23:m23=location_min(C23[0],C23[1],z1[0],r1)li.append(utm2lonlat(m23[0],m23[1],z23))else:li.append(None)if C12 and C13 and C23:
#        print("三个坐标作的圆都有公共点")m=[(m12[0]+m13[0]+m23[0])/3,(m12[1]+m13[1]+m23[1])/3]li.append(utm2lonlat(m[0],m[1],z))return lielif C12 or C13 or C23:
#        print("三个坐标作的圆不全有公共点")li.append(None)return lielse:
#        print("三个坐标作的圆都没有公共点")li.append(None)li.append(None)li.append(None)li.append(None)return lidef central_win(win):win.resizable(0,0)                      # 不可缩放screenwidth = win.winfo_screenwidth() # 获取屏幕分辨率宽screenheight = win.winfo_screenheight()  # 获取屏幕分辨率高win.update()  # 更新窗口width = win.winfo_width()    # 重新赋值height = win.winfo_height()size = '+%d+%d' % ((screenwidth - width)/2, (screenheight - height)/2)# 重新赋值大小 大小为屏幕大小/2win.geometry(size)   # 以新大小定义窗口  def gui_start():root=tk.Tk()root.title("WSG84三点定位系统 By 网易独家音乐人Mike Zhou")mainfram=tk.Frame(root,width=500, height=920)mainfram.grid_propagate(0)mainfram.grid()central_win(root)  labelName=tk.Label(root, text='经度(正E负W)', justify=tk.LEFT)labelName.place(x=120, y=20, width=180, height=50)labelName=tk.Label(root, text='纬度(正N负S)', justify=tk.LEFT)labelName.place(x=300, y=20, width=180, height=50)labelName=tk.Label(root, text='位置1:', justify=tk.LEFT)labelName.place(x=20, y=70, width=100, height=50)labelName=tk.Label(root, text='距离1:', justify=tk.LEFT)labelName.place(x=20, y=120, width=100, height=50)labelName=tk.Label(root, text='位置2:', justify=tk.LEFT)labelName.place(x=20, y=170, width=100, height=50)labelName=tk.Label(root, text='距离2:', justify=tk.LEFT)labelName.place(x=20, y=220, width=100, height=50)labelName=tk.Label(root, text='位置3:', justify=tk.LEFT)labelName.place(x=20, y=270, width=100, height=50)labelName=tk.Label(root, text='距离3:', justify=tk.LEFT)labelName.place(x=20, y=320, width=100, height=50)labelName=tk.Label(root, text='12推测点:', justify=tk.LEFT)labelName.place(x=20, y=440, width=100, height=50)labelName=tk.Label(root, text='13推测点:', justify=tk.LEFT)labelName.place(x=20, y=490, width=100, height=50)labelName=tk.Label(root, text='23推测点:', justify=tk.LEFT)labelName.place(x=20, y=540, width=100, height=50)labelName=tk.Label(root, text='中心推测点:', justify=tk.LEFT)labelName.place(x=20, y=590, width=100, height=50)labelName=tk.Label(root, text='米', justify=tk.LEFT)labelName.place(x=300, y=120, width=20, height=50)labelName=tk.Label(root, text='米', justify=tk.LEFT)labelName.place(x=300, y=220, width=20, height=50)labelName=tk.Label(root, text='米', justify=tk.LEFT)labelName.place(x=300, y=320, width=20, height=50)labelName=tk.Label(root, text='两点定位1:', justify=tk.LEFT)labelName.place(x=20, y=730, width=100, height=50)labelName=tk.Label(root, text='两点定位2:', justify=tk.LEFT)labelName.place(x=20, y=780, width=100, height=50)e1_lon = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e1_lon.delete(0, tk.END)  # 将输入框里面的内容清空e1_lon.insert(0, 114.304569)  e1_lon.place(x=120, y=70, width=180, height=50) e1_r = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e1_r.delete(0, tk.END)  # 将输入框里面的内容清空e1_r.insert(0, 300000)e1_r.place(x=120, y=120, width=180, height=50)    e2_lon = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e2_lon.delete(0, tk.END)  # 将输入框里面的内容清空e2_lon.insert(0, 115.857972)e2_lon.place(x=120, y=170, width=180, height=50) e2_r = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e2_r.delete(0, tk.END)  # 将输入框里面的内容清空e2_r.insert(0, 400000)e2_r.place(x=120, y=220, width=180, height=50)e3_lon = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e3_lon.delete(0, tk.END)  # 将输入框里面的内容清空e3_lon.insert(0, 116.378517)e3_lon.place(x=120, y=270, width=180, height=50)e3_r = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)e3_r.delete(0, tk.END)  # 将输入框里面的内容清空e3_r.insert(0, 900000)e3_r.place(x=120, y=320, width=180, height=50)e1_lat = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e1_lat.delete(0, tk.END)  # 将输入框里面的内容清空e1_lat.insert(0, 30.593354)  e1_lat.place(x=300, y=70, width=180, height=50)e2_lat = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e2_lat.delete(0, tk.END)  # 将输入框里面的内容清空e2_lat.insert(0, 28.682976)  e2_lat.place(x=300, y=170, width=180, height=50)e3_lat = tk.Entry(mainfram)#e1.grid(ipadx=50,row=0,column=1)e3_lat.delete(0, tk.END)  # 将输入框里面的内容清空e3_lat.insert(0, 39.865246)  e3_lat.place(x=300, y=270, width=180, height=50)ex1 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex1.delete(0, tk.END)  # 将输入框里面的内容清空ex1.insert(0, "")ex1.place(x=120, y=440, width=360, height=50)ex1.config(state='readonly')ex2 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex2.delete(0, tk.END)  # 将输入框里面的内容清空ex2.insert(0, "")ex2.place(x=120, y=490, width=360, height=50)ex2.config(state='readonly')ex3 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex3.delete(0, tk.END)  # 将输入框里面的内容清空ex3.insert(0, "")ex3.place(x=120, y=540, width=360, height=50)ex3.config(state='readonly')ex4 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ex4.delete(0, tk.END)  # 将输入框里面的内容清空ex4.insert(0, "")ex4.place(x=120, y=590, width=360, height=50)ex4.config(state='readonly')ey1 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ey1.delete(0, tk.END)  # 将输入框里面的内容清空ey1.insert(0, "")ey1.place(x=120, y=730, width=360, height=50)ey1.config(state='readonly')ey2 = tk.Entry(mainfram)#e2.grid(ipadx=50,row=1,column=1)ey2.delete(0, tk.END)  # 将输入框里面的内容清空ey2.insert(0, "")ey2.place(x=120, y=780, width=360, height=50)ey2.config(state='readonly')def input_judg(e):try:s=float(str(e.get()))except:            e.delete(0, tk.END)e.insert(0, 0)s=0.0return sif e==e1_lat or e==e2_lat or e==e3_lat:if s<-90 or s>90:e.delete(0, tk.END)e.insert(0, 0)s=0.0elif e==e1_lon or e==e2_lon or e==e3_lon:if s<-180 or s>180:e.delete(0, tk.END)e.insert(0, 0)s=0.0elif e==e1_r or e==e2_r or e==e3_r:if s<0 or s>400750170:e.delete(0, tk.END)e.insert(0, 0)s=0.0return sdef view(e,s):s=str(s)e.config(state='normal')e.delete(0, tk.END)e.insert(0, s)e.config(state='readonly')def event():lat1 = input_judg(e1_lat)lon1 = input_judg(e1_lon)r1 = input_judg(e1_r)lat2 = input_judg(e2_lat)lon2 = input_judg(e2_lon)r2 = input_judg(e2_r)lat3 = input_judg(e3_lat)lon3 = input_judg(e3_lon)r3 = input_judg(e3_r)result = location_judg([lon1,lat1],r1,[lon2,lat2],r2,[lon3,lat3],r3)view(ex1,result[0])view(ex2,result[1])view(ex3,result[2])view(ex4,result[3])def double(n):lat1 = input_judg(e1_lat)lon1 = input_judg(e1_lon)r1 = input_judg(e1_r)lat2 = input_judg(e2_lat)lon2 = input_judg(e2_lon)r2 = input_judg(e2_r)lat3 = input_judg(e3_lat)lon3 = input_judg(e3_lon)r3 = input_judg(e3_r)if n==1:result = location_trans([lon1,lat1],r1,[lon2,lat2],r2)elif n==2:result = location_trans([lon1,lat1],r1,[lon3,lat3],r3)elif n==3:result = location_trans([lon2,lat2],r2,[lon3,lat3],r3)else:result = location_trans([lon1,lat1],r1,[lon2,lat2],r2)view(ey1,result[0])view(ey2,result[1])def clean():view(ex1,"")view(ex2,"")view(ex3,"")view(ex4,"")view(ey1,"")view(ey2,"")e1_lon.delete(0, tk.END)e1_lon.insert(0, "")e2_lon.delete(0, tk.END)e2_lon.insert(0, "")e3_lon.delete(0, tk.END)e3_lon.insert(0, "")e1_lat.delete(0, tk.END)e1_lat.insert(0, "")e2_lat.delete(0, tk.END)e2_lat.insert(0, "")e3_lat.delete(0, tk.END)e3_lat.insert(0, "")e1_r.delete(0, tk.END)e1_r.insert(0, "")e2_r.delete(0, tk.END)e2_r.insert(0, "")e3_r.delete(0, tk.END)e3_r.insert(0, "")def start_event():t=Thread(target=event)t.setDaemon(False)t.start()def start_clean():t=Thread(target=clean)t.setDaemon(False)t.start()def start_double(i):t=Thread(target=double,args=(i,))t.setDaemon(False)t.start()def button_event(s):if(s.keysym=='C' or s.keysym=='c'):start_event()elif(s.keysym=='D' or s.keysym=='d'):start_clean()b1=tk.Button(mainfram,width=30,text="计算123三点定位",command=start_event)b1.bind_all('C',button_event)b1.bind_all('c',button_event)b1.place(x=20, y=640, width=460, height=70)b2=tk.Button(mainfram,width=30,text="清空",command=start_clean)b2.bind_all('D',button_event)b2.bind_all('d',button_event)b2.place(x=20, y=370, width=460, height=50)b3=tk.Button(mainfram,width=30,text="计算12两点定位",command=lambda:start_double(1))b3.place(x=20, y=830, width=140, height=70)b4=tk.Button(mainfram,width=30,text="计算13两点定位",command=lambda:start_double(2))b4.place(x=180, y=830, width=140, height=70)b5=tk.Button(mainfram,width=30,text="计算23两点定位",command=lambda:start_double(3))b5.place(x=340, y=830, width=140, height=70)start_event()start_double(1)root.mainloop()if __name__ == "__main__":gui_start()

【GUI界面】基于Python的WSG84三点定位系统(经纬度坐标与平面坐标转换法求解)相关推荐

  1. 【Python】利用Python实现精准三点定位(经纬度坐标与平面坐标转换法求解)

    [Python]利用Python实现精准三点定位(经纬度坐标与平面坐标转换法求解) 众所周知,如果已知三个点的坐标,到一个未知点的距离,则可以利用以距离为半径画圆的方式来求得未知点坐标. 如果只有两个 ...

  2. 【精准三点定位求解汇总】利用Python或JavaScript高德地图开放平台实现精准三点定位(经纬度坐标与平面坐标转换法求解、几何绘图法求解)

    [精准三点定位求解汇总]利用Python或JavaScript高德地图开放平台实现精准三点定位(经纬度坐标与平面坐标转换法求解.几何绘图法求解) 众所周知,如果已知三个点的坐标,到一个未知点的距离,则 ...

  3. Python之GUI:基于Python的GUI界面设计的一套AI课程学习(机器学习、深度学习、大数据、云计算等)推荐系统(包括语音生成、识别等前沿黑科技)

    Python之GUI:基于Python的GUI界面设计的一套AI课程学习(机器学习.深度学习.大数据.云计算等)推荐系统(包括语音生成.识别等前沿黑科技) 导读 基于Python的GUI界面设计的一套 ...

  4. 基于Python的人工智能美颜系统

    基于Python的人工智能美颜系统使用PyQt5模块搭建可视化界面,使用Dlib模型(shape_predictor_68_face_landmarks.dat)实现人脸关键点检测和定位,人脸美颜(美 ...

  5. python毕业设计开题报告-基于Python的教学互动系统的设计与实现开题报告

    基于Python的教学互动系统的设计与实现开题报告 背景: 在各种信息技术与课堂的不断探索中,我们一直在寻找一个能提高教学效率的方式,同时可以发现要提高教学效率,在课堂教学中必不可少的就是师生间的互动 ...

  6. 基于python的分布式扫描器_基于python的服务器监测系统的设计

    基于 python 的服务器监测系统的设计 高正 ; 徐浩 ; 余曼 [期刊名称] <电脑知识与技术> [年 ( 卷 ), 期] 2017(013)002 [摘要] 本文介绍了一种基于 P ...

  7. 【优秀课设】武汉光迅科技22校招笔试Python题改进(增加GUI)——基于Python的125温度传感器模块数据处理

    武汉光迅科技22校招笔试Python题改进(增加GUI) 基于Python的125温度传感器模块数据处理 原本的基础代码: blog.csdn.net/weixin_53403301/article/ ...

  8. python开发的著名软件公司_软件开发公司_软件外包_项目外包平台基于Python开发一个全文检索系统...

    基于Python开发一个全文检索系统.功能要求为: 使用全文检索引擎对文本进行检索.文本的格式为Word.PDF.TXT. 同时按数据域进行复合条件检索.数据域指文本对应的信息,例如创建人.文件编号. ...

  9. python实现文件共享_基于Python的分布式文件共享系统的实现

    龙源期刊网 http://www.qikan.com.cn 基于 Python 的分布式文件共享系统的实现 作者:朱亚林 纪宏伟 来源:<智能计算机与应用> 2015 年第 04 期 摘 ...

最新文章

  1. initrd映像文档的作用和制作
  2. 字符串 编码转换 ATL
  3. 6.ajax应用,ajax应用
  4. JDK 8 新特性 之 方法引用
  5. 公用ip地址查询_是什么使您无法更改公用IP地址并在Internet上造成严重破坏?
  6. 啥叫旁路电容?啥叫去耦?可以不再争论了吗
  7. .Net Core中Dapper的使用详解
  8. CVPR 2021 预讲 · 华为诺亚专场,5 篇精华报告,覆盖NAS、蒸馏、检测和降噪
  9. 无损数据压缩算法c语言,C语言实现无损压缩算法
  10. 解读阿里云是干什么的?
  11. 关于类加载机制,你知道多少
  12. 迪士尼机器人芭蕾舞_浅析迪士尼跳跳虎机器人
  13. 标准解读系列之三:智慧高速建设需要什么样的技术架构?
  14. tableau高级绘图(六)--tableau绘制范围点图
  15. css 优惠券样式大全
  16. 04、Netty学习笔记—(黏包半包及协议设计解析)
  17. 阿翔编程学-Axis
  18. smart200+步进控制
  19. 组件化思想+Vue路由_day09
  20. showdoc mysql版_Showdoc

热门文章

  1. NumPy 初学者指南中文第三版·翻译完成
  2. SMB交换机、接入交换机、汇聚交换机、核心交换机
  3. 将虚拟机VMware从C盘移动到E盘
  4. 跨平台转码软件HandBrake, 一款万能的视频压缩/格式转换工具!
  5. python 之 Qt Designer 高铁火车票查询工具
  6. Verilog HDL 学习篇——六位数码管驱动
  7. 【pyecharts50例】渐变色效果柱状图(直方图)~
  8. 快递取件码生成软件_一种分布式的取件码生成方法技术
  9. solr6 mysql_solr6.6.0学习(2)创建核心和与Mysql数据库连接
  10. 【GD32】GD32设置看门狗