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
|
package FixMyStreet::Cobrand::FixaMinGata;
use base 'FixMyStreet::Cobrand::Default';
use strict;
use warnings;
use Carp;
use mySociety::MaPit;
use FixMyStreet::Geocode::FixaMinGata;
use DateTime;
sub country {
return 'SE';
}
sub languages { [ 'sv,Swedish,sv_SE' ] }
sub language_override { 'sv' }
sub enter_postcode_text {
my ( $self ) = @_;
return _('Enter a nearby postcode, or street name and area');
}
# Is also adding language parameter
sub disambiguate_location {
return {
lang => 'sv',
country => 'se', # Is this the right format? /Rikard
};
}
sub area_types {
my $self = shift;
return $self->next::method() if FixMyStreet->staging_flag('skip_checks');
[ 'KOM' ];
}
sub geocode_postcode {
my ( $self, $s ) = @_;
# Most people write Swedish postcodes like this:
#+ XXX XX, so let's remove the space
# Is this the right place to do this? //Rikard
# This is the right place! // Jonas
$s =~ s/\ //g; # Rikard, remove space in postcode
if ($s =~ /^\d{5}$/) {
my $location = mySociety::MaPit::call('postcode', $s);
if ($location->{error}) {
return {
error => $location->{code} =~ /^4/
? _('That postcode was not recognised, sorry.')
: $location->{error}
};
}
return {
latitude => $location->{wgs84_lat},
longitude => $location->{wgs84_lon},
};
}
return {};
}
# Vad gör den här funktionen? Är "Sverige" rätt här?
sub geocoded_string_check {
my ( $self, $s ) = @_;
return 1 if $s =~ /, Sverige/;
return 0;
}
sub find_closest {
my ( $self, $latitude, $longitude ) = @_;
return FixMyStreet::Geocode::OSM::closest_road_text( $self, $latitude, $longitude );
}
# Used by send-reports, calling find_closest, calling OSM geocoding
sub guess_road_operator {
my ( $self, $inforef ) = @_;
my $highway = $inforef->{highway} || "unknown";
my $refs = $inforef->{ref} || "unknown";
return "Trafikverket"
if $highway eq "trunk" || $highway eq "primary";
for my $ref (split(/;/, $refs)) {
return "Trafikverket"
if $ref =~ m/E ?\d+/ || $ref =~ m/Fv\d+/i;
}
return '';
}
sub remove_redundant_councils {
my $self = shift;
my $all_councils = shift;
# Oslo is both a kommune and a fylke, we only want to show it once
# Jag tror inte detta är applicerbart på Sverige ;-) //Rikard
#delete $all_councils->{301} #
# if $all_councils->{3};
}
sub filter_all_council_ids_list {
my $self = shift;
my @all_councils_ids = @_;
# as above we only want to show Oslo once
# Rikard kommenterar ut detta.
# return grep { $_ != 301 } @all_councils_ids;
# Rikard:
return @all_councils_ids; # Är detta rätt? //Rikard
}
# The pin is green is it's fixed, yellow if it's closed (but not fixed), and
# red otherwise.
sub pin_colour {
my ( $self, $p, $context ) = @_;
return 'green' if $p->is_fixed;
return 'yellow' if $p->is_closed;
return 'red';
}
1;
|