aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map/WMXBase.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-02-05 21:25:48 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-02-17 15:09:12 +0000
commit3649271539482786b721fbc6bc5f614e75e0e7f3 (patch)
tree5616dafd9253b2292c8b6fac08f6daf939a25212 /perllib/FixMyStreet/Map/WMXBase.pm
parent4bf7d600222285ed0110ce78cbb8b1bb3ed276ed (diff)
Add WM* missing compass parameters.
Diffstat (limited to 'perllib/FixMyStreet/Map/WMXBase.pm')
-rw-r--r--perllib/FixMyStreet/Map/WMXBase.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Map/WMXBase.pm b/perllib/FixMyStreet/Map/WMXBase.pm
index c2ed77692..bc529817e 100644
--- a/perllib/FixMyStreet/Map/WMXBase.pm
+++ b/perllib/FixMyStreet/Map/WMXBase.pm
@@ -180,8 +180,20 @@ sub get_map_hash {
layer_names => encode_json( $self->tile_parameters->{layer_names} ),
map_projection => $self->tile_parameters->{projection},
scales => encode_json( \@scales ),
+ compass => $self->compass( $params{x_centre_tile}, $params{y_centre_tile}, $params{zoom} ),
%{ $self->_map_hash_extras },
};
}
+sub compass {
+ my ( $self, $x, $y, $z ) = @_;
+ return {
+ north => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x, $y-1, $z ) ],
+ south => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x, $y+1, $z ) ],
+ west => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x-1, $y, $z ) ],
+ east => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x+1, $y, $z ) ],
+ here => [ map { Utils::truncate_coordinate($_) } $self->tile_to_latlon( $x, $y, $z ) ],
+ };
+}
+
1;