1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/usr/bin/perl
#
# FixMyStreet:Map::FMS
# Bing and OS StreetView maps on FixMyStreet, using OpenLayers.
#
# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
package FixMyStreet::Map::FMS;
use base 'FixMyStreet::Map::OSM';
use strict;
# Is set by the JavaScript
sub map_type {
return '""';
}
sub map_template {
return 'fms';
}
sub copyright {
return '';
}
sub get_quadkey {
my ($x, $y, $z) = @_;
my $key = '';
for (my $i = $z; $i > 0; $i--) {
my $digit = 0;
my $mask = 1 << ($i - 1);
$digit++ if ($x & $mask) != 0;
$digit += 2 if ($y & $mask) != 0;
$key .= $digit;
}
return $key;
}
sub map_tile_base {
'.', "http://%stilma.mysociety.org/sv/%d/%d/%d.png";
}
sub map_tiles {
my ($self, $x, $y, $z) = @_;
if ($z >= 16) {
my ($tile_sep, $tile_base) = $self->map_tile_base;
return [
sprintf($tile_base, 'a' . $tile_sep, $z, $x-1, $y-1),
sprintf($tile_base, 'b' . $tile_sep, $z, $x, $y-1),
sprintf($tile_base, 'c' . $tile_sep, $z, $x-1, $y),
sprintf($tile_base, '', $z, $x, $y),
];
} else {
my $url = "g=701";
$url .= "&productSet=mmOS" if $z > 10;
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",
"//ecn.t2.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y, $z) . ".png?$url",
"//ecn.t3.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y, $z) . ".png?$url",
];
}
}
1;
|