diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-06-22 18:18:38 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-06-22 18:20:35 +0100 |
commit | 19241c52172aec0c797a00b35a090e28f7858e1d (patch) | |
tree | 21a81d44f5c10ce8ffbbc862b113280ccaef3a5b /perllib/FixMyStreet | |
parent | 368d980d25c00248f46b7e8ca8fec287e5dff58d (diff) |
Tidy up some UK specific easting/northing handling
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 13 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 16 |
2 files changed, 10 insertions, 19 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 5b853134e..628497233 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -160,6 +160,7 @@ __PACKAGE__->rabx_column('geocode'); use Moo; use namespace::clean -except => [ 'meta' ]; use Utils; +use FixMyStreet::Map::FMS; with 'FixMyStreet::Roles::Abuser', 'FixMyStreet::Roles::Extra'; @@ -672,13 +673,15 @@ sub duration_string { sub local_coords { my $self = shift; - if ($self->cobrand eq 'zurich') { + my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($self->cobrand)->new; + if ($cobrand->moniker eq 'zurich') { my ($x, $y) = Geo::Coordinates::CH1903::from_latlon($self->latitude, $self->longitude); return ( int($x+0.5), int($y+0.5) ); - } - else { - # return a dummy value until this function is implemented. useful for testing. - return (0, 0); + } elsif ($cobrand->country eq 'GB') { + my $coordsyst = 'G'; + $coordsyst = 'I' if FixMyStreet::Map::FMS::in_northern_ireland_box($self->latitude, $self->longitude); + my ($x, $y) = Utils::convert_latlon_to_en( $self->latitude, $self->longitude, $coordsyst ); + return ($x, $y, $coordsyst); } } diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index 278c58af1..30d24f640 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -108,8 +108,6 @@ sub send(;$) { $h{user_details} .= sprintf(_('Email: %s'), $row->user->email) . "\n\n"; } - $h{easting_northing} = ''; - if ($cobrand->can('process_additional_metadata_for_email')) { $cobrand->process_additional_metadata_for_email($row, \%h); } @@ -150,19 +148,9 @@ sub send(;$) { $reporters{ $sender }->add_body( $body, $sender_info->{config} ); } - # If we are in the UK include eastings and northings, and nearest stuff + # If we are in the UK include eastings and northings if ( $cobrand->country eq 'GB' && !$h{easting} ) { - my $coordsyst = 'G'; - my $first_area = $body->body_areas->first->area_id; - my $area_info = mySociety::MaPit::call('area', $first_area); - $coordsyst = 'I' if $area_info->{type} eq 'LGD'; - - ( $h{easting}, $h{northing} ) = Utils::convert_latlon_to_en( $h{latitude}, $h{longitude}, $coordsyst ); - - # email templates don't have conditionals so we need to format this here - $h{easting_northing} = "Easting/Northing"; - $h{easting_northing} .= " (IE)" if $coordsyst eq 'I'; - $h{easting_northing} .= ": $h{easting}/$h{northing}\n\n"; + ( $h{easting}, $h{northing}, $h{coordsyst} ) = $row->local_coords; } } |