• 毕设_利用经纬度判断距离和角度(三)


    package anglepage;
    
    //import anglepage.Angle;
    public class Angle {
    	// longitude 经度,latitude 纬度
    	MyLatLng A, B;
    
    	public MyLatLng getA() {
    		return A;
    	}
    
    	public MyLatLng getB() {
    		return B;
    	}
    
    	public void setA(MyLatLng a) {
    		A = a;
    	}
    
    	public void setB(MyLatLng b) {
    		B = b;
    	}
    
    	public Angle(double longitudeA, double latitudeA, double longitudeB,
    			double latitudeB) {
    		this.A = new MyLatLng(longitudeA, latitudeA);
    		this.B = new MyLatLng(longitudeB, latitudeB);
    
    	}
    
    	public double getAngle() {
    		double dx = (B.m_RadLo - A.m_RadLo) * A.Ed;
    		double dy = (B.m_RadLa - A.m_RadLa) * A.Ec;
    		double angle = 0.0;
    		angle = Math.atan(Math.abs(dx / dy)) * 180. / Math.PI;
    		double dLo = B.m_Longitude - A.m_Longitude;
    		double dLa = B.m_Latitude - A.m_Latitude;
    		if (dLo > 0 && dLa <= 0) {
    			angle = (90. - angle) + 90;
    		} else if (dLo <= 0 && dLa < 0) {
    			angle = angle + 180.;
    		} else if (dLo < 0 && dLa >= 0) {
    			angle = (90. - angle) + 270;
    		}
    		return angle;
    	}
    
    //	public static void main(String[] args) {
    //		Angle angle = new Angle(113.249648, 23.401553, 113.246033, 23.403362);
    //		System.out.println(angle.getAngle());
    //		angle.A.set(113.246033, 23.403362);
    //		angle.B.set(113.249648, 23.401553);
    //		System.out.println(angle.getAngle());
    //	}
    }
    

      

    package anglepage;
    
    public class MyLatLng {
    
    	final static double Rc = 6378137;
    	final static double Rj = 6356725;
    	double m_LoDeg, m_LoMin, m_LoSec;
    	double m_LaDeg, m_LaMin, m_LaSec;
    	double m_Longitude, m_Latitude;
    	double m_RadLo, m_RadLa;
    	double Ec;
    	double Ed;
    
    	public void set(double longitude, double latitude) {
    		m_Longitude = longitude;
    		m_Latitude = latitude;
    	}
    
    	public MyLatLng(double longitude, double latitude) {
    		m_LoDeg = (int) longitude;
    		m_LoMin = (int) ((longitude - m_LoDeg) * 60);
    		m_LoSec = (longitude - m_LoDeg - m_LoMin / 60.) * 3600;
    
    		m_LaDeg = (int) latitude;
    		m_LaMin = (int) ((latitude - m_LaDeg) * 60);
    		m_LaSec = (latitude - m_LaDeg - m_LaMin / 60.) * 3600;
    
    		m_Longitude = longitude;
    		m_Latitude = latitude;
    		m_RadLo = longitude * Math.PI / 180.;
    		m_RadLa = latitude * Math.PI / 180.;
    		Ec = Rj + (Rc - Rj) * (90. - m_Latitude) / 90.;
    		Ed = Ec * Math.cos(m_RadLa);
    	}
    
    }
    

      

    进行距离的计算:
    d = 6370*math.acos(math.cos(A.x)*math.cos(B.x)*math.cos(A.y-B.y)+math.sin(A.x)*math.sin(B.x))
    该方法是错的,纠正为:
    http://blog.csdn.net/b_h_l/article/details/8657040

    使用python导入该文件转换的jar包后,直接建立一个对象,进行赋值即可。

      jarpath = os.path.join(os.path.abspath('.'), 'C:/Python27/jarpage')
        jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.ext.dirs=%s" % jarpath)
        Test = jpype.JClass('anglepage.Angle')  # 取得包
        angle = Test(113.246033, 23.403362,113.249648,23.401553)
        angle.getA().set(113.249648,23.401553)
        angle.getB().set(113.246033, 23.403362)
        print(angle.getAngle())
        jpype.shutdownJVM()
    

      

  • 相关阅读:
    Python基础03 序列
    Python基础04 运算
    Python基础01 Hello World!
    Python基础02 基本数据类型
    wpf 中AxShockwaveFlash重写以及屏蔽鼠标右键
    正则表达式判断金额
    解决jquery操作checkbox全选全不选无法勾选问题
    关于asp.net网址出现乱码问题的解决方法
    c#中用DirectShow实现媒体播放器的核心(1) DirectShow简介
    “XXX.Index”不扩展类“System.Web.UI.Page”,因此此处不允许的问题
  • 原文地址:https://www.cnblogs.com/lovelystone/p/6692771.html
Copyright © 2020-2023  润新知