Changeset 370


Ignore:
Timestamp:
Nov 19, 2006, 11:09:35 AM (13 years ago)
Author:
David Sheldon
Message:

Add json output mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/cgi/geocoder.fcgi

    r366 r370  
    3232
    3333
    34 my @outputs = qw(text xml);
     34my @outputs = qw(text xml js);
    3535
    3636my $cgi;
     
    116116                print "  <postcode>$pc</postcode>\n";
    117117                print "</geocoder>\n";
    118         } else {
     118        } elsif ($output eq "js") {
     119                print header("text/javascript");
     120        my ($e, $n) = (int($easting), int($northing));
     121          if(defined $cgi->param("method")) {
     122          print ($cgi->param("method") . "(");
     123      }
     124      print "{ pc: \"$pc\", e: $e, n: $n }";
     125          if(defined $cgi->param("method")) {
     126          print ");";
     127      }
     128      print "\n";
     129       
     130    } else {
    119131                print header("text/plain");
    120132                print "# Easting,Northing,Matched Postcode\n";
Note: See TracChangeset for help on using the changeset viewer.