diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-09-30 14:12:13 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-09-30 14:12:13 +0100 |
commit | 81f86542c4d306d89f9a3718154203b35583fee5 (patch) | |
tree | c043ddd72accf65457dbbe624aad339967f9120e /perllib/FixMyStreet/Geocode/Zurich.pm | |
parent | 85dd4e1058dd2a5c54951bd966a2625d23478155 (diff) | |
parent | ab8360f148d8d4026905ef8e10decee43bd16b4a (diff) |
Merge branch 'zurich-staging'
Diffstat (limited to 'perllib/FixMyStreet/Geocode/Zurich.pm')
-rw-r--r-- | perllib/FixMyStreet/Geocode/Zurich.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Geocode/Zurich.pm b/perllib/FixMyStreet/Geocode/Zurich.pm index 38df431c9..0b85ab7b2 100644 --- a/perllib/FixMyStreet/Geocode/Zurich.pm +++ b/perllib/FixMyStreet/Geocode/Zurich.pm @@ -24,6 +24,8 @@ sub setup_soap { # Variables for the SOAP web service my $geocoder = FixMyStreet->config('GEOCODER'); + return unless ref $geocoder eq 'HASH'; + my $url = $geocoder->{url}; my $username = $geocoder->{username}; my $password = $geocoder->{password}; @@ -49,6 +51,34 @@ sub setup_soap { $method = SOAP::Data->name('getLocation95')->attr({ xmlns => $attr }); } +sub admin_district { + my ($e, $n) = @_; + + setup_soap(); + return unless $soap; + + my $attr = 'http://ch/geoz/fixmyzuerich/service'; + my $bo = 'http://ch/geoz/fixmyzuerich/bo'; + my $method = SOAP::Data->name('getInfoByLocation')->attr({ xmlns => $attr }); + my $location = SOAP::Data->name( + 'location' => \SOAP::Data->value( + SOAP::Data->name('bo:easting', $e), + SOAP::Data->name('bo:northing', $n), + ) + )->attr({ 'xmlns:bo' => $bo }); + my $search = SOAP::Data->value($location); + my $result; + eval { + $result = $soap->call($method, $security, $search); + }; + if ($@) { + warn $@ if FixMyStreet->config('STAGING_SITE'); + return 'The geocoder appears to be down.'; + } + $result = $result->result; + return $result; +} + # string STRING CONTEXT # Looks up on Zurich web service a user-inputted location. # Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or |