Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Distance calculating
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Distance calculating

 Post Reply Post Reply Page  <12
Author
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post Posted: 02 November 2004 at 4:44pm

excellent, think ive got it!

try my example/test.... www.rochdaleoffroad.co.uk/pcdistance.asp

Lookup to far away point in autoroute, for example TR19 and KW1, should be 588 miles.

Below is the script for the whole page....

<% if NOT request("calc")="" then
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("******")
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT * FROM tblPC WHERE pc ='" & request("pc1") & "'"
rs.Open sql, conn

do until rs.EOF
  for each entry in rs.Fields
x1=rs("lon")
y1=rs("lat")
     next
  rs.MoveNext
loop
  rs.close
  conn.close

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("/_private/postcodes.mdb")
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT * FROM tblPC WHERE pc ='" & request("pc2") & "'"
rs.Open sql, conn

do until rs.EOF
  for each entry in rs.Fields
x2=rs("lon")
y2=rs("lat")
     next
  rs.MoveNext
loop
  rs.close
  conn.close


xdif = 69.1 * (y2 - y1)
ydif = 69.1 * (x2 - x1) * cos(y1/57.3)
miles=SQR(xdif *xdif +ydif *ydif )


response.write "x1= " & x1& "<BR>"
response.write "y1= " & y1& "<BR>"
response.write "x2= " & x2& "<BR>"
response.write "y2= " & y2& "<BR>"

response.write "xdif = " & xdif & "<BR>"
response.write "ydif = " & ydif & "<BR>"

 

response.write "<P>" & miles & " miles" & "<hr>"
end if
%>
<form method="POST" action="pcdistance.asp">
<p>&nbsp;</p>
<p>Enter first part of post codes (e.g, OL11 for OL11 3RF)</p>
  <p>From postcode: <input type="text" name="pc1" size="4"><br>
  To postcode: <input type="text" name="pc2" size="4"><br>
  <input type="submit" value="Calculate mileage (Crows path)" name="calc"></p>
</form>

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 05 November 2004 at 4:48pm
If OL11 is your postcode you live 24.8394441363593 miles away from me
Back to Top
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post Posted: 05 November 2004 at 6:26pm

oh bloody hell, im moving!

:-)

Where r u? Im in Rochdale

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 05 November 2004 at 7:40pm
You can run, but you can't hide <evil laugh>

Lead me not into temptation... I know the short cut, follow me.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2004 at 7:05am
Originally posted by Mattblack Mattblack wrote:

oh bloody hell, im moving!

:-)

Where r u? Im in Rochdale

Thats about right, I live in Macclesfield.

Back to Top
barryhunter View Drop Down
Newbie
Newbie


Joined: 19 November 2004
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote barryhunter Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2004 at 4:51pm

I have a file containing more accurate grid refs if its any use. Going to RH19 1 accuracy, (so can diffienticate between RH19 1 and RH19 2)

As to Grid Refs they are in meter units, east and north from a point off the Sillily Isles. Using Pythagoras on these units you get a exact measurement in meters  which can be easily converted to miles (rather than the one on lat/long which you approximate to miles).

Also Grid Refs are based on a flat grid so you don't have to worry about curvature of the earth, to work out the distance between points.

Having said that it depends on the accuray you require.

Barry

Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.