aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map/Bristol.pm
blob: 3b60d1acf6985099047ae398a6fad8e663d8e4b1 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# FixMyStreet:Map::Bristol
# Bristol use their own tiles on their cobrand

package FixMyStreet::Map::Bristol;
use base 'FixMyStreet::Map::WMTSBase';

use strict;

sub zoom_parameters {
    my $self = shift;
    my $params = {
        zoom_levels    => scalar $self->scales,
        default_zoom   => 5,
        min_zoom_level => 0,
        id_offset      => 0,
    };
    return $params;
}

sub tile_parameters {
    my $self = shift;
    my $params = {
        urls            => [ 'https://maps.bristol.gov.uk/arcgis/rest/services/base/2015_BCC_96dpi/MapServer/WMTS/tile' ],
        layer_names     => [ '2015_BCC_96dpi' ],
        wmts_version    => '1.0.0',
        layer_style     => 'default',
        matrix_set      => 'default028mm',
        suffix          => '.png', # appended to tile URLs
        size            => 256, # pixels
        dpi             => 96,
        inches_per_unit => 39.3701, # BNG uses metres
        projection      => 'EPSG:27700',
        # The original tile origin values from the getCapabilities call are
        # -5220400.0/4470200.0, but this results in the map tile being offset
        # slightly. These corrected values were figured out manually by
        # trial and error...
        origin_x        => -5220385.5,
        origin_y        => 4470189.0,
    };
    return $params;
}

sub scales {
    my $self = shift;
    my @scales = (
        '192000', # resolution: 50.800101600203206
        '96000', # resolution: 25.400050800101603
        '48000', # resolution: 12.700025400050801
        '24000', # resolution: 6.350012700025401
        '12000', # resolution: 3.1750063500127004
        '6000', # resolution: 1.5875031750063502
        '3000', # resolution: 0.7937515875031751
        '1250', # resolution: 0.33072982812632296
        '750', # resolution: 0.19843789687579377
    );
    return @scales;
}

sub copyright {
    return '© BCC';
}

sub map_type {
    return 'bristol';
}

# Reproject a WGS84 lat/lon into BNG easting/northing
sub reproject_from_latlon($$$) {
    my ($self, $lat, $lon) = @_;
    my ($x, $y) = Utils::convert_latlon_to_en($lat, $lon);
    return ($x, $y);
}

# Reproject a BNG easting/northing into WGS84 lat/lon
sub reproject_to_latlon($$$) {
    my ($self, $x, $y) = @_;
    my ($lat, $lon) = Utils::convert_en_to_latlon($x, $y);
    return ($lat, $lon);
}

1;