aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode/FixaMinGata.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-02-13 12:24:34 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2015-02-13 12:24:34 +0000
commit0db002a977d00d0a6e11333e190de4746e009bfb (patch)
treee754e071d99d3eed7618fe32c004196a8a8f3bd3 /perllib/FixMyStreet/Geocode/FixaMinGata.pm
parent3571f96251df08dd8a9dda3ec4e1fadf30d6c63d (diff)
parent0dc3e4f2c0b6e90c2b67fab5aaf7c9c3d2b1f971 (diff)
Merge branch 'issues/684-expire-geocache'
Diffstat (limited to 'perllib/FixMyStreet/Geocode/FixaMinGata.pm')
-rw-r--r--perllib/FixMyStreet/Geocode/FixaMinGata.pm23
1 files changed, 2 insertions, 21 deletions
diff --git a/perllib/FixMyStreet/Geocode/FixaMinGata.pm b/perllib/FixMyStreet/Geocode/FixaMinGata.pm
index 2ea92c422..68e5bc8a5 100644
--- a/perllib/FixMyStreet/Geocode/FixaMinGata.pm
+++ b/perllib/FixMyStreet/Geocode/FixaMinGata.pm
@@ -14,13 +14,8 @@ package FixMyStreet::Geocode::FixaMinGata;
use warnings;
use strict;
-use Data::Dumper;
-use Digest::MD5 qw(md5_hex);
-use Encode;
-use File::Slurp;
-use File::Path ();
-use LWP::Simple qw($ua);
+use LWP::Simple;
use Memcached;
use XML::Simple;
use mySociety::Locale;
@@ -56,25 +51,11 @@ sub string {
if $params->{country};
$url .= join('&', map { "$_=$query_params{$_}" } keys %query_params);
- my $cache_dir = FixMyStreet->config('GEO_CACHE') . 'osm/';
- my $cache_file = $cache_dir . md5_hex($url);
- my $js;
- if (-s $cache_file) {
- $js = File::Slurp::read_file($cache_file);
- } else {
- $ua->timeout(15);
- $js = LWP::Simple::get($url);
- $js = encode_utf8($js) if utf8::is_utf8($js);
- File::Path::mkpath($cache_dir);
- File::Slurp::write_file($cache_file, $js) if $js;
- }
-
+ my $js = FixMyStreet::Geocode::cache('osm', $url);
if (!$js) {
return { error => _('Sorry, we could not find that location.') };
}
- $js = JSON->new->utf8->allow_nonref->decode($js);
-
my ( %locations, $error, @valid_locations, $latitude, $longitude );
foreach (@$js) {
# These co-ordinates are output as query parameters in a URL, make sure they have a "."