aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Map')
-rw-r--r--perllib/FixMyStreet/Map/FMS.pm16
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm28
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm28
-rw-r--r--perllib/FixMyStreet/Map/Tilma/OpenLayers.pm35
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original.pm250
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original/1_10k.pm28
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original/StreetView.pm28
7 files changed, 8 insertions, 405 deletions
diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm
index c54ee8f3b..2e40bfde3 100644
--- a/perllib/FixMyStreet/Map/FMS.pm
+++ b/perllib/FixMyStreet/Map/FMS.pm
@@ -41,17 +41,17 @@ sub map_tiles {
my ($self, $x, $y, $z) = @_;
if ($z >= 16) {
return [
- "http://a.os.openstreetmap.org/sv/$z/" . ($x-1) . "/" . ($y-1) . ".png",
- "http://b.os.openstreetmap.org/sv/$z/$x/" . ($y-1) . ".png",
- "http://c.os.openstreetmap.org/sv/$z/" . ($x-1) . "/$y.png",
- "http://os.openstreetmap.org/sv/$z/$x/$y.png",
+ "http://a.tilma.mysociety.org/sv/$z/" . ($x-1) . "/" . ($y-1) . ".png",
+ "http://b.tilma.mysociety.org/sv/$z/$x/" . ($y-1) . ".png",
+ "http://c.tilma.mysociety.org/sv/$z/" . ($x-1) . "/$y.png",
+ "http://tilma.mysociety.org/sv/$z/$x/$y.png",
];
} else {
return [
- "http://ecn.t0.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y-1, $z) . ".png?g=587&productSet=mmOS",
- "http://ecn.t1.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y-1, $z) . ".png?g=587&productSet=mmOS",
- "http://ecn.t2.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y, $z) . ".png?g=587&productSet=mmOS",
- "http://ecn.t3.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y, $z) . ".png?g=587&productSet=mmOS",
+ "http://ecn.t0.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y-1, $z) . ".png?g=701&productSet=mmOS",
+ "http://ecn.t1.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y-1, $z) . ".png?g=701&productSet=mmOS",
+ "http://ecn.t2.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y, $z) . ".png?g=701&productSet=mmOS",
+ "http://ecn.t3.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y, $z) . ".png?g=701&productSet=mmOS",
];
}
}
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
deleted file mode 100644
index 46cf3ad40..000000000
--- a/perllib/FixMyStreet/Map/Tilma/Original.pm
+++ /dev/null
@@ -1,250 +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;
-
-use strict;
-use LWP::Simple;
-
-use mySociety::GeoUtil;
-use mySociety::Locale;
-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 );
-}
-
-# display_map C PARAMS
-# PARAMS include:
-# latitude, longitude for the centre point of the map
-# CLICKABLE is set if the map is clickable
-# PINS is array of pins to show, location and colour
-sub display_map {
- my ($self, $c, %params) = @_;
- my $mid_point = TILE_WIDTH; # Map is 2 TILE_WIDTHs in size, square.
- if (my $mp = $c->cobrand->tilma_mid_point) {
- $mid_point = $mp;
- }
-
- # convert map center point to easting, northing
- ( $params{easting}, $params{northing} ) =
- _ll_to_en( $params{latitude}, $params{longitude} );
-
- # X/Y tile co-ords may be overridden in the query string
- my @vars = qw(x y);
- my %input = map { $_ => $c->req->params->{$_} || '' } @vars;
- ($input{x}) = $input{x} =~ /^(\d+)/; $input{x} ||= 0;
- ($input{y}) = $input{y} =~ /^(\d+)/; $input{y} ||= 0;
-
- my ($x, $y, $px, $py) = os_to_px_with_adjust($c, $params{easting}, $params{northing}, $input{x}, $input{y});
-
- foreach my $pin (@{$params{pins}}) {
- my ( $e, $n ) = _ll_to_en( $pin->{latitude}, $pin->{longitude} );
- $pin->{px} = os_to_px($e, $x);
- $pin->{py} = os_to_px($n, $y, 1);
- }
-
- $px = defined($px) ? $mid_point - $px : 0;
- $py = defined($py) ? $mid_point - $py : 0;
- $x = int($x)<=0 ? 0 : $x;
- $y = int($y)<=0 ? 0 : $y;
- my $url = 'http://tilma.mysociety.org/tileserver/' . TILE_TYPE . '/';
- my $tiles_url = $url . ($x-1) . '-' . $x . ',' . ($y-1) . '-' . $y . '/RABX';
- my $tiles = LWP::Simple::get($tiles_url);
- my $tileids = RABX::unserialise($tiles);
- $c->stash->{map} = {
- %params,
- type => 'tilma/original',
- tiles => $tiles,
- url => $url,
- tileids => $tileids,
- x => $x,
- y => $y,
- px => $px,
- py => $py,
- tile_type => TILE_TYPE,
- tilewidth => TILE_WIDTH,
- watermark => $self->watermark(),
- copyright => $self->copyright(),
- };
-}
-
-sub display_pin {
- my ($c, $px, $py, $col, $id, $title, $num) = @_;
- $num = '' if !$num || $num > 9;
- my $host = $c->cobrand->base_url_with_lang;
- my %cols = (red=>'R', green=>'G', blue=>'B', purple=>'P');
- my $out = '<img class="pin" src="' . $host . '/i/pin' . $cols{$col}
- . $num . '.gif" alt="' . _('Problem') . '" style="top:' . ($py-59)
- . 'px; left:' . ($px) . 'px; position: absolute;">';
- return $out unless $id;
- my $url = $c->uri_for( '/report/' . $id );
- $out = '<a title="' . ent($title) . '" href="' . $url . '">' . $out . '</a>';
- return $out;
-}
-
-sub map_pins {
- my ($self, $c, $interval) = @_;
-
- # Our current X/Y middle of visible map
- my $x = ( $c->req->param('x') || 0 ) + 0;
- my $y = ( $c->req->param('y') || 0 ) + 0;
-
- # Where we started as that's the (0,0) we have to work to
- my $sx = ( $c->req->param('sx') || 0 ) + 0;
- my $sy = ( $c->req->param('sy') || 0 ) + 0;
-
- my $e = tile_to_os($x);
- my $n = tile_to_os($y);
-
- my ( $lat, $lon ) = Utils::convert_en_to_latlon( $e, $n );
-
- my ( $around_map, $around_map_list, $nearby, $dist ) =
- FixMyStreet::Map::map_features( $c, $lat, $lon, $interval );
-
- my $pins = '';
- foreach (@$around_map) {
- my ( $easting, $northing ) =
- _ll_to_en( $_->latitude, $_->longitude );
- my $px = os_to_px($easting, $sx);
- my $py = os_to_px($northing, $sy, 1);
- my $col = exists FixMyStreet::DB::Result::Problem->fixed_states()->{$_->state} ? 'green' : 'red';
- $pins .= display_pin($c, $px, $py, $col, $_->id, $_->title);
- }
-
- foreach (@$nearby) {
- my $p = $_->problem;
- my ( $easting, $northing ) =
- _ll_to_en( $p->latitude, $p->longitude );
- my $px = os_to_px($easting, $sx);
- my $py = os_to_px($northing, $sy, 1);
- my $col = exists FixMyStreet::DB::Result::Problem->fixed_states()->{$p->state} ? 'green' : 'red';
- $pins .= display_pin($c, $px, $py, $col, $p->id, $p->title);
- }
-
- return ($pins, $around_map_list, $nearby, $dist);
-}
-
-# P is easting or northing
-# C is centre tile reference of displayed map
-sub os_to_px {
- my ($p, $c, $invert) = @_;
- return tile_to_px(os_to_tile($p), $c, $invert);
-}
-
-# Convert tile co-ordinates to pixel co-ordinates from top left of map
-# C is centre tile reference of displayed map
-sub tile_to_px {
- my ($p, $c, $invert) = @_;
- $p = TILE_WIDTH * ($p - $c + 1);
- $p = 2 * TILE_WIDTH - $p if $invert;
- $p = int($p + .5 * ($p <=> 0));
- return $p;
-}
-
-# Tile co-ordinates are linear scale of OS E/N
-# Will need more generalising when more zooms appear
-sub os_to_tile {
- return $_[0] / SCALE_FACTOR;
-}
-
-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;
- $pin += TILE_WIDTH while $pin < 0;
- $pin = TILE_WIDTH - $pin if $invert; # image submits measured from top down
- return $pin_tile + $pin / TILE_WIDTH;
-}
-
-# Given some click co-ords (the tile they were on, and where in the
-# tile they were), convert to OSGB36 and return.
-sub click_to_os {
- my ($pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_;
- my $tile_x = click_to_tile($pin_tile_x, $pin_x);
- my $tile_y = click_to_tile($pin_tile_y, $pin_y, 1);
- my $easting = tile_to_os($tile_x);
- my $northing = tile_to_os($tile_y);
- return ($easting, $northing);
-}
-
-# Given some click co-ords (the tile they were on, and where in the
-# tile they were), convert to WGS84 and return.
-sub click_to_wgs84 {
- my $self = shift;
- my $c = shift;
- my ( $easting, $northing ) = click_to_os(@_);
- my ( $lat, $lon ) = mySociety::GeoUtil::national_grid_to_wgs84( $easting, $northing, 'G' );
- return ( $lat, $lon );
-}
-
-# Given (E,N) and potential override (X,Y), return the X/Y tile for the centre
-# of the map (either to get the point near the middle, or the override X,Y),
-# and the pixel co-ords of the point, relative to that map.
-sub os_to_px_with_adjust {
- my ($c, $easting, $northing, $in_x, $in_y) = @_;
-
- my $x = os_to_tile($easting);
- my $y = os_to_tile($northing);
- my $x_tile = $in_x || int($x);
- my $y_tile = $in_y || int($y);
-
- # Try and have point near centre of map
- if (!$in_x && $x - $x_tile > 0.5) {
- $x_tile += 1;
- }
- if (!$in_y && $y - $y_tile > 0.5) {
- $y_tile += 1;
- }
-
- my $px = os_to_px($easting, $x_tile);
- my $py = os_to_px($northing, $y_tile, 1);
- if ($c->cobrand->tilma_mid_point == 189) { # Map is 380px, so might need to adjust
- if (!$in_x && $px > 380) {
- $x_tile++;
- $px = os_to_px($easting, $x_tile);
- }
- if (!$in_y && $py > 380) {
- $y_tile--;
- $py = os_to_px($northing, $y_tile, 1);
- }
- }
-
- return ($x_tile, $y_tile, $px, $py);
-}
-
-1;
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 _('&copy; Crown copyright. All rights reserved. Ministry of Justice 100037819&nbsp;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 &copy; Crown copyright and database right 2010.');
-}
-
-sub watermark {
- return 0;
-}
-
-1;