++ed by:

2 PAUSE users

Toby Thurston


bngl.pl -- convert coordinates, and compare (possibly random) spots in the UK on Streetmap and Googlemaps

This programme shows off some features of Geo::Coordinates::OSGB.


  perl bngl.pl [--streetmap] [--googlemap] [--osgb] [ lat lon | grid reference ] 


The argument should be

- either something that represents a grid reference, like 'TQ 123 456' or '314159 271828'

- or a pair of decimal numbers in the range -20 to 70 representing a latitude and longitude pair in the UK like: '51.3 -0.01'. Latitude and longitude can be given in either order. You can leave an optional comma between them if you like. This allows you to cut and paste from a web page for example.

The argument will be converted appropriately. So if you supply a grid reference you will get back a lat/lon pair, and vice versa.

If you supply no argument, then a random grid reference is supplied.

You can also pipe the argument from another program, and pipe the output to something else. If you connect the output to a pipe you will get just the coordinates, without the fancy message.


Open a webpage on Streetmap.co.uk showing the grid point on an online OS map.


Open a webpage showing the grid point on Google maps.


Use the OSGB36 latitude and longitude model instead of the normal WGS84 model

--usage, --help, --man

Show increasing amounts of help text, and exit.


Print version and exit.


This script shows off the conversions in this module.

The argument can be either a grid ref or a lat/lon pair. A simple heurisistic is used to guess which is which. If the argument is missing, then a random grid point is supplied.

Optionally you can show the chosen point on a map using the Streetmap and/or Googlemap options. You can combine both so that you can compare the OS and the Google maps side by side for the same area.

The Google maps parameters are the result of experimentation rather than any API documentation so I've no idea what the data parameter does, but it seems to be necessary. The "14z" controls the level of zoom, and makes it roughly 1:50,000 corresponding to the Streetmap display with "&z=3".


You may need to install Browser::Open and IO::Interactive.


Toby Thurston -- 30 Oct 2017