diff options
Diffstat (limited to 'perllib/FixMyStreet/Gaze.pm')
-rw-r--r-- | perllib/FixMyStreet/Gaze.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Gaze.pm b/perllib/FixMyStreet/Gaze.pm new file mode 100644 index 000000000..a072cd246 --- /dev/null +++ b/perllib/FixMyStreet/Gaze.pm @@ -0,0 +1,24 @@ +package FixMyStreet::Gaze; + +use strict; +use warnings; + +use mySociety::Gaze; + +sub get_radius_containing_population ($$) { + my ($lat, $lon) = @_; + + my $dist = eval { + mySociety::Locale::in_gb_locale { + mySociety::Gaze::get_radius_containing_population($lat, $lon, 200_000); + }; + }; + if ($@) { + # Error fetching from gaze, let's fall back to 10km + $dist = 10; + } + $dist = int( $dist * 10 + 0.5 ) / 10.0; + return $dist; +} + +1; |