% if ( !$error and !$new_tract ) {
% # then set_censustract returned nothing
% # because it's not relevant for this address
% # so output nothing (forces confirm_censustract() to continue)
% $m->clear_buffer;
% $m->abort;
% }
% my $querystring = "census_year=$year&address=$location{address1}, $location{address2}, $location{city}, $location{state}";
Map service module location
% $querystring = "census_year=$year&pre=$pre&zip_code=" . $cache->get('zip');
Map zip code center
Entered census tract
Calculated census tract
<% $old_tract %>
% if ( $error ) {
<% $error %>
% } else {
<% $new_tract %>
% }
<%init>
local $SIG{__DIE__}; #disable Mason error trap
my $DEBUG = 0;
my $conf = new FS::Conf;
warn $cgi->param('q') if $DEBUG;
my $q = decode_json($cgi->param('q'))
or die "bad argument '".$cgi->param('q')."'";
my $pre = $q->{prefix} || '';
my %location = (
map { $_ => $q->{$pre.$_} }
qw( company address1 address2 city state zip country latitude longitude )
);
my $old_tract = $q->{$pre.'censustract'};
my $cache = eval { FS::GeocodeCache->new(%location) };
$cache->set_censustract;
my $year = FS::Conf->new->config('census_year');
my $new_tract = $cache->get('censustract');
my $error = $cache->get('censustract_error');
warn Dumper($cache) if $DEBUG;
%init>