aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm3
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm10
-rw-r--r--perllib/FixMyStreet/Cobrand/HighwaysEngland.pm26
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm10
4 files changed, 47 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 1a300da21..516752b89 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1032,8 +1032,7 @@ sub process_report : Private {
}
# check that we've not indicated we only want to sent to a single body
- # and if we find a matching one then only send to that. e.g. if we clicked
- # on a TfL road on the map.
+ # and if we find a matching one then only send to that.
my $body_string = do {
if (my $single_body_only = $c->get_param('single_body_only')) {
my $body = $c->model('DB::Body')->search({ name => $single_body_only })->first;
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 951804c20..dfb511f39 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -101,6 +101,16 @@ sub munge_report_new_bodies {
my $tfl = FixMyStreet::Cobrand::TfL->new({ c => $self->{c} });
$tfl->munge_surrounding_london($bodies);
}
+
+ if ( $bodies{'Highways England'} ) {
+ my $c = $self->{c};
+ my $he = FixMyStreet::Cobrand::HighwaysEngland->new({ c => $c });
+ my $on_he_road = $c->stash->{on_he_road} = $he->report_new_is_on_he_road;
+
+ if (!$on_he_road) {
+ %$bodies = map { $_->id => $_ } grep { $_->name ne 'Highways England' } values %$bodies;
+ }
+ }
}
sub munge_report_new_contacts {
diff --git a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
index 87cf073eb..d415635c1 100644
--- a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
+++ b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
@@ -111,4 +111,30 @@ sub fetch_area_children {
return $areas;
}
+sub munge_report_new_bodies {
+ my ($self, $bodies) = @_;
+ # On the cobrand there is only the HE body
+ %$bodies = map { $_->id => $_ } grep { $_->name eq 'Highways England' } values %$bodies;
+}
+
+sub report_new_is_on_he_road {
+ my ( $self ) = @_;
+
+ my ($x, $y) = (
+ $self->{c}->stash->{longitude},
+ $self->{c}->stash->{latitude},
+ );
+
+ my $cfg = {
+ url => "https://tilma.mysociety.org/mapserver/highways",
+ srsname => "urn:ogc:def:crs:EPSG::4326",
+ typename => "Highways",
+ filter => "<Filter><DWithin><PropertyName>geom</PropertyName><gml:Point><gml:coordinates>$x,$y</gml:coordinates></gml:Point><Distance units='m'>15</Distance></DWithin></Filter>",
+ };
+
+ my $ukc = FixMyStreet::Cobrand::UKCouncils->new;
+ my $features = $ukc->_fetch_features($cfg, $x, $y);
+ return scalar @$features ? 1 : 0;
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 0ba9ba9c0..290f46d9e 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -304,6 +304,16 @@ sub munge_report_new_bodies {
my $tfl = FixMyStreet::Cobrand::TfL->new({ c => $self->{c} });
$tfl->munge_surrounding_london($bodies);
}
+
+ if ( $bodies{'Highways England'} ) {
+ my $c = $self->{c};
+ my $he = FixMyStreet::Cobrand::HighwaysEngland->new({ c => $c });
+ my $on_he_road = $c->stash->{on_he_road} = $he->report_new_is_on_he_road;
+
+ if (!$on_he_road) {
+ %$bodies = map { $_->id => $_ } grep { $_->name ne 'Highways England' } values %$bodies;
+ }
+ }
}
sub munge_report_new_contacts {