利用两点的经纬度来计算这两点之间的距离

Imports System.Data
Imports System.Math
Imports System.Net
Imports System.IO
Imports System.Windows

'导入对应的名称空间
'数学的计算方法,
'程序的实现很简单

Public Class Diss
    Public Const Ea As Double = 6378137 '赤道半径
    Public Const Eb As Double = 6356725 '极半径
    Public Ec1 As Double = 0.0
    Public Ed1 As Double = 0.0
    Private j1 As Double = 0.0
    Private w1 As Double = 0.0
    Private jd1 As Double = 0.0
    Private wd1 As Double = 0.0

    Public Ec2 As Double = 0.0
    Public Ed2 As Double = 0.0
    Private j2 As Double = 0.0
    Private w2 As Double = 0.0
    Private jd2 As Double = 0.0
    Private wd2 As Double = 0.0

    Private Sub BtnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalc.Click
        Dim dx As Double = 0.0
        Dim dy As Double = 0.0
        Dim d As Double = 0.0

        jd1 = Me.TbJ1.Text.Trim.ToString()
        wd1 = Me.TbW1.Text.Trim.ToString()

        jd2 = Me.TbJ2.Text.Trim.ToString()
        wd2 = Me.TbW2.Text.Trim.ToString()

        j1 = jd1 * Math.PI / 180
        w1 = wd1 * Math.PI / 180
        Ec1 = Eb + (Ea - Eb) * (90 - wd1) / 90
        Ed1 = Ec1 * Math.Cos(w1)

        j2 = jd2 * Math.PI / 180
        w2 = wd2 * Math.PI / 180
        Ec2 = Eb + (Ea - Eb) * (90 - wd2) / 90
        Ed2 = Ec2 * Math.Cos(w2)

        dx = (j2 - j1) * Ed1
        dy = (w2 - w1) * Ec1
        d = Math.Sqrt(dx * dx + dy * dy)
        Me.TextBox5.Text = d.ToString()
 End Sub

    Private Sub BtnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Me.Close()
    End Sub
 End Class

posted @ 2007-09-03 14:49  寒天飞雪  阅读(950)  评论(2编辑  收藏  举报