aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/Lincolnshire.pm
blob: 8d8ba3268556ed74e6ea9a434ecb6850ac7193e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package FixMyStreet::Cobrand::Lincolnshire;
use parent 'FixMyStreet::Cobrand::UKCouncils';

use strict;
use warnings;

use LWP::Simple;
use URI;
use Try::Tiny;
use JSON::MaybeXS;

use Moo;
with 'FixMyStreet::Roles::ConfirmValidation';

sub council_area_id { return 2232; }
sub council_area { return 'Lincolnshire'; }
sub council_name { return 'Lincolnshire County Council'; }
sub council_url { return 'lincolnshire'; }
sub is_two_tier { 1 }

sub enable_category_groups { 1 }
sub send_questionnaires { 0 }
sub report_sent_confirmation_email { 'external_id' }

sub admin_user_domain { 'lincolnshire.gov.uk' }

sub enter_postcode_text {
    my ($self) = @_;
    return 'Enter a Lincolnshire postcode, street name and area, or check an existing report number';
}


sub base_url {
    my $self = shift;
    return $self->next::method() if FixMyStreet->config('STAGING_SITE');
    return 'https://fixmystreet.lincolnshire.gov.uk';
}

sub contact_email {
    my $self = shift;
    return join( '@', 'confirm_support', 'lincolnshire.gov.uk' );
}


sub example_places {
    return ( 'LN1 1YL', 'Orchard Street, Lincoln' );
}

sub disambiguate_location {
    my $self    = shift;
    my $string  = shift;
    return {
        %{ $self->SUPER::disambiguate_location() },
        town   => 'Lincolnshire',
        centre => '53.1128371079972,-0.237920757894981',
        span   => '0.976148231905086,1.17860658530345',
        bounds => [ 52.6402179235688, -0.820651304784901, 53.6163661554738, 0.357955280518546 ],
    };
}


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 };

    # 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 => 200, # metres
    url => "https://tilma.mysociety.org/mapserver/lincs",
    srsname => "urn:ogc:def:crs:EPSG::27700",
    typename => "NSG",
    property => "Site_Code",
    accept_feature => sub { 1 }
} }


sub categories_restriction {
    my ($self, $rs) = @_;
    # Lincolnshire is a two-tier council, but don't want to display
    # all district-level categories on their cobrand - just a couple.
    return $rs->search( { -or => [
        'body.name' => "Lincolnshire County Council",

        # District categories:
        'me.category' => { -in => [
            'Street nameplates',
            'Bench/cycle rack/litter bin/planter',
        ] },
    ] } );
}

sub map_type { 'Lincolnshire' }

sub pin_colour {
    my ( $self, $p, $context ) = @_;
    my $ext_status = $p->get_extra_metadata('external_status_code');
    return 'yellow' if $p->state eq 'confirmed' && $ext_status && $ext_status eq '0135';
    return 'red' if $p->state eq 'confirmed';
    return 'green' if $p->is_fixed || $p->is_closed;
    return 'grey' if $p->state eq 'not responsible' || !$self->owns_problem( $p );
    return 'yellow';
}

1;