diff options
author | Struan Donald <struan@exo.org.uk> | 2018-10-26 11:25:01 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-11-19 13:27:43 +0000 |
commit | 0e8c7453c40db5ade085fb759ba73fb8ecf9b18d (patch) | |
tree | db38c5676a712bc47a12d5fa7e58f2d10042431d /web | |
parent | b97ea167b85dab9ef6a3781e24a457b392f4154c (diff) |
[UK] send reports on highways agency roads to highways agency
Includes an option to send to the council instead for e.g. reports on
underpasses or bridges.
Fixes #736
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/assets.js | 2 | ||||
-rw-r--r-- | web/cobrands/highways/assets.js | 118 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 8 | ||||
-rw-r--r-- | web/js/map-fms.js | 8 |
4 files changed, 133 insertions, 3 deletions
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index c1347ef2f..efb827656 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -131,7 +131,7 @@ OpenLayers.Layer.VectorNearest = OpenLayers.Class(OpenLayers.Layer.VectorAsset, var feature = this.getFeatureAtPoint(point); if (feature == null) { // The click wasn't directly over a road, try and find one nearby - feature = this.getNearestFeature(point, 10); + feature = this.getNearestFeature(point, this.fixmystreet.nearest_radius || 10); } this.selected_feature = feature; }, diff --git a/web/cobrands/highways/assets.js b/web/cobrands/highways/assets.js new file mode 100644 index 000000000..4b6939693 --- /dev/null +++ b/web/cobrands/highways/assets.js @@ -0,0 +1,118 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + +var defaults = { + http_options: { + url: "https://tilma.mysociety.org/mapserver/highways", + params: { + SERVICE: "WFS", + VERSION: "1.1.0", + REQUEST: "GetFeature", + SRSNAME: "urn:ogc:def:crs:EPSG::3857" + } + }, + format_class: OpenLayers.Format.GML.v3.MultiCurveFix, + asset_type: 'area', + // this covers zoomed right out on Cumbrian sections of + // the M6 + max_resolution: 20, + min_resolution: 0.5971642833948135, + asset_id_field: 'CENTRAL_AS', + geometryName: 'msGeometry', + srsName: "EPSG:3857", + strategy_class: OpenLayers.Strategy.FixMyStreet +}; + +var highways_stylemap = new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + fill: false, + stroke: false, + }) +}); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "Highways" + } + }, + stylemap: highways_stylemap, + always_visible: true, + + non_interactive: true, + road: true, + all_categories: true, + // motorways are wide and the lines to define them are narrow so we + // need a bit more margin for error in finding the nearest to stop + // clicking in the middle of them being undetected + nearest_radius: 15, + actions: { + found: function(layer, feature) { + // if we've changed location then we want to reset things otherwise + // this is probably just being called again by a category change + var lat = $('#fixmystreet\\.latitude').val(), + lon = $('#fixmystreet\\.longitude').val(); + if ( fixmystreet.body_overrides.location && + lat == fixmystreet.body_overrides.location.latitude && + lon == fixmystreet.body_overrides.location.longitude ) { + return; + } + $('#highways').remove(); + if ( !fixmystreet.assets.selectedFeature() ) { + fixmystreet.body_overrides.only_send('Highways England'); + add_highways_warning(feature.attributes.ROA_NUMBER); + } + }, + not_found: function(layer) { + fixmystreet.body_overrides.location = null; + fixmystreet.body_overrides.remove_only_send(); + $('#highways').remove(); + } + } +})); + +function add_highways_warning(road_name) { + var $warning = $('<div class="box-warning" id="highways"><p>It looks like you clicked on the <strong>' + road_name + '</strong> which is managed by <strong>Highways England</strong>. ' + + 'Does your report concern something on this road, or somewhere else (e.g a road crossing it)?<p></div>'); + var $radios = $('<p class="segmented-control segmented-control--radio"></p>'); + + $('<input>') + .attr('type', 'radio') + .attr('name', 'highways-choice') + .attr('id', 'js-highways') + .prop('checked', true) + .on('click', function() { + fixmystreet.body_overrides.location = null; + fixmystreet.body_overrides.only_send('Highways England'); + }) + .appendTo($radios); + $('<label>') + .attr('for', 'js-highways') + .text('On the ' + road_name) + .addClass('btn') + .appendTo($radios); + $('<input>') + .attr('type', 'radio') + .attr('name', 'highways-choice') + .attr('id', 'js-not-highways') + .on('click', function() { + fixmystreet.body_overrides.location = { + latitude: $('#fixmystreet\\.latitude').val(), + longitude: $('#fixmystreet\\.longitude').val() + }; + fixmystreet.body_overrides.remove_only_send(); + }) + .appendTo($radios); + $('<label>') + .attr('for', 'js-not-highways') + .text('Somewhere else') + .addClass('btn') + .appendTo($radios); + $radios.appendTo($warning); + $('.change_location').after($warning); +} + +})(); diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index 7715ff5e3..9f8778c90 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -2445,6 +2445,14 @@ a#geolocate_link.loading, .btn--geolocate.loading { margin-bottom: 0; } } + + .segmented-control { + .btn { + &:last-child { + margin-bottom: 1em; + } + } + } } .asset-spot:before { diff --git a/web/js/map-fms.js b/web/js/map-fms.js index 3e23b7590..ac27cfbce 100644 --- a/web/js/map-fms.js +++ b/web/js/map-fms.js @@ -39,10 +39,14 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.Bing, { var c = this.map.getCenter(); var in_uk = c ? this.in_uk(c) : true; if (z >= 16 && in_uk) { - copyrights = 'Contains Ordnance Survey data © Crown copyright and database right 2016'; + copyrights = 'Contains Highways England and Ordnance Survey data © Crown copyright and database right 2016'; } else { logo = '<a href="https://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; - copyrights = '© 2016 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Ordnance Survey'; + if (in_uk) { + copyrights = '© 2016 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Highways England, Ordnance Survey'; + } else { + copyrights = '© 2016 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Ordnance Survey'; + } } this._updateAttribution(copyrights, logo); }, |