تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] كيف يمكن حساب المسافة بدقة على سطح الارض
#3
(21-10-18, 11:43 PM)rnmr كتب : جرب هذا

هذا الموقع يحتوي المعادلة بلغة VB.NET
This routine calculates the distance between two points

قمت بتحويله إلى VB6
كود :
Private Sub Command1_Click()
       
   Dim dist As Double
   ' Point1 = 11.111111, 22.222222
   ' Point2 = 77.777777, 88.888888
   ' Unit = "K" ~ kilometers
       
   dist = distance(11.111111, 22.222222, 77.777777, 88.888888, "K") ' K = km
       
   MsgBox FormatNumber(dist) & " KM"

End Sub


':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::                                                                         :::
':::  This routine calculates the distance between two points (given the     :::
':::  latitude/longitude of those points). It is being used to calculate     :::
':::  the distance between two locations using GeoDataSource (TM) prodducts  :::
':::                                                                         :::
':::  Definitions:                                                           :::
':::    South latitudes are negative, east longitudes are positive           :::
':::                                                                         :::
':::  Passed to function:                                                    :::
':::    lat1, lon1 = Latitude and Longitude of point 1 (in decimal degrees)  :::
':::    lat2, lon2 = Latitude and Longitude of point 2 (in decimal degrees)  :::
':::    unit = the unit you desire for results                               :::
':::           where: 'M' is statute miles (default)                         :::
':::                  'K' is kilometers                                      :::
':::                  'N' is nautical miles                                  :::
':::                                                                         :::
':::  Worldwide cities and other features databases with latitude longitude  :::
':::  are available at https://www.geodatasource.com                          :::
':::                                                                         :::
':::  For enquiries, please contact sales@geodatasource.com                  :::
':::                                                                         :::
':::  Official Web site: https://www.geodatasource.com                        :::
':::                                                                         :::
':::              GeoDataSource.com (C) All Rights Reserved 2017             :::
':::                                                                         :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Public Function distance(ByVal lat1 As Double, ByVal lon1 As Double, ByVal lat2 As Double, ByVal lon2 As Double, ByVal unit As String) As Double
   Dim theta As Double
   theta = lon1 - lon2
   Dim dist As Double
   dist = Sin(deg2rad(lat1)) * Sin(deg2rad(lat2)) + Cos(deg2rad(lat1)) * Cos(deg2rad(lat2)) * Cos(deg2rad(theta))
   dist = ArcCos(dist)
   dist = rad2deg(dist)
   dist = dist * 60 * 1.1515
   If unit = "K" Then
       dist = dist * 1.609344
   ElseIf unit = "N" Then
       dist = dist * 0.8684
   End If
   distance = dist
End Function
Public Function ArcCos(ByVal x As Double) As Double
   ArcCos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function
Public Function ArcSin(ByVal x As Double) As Double
   ArcSin = Atn(x / Sqr(-x * x + 1))
End Function
Public Function Pi() As Double
 Pi = 4 * Atn(1#)
End Function
Private Function deg2rad(ByVal deg As Double) As Double
   deg2rad = (deg * Pi / 180#)
End Function
Private Function rad2deg(ByVal rad As Double) As Double
   rad2deg = rad / Pi * 180#
End Function

مع ملاحظة أن المسافة تقاس بشكل مستقيم بين النقطتين

كل الشكر والتقدير لك اخي العزيز . لكن تبقى مشكلة الدقة . في السافات البعيدة تكون الدقة مقبولة نوعا ما اما في المسافات القصيرة(اقل من 1كم ) مثلا هناك فرق كبير جدا . اكرر شكري لك وتقديري
   تحيــــــــــــــــــــــــــــاتي لكـــــــــــــــــــم    
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: كيف يمكن حساب المسافة بدقة على سطح الارض - بواسطة السيد الغالي - 22-10-18, 12:39 AM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [سؤال] هل يمكن جمع عمود فى datagride mohamed125 2 1,905 07-12-24, 02:27 AM
آخر رد: عبدالمؤمن
  كيف يمكن عمل clear لل datagrid haitham Muhammed 1 294 13-11-24, 12:42 AM
آخر رد: السيد الغالي
Question [vb6.0] كيف يمكن إدراج الاسم الذي موجود في الصورة في Label1 برمجياً ؟ Microformt 2 296 02-10-24, 06:01 PM
آخر رد: Microformt
  هل يمكن تغيير لون الخط في الزر مصمم هاوي 2 449 20-08-24, 09:12 PM
آخر رد: مصمم هاوي
Question [vb6.0] هل يمكن عرض اسماء الاصناف في الرسم البياني في جهة اليمين بشرط ياخد الاسماء من قاعدة Microformt 0 235 14-08-24, 06:42 PM
آخر رد: Microformt
  كيف يمكن استخدام الtimer لملء الكمبوبوكس haitham Muhammed 0 402 27-05-24, 09:55 PM
آخر رد: haitham Muhammed
Question [vb6.0] كيف يمكن برمجة عدد السجلات واستعراض السجلات بشرط رقم الموظف ؟ Microformt 3 601 09-01-24, 01:05 AM
آخر رد: Taha Okla
Question [vb6.0] كيف يمكن استدعاء اسم البرنامج من النافدة هذه وضعة في textbox ؟ Microformt 1 525 02-01-24, 10:06 PM
آخر رد: Taha Okla
Question [vb6.0] كيف يمكن استدعاء هذه الدالة وضعها تحت زر الامر ؟ Microformt 1 587 31-12-23, 11:52 PM
آخر رد: Taha Okla
  [vb6.0] كيف يمكن إخفاء عمود رقم الصنف و إظهاره برمجياً نامل المساعدة في المثال التالي ؟ Microformt 2 723 19-11-23, 10:49 PM
آخر رد: Microformt

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم