Working out distance between places, using OS grid references and a program in Tcl
Archive - Originally posted on "The Horse's Mouth" - 2015-03-11 06:16:48 - Graham EllisIn Great Britain, locations have Ordnance Survey grid reference positions which place them to within 100 metres. Our training centre / hotel is at ST907633 - that's
100 km square ST
90.7 km into that square from the west side
63.3 km into that squate from the south side
One of the requirements that I've got at present is to take 597 survey inputs from the TransWilts survey we did last October and come up with some metrics of journey length. From previous work I have details of all the stations on the network, including their OS references, [here], and I've got the layout of the 100 km squares in a data file [here].
As I'm teaching a Tcl course this week, I've chosen to write my distance calculation code in that language. Here's the program in use - calculating the dictance from Melksham to Swindon, and from Swindon on to London Paddington.
munchkin:survey grahamellis$ tclsh distance_between
What are the grid reference on your journey (space separated?)
ST899646 SU149853 TQ265814
32.46
111.67
munchkin:survey grahamellis$
(Take a look at the source code which is commented if you want to see the logic in Tcl. It makes strong use of string handling and lists in Tcl, and you'll see examples of for, foreach and while loops too - they make an excellent comparison)