diff options
author | Matthew Somerville <matthew@balti.ukcod.org.uk> | 2010-12-21 16:44:01 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@balti.ukcod.org.uk> | 2010-12-21 16:44:01 +0000 |
commit | be02fdfda244dd18b958dd0759369d842bca00ab (patch) | |
tree | 1557740ab3ef430c527d131fb758821ff1573b57 | |
parent | e088d79b83456d5650d99d3fe71bf31e63909886 (diff) |
Tidy up map importing a bit.
-rw-r--r-- | conf/general-example | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm (renamed from perllib/FixMyStreet/Map/Utils.pm) | 36 | ||||
-rw-r--r-- | perllib/Page.pm | 4 | ||||
-rw-r--r-- | perllib/Standard.pm | 2 |
4 files changed, 15 insertions, 29 deletions
diff --git a/conf/general-example b/conf/general-example index 353798aef..0a5c9e44d 100644 --- a/conf/general-example +++ b/conf/general-example @@ -49,7 +49,7 @@ define('OPTION_GEO_CACHE', '/cache/'); define('OPTION_GOOGLE_MAPS_API_KEY', ''); define('OPTION_MAPIT_URL', 'http://services.mysociety.org/mapit'); - +define('OPTION_MAP_TYPE', 'Tilma::Original::1_10k'); define('OPTION_EVEL_URL', 'http://services.mysociety.org/evel'); define('OPTION_GAZE_URL', 'http://gaze.mysociety.org/gaze'); diff --git a/perllib/FixMyStreet/Map/Utils.pm b/perllib/FixMyStreet/Map.pm index c1c366c68..12ecf78fe 100644 --- a/perllib/FixMyStreet/Map/Utils.pm +++ b/perllib/FixMyStreet/Map.pm @@ -12,11 +12,22 @@ use strict; use Problems; use Cobrand; +use mySociety::Config; use mySociety::Gaze; use mySociety::GeoUtil; use mySociety::Locale; use mySociety::Web qw(ent NewURL); +# Run on module boot up +load(); + +# This is yucky, but no-one's taught me a better way +sub load { + my $type = mySociety::Config::get('MAP_TYPE'); + my $class = "FixMyStreet::Map::$type"; + eval "use $class"; +} + sub header { my ($q, $type) = @_; return '' unless $type; @@ -69,31 +80,6 @@ sub map_features { return ($around_map, $around_map_list, $nearby, $dist); } -sub map_pins { - my ($q, $x, $y, $sx, $sy, $interval) = @_; - - my $e = FixMyStreet::Map::tile_to_os($x); - my $n = FixMyStreet::Map::tile_to_os($y); - my ($around_map, $around_map_list, $nearby, $dist) = FixMyStreet::Map::map_features($q, $e, $n, $interval); - - my $pins = ''; - foreach (@$around_map) { - my $px = FixMyStreet::Map::os_to_px($_->{easting}, $sx); - my $py = FixMyStreet::Map::os_to_px($_->{northing}, $sy, 1); - my $col = $_->{state} eq 'fixed' ? 'green' : 'red'; - $pins .= FixMyStreet::Map::display_pin($q, $px, $py, $col); - } - - foreach (@$nearby) { - my $px = FixMyStreet::Map::os_to_px($_->{easting}, $sx); - my $py = FixMyStreet::Map::os_to_px($_->{northing}, $sy, 1); - my $col = $_->{state} eq 'fixed' ? 'green' : 'red'; - $pins .= FixMyStreet::Map::display_pin($q, $px, $py, $col); - } - - return ($pins, $around_map_list, $nearby, $dist); -} - sub compass ($$$) { my ($q, $x, $y) = @_; my @compass; diff --git a/perllib/Page.pm b/perllib/Page.pm index 41e1c9105..fddbc61d1 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -26,7 +26,6 @@ use Text::Template; use Memcached; use Problems; use Cobrand; -use FixMyStreet::Map::Tilma::Original::1_10k; use mySociety::Config; use mySociety::DBHandle qw/dbh select_all/; @@ -43,6 +42,9 @@ BEGIN { mySociety::Config::set_file("$dir/../conf/general"); } +# Under the BEGIN so that the config has been set. +use FixMyStreet::Map; + my $lastmodified; sub do_fastcgi { diff --git a/perllib/Standard.pm b/perllib/Standard.pm index 293bf8ad8..571065c14 100644 --- a/perllib/Standard.pm +++ b/perllib/Standard.pm @@ -19,8 +19,6 @@ use lib "$FindBin::Bin/../perllib"; use lib "$FindBin::Bin/../commonlib/perllib"; use Page; -use FixMyStreet::Map::Utils; -use FixMyStreet::Map::Tilma::Original::1_10k; package Standard; |