diff options
-rw-r--r-- | perllib/FixMyStreet/Map/Bristol.pm | 50 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Buckinghamshire.pm | 40 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/UKCouncilWMTS.pm | 50 | ||||
-rw-r--r-- | t/map/tests.t | 2 | ||||
-rw-r--r-- | templates/web/buckinghamshire/maps/buckinghamshire.html | 4 | ||||
-rw-r--r-- | web/cobrands/buckinghamshire/assets.js | 4 | ||||
-rw-r--r-- | web/cobrands/fixmystreet-uk-councils/roadworks.js | 1 | ||||
-rw-r--r-- | web/js/map-wmts-buckinghamshire.js | 147 | ||||
-rw-r--r-- | web/vendor/OpenLayers/OpenLayers.wmts.js (renamed from web/vendor/OpenLayers/OpenLayers.bristol.js) | 0 |
9 files changed, 247 insertions, 51 deletions
diff --git a/perllib/FixMyStreet/Map/Bristol.pm b/perllib/FixMyStreet/Map/Bristol.pm index 99bdd26d7..e32026ee4 100644 --- a/perllib/FixMyStreet/Map/Bristol.pm +++ b/perllib/FixMyStreet/Map/Bristol.pm @@ -2,39 +2,15 @@ # Bristol use their own tiles on their cobrand package FixMyStreet::Map::Bristol; -use base 'FixMyStreet::Map::WMTSBase'; +use base 'FixMyStreet::Map::UKCouncilWMTS'; 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 default_zoom { 5; } -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', - origin_x => -5220400.0, - origin_y => 4470200.0, - }; - return $params; -} +sub urls { [ 'https://maps.bristol.gov.uk/arcgis/rest/services/base/2015_BCC_96dpi/MapServer/WMTS/tile' ] } + +sub layer_names { [ '2015_BCC_96dpi' ] } sub scales { my $self = shift; @@ -59,7 +35,7 @@ sub copyright { sub map_template { 'bristol' } sub map_javascript { [ - '/vendor/OpenLayers/OpenLayers.bristol.js', + '/vendor/OpenLayers/OpenLayers.wmts.js', '/js/map-OpenLayers.js', '/js/map-wmts-base.js', '/js/map-wmts-bristol.js', @@ -67,18 +43,4 @@ sub map_javascript { [ '/cobrands/bristol/assets.js', ] } -# 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; diff --git a/perllib/FixMyStreet/Map/Buckinghamshire.pm b/perllib/FixMyStreet/Map/Buckinghamshire.pm index 10ee2a080..0e1a7f493 100644 --- a/perllib/FixMyStreet/Map/Buckinghamshire.pm +++ b/perllib/FixMyStreet/Map/Buckinghamshire.pm @@ -2,17 +2,49 @@ # More JavaScript, for street assets package FixMyStreet::Map::Buckinghamshire; -use base 'FixMyStreet::Map::OSM'; +use base 'FixMyStreet::Map::UKCouncilWMTS'; use strict; +sub default_zoom { 8; } + +sub urls { [ 'https://maps.buckscc.gov.uk/arcgis/rest/services/Basemapping2018/MapServer/WMTS/tile' ] } + +sub layer_names{ [ 'Basemapping2018' ] } + +sub scales { + my $self = shift; + my @scales = ( + '1000000', + '500000', + '250000', + '125000', + '64000', + '32000', + '16000', + '8000', + '4000', + '2000', + '1000', + ); + return @scales; + +} + +sub copyright { + return '© BCC'; +} + +sub map_template { 'buckinghamshire' } + sub map_javascript { [ - '/vendor/OpenLayers/OpenLayers.wfs.js', + '/vendor/OpenLayers/OpenLayers.wmts.js', '/vendor/OpenLayers.Projection.OrdnanceSurvey.js', '/js/map-OpenLayers.js', - '/js/map-OpenStreetMap.js', - '/cobrands/fixmystreet-uk-councils/roadworks.js', + '/js/map-wmts-base.js', + '/js/map-wmts-buckinghamshire.js', '/cobrands/fixmystreet/assets.js', + '/cobrands/fixmystreet-uk-councils/roadworks.js', '/cobrands/buckinghamshire/js.js', '/cobrands/buckinghamshire/assets.js', ] } diff --git a/perllib/FixMyStreet/Map/UKCouncilWMTS.pm b/perllib/FixMyStreet/Map/UKCouncilWMTS.pm new file mode 100644 index 000000000..c1a729f85 --- /dev/null +++ b/perllib/FixMyStreet/Map/UKCouncilWMTS.pm @@ -0,0 +1,50 @@ +package FixMyStreet::Map::UKCouncilWMTS; +use base 'FixMyStreet::Map::WMTSBase'; + +use strict; + +sub zoom_parameters { + my $self = shift; + my $params = { + zoom_levels => scalar $self->scales, + default_zoom => $self->default_zoom, + min_zoom_level => 0, + id_offset => 0, + }; + return $params; +} + +sub tile_parameters { + my $self = shift; + my $params = { + urls => $self->urls, + layer_names => $self->layer_names, + 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', + origin_x => -5220400.0, + origin_y => 4470200.0, + }; + return $params; +} + +# 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; diff --git a/t/map/tests.t b/t/map/tests.t index 728aa5125..7cc8f6860 100644 --- a/t/map/tests.t +++ b/t/map/tests.t @@ -20,7 +20,7 @@ my $requires = { }; foreach (FixMyStreet::Map->maps) { - next if /WMTSBase/; # Only its subclasses have JS + next if /WMTSBase|UKCouncilWMTS/; # Only its subclasses have JS my $js = $_->map_javascript; my $test_file = $js->[-1]; s/.*:://; diff --git a/templates/web/buckinghamshire/maps/buckinghamshire.html b/templates/web/buckinghamshire/maps/buckinghamshire.html new file mode 100644 index 000000000..1dcc82635 --- /dev/null +++ b/templates/web/buckinghamshire/maps/buckinghamshire.html @@ -0,0 +1,4 @@ +[% map_html = BLOCK %] +[% INCLUDE maps/openlayers.html %] +[% INCLUDE maps/wmts_config.html %] +[% END %] diff --git a/web/cobrands/buckinghamshire/assets.js b/web/cobrands/buckinghamshire/assets.js index 66590ca71..569806d3d 100644 --- a/web/cobrands/buckinghamshire/assets.js +++ b/web/cobrands/buckinghamshire/assets.js @@ -11,7 +11,7 @@ var defaults = { SERVICE: "WFS", VERSION: "1.1.0", REQUEST: "GetFeature", - SRSNAME: "urn:ogc:def:crs:EPSG::3857" + SRSNAME: "urn:ogc:def:crs:EPSG::27700" } }, format_class: OpenLayers.Format.GML.v3.MultiCurveFix, @@ -24,7 +24,7 @@ var defaults = { site_code: 'site_code' }, geometryName: 'msGeometry', - srsName: "EPSG:3857", + srsName: "EPSG:27700", body: "Buckinghamshire County Council", strategy_class: OpenLayers.Strategy.FixMyStreet }; diff --git a/web/cobrands/fixmystreet-uk-councils/roadworks.js b/web/cobrands/fixmystreet-uk-councils/roadworks.js index ea95d1d40..05417545d 100644 --- a/web/cobrands/fixmystreet-uk-councils/roadworks.js +++ b/web/cobrands/fixmystreet-uk-councils/roadworks.js @@ -135,6 +135,7 @@ var roadworks_defaults = { return params; } }, + srsName: "EPSG:4326", format_class: OpenLayers.Format.RoadworksForwardPlanning, strategy_class: OpenLayers.Strategy.FixMyStreet, stylemap: stylemap, diff --git a/web/js/map-wmts-buckinghamshire.js b/web/js/map-wmts-buckinghamshire.js new file mode 100644 index 000000000..bb76a800b --- /dev/null +++ b/web/js/map-wmts-buckinghamshire.js @@ -0,0 +1,147 @@ +/* + * Maps for FMS using Buckinghamshire County Council's WMTS tile server + */ + +fixmystreet.maps.layer_bounds = new OpenLayers.Bounds( + 381056.269, + 138592.641, + 584521.259, + 284907.516); + +fixmystreet.maps.matrix_ids = [ + { + "identifier": "0", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 944942.3660750897, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 86, + "matrixHeight": 64, + }, + { + "identifier": "1", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 472471.18303754483, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 172, + "matrixHeight": 128, + }, + { + "identifier": "2", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 236235.59151877242, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 343, + "matrixHeight": 256, + }, + { + "identifier": "3", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 118117.79575938621, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 686, + "matrixHeight": 512, + }, + { + "identifier": "4", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 60476.31142880573, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 1340, + "matrixHeight": 1000, + }, + { + "identifier": "5", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 30238.155714402867, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 2679, + "matrixHeight": 1999, + }, + { + "identifier": "6", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 15119.077857201433, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 5357, + "matrixHeight": 3997, + }, + { + "identifier": "7", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 7559.538928600717, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 10713, + "matrixHeight": 7994, + }, + { + "identifier": "8", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 3779.7694643003583, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 21426, + "matrixHeight": 15988, + }, + { + "identifier": "9", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 1889.8847321501792, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 42852, + "matrixHeight": 31976, + }, + { + "identifier": "10", + "supportedCRS": "urn:ogc:def:crs:EPSG:27700", + "scaleDenominator": 944.9423660750896, + "tileWidth": 256, + "tileHeight": 256, + "matrixWidth": 85703, + "matrixHeight": 63951, + } +]; + +/* + * maps.config() is called on dom ready in map-OpenLayers.js + * to setup the way the map should operate. + */ +fixmystreet.maps.config = function() { + var permalink_id; + if ($('#map_permalink').length) { + permalink_id = 'map_permalink'; + } + + fixmystreet.controls = [ + new OpenLayers.Control.ArgParserFMS(), + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PermalinkFMS(permalink_id), + new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) + ]; + + /* Linking back to around from report page, keeping track of map moves */ + if ( fixmystreet.page == 'report' ) { + fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); + } + + this.setup_wmts_base_map(); +}; + +fixmystreet.maps.marker_size = function() { + var zoom = fixmystreet.map.getZoom() + fixmystreet.zoomOffset; + if (zoom >= 7) { + return 'normal'; + } else if (zoom >= 4) { + return 'small'; + } else { + return 'mini'; + } +}; diff --git a/web/vendor/OpenLayers/OpenLayers.bristol.js b/web/vendor/OpenLayers/OpenLayers.wmts.js index 388de520f..388de520f 100644 --- a/web/vendor/OpenLayers/OpenLayers.bristol.js +++ b/web/vendor/OpenLayers/OpenLayers.wmts.js |