aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm13
-rw-r--r--perllib/FixMyStreet/Cobrand/EastSussex.pm114
-rw-r--r--perllib/FixMyStreet/Geocode.pm2
3 files changed, 128 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 8eb637879..779c0a7a2 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -862,6 +862,19 @@ Perform any extra validation on the contact form.
sub extra_contact_validation { (); }
+
+=head2 get_geocoder
+
+Return the default geocoder from config.
+
+=cut
+
+sub get_geocoder {
+ my ($self, $c) = @_;
+ return $c->config->{GEOCODER};
+}
+
+
sub problem_as_hashref {
my $self = shift;
my $problem = shift;
diff --git a/perllib/FixMyStreet/Cobrand/EastSussex.pm b/perllib/FixMyStreet/Cobrand/EastSussex.pm
new file mode 100644
index 000000000..c039b8410
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/EastSussex.pm
@@ -0,0 +1,114 @@
+package FixMyStreet::Cobrand::EastSussex;
+use base 'FixMyStreet::Cobrand::UKCouncils';
+
+use strict;
+use warnings;
+
+sub council_id { return 2224; }
+sub council_area { return 'East Sussex'; }
+sub council_name { return 'East Sussex County Council'; }
+sub council_url { return 'eastsussex'; }
+# sub is_two_tier { return 1; }
+
+sub path_to_web_templates {
+ my $self = shift;
+ return [
+ FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
+ FixMyStreet->path_to( 'templates/web/fixmystreet' )->stringify
+ ];
+}
+
+sub disambiguate_location {
+ my $self = shift;
+ my $string = shift;
+ return {
+ %{ $self->SUPER::disambiguate_location() },
+ town => 'East Sussex',
+ centre => '50.9413275309703,0.276320277101682',
+ span => '0.414030932264716,1.00374244745585',
+ bounds => [ 50.7333642759327, -0.135851370247794, 51.1473952081975, 0.867891077208056 ],
+ };
+}
+
+sub example_places {
+ return ( 'BN7 2LZ', 'White Hill, Lewes' );
+}
+
+sub enter_postcode_text {
+ my ($self) = @_;
+ return 'Enter an East Sussex postcode, or street name and area';
+}
+
+# increase map zoom level so street names are visible
+sub default_map_zoom { return 3; }
+
+
+=head2 temp_update_potholes_contact
+
+Routine to update the extra for potholes (temporary setup hack, will be
+superseded by Open311/integration).
+
+Can run with a script or command line like:
+
+ bin/cron-wrapper perl -MFixMyStreet::App -MFixMyStreet::Cobrand::EastSussex -e \
+ 'FixMyStreet::Cobrand::EastSussex->new({c => FixMyStreet::App->new})->temp_update_potholes_contact'
+
+=cut
+
+use constant POTHOLE_SIZES => [
+ {'key' => ['Blank'], 'name' => ['--']},
+ {'key' => ['golf'], 'name' => ['Golf ball sized']},
+ {'key' => ['tennis'], 'name' => ['Tennis ball sized']},
+ {'key' => ['football'], 'name' => ['Football sized']},
+ {'key' => ['larger'], 'name' => ['Larger']}
+];
+
+use constant POTHOLE_DICT => {
+ map {
+ @{ $_->{key} },
+ @{ $_->{name} },
+ } @{ POTHOLE_SIZES() },
+};
+
+sub resolve_pothole_size {
+ my ($self, $key) = @_;
+ return $self->POTHOLE_DICT->{$key};
+}
+
+sub temp_update_potholes_contact {
+ my $self = shift;
+
+ my $category = 'Potholes';
+ my $contact = $self->{c}->model('DB::Contact')
+ ->search({
+ body_id => $self->council_id,
+ category => $category,
+ })->first
+ or die "No such category: $category";
+
+ my $fields = [
+ {
+ 'code' => 'detail_size', # there is already builtin handling for this field in Report::New
+ 'variable' => 'true',
+ 'order' => '1',
+ 'description' => 'Size of the pothole?',
+ 'required' => 'true',
+ 'datatype' => 'singlevaluelist',
+ 'datatype_description' => {},
+ 'values' => {
+ 'value' => $self->POTHOLE_SIZES,
+ },
+ }
+ ];
+ # require IO::String; require RABX;
+ # RABX::wire_wr( $fields, IO::String->new(my $extra) );
+
+ $contact->update({ extra => $fields });
+}
+
+sub get_geocoder {
+ return 'OSM'; # default of Bing gives poor results, let's try overriding.
+}
+
+1;
+
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index 61c398985..2a318ea5a 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -35,7 +35,7 @@ sub lookup {
sub string {
my ($s, $c) = @_;
- my $service = $c->config->{GEOCODER};
+ my $service = $c->cobrand->get_geocoder($c);
$service = $service->{type} if ref $service;
$service = 'OSM' unless $service =~ /^(Bing|Google|OSM|Zurich)$/;
$service = 'OSM' if $service eq 'Bing' && !FixMyStreet->config('BING_MAPS_API_KEY');