diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Lincolnshire.pm | 24 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Lincolnshire.pm | 21 | ||||
-rw-r--r-- | t/map/tests.t | 1 | ||||
-rw-r--r-- | templates/web/fixmystreet.com/footer_extra_js.html | 1 | ||||
-rw-r--r-- | web/cobrands/lincolnshire/assets.js | 231 | ||||
-rw-r--r-- | web/cobrands/lincolnshire/base.scss | 10 | ||||
-rw-r--r-- | web/cobrands/lincolnshire/roadworks.js | 42 |
7 files changed, 330 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Lincolnshire.pm b/perllib/FixMyStreet/Cobrand/Lincolnshire.pm index 1e88ec624..d86afd77b 100644 --- a/perllib/FixMyStreet/Cobrand/Lincolnshire.pm +++ b/perllib/FixMyStreet/Cobrand/Lincolnshire.pm @@ -29,9 +29,31 @@ sub open311_config { { name => 'description', value => $row->detail }; + # Reports made via FMS.com or the app probably won't have a site code + # value because we don't display the adopted highways layer on those + # frontends. Instead we'll look up the closest asset from the WFS + # service at the point we're sending the report over Open311. + if (!$row->get_extra_field_value('site_code')) { + if (my $site_code = $self->lookup_site_code($row)) { + push @$extra, + { name => 'site_code', + value => $site_code }; + } + } + $row->set_extra_fields(@$extra); } +sub lookup_site_code_config { { + buffer => 200, # metres + url => "https://tilma.mysociety.org/mapserver/lincs", + srsname => "urn:ogc:def:crs:EPSG::27700", + typename => "NSG", + property => "Site_Code", + accept_feature => sub { 1 } +} } + + sub categories_restriction { my ($self, $rs) = @_; # Lincolnshire is a two-tier council, but don't want to display @@ -47,4 +69,6 @@ sub categories_restriction { ] } ); } +sub map_type { 'Lincolnshire' } + 1; diff --git a/perllib/FixMyStreet/Map/Lincolnshire.pm b/perllib/FixMyStreet/Map/Lincolnshire.pm new file mode 100644 index 000000000..7dbfe5d8e --- /dev/null +++ b/perllib/FixMyStreet/Map/Lincolnshire.pm @@ -0,0 +1,21 @@ +# FixMyStreet:Map::Lincolnshire +# More JavaScript, for street assets + +package FixMyStreet::Map::Lincolnshire; +use base 'FixMyStreet::Map::FMS'; + +use strict; + +sub map_javascript { [ + '/vendor/OpenLayers/OpenLayers.wfs.js', + '/vendor/OpenLayers.Projection.OrdnanceSurvey.js', + '/js/map-OpenLayers.js', + '/js/map-bing-ol.js', + '/js/map-fms.js', + '/cobrands/fixmystreet-uk-councils/roadworks.js', + '/cobrands/fixmystreet/assets.js', + '/cobrands/lincolnshire/roadworks.js', + '/cobrands/lincolnshire/assets.js', +] } + +1; diff --git a/t/map/tests.t b/t/map/tests.t index 5575eafbb..396601379 100644 --- a/t/map/tests.t +++ b/t/map/tests.t @@ -8,6 +8,7 @@ my $requires = { 'Bristol' => 'bristol/assets.js', 'Bromley' => 'bromley/assets.js', 'Buckinghamshire' => 'buckinghamshire/assets.js', + 'Lincolnshire' => 'lincolnshire/assets.js', 'FMS' => 'map-fms.js', 'Google' => 'map-google.js', 'GoogleOL' => 'map-google-ol.js', diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html index c1ba95c25..c1d1b09b0 100644 --- a/templates/web/fixmystreet.com/footer_extra_js.html +++ b/templates/web/fixmystreet.com/footer_extra_js.html @@ -8,6 +8,7 @@ IF bodyclass.match('mappage'); scripts.push( version('/cobrands/bristol/assets.js') ); scripts.push( version('/cobrands/bromley/assets.js') ); scripts.push( version('/cobrands/buckinghamshire/assets.js') ); + scripts.push( version('/cobrands/lincolnshire/assets.js') ); scripts.push( version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), ); diff --git a/web/cobrands/lincolnshire/assets.js b/web/cobrands/lincolnshire/assets.js new file mode 100644 index 000000000..40187e188 --- /dev/null +++ b/web/cobrands/lincolnshire/assets.js @@ -0,0 +1,231 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + +var defaults = { + http_options: { + url: "https://tilma.mysociety.org/mapserver/lincs", + 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: 'spot', + max_resolution: 2.388657133579254, + min_resolution: 0.5971642833948135, + asset_id_field: 'Confirm_CA', + attributes: { + central_asset_id: 'Confirm_CA', + asset_details: 'Asset_Id' + }, + geometryName: 'msGeometry', + srsName: "EPSG:3857", + strategy_class: OpenLayers.Strategy.FixMyStreet, + body: "Lincolnshire County Council" +}; + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "SL_Bollards" + } + }, + asset_category: "Bollards (lit)", + asset_item: 'bollard' +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "SL_Street_Light_Units" + } + }, + asset_category: "Street light", + asset_item: 'street light', + filter_key: 'Type', + filter_value: [ + "SL: Bulkhead Lighting", "SL: Refuge Beacon", "SL: Street Lighting Unit" + ] +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "SL_Street_Light_Units" + } + }, + asset_category: "Subway light", + asset_item: 'light', + filter_key: 'Type', + filter_value: "SL: Subway Lighting Unit" +})); + +function get_barrier_stylemap() { + return new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + strokeColor: "#000000", + strokeOpacity: 0.9, + strokeWidth: 4 + }), + 'select': new OpenLayers.Style({ + strokeColor: "#55BB00", + strokeOpacity: 1, + strokeWidth: 8 + }), + 'hover': new OpenLayers.Style({ + strokeWidth: 6, + strokeOpacity: 1, + strokeColor: "#FFFF00", + cursor: 'pointer' + }) + }); +} + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "Safety_Barriers" + } + }, + asset_category: ["Roadside safety barrier", "Missing safety fence"], + asset_item: 'barrier or fence', + filter_key: 'Type', + filter_value: "ST: Safety Barrier", + stylemap: get_barrier_stylemap(), + max_resolution: 1.194328566789627 +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "LCC_Drainage-GulliesOffletsManholes" + } + }, + asset_category: "Blocked drain", + asset_item: 'drain' +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "ST_All_Structures" + } + }, + asset_category: "Damaged dyke, ditch or culvert", + asset_item: 'culvert', + filter_key: 'Type', + filter_value: [ + "ST: Culvert 1 Cell", "ST: Culvert 2+ Cells", "ST: Culvert/Pipe" + ] +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "SL_Lit_Signs" + } + }, + asset_category: "Sign (lit)", + asset_item: 'street sign' +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "ST_All_Structures" + } + }, + asset_category: "Bridge", + asset_item: 'bridge', + filter_key: 'Type', + filter_value: [ + "ST: Bridge", "ST: Bridge Ped/Cycle 1 Span", + "ST: Bridge Ped/Cycle 2+ Spans", "ST: Bridge Vehicular 1 Span", + "ST: Bridge Vehicular 2-3 Spans", "ST: Bridge Vehicular 4+ Spans" + ] +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "Carriageway" + } + }, + asset_category: [ + "Damaged/missing cats eye", + "Damaged road edge, encroaches less than 100mm", + "Damaged road edge, encroaches more than 100mm", + "Loose chippings", + "Manhole/drain cover on road/cycleway", + "Obstruction on road/cycleway", + "Pothole on road/cycleway", + "Road markings faded/missing", + "Road surface issue" + ], + asset_item: 'road', + asset_item_message: null, + disable_pin_snapping: true, + stylemap: new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + fill: false, + stroke: false + }) + }) +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "NSG" + } + }, + always_visible: true, + non_interactive: true, + usrn: { + attribute: 'Site_Code', + field: 'site_code' + }, + stylemap: new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + fill: false, + stroke: false + }) + }) + +})); + +var llpg_stylemap = new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + fillOpacity: 0, + strokeColor: "#000000", + strokeOpacity: 0.25, + strokeWidth: 2, + pointRadius: 10, + + label: "${label}", + labelOutlineColor: "white", + labelOutlineWidth: 2, + fontSize: '11px', + fontWeight: 'bold' + }) +}); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "LLPG" + } + }, + // LLPG is only to be shown when fully zoomed in + max_resolution: 0.5971642833948135, + stylemap: llpg_stylemap, + non_interactive: true, + always_visible: true +})); + +})(); diff --git a/web/cobrands/lincolnshire/base.scss b/web/cobrands/lincolnshire/base.scss index 468a678e4..1d045f4ea 100644 --- a/web/cobrands/lincolnshire/base.scss +++ b/web/cobrands/lincolnshire/base.scss @@ -142,6 +142,16 @@ body.mappage .big-green-banner { padding: 2em 0 3em; } +.js-roadworks-message dd:last-child { + margin-bottom: 0; +} + +// Certain categories have linear assets so hide the spot marker in the guidance +#category_meta_message_Missingsafetyfence, #category_meta_message_Roadsidesafetybarrier { + .asset-spot:before { + display: none; + } +} // admin diff --git a/web/cobrands/lincolnshire/roadworks.js b/web/cobrands/lincolnshire/roadworks.js new file mode 100644 index 000000000..a9fa64bb6 --- /dev/null +++ b/web/cobrands/lincolnshire/roadworks.js @@ -0,0 +1,42 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + +fixmystreet.roadworks.display_message = function(feature) { + var attr = feature.attributes, + start = new Date(attr.start.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), + end = new Date(attr.end.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), + tooltip = attr.tooltip.replace(/\\n/g, '\n'), + desc = attr.works_desc.replace(/\\n/g, '\n'); + + var $msg = $('<div class="js-roadworks-message box-warning"><p>Roadworks are scheduled near this location, so you may not need to report your issue.</p></div>'); + var $dl = $("<dl></dl>").appendTo($msg); + $dl.append("<dt>Dates</dt>"); + $dl.append($("<dd></dd>").text(start + " until " + end)); + $dl.append("<dt>Summary</dt>"); + var $summary = $("<dd></dd>").appendTo($dl); + tooltip.split("\n").forEach(function(para) { + if (para.match(/^(\d{2}\s+\w{3}\s+(\d{2}:\d{2}\s+)?\d{4}( - )?){2}/)) { + // skip showing the date again + return; + } + $summary.append(para).append("<br />"); + }); + if (desc) { + $dl.append("<dt>Description</dt>"); + $dl.append($("<dd></dd>").text(desc)); + } + + $('.change_location').after($msg); +}; + +fixmystreet.assets.add($.extend(true, {}, fixmystreet.roadworks.layer_future, { + http_options: { params: { organisation_id: '1070' } }, + body: "Lincolnshire County Council" +})); +// NB Lincs don't want forward planning works displayed, so +// fixmystreet.roadworks.layer_planned is deliberately missing here. + +})(); |