diff options
-rwxr-xr-x | bin/import-flickr | 1 | ||||
-rwxr-xr-x | bin/send-reports | 8 | ||||
-rwxr-xr-x | bin/test-run | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Alert.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original.pm | 5 | ||||
-rw-r--r-- | perllib/Utils.pm | 28 | ||||
-rwxr-xr-x | web/import.cgi | 8 | ||||
-rwxr-xr-x | web/index.cgi | 5 | ||||
-rwxr-xr-x | web/rss.cgi | 1 |
11 files changed, 31 insertions, 34 deletions
diff --git a/bin/import-flickr b/bin/import-flickr index b187189b7..f4a838547 100755 --- a/bin/import-flickr +++ b/bin/import-flickr @@ -24,7 +24,6 @@ use mySociety::Config; use mySociety::DBHandle qw(dbh select_all); use mySociety::EmailUtil; use mySociety::Email; -use mySociety::GeoUtil; BEGIN { mySociety::Config::set_file("$FindBin::Bin/../conf/general"); diff --git a/bin/send-reports b/bin/send-reports index 2d5245269..ef3da8c46 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -27,7 +27,6 @@ use mySociety::Config; use mySociety::DBHandle qw(dbh); use mySociety::Email; use mySociety::EmailUtil; -use mySociety::GeoUtil; use mySociety::Locale; use mySociety::MaPit; use mySociety::Random qw(random_bytes); @@ -103,12 +102,7 @@ foreach my $row (@$unsent) { $h{easting_northing} = ''; if ( mySociety::Config::get('COUNTRY') eq 'GB' ) { - ( $h{easting}, $h{northing} ) = - mySociety::Locale::in_gb_locale { - mySociety::GeoUtil::wgs84_to_national_grid( - $h{latitude}, $h{longitude}, 'G' - ); - }; + ( $h{easting}, $h{northing} ) = Utils::convert_latlon_to_en( $h{latitude}, $h{longitude} ); # email templates don't have conditionals so we need to farmat this here $h{easting_northing} # diff --git a/bin/test-run b/bin/test-run index b2fea2fb5..1c41e7c3a 100755 --- a/bin/test-run +++ b/bin/test-run @@ -27,7 +27,6 @@ use FindBin; use mySociety::Config; mySociety::Config::set_file('../conf/general'); use mySociety::DBHandle qw(dbh); -use mySociety::GeoUtil; use mySociety::WebTestHarness; use Test::Harness; use File::Find; diff --git a/perllib/FixMyStreet/Alert.pm b/perllib/FixMyStreet/Alert.pm index 45985502f..cdc070290 100644 --- a/perllib/FixMyStreet/Alert.pm +++ b/perllib/FixMyStreet/Alert.pm @@ -30,7 +30,6 @@ use mySociety::DBHandle qw(dbh); use mySociety::Email; use mySociety::EmailUtil; use mySociety::Gaze; -use mySociety::GeoUtil; use mySociety::Locale; use mySociety::MaPit; use mySociety::Random qw(random_bytes); diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index 9ab958cd9..14cedbaeb 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -18,8 +18,8 @@ use URI::Escape; use Cobrand; use Page; +use Utils; use mySociety::Config; -use mySociety::GeoUtil; use mySociety::Locale; use mySociety::MaPit; use mySociety::PostcodeUtil; @@ -63,9 +63,7 @@ sub geocoded_string_coordinates { $longitude = $1; $latitude = $2; try { - my ($easting, $northing) = mySociety::Locale::in_gb_locale { - mySociety::GeoUtil::wgs84_to_national_grid($latitude, $longitude, 'G'); - }; + my ($easting, $northing) = Utils::convert_latlon_to_en( $latitude, $longitude ); } catch Error::Simple with { $error = shift; $error = _('That location does not appear to be in Britain; please try again.') diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 0902914dd..a9978103f 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -14,7 +14,6 @@ use Problems; use Cobrand; use mySociety::Config; use mySociety::Gaze; -use mySociety::GeoUtil qw(national_grid_to_wgs84); use mySociety::Locale; use mySociety::Web qw(ent NewURL); use Utils; diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index 4dc4a5817..e32d62442 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -12,16 +12,13 @@ use strict; use LWP::Simple; use Cobrand; -use mySociety::GeoUtil; use mySociety::Locale; use mySociety::Web qw(ent NewURL); use Utils; sub _ll_to_en { my ($lat, $lon) = @_; - return mySociety::Locale::in_gb_locale { - mySociety::GeoUtil::wgs84_to_national_grid( $lat, $lon, 'G' ); - }; + return Utils::convert_latlon_to_en( $lat, $lon ); } sub header_js { diff --git a/perllib/Utils.pm b/perllib/Utils.pm index d54e081c8..91dab033a 100644 --- a/perllib/Utils.pm +++ b/perllib/Utils.pm @@ -14,6 +14,7 @@ package Utils; use strict; use mySociety::DBHandle qw(dbh); use mySociety::GeoUtil; +use mySociety::Locale; sub workaround_pg_bytea { my ( $st, $img_idx, @elements ) = @_; @@ -33,11 +34,30 @@ sub workaround_pg_bytea { $s->execute(); } +=head2 convert_latlon_to_en + + ( $easting, $northing ) = Utils::convert_en_to_latlon( $latitude, $longitude ); + +Takes the WGS84 latitude and longitude and returns OSGB36 easting and northing. + +=cut + +sub convert_latlon_to_en { + my ( $latitude, $longitude ) = @_; + + my ( $easting, $northing ) = + mySociety::Locale::in_gb_locale { + mySociety::GeoUtil::wgs84_to_national_grid( $latitude, $longitude, 'G' ); + }; + + return ( $easting, $northing ); +} + =head2 convert_en_to_latlon ( $latitude, $longitude ) = Utils::convert_en_to_latlon( $easting, $northing ); -Takes the easting and northing and returns latitude and longitude. +Takes the OSGB36 easting and northing and returns WGS84 latitude and longitude. =cut @@ -56,8 +76,8 @@ sub convert_en_to_latlon { ( $lat, $lon ) = Utils::convert_en_to_latlon( $easting, $northing ); -Takes the easting and northing and returns latitude and longitude (truncated -using C<Utils::truncate_coordinate>). +Takes the OSGB36 easting and northing and returns WGS84 latitude and longitude +(truncated using C<Utils::truncate_coordinate>). =cut @@ -74,7 +94,7 @@ sub convert_en_to_latlon_truncated { $short = Utils::truncate_coordinate( $long ); Given a long coordinate returns a shorter one - rounded to 6 decimal places - -which is < 1m at the equator. +which is < 1m at the equator, if you're using WGS84 lat/lon. =cut diff --git a/web/import.cgi b/web/import.cgi index 919f7a653..ac36b2ee5 100755 --- a/web/import.cgi +++ b/web/import.cgi @@ -16,7 +16,6 @@ use mySociety::AuthToken; use mySociety::Config; use mySociety::EmailUtil; use mySociety::EvEl; -use mySociety::GeoUtil; use mySociety::Locale; sub main { @@ -65,11 +64,8 @@ sub main { if ( $latitude && mySociety::Config::get('COUNTRY') eq 'GB' ) { try { - mySociety::Locale::in_gb_locale { - mySociety::GeoUtil::wgs84_to_national_grid( $latitude, $longitude, 'G' ); - }; - } - catch Error::Simple with { + Utils::convert_latlon_to_en( $latitude, $longitude ); + } catch Error::Simple with { my $e = shift; push @errors, "We had a problem with the supplied co-ordinates - outside the UK?"; }; diff --git a/web/index.cgi b/web/index.cgi index f5db6e1e7..1a60b05a7 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -24,7 +24,6 @@ use mySociety::AuthToken; use mySociety::Config; use mySociety::DBHandle qw(select_all); use mySociety::EmailUtil; -use mySociety::GeoUtil; use mySociety::Locale; use mySociety::MaPit; use mySociety::PostcodeUtil; @@ -282,9 +281,7 @@ sub submit_problem { # If in UK and we have a lat,lon coocdinate check it is in UK if ( $input{latitude} && mySociety::Config::get('COUNTRY') eq 'GB' ) { try { - mySociety::Locale::in_gb_locale { - mySociety::GeoUtil::wgs84_to_national_grid($input{latitude}, $input{longitude}, 'G'); - }; + Utils::convert_latlon_to_en( $input{latitude}, $input{longitude} ); } catch Error::Simple with { my $e = shift; push @errors, "We had a problem with the supplied co-ordinates - outside the UK?"; diff --git a/web/rss.cgi b/web/rss.cgi index cb5221537..2a9aeaa52 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -15,7 +15,6 @@ use URI::Escape; use FixMyStreet::Alert; use FixMyStreet::Geocode; use mySociety::MaPit; -use mySociety::GeoUtil; use mySociety::Gaze; use Utils; |