source: trunk/npemap.org.uk/static/api/geocoder.shtml @ 404

Last change on this file since 404 was 404, checked in by Nick Burch, 14 years ago

Update API docs, and an associated tweak to the geocoder

File size: 3.3 KB
Line 
1
2<!--#set var="title" value="Geocoder" -->
3<!--#set var="shownav" value="yes" -->
4<!--#include virtual="../inc/header.shtml" -->
5
6<div id="api">
7
8<h4>Geocoder</h4>
9
10<p>The geocoder supports various methods for turning postcodes into
11 locations, or locations into postcodes, using our collected data.</p>
12
13<h5>Postcode -&gt; Location</h5>
14<p>Look up the location that we have for a postcode. If we don't have an exact
15match for the postcode you request, then we will do our best. If we don't have
16an exact match, we will return #s where we don't have exact matches.</p>
17
18<h5>Location -&gt; Postcode</h5>
19<p>Look up the nearest postcode for a location. You can optionally get the
20 n nearest postcodes to a location.</p>
21
22<h5>Location -&gt; Postcode Areas</h5>
23<p>Look up the nearest postcode area (eg 'OX2') for a location. You can
24 optionally get the n nearest postcode areas to a location.</p>
25
26<h4>Result Formats</h4>
27<p>The results can be returned as plain text (csv with header), XML, or
28 javascript / javascript callback.</p>
29
30<p>If you request the response with the format of 'js', then you can specify
31the name of a funtion call to wrap around the JSON response. This will call
32that method with the JSON as a parameter. </p>
33
34<h4>URL</h4>
35
36<pre>http://www.npemap.org.uk/cgi/geocoder.fcgi</pre>
37
38<h4>Arguments</h4>
39<dl>
40<dt>postcode (required, unless easting and northing given)</dt>
41<dd>The postcode that you wish the location of. You can enter just the
42 outward part if you wish.</dd>
43
44<dt>easting (required, unless postcode given)</dt>
45<dd>The easting part of the location, to find nearby postcodes or postcode
46 areas. If given, 'northing' must also be supplied.</dd>
47
48<dt>northing (required, unless postcode given)</dt>
49<dd>The northing part of the location, to find nearby postcodes or postcode
50 areas. If given, 'easting' must also be supplied.</dd>
51
52<dt>format (optional)</dt>
53<dd>The format to return the results in. Can be 'text', 'js' or 'xml'. The
54 default is plain text.</dd>
55
56<dt>results (optional)</dt>
57<dd>The number of results to return. The default is 1. (postcode to location
58 searching always returns one result).</dd>
59
60<dt>areas (optional)</dt>
61<dd>If searching by easting and northing, should postcodes be returned, or
62 should postcode areas be returned? The default is to return postcodes.</dd>
63
64</dl>
65
66<h4>Example response</h4>
67
68<pre>
69# Easting,Northing,Matched Postcode
70434807,219133,'OX7 3##'
71</pre>
72
73
74<h4>Explorer</h4>
75<p>Try out this method without writing any code.</p>
76
77<form method="get" action="/cgi/geocoder.fcgi" target="iframe">
78
79<p>
80 postcode: <input type="text" name="postcode" value="" size="30" /> 
81 <i>or</i><br/>
82 easting: <input type="text" name="easting" value="" size="10" /> &nbsp;
83 northing: <input type="text" name="northing" value="" size="10" />
84</p>
85<p>
86 number of results: <input type="text" name="results" value="1" size="30" />
87 <br />
88 format:
89 <input id="format_text" type="radio" name="format" value="text"> <label for="format_text">Text</label>
90 <input id="format_js" type="radio" name="format" value="js" checked> <label for="format_js">JS</label>
91 <input id="format_xml" type="radio" name="format" value="xml"> <label for="format_xml">XML</label>
92
93 <input type="submit" value="Go" />
94</p>
95</form>
96<iframe name="iframe" style="width: 40em; height: 20em">Output here</iframe
97
98</div>
99
100<!--#include virtual="../inc/footer.shtml" -->
Note: See TracBrowser for help on using the repository browser.