aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Map')
-rw-r--r--perllib/FixMyStreet/Map/FMS.pm14
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm16
-rw-r--r--perllib/FixMyStreet/Map/OSM/MapQuest.pm3
3 files changed, 20 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm
index b1dd29002..e7aa46784 100644
--- a/perllib/FixMyStreet/Map/FMS.pm
+++ b/perllib/FixMyStreet/Map/FMS.pm
@@ -42,8 +42,10 @@ sub map_tile_base {
}
sub map_tiles {
- my ($self, $x, $y, $z) = @_;
- if ($z >= 16) {
+ my ( $self, %params ) = @_;
+ my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
+ my $ni = in_northern_ireland_box( $params{latitude}, $params{longitude} );
+ if (!$ni && $z >= 16) {
my ($tile_sep, $tile_base) = $self->map_tile_base;
return [
sprintf($tile_base, 'a' . $tile_sep, $z, $x-1, $y-1),
@@ -53,7 +55,7 @@ sub map_tiles {
];
} else {
my $url = "g=701";
- $url .= "&productSet=mmOS" if $z > 10;
+ $url .= "&productSet=mmOS" if $z > 10 && !$ni;
return [
"//ecn.t0.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y-1, $z) . ".png?$url",
"//ecn.t1.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y-1, $z) . ".png?$url",
@@ -63,4 +65,10 @@ sub map_tiles {
}
}
+sub in_northern_ireland_box {
+ my ($lat, $lon) = @_;
+ return 1 if $lat >= 54.015 && $lat <= 55.315 && $lon >= -8.18 && $lon <= -5.415;
+ return 0;
+}
+
1;
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 119337e37..693f42e4f 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -25,7 +25,8 @@ sub map_template {
}
sub map_tiles {
- my ($self, $x, $y, $z) = @_;
+ my ( $self, %params ) = @_;
+ my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
my $tile_url = $self->base_tile_url();
return [
"http://a.$tile_url/$z/" . ($x - 1) . "/" . ($y - 1) . ".png",
@@ -73,26 +74,23 @@ sub display_map {
my $zoom = defined $c->req->params->{zoom} ? $c->req->params->{zoom} + 0 : $default_zoom;
$zoom = $numZoomLevels - 1 if $zoom >= $numZoomLevels;
$zoom = 0 if $zoom < 0;
- my $zoom_act = $zoomOffset + $zoom;
- my ($x_tile, $y_tile) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $zoom_act);
+ $params{zoom_act} = $zoomOffset + $zoom;
+ ($params{x_tile}, $params{y_tile}) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $params{zoom_act});
foreach my $pin (@{$params{pins}}) {
- ($pin->{px}, $pin->{py}) = latlon_to_px($pin->{latitude}, $pin->{longitude}, $x_tile, $y_tile, $zoom_act);
+ ($pin->{px}, $pin->{py}) = latlon_to_px($pin->{latitude}, $pin->{longitude}, $params{x_tile}, $params{y_tile}, $params{zoom_act});
}
$c->stash->{map} = {
%params,
type => $self->map_template(),
map_type => $self->map_type(),
- tiles => $self->map_tiles( $x_tile, $y_tile, $zoom_act ),
+ tiles => $self->map_tiles( %params ),
copyright => $self->copyright(),
- x_tile => $x_tile,
- y_tile => $y_tile,
zoom => $zoom,
- zoom_act => $zoom_act,
zoomOffset => $zoomOffset,
numZoomLevels => $numZoomLevels,
- compass => compass( $x_tile, $y_tile, $zoom_act ),
+ compass => compass( $params{x_tile}, $params{y_tile}, $params{zoom_act} ),
};
}
diff --git a/perllib/FixMyStreet/Map/OSM/MapQuest.pm b/perllib/FixMyStreet/Map/OSM/MapQuest.pm
index 9cf6de01f..4751679f5 100644
--- a/perllib/FixMyStreet/Map/OSM/MapQuest.pm
+++ b/perllib/FixMyStreet/Map/OSM/MapQuest.pm
@@ -16,7 +16,8 @@ sub map_type {
}
sub map_tiles {
- my ($self, $x, $y, $z) = @_;
+ my ( $self, %params ) = @_;
+ my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
my $tile_url = $self->base_tile_url();
return [
"http://otile1.$tile_url/$z/" . ($x - 1) . "/" . ($y - 1) . ".png",