I've already written about conversion of postal addresses to latitude and longitude using Google's interface - but what is I want to convert the Ordinance Survey's grid references into latitude and longitude? Google's interface doesn't support the OS units - and in any case it's "just" a a calculation. I have put quotes around the word "just" because it's actually a complex calculation that I had no desire to re-code from learned papers.

Of course ... it's been done already. Perl's Geography::NationalGrid module which you can download from the CPAN. Now I wanted to use that in a PHP page to demonstrate to you, so I've written a quick Perl command line program that my PHP calls up when it needs to and .... bob's your uncle.

Try it out here (examples ST906637 is in Melksham ... SJ347904 is in Liverpool) :
Enter a grid reference:

P219 - Perl - Libraries and Resources[3377] What do I mean when I add things in Perl? - (2011-08-02)[3101] The week before Christmas - (2010-12-23)[3009] Expect in Perl - a short explanation and a practical example - (2010-10-22)[2931] Syncronise - software, trains, and buses. Please! - (2010-08-22)[2427] Operator overloading - redefining addition and other Perl tricks - (2009-09-27)[2234] Loading external code into Perl from a nonstandard directory - (2009-06-12)[2229] Do not re-invent the wheel - use a Perl module - (2009-06-11)[1865] Debugging and Data::Dumper in Perl - (2008-11-02)[1863] About dieing and exiting in Perl - (2008-11-01)[1444] Using English can slow you right down! - (2007-11-25)[1235] Outputting numbers as words - MySQL with Perl or PHP - (2007-06-17)[1219] Judging the quality of contributed Perl code - (2007-06-06)[760] Self help in Perl - (2006-06-14)[737] Coloured text in a terminal from Perl - (2006-05-29)[712] Why reinvent the wheel - (2006-05-06)[358] Use standard Perl modules - (2005-06-25)[357] Where do Perl modules load from - (2005-06-24)[112] Avoid the wheel being re-invented by using Perl modules - (2004-11-08)[86] Talk review - Idiomatic Perl, David Cross - (2004-10-12)

Q110 - Object Orientation and General technical topics - Programming Algorithms[4410] A good example of recursion - a real use in Python - (2015-02-01)[4402] Finding sum, minimum, maximum and average in Python (and Ruby) - (2015-01-19)[4401] Selecting RECENT and POPULAR news and trends for your web site users - (2015-01-19)[4325] Learning to program - what are algorithms and design patterns? - (2014-11-22)[3662] Finding all the unique lines in a file, using Python or Perl - (2012-03-20)[3620] Finding the total, average, minimum and maximum in a program - (2012-02-22)[3451] Why would you want to use a Perl hash? - (2011-09-20)[3102] AND and OR operators - what is the difference between logical and bitwise varieties? - (2010-12-24)[3093] How many toilet rolls - hotel inventory and useage - (2010-12-18)[3072] Finding elements common to many lists / arrays - (2010-11-26)[3042] Least Common Ancestor - what is it, and a Least Common Ancestor algorithm implemented in Perl - (2010-11-11)[2993] Arrays v Lists - what is the difference, why use one or the other - (2010-10-10)[2951] Lots of way of converting 3 letter month abbreviations to numbers - (2010-09-10)[2894] Sorting people by their names - (2010-07-29)[2617] Comparing floating point numbers - a word of caution and a solution - (2010-02-01)[2586] And and Or illustrated by locks - (2010-01-17)[2509] A life lesson from the accuracy of numbers in Excel and Lua - (2009-11-21)[2259] Grouping rows for a summary report - MySQL and PHP - (2009-06-27)[2189] Matching disparate referencing systems (MediaWiki, PHP, also Tcl) - (2009-05-19)[1949] Nuclear Physics comes to our web site - (2008-12-17)[1840] Validating Credit Card Numbers - (2008-10-14)[1187] Updating a page strictly every minute (PHP, Perl) - (2007-05-14)[1157] Speed Networking - a great evening and how we arranged it - (2007-04-21)[642] How similar are two words - (2006-03-11)[227] Bellringing and Programming and Objects and Perl - (2005-02-25)[202] Searching for numbers - (2005-02-04)

This is a page archived from The Horse's Mouth at
http://www.wellho.net/horse/ -
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.