diff options
-rw-r--r-- | conf/general.yml-example | 27 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Council.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/EmptyHomes.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UK.pm | 6 |
9 files changed, 49 insertions, 39 deletions
diff --git a/conf/general.yml-example b/conf/general.yml-example index 78bf9426c..815494757 100644 --- a/conf/general.yml-example +++ b/conf/general.yml-example @@ -44,15 +44,30 @@ GEO_CACHE: '../cache/' GOOGLE_MAPS_API_KEY: '' BING_MAPS_API_KEY: '' -# Location of MapIt, to map points to administrative areas. -# If left blank, a default area will be used everywhere -# (a URL needs to be given for non-web things, like sending -# of reports, to function). -MAPIT_URL: '' +# Location of MapIt, to map points to administrative areas, and what types of +# area from it you want to use. If left blank, a default area will be used +# everywhere (a URL needs to be given for non-web things, like sending of +# reports, to function). # If using the Catalyst development server, set to # MAPIT_URL: 'http://localhost:3000/fakemapit/' -# In the UK, you probably want: +# MAPIT_TYPES: [ 'ZZZ' ] +# In the UK, you probably want, to cover all councils: # MAPIT_URL: 'http://mapit.mysociety.org/' +# MAPIT_TYPES: [ 'DIS', 'LBO', 'MTD', 'UTA', 'CTY', 'COI', 'LGD' ] +# But perhaps MAPIT_TYPES: [ 'WMC' ] if you want to report on a per-constituency basis? +# If our global MapIt (using OpenStreetMap data) contains boundaries you can use: +# MAPIT_URL: 'http://global.mapit.mysociety.org/' +# And then specify whichever type code have the boundaries you want: +# MAPIT_TYPES: [ 'O06' ] +MAPIT_URL: '' +MAPIT_TYPES: [ 'ZZZ' ] + +# If your MapIt has the concept of council wards (subareas of councils, where +# people can sign up for alerts, but not report things), then you can give the +# MapIt type codes for them here. +# You can probably leave this blank, but in the UK we use something like: +# MAPIT_TYPES_CHILDREN: [ 'DIW', 'LBW', 'MTW', 'UTE', 'UTW', 'CED', 'COP', 'LGW' ] +MAPIT_TYPES_CHILDREN: # The type of map you want to use. If left blank, the default is OpenStreetMap. # Other options are currently pretty UK specific, including "FMS" for UK diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 58977473f..4de3d0d1e 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -221,10 +221,10 @@ sub council_list : Path('council_list') : Args(0) { $c->stash->{edit_activity} = $edit_activity; # Not London, as treated separately - my @area_types = $c->cobrand->moniker eq 'emptyhomes' + my $area_types = $c->cobrand->moniker eq 'emptyhomes' ? $c->cobrand->area_types - : grep { $_ ne 'LBO' } $c->cobrand->area_types; - my $areas = mySociety::MaPit::call('areas', \@area_types); + : [ grep { $_ ne 'LBO' } @{ $c->cobrand->area_types } ]; + my $areas = mySociety::MaPit::call('areas', $area_types); my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas; @councils_ids = $c->cobrand->filter_all_council_ids_list( @councils_ids ); @@ -1255,8 +1255,7 @@ sub check_page_allowed : Private { sub set_up_council_details : Private { my ($self, $c ) = @_; - my @area_types = $c->cobrand->area_types; - my $areas = mySociety::MaPit::call('areas', \@area_types); + my $areas = mySociety::MaPit::call('areas', $c->cobrand->area_types); my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas; @councils_ids = $c->cobrand->filter_all_council_ids_list( @councils_ids ); diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm index fbdc5261f..a6ce533e4 100644 --- a/perllib/FixMyStreet/App/Controller/Council.pm +++ b/perllib/FixMyStreet/App/Controller/Council.pm @@ -23,8 +23,8 @@ there are no councils then return false. sub load_and_check_councils_and_wards : Private { my ( $self, $c ) = @_; - my @area_types = ( $c->cobrand->area_types(), $c->cobrand->area_types_children() ); - $c->stash->{area_types} = \@area_types; + my $area_types = [ @{$c->cobrand->area_types}, @{$c->cobrand->area_types_children} ]; + $c->stash->{area_types} = $area_types; $c->forward('load_and_check_councils'); } @@ -42,11 +42,11 @@ sub load_and_check_councils : Private { my $longitude = $c->stash->{longitude}; # Look up councils and do checks for the point we've got - my @area_types; + my $area_types; if ( $c->stash->{area_types} and scalar @{ $c->stash->{area_types} } ) { - @area_types = @{ $c->stash->{area_types} }; + $area_types = $c->stash->{area_types}; } else { - @area_types = $c->cobrand->area_types(); + $area_types = $c->cobrand->area_types; } my $short_latitude = Utils::truncate_coordinate($latitude); @@ -55,7 +55,7 @@ sub load_and_check_councils : Private { # TODO: I think we want in_gb_locale around the MaPit line, needs testing my $all_councils; if ( $c->stash->{fetch_all_areas} ) { - my %area_types = map { $_ => 1 } @area_types; + my %area_types = map { $_ => 1 } @$area_types; my $all_areas = mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude" ); $c->stash->{all_areas} = $all_areas; @@ -67,7 +67,7 @@ sub load_and_check_councils : Private { } else { $all_councils = mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude", - type => \@area_types ); + type => $area_types ); } if ($all_councils->{error}) { $c->stash->{location_error} = $all_councils->{error}; diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index 14b790db8..040b0d3e6 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -163,10 +163,10 @@ sub get_services : Private { my $categories = $c->model('DB::Contact')->not_deleted; if ($lat || $lon) { - my @area_types = $c->cobrand->area_types; + my $area_types = $c->cobrand->area_types; my $all_councils = mySociety::MaPit::call('point', "4326/$lon,$lat", - type => \@area_types); + type => $area_types); $categories = $categories->search( { area_id => [ keys %$all_councils ], } ); diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index f275410dc..37766db44 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -34,8 +34,8 @@ sub index : Path : Args(0) { # Fetch all areas of the types we're interested in my $areas_info; eval { - my @area_types = $c->cobrand->area_types; - $areas_info = mySociety::MaPit::call('areas', \@area_types, + my $area_types = $c->cobrand->area_types; + $areas_info = mySociety::MaPit::call('areas', $area_types, min_generation => $c->cobrand->area_min_generation ); }; @@ -231,9 +231,9 @@ sub council_check : Private { } # We must now have a string to check - my @area_types = $c->cobrand->area_types; + my $area_types = $c->cobrand->area_types; my $areas = mySociety::MaPit::call( 'areas', $q_council, - type => \@area_types, + type => $area_types, min_generation => $c->cobrand->area_min_generation ); if (keys %$areas == 1) { diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 9b22095f7..1f4cea87a 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -537,8 +537,8 @@ The MaPit types this site handles =cut -sub area_types { qw(ZZZ) } -sub area_types_children { qw() } +sub area_types { FixMyStreet->config('MAPIT_TYPES') || [ 'ZZZ' ] } +sub area_types_children { FixMyStreet->config('MAPIT_TYPES_CHILDREN') || [] } sub area_min_generation { '' } =head2 contact_name, contact_email diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm index d99dcb3de..b9dea87c9 100644 --- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm +++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm @@ -27,7 +27,7 @@ sub admin_base_url { } sub area_types { - return qw(DIS LBO MTD UTA LGD COI); # No CTY + [ 'DIS', 'LBO', 'MTD', 'UTA', 'LGD', 'COI' ]; # No CTY } @@ -89,7 +89,7 @@ sub council_rss_alert_options { my $all_councils = shift; my $c = shift; - my %councils = map { $_ => 1 } $self->area_types(); + my %councils = map { $_ => 1 } @{$self->area_types}; my $num_councils = scalar keys %$all_councils; diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index fc21baed7..7dcd91710 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -34,11 +34,7 @@ sub disambiguate_location { } sub area_types { - return ( 'NKO', 'NFY', 'NRA' ); -} - -sub area_min_generation { - return ''; + [ 'NKO', 'NFY', 'NRA' ]; } sub admin_base_url { @@ -236,9 +232,9 @@ sub reports_council_check { # Some kommunes have the same name, use the fylke name to work out which. my ($kommune, $fylke) = split /\s*,\s*/, $council; - my @area_types = $c->cobrand->area_types; - my $areas_k = mySociety::MaPit::call('areas', $kommune, type => \@area_types); - my $areas_f = mySociety::MaPit::call('areas', $fylke, type => \@area_types); + my $area_types = $c->cobrand->area_types; + my $areas_k = mySociety::MaPit::call('areas', $kommune, type => $area_types); + my $areas_f = mySociety::MaPit::call('areas', $fylke, type => $area_types); if (keys %$areas_f == 1) { ($fylke) = values %$areas_f; foreach (values %$areas_k) { diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm index 3abd7a77a..c2618cbd9 100644 --- a/perllib/FixMyStreet/Cobrand/UK.pm +++ b/perllib/FixMyStreet/Cobrand/UK.pm @@ -9,8 +9,8 @@ sub path_to_web_templates { } sub country { return 'GB'; } -sub area_types { return qw(DIS LBO MTD UTA CTY COI LGD); } -sub area_types_children { return @$mySociety::VotingArea::council_child_types } +sub area_types { [ 'DIS', 'LBO', 'MTD', 'UTA', 'CTY', 'COI', 'LGD' ] } +sub area_types_children { $mySociety::VotingArea::council_child_types } sub area_min_generation { 10 } sub enter_postcode_text { @@ -212,7 +212,7 @@ sub council_rss_alert_options { my $all_councils = shift; my $c = shift; - my %councils = map { $_ => 1 } $self->area_types(); + my %councils = map { $_ => 1 } @{$self->area_types}; my $num_councils = scalar keys %$all_councils; |