From 850f7e02ff0ca9f3514989d7d6c2a0ab96ac4e06 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 27 Apr 2022 13:50:36 -0700 Subject: restore correct workflow when no census match is found: offer map-based picker, RT#86245, RT#76968 --- httemplate/misc/confirm-censustract.html | 8 ++++++-- httemplate/misc/openmap.html | 5 ++--- httemplate/misc/xmlhttp-censustract.html | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'httemplate') diff --git a/httemplate/misc/confirm-censustract.html b/httemplate/misc/confirm-censustract.html index 8535c1495..f3fd0383e 100644 --- a/httemplate/misc/confirm-censustract.html +++ b/httemplate/misc/confirm-censustract.html @@ -18,10 +18,14 @@ Confirm census tract
% my $querystring = "census_year=$year&address=$location{address1}, $location{address2}, $location{city}, $location{state}"; Map service module location
+ REL="opener" + TARGET="_blank" +>Map service module location
% $querystring = "census_year=$year&pre=$pre&zip_code=" . $cache->get('zip'); Map zip code center
+ REL="opener" + TARGET="_blank" +>Map zip code center

diff --git a/httemplate/misc/openmap.html b/httemplate/misc/openmap.html index 88f64c1ff..a9a70337f 100644 --- a/httemplate/misc/openmap.html +++ b/httemplate/misc/openmap.html @@ -44,8 +44,7 @@ function getCensusTract(lat, lon) { var url = 'xmlhttp-censustract.html?lat=' + lat + '&lon=' + lon + '&census_year=<%$census_year%>'; $.getJSON(url,function(data){ - var tract = (data.Block.FIPS.substr(0, 11) / 100).toFixed(2); - document.getElementById("mycensustract").innerHTML = tract; + document.getElementById("mycensustract").innerHTML = data.Block.FIPS; }); } @@ -81,4 +80,4 @@ my $zip_code = $cgi->param('zip_code'); my $address = $cgi->param('address'); my $loc = $zip_code ? $zip_code : $address; - \ No newline at end of file + diff --git a/httemplate/misc/xmlhttp-censustract.html b/httemplate/misc/xmlhttp-censustract.html index 985fb90e5..855e172e2 100644 --- a/httemplate/misc/xmlhttp-censustract.html +++ b/httemplate/misc/xmlhttp-censustract.html @@ -5,12 +5,19 @@ my $DEBUG = 0; my $conf = new FS::Conf; -my $return = {}; - ## new api link, see doc https://geo.fcc.gov/api/census/ my $url = "https://geo.fcc.gov/api/census/block/find?format=json&censusYear=" . $cgi->param('census_year') . "&latitude=" . $cgi->param('lat') . "&longitude=" . $cgi->param('lon'); -use LWP::Simple; -my $return = get $url; +my $ua = new LWP::UserAgent; +$ua->agent('Freeside/'. $FS::VERSION); #libwww* elicits "403 Forbidden" +my $res = $ua->get($url); + +my $return = ''; +if ( $res->is_success ) { + $return = $res->decoded_content; +} else { + #better error handling? well, hopefully the site is reliable enough + warn 'Error from geo.fcc.gov: '. $res->status_line. "\n"; +} - \ No newline at end of file + -- cgit v1.2.1