Archive for the ‘Coordinate Converter’ Category

Full UK postcodes in the API!

Friday, April 30th, 2010

Thanks to OS Opendata, the Nearby Converter API now can convert to and from full Unit UK postcodes!

So as not to break applications expecting Sector postcodes in the API, there is a new API endpoint:

http://api1.nearby.org.uk/api/convert.php

API requests against this domain will give the position of the full postcode, and also reverse geocode (return you the nearest) full postcode!

- The Original URL for the API is still available – and will continue to be. I’ve also taken the opportunity to add a version number to the URL. It’s been 4 years since I created this API, and learnt lots in that time, so should be able to create a better version 2 :) When introduce that don’t want to break compatibility.

Of course the ‘Coordinate Convertor‘ is now using CodePoint Open too – the end of having to pay a commercial provider!

(sorry this has taken so long, OS Opendata was introduced at the beginning of the month!, its been a busy month)

Will take the opportunity to duplicate the copyright message:

Contains Royal Mail data © Royal mail copyright and database right 2010.

As it serves as a useful thank you, for making this data available.

ITM <-> WGS84 (<-> Irish Grid <-> British National Grid) PHP code

Wednesday, May 13th, 2009

With Ireland soon to be moving to ITM (Irish Transverse Mercator) coordinates, over IG (Irish Grid) that has been used since about 1965 in Ireland, many websites – including Geograph.ie and nearby.org.uk will be looking to support ITM coordinates – even if they still use Irish Grid.

So to that end have been looking for PHP code to do the conversion, but thanks to a little bit of inspiration from FieldenMaps.info’s Javascript Ireland Coordinate Converter (an excellent resource in its own right!), realised it would be simple to add to the conversion class we already use. In fact as ITM is based on GRS80 which is effectivly WGS84 the conversion was just a matter of plugging in the constants used by ITM, and the code just worked.

Better yet as Geograph is Open Source (and we got permission to open source the code based on OSGB’s conversion spreadsheet), the code is available for anyone to use as a PHP class. It should be trivial to add support to our Javascript class – which will do shortly!

Grab the class from Geograph SVN (or even better do a SVN checkout!) and put it somewhere safe. (but you will probably want to remove the “extends Conversions” bit from the definition – we use that for convience in Geograph source)

Then can just use it

$conv = new ConversionsLatLong;
list($lat,$lng) = $conv->itm_to_wgs84($e,$n);

But as we already use the same code for Irish Grid, and OSGB36 British National Grid, can also use it for them, and even IG< ->ITM conversion

list($lat,$lng) = $conv->itm_to_wgs84($e,$n);
list($lat,$lng) = $conv->irish_to_wgs84($e,$n,true);
list($lat,$lng) = $conv->osgb_to_wgs84($e,$n);

list($e,$n) = $conv->wgs84_to_itm($lat,$lng);
list($e,$n) = $conv->wgs84_to_irish($lat,$lng,true);

list($e,$n) = $conv->wgs84_to_osgb36($lat,$lng);
//even a short convience function to create a 10 figure grid reference
$gr10 = $conv->osgb36_to_gridref($e,$n);

See it used in anger here and here.

MGRS coordinate entry

Friday, December 12th, 2008

Prompted by one of those infernal* posts on a Google Maps group, have finally been inspired to cobble together a MGRS -> Lat/Long conversion. It seems trvial, the UTM->MGRS conversion is quite simple, but there are a few gotchas!, so after much puzzleing over some C code from GeoTrans (and Trial&Error for good measure!), I think** have something working.

Anyway try it out here: 

Coordinate Flyto for Google Earth/Maps

also added today is a tickbox to open the result direct in Google Maps (rather than Google Earth). 

I’ll tidy it up and post the code, which is based on the PHPcoord conversion class, incase others have a use. I’ll also add it to the API – and possibly even back port it into Perl for use on the on site coordinate covertor. 

Finally possibly of interest is the realisation that the MGRS Google Earth Gridlines layer, will actully load directly in Google Maps, so:

MGRS Gridlines in Google Maps

the lines should update a few seconds after dragging/zooming. Ideally will suppress the big blue pins (which are show as numbers in GE) , but not tonight…

 

 

* in the nicest possible sence!

** I tested it by converting utm->mgrs->utm globally on a worldwide 1 degree grid – all check out with absolute precision.

Towards a standard Geotag Icon?

Sunday, March 2nd, 2008

Geotag DemoJust spotted a proposal for a standard icon to represent geotagged content, the homepage is at geotagicons.com, can’t say a big fan of the icon itself, but the idea is great.

<OT>Was sort of involved in trying to find a standard icon for GeoRSS (in fact they use my icon as the favicon ;) ), but not sure (in hindsight!) if that a good idea, really it just saying this is a geotagged feed, which really shouldn’t mean much different to the end user than the standard feed icon. If their feed reader is geoenabled – great, if not tough, although it can help people specifically looking for geo-content.</OT>

Anyway to try the waters, have enabled it for geotagged content on this blog, see the PhotoSpot category for example :)

(via)

Where in Great Britain are people searching?

Saturday, March 1st, 2008

Great Britain usage Coverage map :: NearbyNearby Coordinate Converter >>>
Following on from the Coverage map for Google Earth Layer usage, remembered I been keeping a log from the Coordinate Converter specifically for mapping (but only for GB) , but never actully got round to it, until now that is! Click the image for a full 1px per km version!

British Isles searching Coverage map :: Geograph
Update: Inspired by the above, heres one for the Geograph Search, ok so actully its for the British Isles!
<<<Geograph Searches

Geohash converter; API limit upped

Thursday, February 28th, 2008

Recently geohash.org was released; the premise: short easy links that encode a location. The website offers instant conversion, but as the algorithm is Public Domain, Lordelph was quick to implement a php class, and I could quickly add the conversion to my existing conversion API. Convert a postcode to geohash anyone?

Updating the documentation noticed the API was last updated in 2005 – gulp, how time flies! Anyway as a celebration have upped the throttling on the API, now three times the previous limit. Running on much improved hardware than when it was launched so maybe the limit can be tweaked even more, will run some analysis of its impact – it already seems the API is a minor part of the overall load on the server – particularly against the Google Earth layers.

Landranger Coordinates

Thursday, December 7th, 2006

Not sure if this really deserves a post of its own, but it is mildly exciting to delve back into the Perl of the Coordinate converter

Anyway it can now understand ‘Landranger References’ which are common in some walking books (that’s the main place I seen them anyway!), basically where just the digits of a Grid reference are specified along with a Landranger sheet number.

Example: OS52 894334 which is 894334 on Landranger sheet 52, converted to NN894334 as a standard Grid Reference.

Ireland support

Monday, May 1st, 2006

It seems there was few issues with Northern Ireland Postcodes, the Coordinate converter and API should both handle them properly. As well as adding support to the Maps section.

IARU Locators in the Geocoder

Friday, March 3rd, 2006

I have now added support for IARU Locators to the Nearby Geocoder. If want to work with these you have to explicitly request them and inform the geocoder thats what to supplying as they look teribly like UK postcodes…