diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-07-01 12:44:59 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-07-01 12:45:22 +0100 |
commit | d1d67bd600324ac30ce7fb640c81b4b9d09254a8 (patch) | |
tree | 1a8d7b49907b180951c06e0d3b8b5270c9b4d490 | |
parent | c6a20311276f00befd27fe0ea7e606db4a13844d (diff) |
Remove unused Tilma, consolidate tile lookup for legacy URLs to work in different map format.
-rw-r--r-- | conf/general-example | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/OpenLayers.pm | 35 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original.pm | 33 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original/1_10k.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original/StreetView.pm | 28 | ||||
-rw-r--r-- | web/js/map-tilma-ol.js | 41 |
9 files changed, 22 insertions, 215 deletions
diff --git a/conf/general-example b/conf/general-example index bc58f56d3..65e192b4d 100644 --- a/conf/general-example +++ b/conf/general-example @@ -44,7 +44,7 @@ define('OPTION_LONDON_REPORTIT_KEY', ''); define('OPTION_LONDON_REPORTIT_SECRET', ''); define('OPTION_MAPIT_URL', 'http://mapit.mysociety.org/'); -define('OPTION_MAP_TYPE', 'Tilma::Original::1_10k'); +define('OPTION_MAP_TYPE', 'OSM'); define('OPTION_EVEL_URL', 'http://services.mysociety.org/evel'); define('OPTION_GAZE_URL', 'http://gaze.mysociety.org/gaze'); diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 6b5a811a6..20f18a547 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -23,6 +23,7 @@ use mySociety::Config; use mySociety::Gaze; use mySociety::Locale; use mySociety::Web qw(ent); +use Utils; =head2 allowed_maps @@ -124,8 +125,19 @@ sub click_to_wgs84 { return $map_class->click_to_wgs84(@_); } +=head2 tile_xy_to_wgs84 + +Takes the tile x,y and converts to lat, lon. Legacy to deal with old URLs, +hence hard-coded things. + +=cut + sub tile_xy_to_wgs84 { - return $map_class->tile_xy_to_wgs84(@_); + my ( $x, $y ) = @_; + my $easting = int( $x * (5000/31) + 0.5 ); + my $northing = int( $y * (5000/31) + 0.5 ); + my ( $lat, $lon ) = Utils::convert_en_to_latlon( $easting, $northing ); + return ( $lat, $lon ); } 1; diff --git a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm deleted file mode 100644 index 34df8dc8b..000000000 --- a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl -# -# FixMyStreet:Map::Tilma::1_10k_OL -# Using tilma.mysociety.org with OpenLayers -# -# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ - -package FixMyStreet::Map::Tilma::OL::1_10k; -use base 'FixMyStreet::Map::Tilma::OpenLayers'; - -use strict; - -sub tile_width { return 254; } -sub tif_size_m { return 5000; } -sub tif_size_px { return 7874; } -sub scale_factor { return tif_size_m() / (tif_size_px() / tile_width()); } -sub tile_type { return '10k-full'; } - -sub copyright { - return _('© Crown copyright. All rights reserved. Ministry of Justice 100037819 2008.'); -} - -sub watermark { - return 1; -} - -1; diff --git a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm deleted file mode 100644 index 2a531766c..000000000 --- a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl -# -# FixMyStreet:Map::TilmaXY -# Using tilma.mysociety.org but accessing images directly. -# -# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ - -package FixMyStreet::Map::Tilma::OL::StreetView; -use base 'FixMyStreet::Map::Tilma::OpenLayers'; - -use strict; - -sub tile_width { return 250; } -sub tif_size_m { return 5000; } -sub tif_size_px { return 5000; } -sub scale_factor { return tif_size_m() / (tif_size_px() / tile_width()); } -sub tile_type { return 'streetview'; } - -sub copyright { - return _('Map contains Ordnance Survey data © Crown copyright and database right 2010.'); -} - -sub watermark { - return 0; -} - -1; diff --git a/perllib/FixMyStreet/Map/Tilma/OpenLayers.pm b/perllib/FixMyStreet/Map/Tilma/OpenLayers.pm deleted file mode 100644 index 31e9eb096..000000000 --- a/perllib/FixMyStreet/Map/Tilma/OpenLayers.pm +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl -# -# FixMyStreet:Map::Tilma::1_10k_OL -# Using tilma.mysociety.org with OpenLayers -# -# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ - -package FixMyStreet::Map::Tilma::OpenLayers; - -use strict; - -sub TILE_WIDTH() { return $FixMyStreet::Map::map_class->tile_width; } -sub SCALE_FACTOR() { return $FixMyStreet::Map::map_class->scale_factor; } -sub TILE_TYPE() { return $FixMyStreet::Map::map_class->tile_type; } - -# display_map C PARAMS -# PARAMS include: -# latitude, longitude for the centre point of the map -# TYPE is 1 if the map is clickable, 0 otherwise. -# PINS is array of pins to show, location and colour -sub display_map { - my ($self, $c, %params) = @_; - $c->stash->{map} = { - %params, - type => 'tilma/openlayers', - tile_type => TILE_TYPE, - tilewidth => TILE_WIDTH, - watermark => $self->watermark(), - copyright => $self->copyright(), - maxResolution => SCALE_FACTOR / TILE_WIDTH, - }; -} - -1; diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index 0baa82011..08260708c 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -8,6 +8,12 @@ package FixMyStreet::Map::Tilma::Original; +sub TILE_WIDTH { return 254; } +sub TIF_SIZE_M { return 5000; } +sub TIF_SIZE_PX { return 7874; } +sub SCALE_FACTOR { return TIF_SIZE_M() / (TIF_SIZE_PX() / TILE_WIDTH()); } +sub TILE_TYPE { return '10k-full'; } + use strict; use LWP::Simple; @@ -17,10 +23,6 @@ use mySociety::Web qw(ent NewURL); use Utils; use RABX; -sub TILE_WIDTH() { return $FixMyStreet::Map::map_class->tile_width; } -sub SCALE_FACTOR() { return $FixMyStreet::Map::map_class->scale_factor; } -sub TILE_TYPE() { return $FixMyStreet::Map::map_class->tile_type; } - sub _ll_to_en { my ($lat, $lon) = @_; return Utils::convert_latlon_to_en( $lat, $lon ); @@ -76,8 +78,8 @@ sub display_map { py => $py, tile_type => TILE_TYPE, tilewidth => TILE_WIDTH, - watermark => $self->watermark(), - copyright => $self->copyright(), + watermark => 1, + copyright => _('© Crown copyright. All rights reserved. Ministry of Justice 100037819 2008.'), }; } @@ -163,25 +165,6 @@ sub tile_to_os { return int($_[0] * SCALE_FACTOR + 0.5); } -=head2 tile_xy_to_wgs84 - - ($lat, $lon) = tile_xy_to_wgs84( $x, $y ); - -Takes the tile x,y and converts to lat, lon. - -=cut - -sub tile_xy_to_wgs84 { - my ( $self, $x, $y ) = @_; - - my $easting = tile_to_os($x); - my $northing = tile_to_os($y); - - my ( $lat, $lon ) = Utils::convert_en_to_latlon( $easting, $northing ); - return ( $lat, $lon ); -} - - sub click_to_tile { my ($pin_tile, $pin, $invert) = @_; $pin -= TILE_WIDTH while $pin > TILE_WIDTH; diff --git a/perllib/FixMyStreet/Map/Tilma/Original/1_10k.pm b/perllib/FixMyStreet/Map/Tilma/Original/1_10k.pm deleted file mode 100644 index 722df2a46..000000000 --- a/perllib/FixMyStreet/Map/Tilma/Original/1_10k.pm +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl -# -# FixMyStreet:Map -# Adding the ability to have different maps on FixMyStreet. -# -# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ - -package FixMyStreet::Map::Tilma::Original::1_10k; -use base 'FixMyStreet::Map::Tilma::Original'; - -use strict; - -sub tile_width { return 254; } -sub tif_size_m { return 5000; } -sub tif_size_px { return 7874; } -sub scale_factor { return tif_size_m() / (tif_size_px() / tile_width()); } -sub tile_type { return '10k-full'; } - -sub copyright { - return _('© Crown copyright. All rights reserved. Ministry of Justice 100037819 2008.'); -} - -sub watermark { - return 1; -} - -1; diff --git a/perllib/FixMyStreet/Map/Tilma/Original/StreetView.pm b/perllib/FixMyStreet/Map/Tilma/Original/StreetView.pm deleted file mode 100644 index fe03fdb00..000000000 --- a/perllib/FixMyStreet/Map/Tilma/Original/StreetView.pm +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl -# -# FixMyStreet:Map -# Adding the ability to have different maps on FixMyStreet. -# -# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ - -package FixMyStreet::Map::Tilma::Original::StreetView; -use base 'FixMyStreet::Map::Tilma::Original'; - -use strict; - -sub tile_width { return 250; } -sub tif_size_m { return 5000; } -sub tif_size_px { return 5000; } -sub scale_factor { return tif_size_m() / (tif_size_px() / tile_width()); } -sub tile_type { return 'streetview'; } - -sub copyright { - return _('Map contains Ordnance Survey data © Crown copyright and database right 2010.'); -} - -sub watermark { - return 0; -} - -1; diff --git a/web/js/map-tilma-ol.js b/web/js/map-tilma-ol.js deleted file mode 100644 index 5230a5d2c..000000000 --- a/web/js/map-tilma-ol.js +++ /dev/null @@ -1,41 +0,0 @@ -function set_map_config(perm) { - fixmystreet.controls = [ - new OpenLayers.Control.ArgParser(), - perm, - new OpenLayers.Control.Navigation(), - new OpenLayers.Control.PanPanel() - ]; - fixmystreet.map_type = OpenLayers.Layer.Tilma; - fixmystreet.layer_options = { - maxResolution: fixmystreet.maxResolution, - tileSize: new OpenLayers.Size(fixmystreet.tilewidth, fixmystreet.tileheight), - map_type: fixmystreet.tile_type, - numZoomLevels: 1, - zoomOffset: 0 - }; -} - -OpenLayers.Layer.Tilma = OpenLayers.Class(OpenLayers.Layer.XYZ, { - initialize: function(name, options) { - var url = "http://tilma.mysociety.org/tileserver/${type}/${x},${y}/png"; - options = OpenLayers.Util.extend({ - transitionEffect: "resize", - numZoomLevels: 1, - projection: "EPSG:27700", - units: "m", - maxExtent: new OpenLayers.Bounds(0, 0, 700000, 1300000) - }, options); - var newArguments = [name, url, options]; - OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); - }, - - getURL: function (bounds) { - var res = this.map.getResolution(); - var x = Math.round(bounds.left / (res * this.tileSize.w)); - var y = Math.round(bounds.bottom / (res * this.tileSize.h)); - var path = OpenLayers.String.format(this.url, {'x': x, 'y': y, 'type': this.map_type}); - return path; - }, - - CLASS_NAME: "OpenLayers.Layer.Tilma" -}); |