aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-07-12 19:06:13 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-07-12 19:06:13 +0100
commit42a92773a123d2b0fa1eaed93201fa45a8b7e436 (patch)
treea72a7b86c3f871ea1675a2360eb1160ea9b097a5 /perllib/FixMyStreet/Cobrand/FiksGataMi.pm
parent3cb0b6ce80882fc8411af929234cd5f1ffa0aea2 (diff)
Factor out postcode lookups into cobrands, and string lookups into separate packages.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/FiksGataMi.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index 15cdf80d2..a606dc3b9 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -61,6 +61,26 @@ sub uri {
return $uri;
}
+sub geocode_postcode {
+ my ( $self, $s ) = @_;
+
+ if ($s =~ /^\d{4}$/) {
+ my $location = mySociety::MaPit::call('postcode', $s);
+ if ($location->{error}) {
+ return {
+ error => $location->{code} =~ /^4/
+ ? _('That postcode was not recognised, sorry.')
+ : $location->{error}
+ };
+ }
+ return {
+ latitude => $location->{wgs84_lat},
+ longitude => $location->{wgs84_lon},
+ };
+ }
+ return {};
+}
+
sub geocoded_string_check {
my ( $self, $s ) = @_;
return 1 if $s =~ /, Norge/;