aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map/Zurich.pm
blob: 1e302bddabe5a8a5afba0936f2213a4df4f10c10 (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
82
83
84
85
86
87
88
89
# FixMyStreet:Map::Zurich
# Zurich have their own tileserver.

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

use strict;
use Geo::Coordinates::CH1903Plus;

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

sub tile_parameters {
    my $self = shift;
    my $params = {
        urls            => [
          'https://www.gis.stadt-zuerich.ch/maps/rest/services/tiled95/LuftbildHybrid/MapServer/WMTS/tile',
          'https://www.gis.stadt-zuerich.ch/maps/rest/services/tiled95/Stadtplan3D/MapServer/WMTS/tile'
        ],
        layer_names     => [ 'LuftbildHybrid', 'Stadtplan3D' ],
        wmts_version    => '1.0.0',
        layer_style     => 'default',
        matrix_set      => 'default028mm',
        suffix          => '.jpg', # appended to tile URLs
        size            => 512, # pixels
        dpi             => 96,
        inches_per_unit => 39.3701, # BNG uses metres
        projection      => 'EPSG:2056',
        # The original tile origin values from the getCapabilities call are
        # -27386400.0/31814500.0, but this results in the map tile being offset
        # slightly. These corrected values were figured out manually by
        # trial and error...
        origin_x        => -27386322.5,
        origin_y        => 31814423.0,
    };
    return $params;
}

sub scales {
    my $self = shift;
    my @scales = (
        # The two highest zoom levels are pretty much useless so they're disabled.
        # '256000', # resolution 67.73346880027094
        # '128000', # resolution 33.86673440013547
        '64000', # resolution 16.933367200067735
        '32000', # resolution 8.466683600033868
        '16000', # resolution 4.233341800016934
        '8000', # resolution 2.116670900008467
        '4000', # resolution 1.0583354500042335
        '2000', # resolution 0.5291677250021167
        '1000', # resolution 0.26458386250105836
        '500', # resolution 0.13229193125052918
        '250', # resolution 0.06614596562526459
    );
    return @scales;
}

sub copyright {
    return '© Stadt Zürich';
}

sub map_type {
    return 'zurich';
}


# Reproject a WGS84 lat/lon into Swiss easting/northing
sub reproject_from_latlon($$$) {
    my ($self, $lat, $lon) = @_;
    my ($x, $y) = Geo::Coordinates::CH1903Plus::from_latlon($lat, $lon);
    return ($x, $y);
}

# Reproject a Swiss easting/northing into WGS84 lat/lon
sub reproject_to_latlon($$$) {
    my ($self, $x, $y) = @_;
    my ($lat, $lon) = Geo::Coordinates::CH1903Plus::to_latlon($x, $y);
    return ($lat, $lon);
}

1;