aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Gaze.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-05-18 15:30:35 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-05-18 15:30:35 +0100
commit173abd37716cb49cde3d4836a9cf51a285bd3b79 (patch)
tree4be29d9830e00b243d6b7bfdbf410a9bfad84c64 /perllib/FixMyStreet/Gaze.pm
parentd4a75fd58381f2964607a2937946202e34cb6f30 (diff)
parent1a1bfff12415a7793fee22bcd4e5e39e10dbd4d3 (diff)
Merge branch '1286-catching-gaze'
Diffstat (limited to 'perllib/FixMyStreet/Gaze.pm')
-rw-r--r--perllib/FixMyStreet/Gaze.pm24
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;