Hi friends,
I need some help in doing the following:
The supervisor has the zip code of the customer displayed on the form.We have the database of about 10,000 people ,with their addresses and zipcodes.When the supervisor hits submit,i should get a list of all the people who are more near to the clients place.May be we can display the list in asending order.
I have the function how to calculate distances between two zipcodes.What i dont know is how should i integrate this fucntion and how should i pass the zip codes (of client ) and tell the code to check it agains the database of 10,000 people ?
Here is the fucntion which i got it online:
<%
const pi = 3.14159265358979323846
function GetDistance(Lat1, Long1, Lat2, Long2, Unit)
dim x
' do the nasty calcs
x = (sin(DegToRads(Lat1)) * sin(DegToRads(Lat2)) + cos(DegToRads(Lat1)) * _
cos(DegToRads(Lat2)) * cos(abs((DegToRads(long2))-(DegToRads(long1)))))
' Get Acos(x)
x = atn((sqr(1-x^2))/x)
' Get distance in kilometers
GetDistance = 1.852 * 60.0 * ((x/pi)*180)
' Convert units if necessary
select case ucase(Unit)
case "M"
GetDistance = GetDistance / 1.609344
case "N"
GetDistance = GetDistance / 1.852
end select
end function
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
'::: This function converts decimal degrees (e.g. 79.1928376) to radians :::
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
function DegToRads(Deg)
DegToRads = cdbl(Deg * pi / 180)
end function
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
'::: This function converts decimal degrees (e.g. 79.1928376) to degrees, :::
'::: minutes and seconds :::
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
sub DecimalDegToDMS(DecimalDegrees, Degs, Mins, Secs)
Dim temp
Degs = fix(DecimalDegrees)
temp = (DecimalDegrees - Degs) * 60.
Mins = fix(temp)
temp = (temp - Mins) * 60.
Secs = fix(temp)
end sub
%>
Please help!!!!
I need some help in doing the following:
The supervisor has the zip code of the customer displayed on the form.We have the database of about 10,000 people ,with their addresses and zipcodes.When the supervisor hits submit,i should get a list of all the people who are more near to the clients place.May be we can display the list in asending order.
I have the function how to calculate distances between two zipcodes.What i dont know is how should i integrate this fucntion and how should i pass the zip codes (of client ) and tell the code to check it agains the database of 10,000 people ?
Here is the fucntion which i got it online:
<%
const pi = 3.14159265358979323846
function GetDistance(Lat1, Long1, Lat2, Long2, Unit)
dim x
' do the nasty calcs
x = (sin(DegToRads(Lat1)) * sin(DegToRads(Lat2)) + cos(DegToRads(Lat1)) * _
cos(DegToRads(Lat2)) * cos(abs((DegToRads(long2))-(DegToRads(long1)))))
' Get Acos(x)
x = atn((sqr(1-x^2))/x)
' Get distance in kilometers
GetDistance = 1.852 * 60.0 * ((x/pi)*180)
' Convert units if necessary
select case ucase(Unit)
case "M"
GetDistance = GetDistance / 1.609344
case "N"
GetDistance = GetDistance / 1.852
end select
end function
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
'::: This function converts decimal degrees (e.g. 79.1928376) to radians :::
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
function DegToRads(Deg)
DegToRads = cdbl(Deg * pi / 180)
end function
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
'::: This function converts decimal degrees (e.g. 79.1928376) to degrees, :::
'::: minutes and seconds :::
'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
sub DecimalDegToDMS(DecimalDegrees, Degs, Mins, Secs)
Dim temp
Degs = fix(DecimalDegrees)
temp = (DecimalDegrees - Degs) * 60.
Mins = fix(temp)
temp = (temp - Mins) * 60.
Secs = fix(temp)
end sub
%>
Please help!!!!