diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Peterborough.pm | 85 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/OSM.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Roles/Extra.pm | 2 |
3 files changed, 88 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Peterborough.pm b/perllib/FixMyStreet/Cobrand/Peterborough.pm new file mode 100644 index 000000000..46242fcf3 --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/Peterborough.pm @@ -0,0 +1,85 @@ +package FixMyStreet::Cobrand::Peterborough; +use parent 'FixMyStreet::Cobrand::Whitelabel'; + +use strict; +use warnings; + +use Moo; +with 'FixMyStreet::Roles::ConfirmValidation'; + +sub council_area_id { 2566 } +sub council_area { 'Peterborough' } +sub council_name { 'Peterborough City Council' } +sub council_url { 'peterborough' } + +sub disambiguate_location { + my $self = shift; + my $string = shift; + + return { + %{ $self->SUPER::disambiguate_location() }, + centre => '52.6085234396978,-0.253091266573947', + bounds => [ 52.5060949603654, -0.497663559599628, 52.6752139533306, -0.0127696975457487 ], + }; +} + +sub get_geocoder { 'OSM' } + +sub geocoder_munge_results { + my ($self, $result) = @_; + $result->{display_name} = '' unless $result->{display_name} =~ /City of Peterborough/; + $result->{display_name} =~ s/, UK$//; + $result->{display_name} =~ s/, City of Peterborough, East of England, England//; +} + +sub admin_user_domain { "peterborough.gov.uk" } + +sub open311_config { + my ($self, $row, $h, $params) = @_; + + my $extra = $row->get_extra_fields; + push @$extra, + { name => 'report_url', + value => $h->{url} }, + { name => 'title', + value => $row->title }, + { name => 'description', + value => $row->detail }; + + # remove the emergency category which is informational only + @$extra = grep { $_->{name} ne 'emergency' } @$extra; + + # Reports made via FMS.com or the app probably won't have a site code + # value because we don't display the adopted highways layer on those + # frontends. Instead we'll look up the closest asset from the WFS + # service at the point we're sending the report over Open311. + if (!$row->get_extra_field_value('site_code')) { + if (my $site_code = $self->lookup_site_code($row)) { + push @$extra, + { name => 'site_code', + value => $site_code }; + } + } + + $row->set_extra_fields(@$extra); +} + +sub lookup_site_code_config { { + buffer => 50, # metres + url => "https://tilma.mysociety.org/mapserver/peterborough", + srsname => "urn:ogc:def:crs:EPSG::27700", + typename => "highways", + property => "Usrn", + accept_feature => sub { 1 }, + accept_types => { Polygon => 1 }, +} } + +sub open311_munge_update_params { + my ($self, $params, $comment, $body) = @_; + + # Peterborough want to make it clear in Confirm when an update has come + # from FMS. + $params->{description} = "[Customer FMS update] " . $params->{description}; +} + +1; diff --git a/perllib/FixMyStreet/Geocode/OSM.pm b/perllib/FixMyStreet/Geocode/OSM.pm index a36ae3192..6e6dbfbb1 100644 --- a/perllib/FixMyStreet/Geocode/OSM.pm +++ b/perllib/FixMyStreet/Geocode/OSM.pm @@ -55,6 +55,7 @@ sub string { my ( $error, @valid_locations, $latitude, $longitude, $address ); foreach (@$js) { $c->cobrand->call_hook(geocoder_munge_results => $_); + next unless $_->{display_name}; ( $latitude, $longitude ) = map { Utils::truncate_coordinate($_) } ( $_->{lat}, $_->{lon} ); diff --git a/perllib/FixMyStreet/Roles/Extra.pm b/perllib/FixMyStreet/Roles/Extra.pm index 883ac2fd7..5132c3e58 100644 --- a/perllib/FixMyStreet/Roles/Extra.pm +++ b/perllib/FixMyStreet/Roles/Extra.pm @@ -141,6 +141,7 @@ sub push_extra_fields { Given an extra field, will replace one with the same code in the existing list of fields, or add to the end if not present. +Returns true if it was already present, false if newly added. =cut @@ -167,6 +168,7 @@ sub update_extra_field { } $self->set_extra_fields(@$existing); + return $found; } =head2 remove_extra_field |