aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Reports.pm4
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm13
-rw-r--r--perllib/FixMyStreet/Cobrand/Bexley.pm20
-rw-r--r--perllib/FixMyStreet/Cobrand/CheshireEast.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm2
-rw-r--r--perllib/FixMyStreet/Map/CheshireEast.pm70
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm40
7 files changed, 128 insertions, 25 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm
index 91b086637..c57b207e2 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm
@@ -255,7 +255,7 @@ sub edit : Path('/admin/report_edit') : Args(1) {
$c->detach('edit_display') if $done;
}
- if ( $c->get_param('resend') && !$c->cobrand->call_hook('disable_resend') ) {
+ if ( $c->get_param('resend') && !$c->cobrand->call_hook('disable_resend_button') ) {
$c->forward('/auth/check_csrf_token');
$problem->resend;
@@ -382,7 +382,7 @@ sub edit_category : Private {
my ($self, $c, $problem, $no_comment) = @_;
if ((my $category = $c->get_param('category')) ne $problem->category) {
- my $force_resend = $c->cobrand->call_hook('category_change_force_resend');
+ my $force_resend = $c->cobrand->call_hook('category_change_force_resend', $problem->category, $category);
my $disable_resend = $c->cobrand->call_hook('disable_resend');
my $category_old = $problem->category;
$problem->category($category);
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 650881da3..cbbf8971a 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -697,6 +697,8 @@ sub setup_categories_and_bodies : Private {
my %category_extras = (); # extra fields to fill in for open311
my %category_extras_hidden =
(); # whether all of a category's fields are hidden
+ my %category_extras_notices =
+ (); # whether all of a category's fields are simple notices and not inputs
my %non_public_categories =
(); # categories for which the reports are not public
$c->stash->{unresponsive} = {};
@@ -729,6 +731,16 @@ sub setup_categories_and_bodies : Private {
} else {
$category_extras_hidden{$contact->category} = $all_hidden;
}
+
+ my $all_notices = (grep {
+ ( $_->{variable} || '' ) ne 'false'
+ && !$c->cobrand->category_extra_hidden($_)
+ } @$metas) ? 0 : 1;
+ if (exists($category_extras_notices{$contact->category})) {
+ $category_extras_notices{$contact->category} &&= $all_notices;
+ } else {
+ $category_extras_notices{$contact->category} = $all_notices;
+ }
}
$non_public_categories{ $contact->category } = 1 if $contact->non_public;
@@ -760,6 +772,7 @@ sub setup_categories_and_bodies : Private {
$c->stash->{category_options} = \@category_options;
$c->stash->{category_extras} = \%category_extras;
$c->stash->{category_extras_hidden} = \%category_extras_hidden;
+ $c->stash->{category_extras_notices} = \%category_extras_notices;
$c->stash->{non_public_categories} = \%non_public_categories;
$c->stash->{extra_name_info} = $first_area->{id} == COUNCIL_ID_BROMLEY ? 1 : 0;
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm
index 5900ba02d..bbef4154b 100644
--- a/perllib/FixMyStreet/Cobrand/Bexley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bexley.pm
@@ -27,7 +27,25 @@ sub disambiguate_location {
};
}
-sub disable_resend { 1 }
+sub disable_resend_button { 1 }
+
+# We can resend reports upon category change, unless it will be going to the
+# same Symology database, because that will reject saying it already has the
+# ID.
+sub category_change_force_resend {
+ my ($self, $old, $new) = @_;
+
+ # Get the Open311 identifiers
+ my $contacts = $self->{c}->stash->{contacts};
+ ($old) = map { $_->email } grep { $_->category eq $old } @$contacts;
+ ($new) = map { $_->email } grep { $_->category eq $new } @$contacts;
+
+ # Okay if we're switching to/from/within Confirm/Uniform
+ return 1 if $old =~ /^(Confirm|Uniform)/ || $new =~ /^(Confirm|Uniform)/;
+
+ # Otherwise, okay if we're switching between Symology DBs, but not within
+ return ($old =~ /^StreetLighting/ xor $new =~ /^StreetLighting/);
+}
sub on_map_default_status { 'open' }
diff --git a/perllib/FixMyStreet/Cobrand/CheshireEast.pm b/perllib/FixMyStreet/Cobrand/CheshireEast.pm
index a2c6c1c19..3ac81ab95 100644
--- a/perllib/FixMyStreet/Cobrand/CheshireEast.pm
+++ b/perllib/FixMyStreet/Cobrand/CheshireEast.pm
@@ -32,7 +32,7 @@ sub disambiguate_location {
}
sub enter_postcode_text {
- 'Enter a postcode or street name and area in Cheshire East';
+ 'Enter a postcode, or a road and place name';
}
sub admin_user_domain { 'cheshireeast.gov.uk' }
@@ -46,6 +46,8 @@ sub geocoder_munge_results {
$result->{display_name} =~ s/, Cheshire East, North West England, England//;
}
+sub map_type { 'CheshireEast' }
+
sub default_map_zoom { 3 }
sub on_map_default_status { 'open' }
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index e76113b9a..9dce32d2d 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -41,7 +41,7 @@ sub area_check {
sub enter_postcode_text {
my ($self) = @_;
- return 'Enter a London postcode, or street name and area';
+ return 'Enter a London postcode, or street name and area, or a reference number of a problem previous reported';
}
sub privacy_policy_url { 'https://tfl.gov.uk/corporate/privacy-and-cookies/reporting-street-problems' }
diff --git a/perllib/FixMyStreet/Map/CheshireEast.pm b/perllib/FixMyStreet/Map/CheshireEast.pm
new file mode 100644
index 000000000..4e59f2593
--- /dev/null
+++ b/perllib/FixMyStreet/Map/CheshireEast.pm
@@ -0,0 +1,70 @@
+package FixMyStreet::Map::CheshireEast;
+use base 'FixMyStreet::Map::OSM';
+
+use strict;
+use Utils;
+
+use constant MIN_ZOOM_LEVEL => 7;
+
+sub map_javascript { [
+ '/vendor/OpenLayers/OpenLayers.wfs.js',
+ '/js/map-OpenLayers.js',
+ '/js/map-cheshireeast.js',
+] }
+
+sub tile_parameters { {
+ origin_x => -3276800,
+ origin_y => 3276800,
+} }
+
+sub resolutions { (
+ 1792.003584007169,
+ 896.0017920035843,
+ 448.0008960017922,
+ 224.0004480008961,
+ 112.000224000448,
+ 56.000112000224014,
+ 28.000056000111993,
+ 14.000028000056004,
+ 7.000014000028002,
+ 2.8000056000112004,
+ 1.4000028000056002,
+ 0.7000014000028001,
+ 0.35000070000140004,
+ 0.14000028000056003,
+) }
+
+my $url = 'https://maps-cache.cheshiresharedservices.gov.uk/maps/?wmts/CE_OS_AllBasemaps_COLOUR/oscce_grid/%d/%d/%d.jpeg&KEY=3a3f5c60eca1404ea114e6941c9d3895';
+
+sub map_tiles {
+ my ( $self, %params ) = @_;
+ my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
+ return [
+ sprintf($url, $z, $x-1, $y-1),
+ sprintf($url, $z, $x, $y-1),
+ sprintf($url, $z, $x-1, $y),
+ sprintf($url, $z, $x, $y),
+ ];
+}
+
+sub latlon_to_tile($$$$) {
+ my ($self, $lat, $lon, $zoom) = @_;
+ my ($x, $y) = eval { Utils::convert_latlon_to_en($lat, $lon) };
+ my $tile_params = $self->tile_parameters;
+ my $res = ($self->resolutions)[$zoom];
+ my $fx = ( $x - $tile_params->{origin_x} ) / ($res * 256);
+ my $fy = ( $tile_params->{origin_y} - $y ) / ($res * 256);
+ return ( $fx, $fy );
+}
+
+sub tile_to_latlon {
+ my ($self, $fx, $fy, $zoom) = @_;
+ my $tile_params = $self->tile_parameters;
+ my $res = ($self->resolutions)[$zoom];
+ my $x = $fx * $res * 256 + $tile_params->{origin_x};
+ my $y = $tile_params->{origin_y} - $fy * $res * 256;
+ my ($lat, $lon) = Utils::convert_en_to_latlon($x, $y);
+ return ( $lat, $lon );
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index a6cb6acea..ef465d7dc 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -87,10 +87,10 @@ sub generate_map_data {
$zoom = $numZoomLevels - 1 if $zoom >= $numZoomLevels;
$zoom = 0 if $zoom < 0;
$params{zoom_act} = $zoomOffset + $zoom;
- ($params{x_tile}, $params{y_tile}) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $params{zoom_act});
+ ($params{x_tile}, $params{y_tile}) = $self->latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $params{zoom_act});
foreach my $pin (@{$params{pins}}) {
- ($pin->{px}, $pin->{py}) = latlon_to_px($pin->{latitude}, $pin->{longitude}, $params{x_tile}, $params{y_tile}, $params{zoom_act});
+ ($pin->{px}, $pin->{py}) = $self->latlon_to_px($pin->{latitude}, $pin->{longitude}, $params{x_tile}, $params{y_tile}, $params{zoom_act});
}
return {
@@ -102,24 +102,24 @@ sub generate_map_data {
zoom => $zoom,
zoomOffset => $zoomOffset,
numZoomLevels => $numZoomLevels,
- compass => compass( $params{x_tile}, $params{y_tile}, $params{zoom_act} ),
+ compass => $self->compass( $params{x_tile}, $params{y_tile}, $params{zoom_act} ),
};
}
sub compass {
- my ( $x, $y, $z ) = @_;
+ my ( $self, $x, $y, $z ) = @_;
return {
- north => [ map { Utils::truncate_coordinate($_) } tile_to_latlon( $x, $y-1, $z ) ],
- south => [ map { Utils::truncate_coordinate($_) } tile_to_latlon( $x, $y+1, $z ) ],
- west => [ map { Utils::truncate_coordinate($_) } tile_to_latlon( $x-1, $y, $z ) ],
- east => [ map { Utils::truncate_coordinate($_) } tile_to_latlon( $x+1, $y, $z ) ],
- here => [ map { Utils::truncate_coordinate($_) } tile_to_latlon( $x, $y, $z ) ],
+ north => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x, $y-1, $z ) ],
+ south => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x, $y+1, $z ) ],
+ west => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x-1, $y, $z ) ],
+ east => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x+1, $y, $z ) ],
+ here => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x, $y, $z ) ],
};
}
# Given a lat/lon, convert it to OSM tile co-ordinates (precise).
-sub latlon_to_tile($$$) {
- my ($lat, $lon, $zoom) = @_;
+sub latlon_to_tile($$$$) {
+ my ($self, $lat, $lon, $zoom) = @_;
my $x_tile = ($lon + 180) / 360 * 2**$zoom;
my $y_tile = (1 - log(tan(deg2rad($lat)) + sec(deg2rad($lat))) / pi) / 2 * 2**$zoom;
return ( $x_tile, $y_tile );
@@ -127,9 +127,9 @@ sub latlon_to_tile($$$) {
# Given a lat/lon, convert it to OSM tile co-ordinates (nearest actual tile,
# adjusted so the point will be near the centre of a 2x2 tiled map).
-sub latlon_to_tile_with_adjust($$$) {
- my ($lat, $lon, $zoom) = @_;
- my ($x_tile, $y_tile) = latlon_to_tile($lat, $lon, $zoom);
+sub latlon_to_tile_with_adjust($$$$) {
+ my ($self, $lat, $lon, $zoom) = @_;
+ my ($x_tile, $y_tile) = $self->latlon_to_tile($lat, $lon, $zoom);
# Try and have point near centre of map
if ($x_tile - int($x_tile) > 0.5) {
@@ -143,7 +143,7 @@ sub latlon_to_tile_with_adjust($$$) {
}
sub tile_to_latlon {
- my ($x, $y, $zoom) = @_;
+ my ($self, $x, $y, $zoom) = @_;
my $n = 2 ** $zoom;
my $lon = $x / $n * 360 - 180;
my $lat = rad2deg(atan(sinh(pi * (1 - 2 * $y / $n))));
@@ -151,9 +151,9 @@ sub tile_to_latlon {
}
# Given a lat/lon, convert it to pixel co-ordinates from the top left of the map
-sub latlon_to_px($$$$$) {
- my ($lat, $lon, $x_tile, $y_tile, $zoom) = @_;
- my ($pin_x_tile, $pin_y_tile) = latlon_to_tile($lat, $lon, $zoom);
+sub latlon_to_px($$$$$$) {
+ my ($self, $lat, $lon, $x_tile, $y_tile, $zoom) = @_;
+ my ($pin_x_tile, $pin_y_tile) = $self->latlon_to_tile($lat, $lon, $zoom);
my $pin_x = tile_to_px($pin_x_tile, $x_tile);
my $pin_y = tile_to_px($pin_y_tile, $y_tile);
return ($pin_x, $pin_y);
@@ -182,8 +182,8 @@ sub click_to_wgs84 {
my ($self, $c, $pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_;
my $tile_x = click_to_tile($pin_tile_x, $pin_x);
my $tile_y = click_to_tile($pin_tile_y, $pin_y);
- my $zoom = MIN_ZOOM_LEVEL + (defined $c->get_param('zoom') ? $c->get_param('zoom') : 3);
- my ($lat, $lon) = tile_to_latlon($tile_x, $tile_y, $zoom);
+ my $zoom = $self->MIN_ZOOM_LEVEL + (defined $c->get_param('zoom') ? $c->get_param('zoom') : 3);
+ my ($lat, $lon) = $self->tile_to_latlon($tile_x, $tile_y, $zoom);
return ( $lat, $lon );
}