Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Google Map Math question
Message
 
À
19/11/2010 12:11:53
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Produits tierce partie
Divers
Thread ID:
01489799
Message ID:
01489806
Vues:
110
Lparameters lnLat_1, lnLong_1, lnLat_2, lnLong_2

*Method to determine distance between 2 points

*** lnlat_1, lnLong_1 point A
*** lnlat_2, lnLong_2 Point B

lnDistance = 0
lnFunctionCall = 2
lnType = 2

lcDecimals = Set("decimals")

Set Decimals To 9
lnPie = Pi()

lnLat_1_degN = lnLat_1
lnLong_1_degW = lnLong_1
lnLat_2_degW = lnLat_2
lnLong_2_degW = lnLong_2

p_lat1 = lnLat_1_degN * lnPie / 180
p_lon1 = lnLong_1_degW * lnPie / 180
p_lat2 = lnLat_2_degW * lnPie / 180
p_lon2 = lnLong_2_degW * lnPie / 180

p_er = 6371.315 && Average radius of the Earth

***Assume N lattitude and W longitude
*** For S lattitude: p_radlat1 = (lnPie / 2) + p_lat1
*** Others remain the same
p_radlat1 = (lnPie / 2) - p_lat1
p_radlon1 = (lnPie * 2) - p_lon1
p_radlat2 = (lnPie / 2) - p_lat2
p_radlon2 = (lnPie * 2) - p_lon2

***Spherical coordinates: x=r*cos(long)sin(lat), y=r*sin(long)*cos(lat), z=r*cos(lat)
p_x1 = p_er * Cos(p_radlon1) * Sin(p_radlat1)
p_y1 = p_er * Sin(p_radlon1) * Sin(p_radlat1)
p_z1 = p_er * Cos(p_radlat1)

p_x2 = p_er * Cos(p_radlon2) * Sin(p_radlat2)
p_y2 = p_er * Sin(p_radlon2) * Sin(p_radlat2)
p_z2 = p_er * Cos(p_radlat2)

p_d = Sqrt((p_x1 - p_x2)^2 + (p_y1 - p_y2)^2 + (p_z1 - p_z2)^2)

***Side, side, side, law of cosines and arccos
p_theta = Acos(((p_er^2 * 2) - (p_d^2)) / (p_er^2 * 2))

***These need to be rounded
*lnDistance2 = p_theta * p_er && Distance in Kilometers
lnDistance = (p_theta * p_er) / 1.609344 && Distance in Miles
*lnDistance4 = lnDistance2 / 1.852 && Distance in Nautical Miles

Set Decimals To &lcDecimals


Return lnDistance








>Hi All
>
>I have finally been pulled into the world of Google maps and math is not one of my strongest talents. I have been doing some research and I am quickly getting over my head so I am hoping someone can give me some help. I know the coordinates from a GPS unit and now I need to find all addresses in a database that are within xx miles from those coordinates. A square is good enough. I need to keep it simple. The values in the database are stored in decimal xx.xxxxx format.
>
>Thanks for your help.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform